问题描述
我需要进行线性混合模型模拟以获得不同样本量的功效。
我的模型是:
评分 = y
固定效果,x = Ring
随机效应 = 参与者
我试过的代码如下。它只返回“基于 100 次模拟,(0 个警告,100 个错误)” alpha = 0.05,nrow = 2000' ....
谢谢!!
#create a dataframe
library(lmertest)
library(simr)
library(tidyverse)
Ring = c('Ring','noring')
#from 1 to 10 (11 is not included).
Ring = rep(Ring,times = 1000)
attractiveness = floor(runif(10,min=1,max=11)) #this creates random numbers
#from 1 to 10 (11 is not included).
participants<-rep(factor(1:100),each=20)
targetID = rep(c(1,2,3,4,5,6,7,8,9,10),each= 2)
targetimage= rep(targetID,times= 100)
ratings = rep(attractiveness,times = 200)
data<-data.frame(participants,Ring,targetimage,ratings)
#parameters for the model:
## Intercept and slopes for ring
fixed <- c(3,0.5)
## Random intercepts for participants
rand <- 0.5
## residual variance
res <- 2
model <- makeLmer(ratings ~ Ring + (1|participants),fixef=fixed,VarCorr=rand,sigma=res,data=data)
sim_treat <- powerSim(model,nsim=100,test = fcompare(ratings~Ring))
sim_treat
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)