obtaining Intraclass correlation (icc) in SEM-Modell

61 views
Skip to first unread message

Ingo Man

unread,
May 12, 2025, 3:38:33 AMMay 12
to lavaan
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

Ingo Man

unread,
May 12, 2025, 9:09:53 AMMay 12
to lavaan
Maybe I don't quite understand the concept, but is it possible to determine iccs for my latent scale variables (aka the factors) or is it only possible for observed variables?

Serena

unread,
May 29, 2025, 9:23:38 PMMay 29
to lavaan
Hi there,

I was wondering the same thing a while back, and from what I understand, yes — you can get ICCs for latent factors too. As long as you’re using something like MSEM that gives you the between- and within-level variance for the latent construct, you can compute ICCs just like with observed variables.  

Best,
Serena

Serena

unread,
May 29, 2025, 9:42:17 PMMay 29
to lavaan
Hi Marcus,

Did you happen to find a good solution for this? I’ve been trying to work through the same issue.  

From what I understand, it should be possible to calculate ICCs manually using the variance estimates at different levels.  It’s a bit of a workaround, but seems to do the trick. Would love to hear if you’ve found a cleaner or more built-in way to do this!  

Best,
Serena
Reply all
Reply to author
Forward
0 new messages