Skip to contents

In this example, the Monte Carlo method is used to generate confidence intervals for composite reliability using the Holzinger and Swineford (1939) data set.

data(HolzingerSwineford1939, package = "lavaan")
head(HolzingerSwineford1939)
#>   id sex ageyr agemo  school grade       x1   x2    x3       x4   x5        x6
#> 1  1   1    13     1 Pasteur     7 3.333333 7.75 0.375 2.333333 5.75 1.2857143
#> 2  2   2    13     7 Pasteur     7 5.333333 5.25 2.125 1.666667 3.00 1.2857143
#> 3  3   2    13     1 Pasteur     7 4.500000 5.25 1.875 1.000000 1.75 0.4285714
#> 4  4   1    13     2 Pasteur     7 5.333333 7.75 3.000 2.666667 4.50 2.4285714
#> 5  5   2    12     2 Pasteur     7 4.833333 4.75 0.875 2.666667 4.00 2.5714286
#> 6  6   2    14     1 Pasteur     7 5.333333 5.00 2.250 1.000000 3.00 0.8571429
#>         x7   x8       x9
#> 1 3.391304 5.75 6.361111
#> 2 3.782609 6.25 7.916667
#> 3 3.260870 3.90 4.416667
#> 4 3.000000 5.30 4.861111
#> 5 3.695652 6.30 5.916667
#> 6 4.347826 6.65 7.500000

The confirmatory factor analysis model for \(X_{1}, \dots, X_{9}\) is given by

Three-Factor Confirmatory Factor Analysis Model

\(\eta_{1}\), \(\eta_{2}\), and \(\eta_{3}\) are the latent factors. \(\eta_{1}\) has three indicators \(X_{1}\), \(X_{2}\), and \(X_{3}\); \(\eta_{2}\) has three indicators \(X_{4}\), \(X_{5}\), and \(X_{6}\); and \(\eta_{3}\) has three indicators \(X_{7}\), \(X_{8}\), and \(X_{9}\) . The variances of \(\eta_{1}\), \(\eta_{2}\), and \(\eta_{3}\) are constrained to one.

Model Specification

Assuming that the latent variable variance is constrained to one, the omega total reliability coefficient is given by

\[\begin{equation} \omega_{\mathrm{total}} = \frac{ \left( \sum_{i = 1}^{k} \lambda_{i} \right)^2 }{ \left( \sum_{i = 1}^{k} \lambda_{i} \right)^2 + \sum_{i = 1}^{k} \theta_{\varepsilon_{ii}} } \end{equation}\]

where \(\lambda_{i}\) is the factor loading for item \(i\), \(\theta_{\varepsilon_{ii}}\) is the residual variance for item \(i\), and \(k\) is the number of items for a particular latent variable.

In the model specification below, the variances of the latent variables eta1, eta2, and eta3 are constrained to one, all the relevant parameters are labeled particularly the factor loadings and the error variances, and the omega total reliability coefficient per latent variable are defined using the := operator.

model <- "
  # fix latent variable variances to 1
  eta1 ~~ 1 * eta1
  eta2 ~~ 1 * eta2
  eta3 ~~ 1 * eta3
  # factor loadings
  eta1 =~ NA * x1 + l11 * x1 + l12 * x2 + l13 * x3
  eta2 =~ NA * x4 + l24 * x4 + l25 * x5 + l26 * x6
  eta3 =~ NA * x7 + l37 * x7 + l38 * x8 + l39 * x9
  # error variances
  x1 ~~ t1 * x1
  x2 ~~ t2 * x2
  x3 ~~ t3 * x3
  x4 ~~ t4 * x4
  x5 ~~ t5 * x5
  x6 ~~ t6 * x6
  x7 ~~ t7 * x7
  x8 ~~ t8 * x8
  x9 ~~ t9 * x9
  # composite reliability
  omega1 := (l11 + l12 + l13)^2 / ((l11 + l12 + l13)^2 + (t1 + t2 + t3))
  omega2 := (l24 + l25 + l26)^2 / ((l24 + l25 + l26)^2 + (t4 + t5 + t6))
  omega3 := (l37 + l38 + l39)^2 / ((l37 + l38 + l39)^2 + (t7 + t8 + t9))
"

Model Fitting

We can now fit the model using the cfa() function from lavaan.

fit <- cfa(model = model, data = HolzingerSwineford1939)

Monte Carlo Confidence Intervals

The fit lavaan object can then be passed to the MC() function to generate Monte Carlo confidence intervals.

MC(fit, R = 20000L, alpha = 0.05)
#> Monte Carlo Confidence Intervals
#>               est     se     R   2.5%  97.5%
#> l11        0.8996 0.0808 20000 0.7379 1.0566
#> l12        0.4979 0.0770 20000 0.3475 0.6502
#> l13        0.6562 0.0746 20000 0.5098 0.8026
#> l24        0.9897 0.0564 20000 0.8793 1.0994
#> l25        1.1016 0.0629 20000 0.9782 1.2245
#> l26        0.9166 0.0537 20000 0.8108 1.0209
#> l37        0.6195 0.0693 20000 0.4829 0.7561
#> l38        0.7309 0.0653 20000 0.6030 0.8596
#> l39        0.6700 0.0655 20000 0.5427 0.7991
#> t1         0.5491 0.1140 20000 0.3263 0.7748
#> t2         1.1338 0.1032 20000 0.9318 1.3374
#> t3         0.8443 0.0913 20000 0.6641 1.0226
#> t4         0.3712 0.0478 20000 0.2767 0.4645
#> t5         0.4463 0.0584 20000 0.3316 0.5610
#> t6         0.3562 0.0428 20000 0.2725 0.4397
#> t7         0.7994 0.0816 20000 0.6406 0.9556
#> t8         0.4877 0.0737 20000 0.3426 0.6319
#> t9         0.5661 0.0708 20000 0.4259 0.7034
#> eta1~~eta2 0.4585 0.0642 20000 0.3335 0.5863
#> eta1~~eta3 0.4705 0.0728 20000 0.3269 0.6131
#> eta2~~eta3 0.2830 0.0693 20000 0.1471 0.4194
#> omega1     0.6253 0.0363 20000 0.5490 0.6909
#> omega2     0.8852 0.0116 20000 0.8599 0.9058
#> omega3     0.6878 0.0311 20000 0.6212 0.7437