Hi folks,
I'm new to simulation with lavaan and simsem and trying to implement a particular design. I want to see how well certain estimating models perform at recovering population estimates as well as examine model fit. I need to create at least two population models and then two estimating models.
The population models will consistent of 2 correlated latent variables (c1 ~ .2*c2; I call these "substantive") with 4 indicators each (x1-x8). However, one model will have one additional latent variable that functions as a method factor. In this iteration, the method factor (m1) contributes to x1-x8. This is a bifactor model. Another population model will include another method factor (m2) but this model will have m1 contributing to x1-x4 and m2 contributing to m4-m8 (m1 ~ 0*m2).
There will be two estimating models: one where the there are two substantive factors (method factors ignored) and another where there are two substantive factors and one method factor. While the former model is misspecified for both population models, the latter model should work well when there is one method factor underlying the data.
We want to examine how well the estimating models perform across different sample sizes (n = 100, 300, 1000) and scale reliability levels (.70, .80, .90). So there are 18 conditions in this sample, but in our research setting there could be well over 200 conditions (I've kept things relatively small and easy to digest). That's a lot of code. I'm looking for any suggestions on using the sim() function of the simsem package for conducting the simulation and reporting the results.
To share some sample code, the population, estimation, and my use of the sim() function are below:
pop <- '
# define two substantive factors with standardized loadings
c1 =~ 0.570*x1 + 0.632*x2 + 0.744*x3 + 0.543*x4
c2 =~ 0.570*x5 + 0.632*x6 + 0.744*x7 + 0.543*x8
# define a single ULMC
m1 =~ .271*x1 + .316*x2 + .374*x3 + .3000*x4 + .374*x5 + .3000*x6 + .271*x7 + .316*x8
# define a relationship linking substantive factors
c1 ~~ 0.2*c2
# substantive factors standardized
c1 ~~ 1*c1
c2 ~~ 1*c2
# method factor standardized
m1 ~~ 1*m1
# method factors are not correlated with substantive factors
c1 ~ 0*m1
c2 ~ 0*m1
# error variances for substantive factors
x1 ~~ 0.602*x1
x2 ~~ 0.501*x2
x3 ~~ 0.307*x3
x4 ~~ 0.615*x4
x5 ~~ 0.535*x5
x6 ~~ 0.511*x6
x7 ~~ 0.373*x7
x8 ~~ 0.605*x8
'
est <- '
# define a single ULMC
m1 =~ x8 + x7 + x6 + x5 + x4 + x3 + x2 + x1
# define three substantive factors with standardized loadings
c2 =~ x5 + x6 + x7 + x8
c1 =~ x1 + x2 + x3 + x4
# define a relationship linking substantive factors
c1 ~~ c2
'
simOutput_1.100 <- sim(
nRep = 100,
model = est, # estimating model is pop model
n = 1000,
generate = pop, # generating model
lavaanfun = 'cfa'
)
Any guidance is appreciated!
Chris