Reputation: 11
I have some troubles building my mixed model power simulation in simr. I have some statistical learning gaps so please be kind :) I want to run a simulation for a longitudinal single-group study with 6 assessment points in which a continuous outcome measure is assessed.
library(simr)
library(lme4)
library(Matrix)
simrOptions(progress=FALSE)
follow_up <- rep(1:6) #assessment points
ID <- 1:4000 #up to 4000 participants
X <- expand.grid(follow_up=follow_up, ID=ID) #creates a matrix with all assessment points
b <- c(2, -0.1) # fixed intercept and slope
V1 <- 0.5 # random intercept variance
V2 <- matrix(c(0.5,0.05,0.05,0.1), 2) # random intercept and slope variance-covariance matrix
s <- 1 # residual variance
model1 <- makeLmer(y ~ follow_up + (follow_up |ID ), fixef=b, VarCorr=V1, sigma=s, data=X)
However, I receive the following error: Error in setParams(object, newparams) : length mismatch in theta (1!=3)
Could you please help me understand my mistake and how to proceed?
Additional questions I'm wondering about: a) I don't have variables in my matrix for the result of the continuous outcome. Can I leave it empty or do I need to simulate it as well somehow? b) The command "fixef(model1)["x"] <- -0.05" changes the effect sizes of the slope. However, I'm wondering whether it is possible to get an understanding of how much that would be in a Cohen's d.
Thank you in advance!
Upvotes: 1
Views: 324