Example syntax in R and Mplus for the paper can be found in https://github.com/marklhc/mcfa_reliability_supp. Going back to the multilevel demo data, we can consider the reliability for between-level and within-level composite scores when summing y1, y2, and y3. This can be done using

The following objects are masked from 'package:semTools':
reliability, skew

The following object is masked from 'package:lavaan':
cor2cov

Parallel analysis suggests that the number of factors = NA and the number of components = 1
Parallel analysis suggests that the number of factors = NA and the number of components = 1

Note that the \(\omega\) indices assume unidimensionality, local independence, and cross-level invariance. There were a total of six indices: three \(\alpha\)s and three \(\omega\)s, corresponding to raw composite (“2l”), between-level composite (“b”), and within-level composite (“w”). The 95% CIs were obtained using the Monte Carlo method by simulating from the asymptotic distribution of the model parameters. In addition, the function also implemented a parallel analysis procedure for determining the number of factors/components at each level, as discussed in this paper.

Using semTools::compRelSEM()

Some of the above procedures were implemented in the semTools package. To use that, one needs to fit a two-level CFA in lavaan first (see ?compRelSEM:

mcfa_mod <-' level: 1 f =~ y1 + L2*y2 + L3*y3 level: 2 f =~ y1 + L2*y2 + L3*y3'mcfa_fit <-cfa(mcfa_mod, data = Demo.twolevel, cluster ="cluster")