1

注意:此问题已作为GitHub 问题交叉发布。

我根据之前包含 40 名参与者的实验的数据来估计样本量。

我使用simr::powerCurve了几个小于原始样本大小的样本:

pc <- powerCurve(fit = model, nsim = 100, alpha=0.02, 
                 breaks = c(10, 20, 30, 40), along = 'subject_id')

所有尺寸的结果都相同,接近 100%。我认为这是由于模拟样本量小于原始样本量。

有没有一种方法可以估计样本量小于用于拟合模型的样本量的功效?

这是一个使用合成数据的可重现示例(代码取自https://humburg.github.io/Power-Analysis/simr_power_analysis.html并稍作修改):

library(simr)

subj <- factor(1:40)
class_id <- letters[1:5]
time <- 0:2
group <- c("control", "intervention")

subj_full <- rep(subj, 15)
class_full <- rep(rep(class_id, each=10), 3)
time_full <- rep(time, each=50)
group_full <- rep(rep(group, each=5), 15)

covars <- data.frame(id=subj_full, class=class_full, treat=group_full, time=factor(time_full))

## Intercept and slopes for intervention, time1, time2, intervention:time1, intervention:time2
fixed <- c(5, 2, 0.1, 0.2)

## Random intercepts for participants clustered by class
rand <- list(0.5, 0.1)

## residual variance
res <- 2

model <- makeLmer(y ~ treat + time + (1|class/id), fixef=fixed, VarCorr=rand, sigma=res, data=covars)

pc <- powerCurve(model, test = fixed('treat'), nsim=100, along='subj', breaks = c(10, 20, 30, 40))
print(pc)

输出是

Power for predictor 'treat', (95% confidence interval),
by number of levels in subj:
     10: 100.0% (96.38, 100.0) - 150 rows
     20: 100.0% (96.38, 100.0) - 300 rows
     30: 100.0% (96.38, 100.0) - 450 rows
     40: 100.0% (96.38, 100.0) - 600 rows

Time elapsed: 0 h 0 m 55 s
4

0 回答 0