Dear lavaan-users,
I have been trying for some time to determine intraclass correlations from my SEM model. First of all, I don't want to calculate an MLSEM yet, I only want to obtain the iccs. So far, I have always done this with the <misty> package by creating manifest scales and using these variables, worked well.
How can I output the iccs directly in lavaan in my SEM model? It must work via the “Multilevel SEM model syntax”. I have students in school classes (level 2), which are nested in schools (level 3). First, it would be enough for me to determine the iccs for the school classes, maybe it is possible to calculate the iccs at level 3 at the same time? My sem model looks like this:
sem2 <- '
# measurement model
DV =~ 1*ma1h + ma1d + ma2h
IV1 =~ 1*aff3 + aff5 + aff6 + aff8 + aff11 + aff15
IV2 =~ NA*kn1 + kn2 + 1*kn3
IV3 =~ NA*seko1 + seko2 + seko3 + seko7 + 1*seko8
IV4 =~ NA*sndm2 + 1*sndm + sndm1
IV5 =~ NA*snim1 + 1*snim2 + snim3
IV6 =~ NA*kon1 + 1*kon3 + kon5 + kon6
# regression
DV ~ IV1 + IV2 + IV3 + IV4 + IV5 + IV6
# residual covariances
sndm1 ~~ sndm2
'
fitsem2 <- sem(sem2, data=data, estimator=“MLR”, missing=“fiml”, cluster = “code_sc”)
How should I write the MLSEM syntax for this? Something like this? In particular, how should I specify the level 2? Refering to the lavaan manual "if you do not have a model in mind for level 2, you can specify a
saturated level by adding all variances and covariances of the
endogenous variables"
sem2 <- '
level: 1
DV =~ 1*ma1h + ma1d + ma2h
IV1 =~ 1*aff3 + aff5 + aff6 + aff8 + aff11 + aff15
IV2 =~ NA*kn1 + kn2 + 1*kn3
IV3 =~ NA*seko1 + seko2 + seko3 + seko7 + 1*seko8
IV4 =~ NA*sndm2 + 1*sndm + sndm1
IV5 =~ NA*snim1 + 1*snim2 + snim3
IV6 =~ NA*kon1 + 1*kon3 + kon5 + kon6
DV ~ IV1 + IV2 + IV3 + IV4 + IV5 + IV6
# residual covariances
sndm1 ~~ sndm2
level: 2
ma1h ~~ ma1d + ma2h + aff3 + aff5 + aff6 + aff8 + aff11 + aff15 + kn1 + kn2 + kn3 + seko1 + seko2 + seko3 + seko7 + seko8 + sndm2 + sndm + sndm1 + snim1 + snim2 + snim3 + kon1 + kon3 + kon5 + kon6
ma1d ~~ and so on
'
fitsem2 <- sem(sem2, data=data, estimator=“MLR”, missing=“fiml”, cluster = “code_sc”)
Thank you in advance,
Marcus