Measurement Invariance Example in R

Ben Kite, Center for Research Methods and Data Analysis, University of Kansas <bakite@ku.edu>

Chong Xing, Center for Research Methods and Data Analysis, University of Kansas <cxing@ku.edu>

Please visit http://crmda.ku.edu/guides

Keywords: SEM, CFA, Measurement Invariance, R, lavaan

Abstract

This guide outlines how to conduct measurement invariance testing in the R package lavaan. The manifest variables used in this example are continuous in scale and tested for invariance across gender. This guide is intended for researchers familiar with structural equation modeling. Model syntax is compared to the popular SEM software package Mplus.

Package and Data

Load the lavaan package at the beginning of the session

library(lavaan)
This is lavaan 0.6-3
lavaan is BETA software! Please report any bugs.

The data file is read in, columns are named, and missing values are specified.

dat <- read.csv("../../data/job_placement.csv", header = FALSE)

colnames(dat) <- c("id", "wjcalc", "wjspl", "wratspl", "wratcalc",
                   "waiscalc", "waisspl", "edlevel", "newschl",
                   "suspend", "expelled", "haveld", "gender", "age")

dat[dat == 99999] <- NA ## convert the original missing data value "99999" to NA

dat$gender <- as.factor(dat$gender) ## change "gender" to a factor variable
levels(dat$gender) ## check the levels of the factor variable               
[1] "0" "1"
table(dat$gender) ## request a frequency summary

  0   1 
221 101 
levels(dat$gender) <- c("Male", "Female") ## assign level labels
table(dat$gender) ## request a frequency summary to verify assigned labels 

  Male Female 
   221    101 

Configural Invariance (also known as Equal Form)

Now the CFA model that is to be tested needs to be specified as an R object. In lavaan the “=~” operator is the exact same as the BY operator in Mplus. In the statements below the variables on the right of the “=~” are indicators of the variable to the left of the “=~”. Also notice that there are “+” signs that separate the variables on the right side of the equation. The entire model statement needs to be wrapped in quotation marks.

ConfigModel <- 'MATH =~ wratcalc + wjcalc + waiscalc
                SPELL =~ wratspl + wjspl + waisspl'

The cfa function is used to actually fit the model. The grouping variable must be provided to the group argument. The std.lv = TRUE argument tells lavaan to used fixed factor model identification where the latent variables are standardized with a mean of 0 and a variance of 1.

ConfigOutput <- cfa(model = ConfigModel, data = dat, std.lv = TRUE,
                    missing = "fiml", mimic = "Mplus", group = "gender")
summary(ConfigOutput, standardized = TRUE, fit.measures = TRUE)
lavaan 0.6-3 ended normally after 67 iterations

  Optimization method                           NLMINB
  Number of free parameters                         38

  Number of observations per group         
  Female                                           101
  Male                                             221
  Number of missing patterns per group     
  Female                                             4
  Male                                               2

  Estimator                                         ML
  Model Fit Test Statistic                      19.215
  Degrees of freedom                                16
  P-value (Chi-square)                           0.258

Chi-square for each group:

  Female                                        11.555
  Male                                           7.660

Model test baseline model:

  Minimum Function Test Statistic             1905.113
  Degrees of freedom                                30
  P-value                                        0.000

User model versus baseline model:

  Comparative Fit Index (CFI)                    0.998
  Tucker-Lewis Index (TLI)                       0.997

Loglikelihood and Information Criteria:

  Loglikelihood user model (H0)              -5112.407
  Loglikelihood unrestricted model (H1)      -5102.800

  Number of free parameters                         38
  Akaike (AIC)                               10300.815
  Bayesian (BIC)                             10444.248
  Sample-size adjusted Bayesian (BIC)        10323.717

Root Mean Square Error of Approximation:

  RMSEA                                          0.035
  90 Percent Confidence Interval          0.000  0.085
  P-value RMSEA <= 0.05                          0.631

Standardized Root Mean Square Residual:

  SRMR                                           0.029

Parameter Estimates:

  Information                                 Observed
  Observed information based on                Hessian
  Standard Errors                             Standard


Group 1 [Female]:

Latent Variables:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
  MATH =~                                                               
    wratcalc          6.545    0.496   13.187    0.000    6.545    0.978
    wjcalc            4.215    0.366   11.530    0.000    4.215    0.904
    waiscalc          2.290    0.276    8.306    0.000    2.290    0.724
  SPELL =~                                                              
    wratspl           7.010    0.547   12.817    0.000    7.010    0.950
    wjspl             6.833    0.518   13.182    0.000    6.833    0.965
    waisspl           6.638    0.520   12.763    0.000    6.638    0.949

Covariances:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
  MATH ~~                                                               
    SPELL             0.634    0.064    9.914    0.000    0.634    0.634

Intercepts:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
   .wratcalc         38.267    0.666   57.464    0.000   38.267    5.718
   .wjcalc           23.603    0.465   50.781    0.000   23.603    5.064
   .waiscalc         10.266    0.316   32.528    0.000   10.266    3.245
   .wratspl          37.171    0.735   50.590    0.000   37.171    5.037
   .wjspl            42.337    0.705   60.073    0.000   42.337    5.978
   .waisspl          38.030    0.697   54.579    0.000   38.030    5.435
    MATH              0.000                               0.000    0.000
    SPELL             0.000                               0.000    0.000

Variances:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
   .wratcalc          1.957    1.621    1.208    0.227    1.957    0.044
   .wjcalc            3.960    0.848    4.671    0.000    3.960    0.182
   .waiscalc          4.765    0.714    6.678    0.000    4.765    0.476
   .wratspl           5.307    1.105    4.804    0.000    5.307    0.097
   .wjspl             3.474    0.910    3.818    0.000    3.474    0.069
   .waisspl           4.900    1.007    4.865    0.000    4.900    0.100
    MATH              1.000                               1.000    1.000
    SPELL             1.000                               1.000    1.000


Group 2 [Male]:

Latent Variables:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
  MATH =~                                                               
    wratcalc          5.764    0.330   17.492    0.000    5.764    0.929
    wjcalc            4.123    0.244   16.926    0.000    4.123    0.910
    waiscalc          2.446    0.200   12.212    0.000    2.446    0.729
  SPELL =~                                                              
    wratspl           6.278    0.337   18.646    0.000    6.278    0.943
    wjspl             6.788    0.359   18.929    0.000    6.788    0.951
    waisspl           6.177    0.335   18.441    0.000    6.177    0.937

Covariances:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
  MATH ~~                                                               
    SPELL             0.520    0.053    9.762    0.000    0.520    0.520

Intercepts:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
   .wratcalc         39.222    0.417   93.962    0.000   39.222    6.321
   .wjcalc           23.910    0.305   78.420    0.000   23.910    5.275
   .waiscalc         11.367    0.226   50.320    0.000   11.367    3.389
   .wratspl          36.172    0.448   80.762    0.000   36.172    5.433
   .wjspl            41.371    0.480   86.157    0.000   41.371    5.796
   .waisspl          36.767    0.444   82.899    0.000   36.767    5.579
    MATH              0.000                               0.000    0.000
    SPELL             0.000                               0.000    0.000

Variances:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
   .wratcalc          5.280    1.232    4.285    0.000    5.280    0.137
   .wjcalc            3.549    0.664    5.342    0.000    3.549    0.173
   .waiscalc          5.269    0.557    9.463    0.000    5.269    0.468
   .wratspl           4.915    0.726    6.772    0.000    4.915    0.111
   .wjspl             4.881    0.795    6.138    0.000    4.881    0.096
   .waisspl           5.285    0.736    7.176    0.000    5.285    0.122
    MATH              1.000                               1.000    1.000
    SPELL             1.000                               1.000    1.000

Metric Invariance (also Known as Weak Factorial Invariance or Equal Factor Loadings)

Now we fit a model where the factor loadings are constrained to equality across males and females.

In the model we define we are specifying the measurement structure and the latent variable variances. Because we are constraining the factor loadings, we can estimate the latent variable variances for the second group (males in this case). We can constrain the factor loadings using the group.equal = “loadings” argument in the “cfa” function.

metricModel <-
    ' MATH =~ c(NA, NA)*wratcalc + wjcalc + waiscalc
      ## freely estimate the first factor loading in both groups

      MATH ~~ c(NA, 1)*MATH
      ## fix the factor variance of MATH to 1 in male group, and freely estimate in female group

      MATH ~ c(0, 0)*1

      SPELL =~ c(NA, NA)*wratspl + wjspl + waisspl
      ## freely estimate the first factor loading in both groups

      SPELL ~~ c(NA, 1)*SPELL
      ## fix the factor variance of SPELL to 1 in male group, and freely estimate in female group

      SPELL ~ c(0, 0)*1
    '
metricOutput <- cfa(model = metricModel, data = dat,
                    missing = "fiml", mimic = "Mplus",
                    group = "gender", group.equal = "loadings")
summary(metricOutput, standardized = TRUE, fit.measures = TRUE)
lavaan 0.6-3 ended normally after 69 iterations

  Optimization method                           NLMINB
  Number of free parameters                         40
  Number of equality constraints                     6

  Number of observations per group         
  Female                                           101
  Male                                             221
  Number of missing patterns per group     
  Female                                             4
  Male                                               2

  Estimator                                         ML
  Model Fit Test Statistic                      25.871
  Degrees of freedom                                20
  P-value (Chi-square)                           0.170

Chi-square for each group:

  Female                                        15.581
  Male                                          10.290

Model test baseline model:

  Minimum Function Test Statistic             1905.113
  Degrees of freedom                                30
  P-value                                        0.000

User model versus baseline model:

  Comparative Fit Index (CFI)                    0.997
  Tucker-Lewis Index (TLI)                       0.995

Loglikelihood and Information Criteria:

  Loglikelihood user model (H0)              -5115.735
  Loglikelihood unrestricted model (H1)      -5102.800

  Number of free parameters                         34
  Akaike (AIC)                               10299.471
  Bayesian (BIC)                             10427.805
  Sample-size adjusted Bayesian (BIC)        10319.962

Root Mean Square Error of Approximation:

  RMSEA                                          0.043
  90 Percent Confidence Interval          0.000  0.085
  P-value RMSEA <= 0.05                          0.566

Standardized Root Mean Square Residual:

  SRMR                                           0.053

Parameter Estimates:

  Information                                 Observed
  Observed information based on                Hessian
  Standard Errors                             Standard


Group 1 [Female]:

Latent Variables:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
  MATH =~                                                               
    wratclc (.p1.)    5.898    0.317   18.615    0.000    6.359    0.964
    wjcalc  (.p2.)    4.039    0.232   17.414    0.000    4.354    0.917
    waisclc (.p3.)    2.321    0.173   13.389    0.000    2.502    0.756
  SPELL =~                                                              
    wratspl (.p6.)    6.387    0.332   19.245    0.000    6.751    0.943
    wjspl   (.p7.)    6.640    0.346   19.186    0.000    7.020    0.969
    waisspl (.p8.)    6.213    0.326   19.054    0.000    6.568    0.947

Covariances:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
  MATH ~~                                                               
    SPELL             0.731    0.150    4.857    0.000    0.641    0.641

Intercepts:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
    MATH              0.000                               0.000    0.000
    SPELL             0.000                               0.000    0.000
   .wratcalc         38.267    0.656   58.319    0.000   38.267    5.803
   .wjcalc           23.602    0.474   49.832    0.000   23.602    4.969
   .waiscalc         10.263    0.330   31.085    0.000   10.263    3.100
   .wratspl          37.172    0.713   52.136    0.000   37.172    5.192
   .wjspl            42.337    0.721   58.719    0.000   42.337    5.843
   .waisspl          38.031    0.691   55.052    0.000   38.031    5.482

Variances:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
    MATH              1.162    0.211    5.501    0.000    1.000    1.000
    SPELL             1.117    0.197    5.676    0.000    1.000    1.000
   .wratcalc          3.047    1.413    2.157    0.031    3.047    0.070
   .wjcalc            3.603    0.778    4.632    0.000    3.603    0.160
   .waiscalc          4.700    0.714    6.586    0.000    4.700    0.429
   .wratspl           5.686    1.123    5.061    0.000    5.686    0.111
   .wjspl             3.230    0.929    3.478    0.001    3.230    0.062
   .waisspl           4.995    1.023    4.883    0.000    4.995    0.104


Group 2 [Male]:

Latent Variables:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
  MATH =~                                                               
    wratclc (.p1.)    5.898    0.317   18.615    0.000    5.898    0.940
    wjcalc  (.p2.)    4.039    0.232   17.414    0.000    4.039    0.900
    waisclc (.p3.)    2.321    0.173   13.389    0.000    2.321    0.708
  SPELL =~                                                              
    wratspl (.p6.)    6.387    0.332   19.245    0.000    6.387    0.946
    wjspl   (.p7.)    6.640    0.346   19.186    0.000    6.640    0.946
    waisspl (.p8.)    6.213    0.326   19.054    0.000    6.213    0.938

Covariances:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
  MATH ~~                                                               
    SPELL             0.519    0.053    9.733    0.000    0.519    0.519

Intercepts:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
    MATH              0.000                               0.000    0.000
    SPELL             0.000                               0.000    0.000
   .wratcalc         39.222    0.422   92.880    0.000   39.222    6.248
   .wjcalc           23.910    0.302   79.192    0.000   23.910    5.327
   .waiscalc         11.367    0.221   51.462    0.000   11.367    3.466
   .wratspl          36.172    0.454   79.673    0.000   36.172    5.359
   .wjspl            41.371    0.472   87.637    0.000   41.371    5.895
   .waisspl          36.767    0.446   82.523    0.000   36.767    5.553

Variances:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
    MATH              1.000                               1.000    1.000
    SPELL             1.000                               1.000    1.000
   .wratcalc          4.619    1.205    3.834    0.000    4.619    0.117
   .wjcalc            3.835    0.654    5.864    0.000    3.835    0.190
   .waiscalc          5.370    0.564    9.525    0.000    5.370    0.499
   .wratspl           4.764    0.721    6.607    0.000    4.764    0.105
   .wjspl             5.154    0.790    6.526    0.000    5.154    0.105
   .waisspl           5.233    0.732    7.153    0.000    5.233    0.119

Scalar Invariance (also Known as Strong Factorial Invariance or Equal Intercepts)

In the scalar invariance model we want to constrain the factor loadings and intercepts. The latent variable means and variances are freely estimated for males. The loadings and intercepts are constrained with the group.equal argument.

scalarModel <- 'MATH =~ c(NA, NA)*wratcalc + wjcalc + waiscalc
                MATH ~~ c(NA, 1)*MATH
                MATH ~ c(NA, 0)*1

                SPELL =~ c(NA, NA)*wratspl + wjspl + waisspl
                SPELL ~~ c(NA, 1)*SPELL
                SPELL ~ c(NA, 0)*1'
scalarOutput <- cfa(model = scalarModel, data = dat,
                    missing = "fiml", mimic = "Mplus",
                    group = "gender",
                    group.equal = c("loadings", "intercepts"))
summary(scalarOutput, standardized = TRUE, fit.measures = TRUE)
lavaan 0.6-3 ended normally after 65 iterations

  Optimization method                           NLMINB
  Number of free parameters                         42
  Number of equality constraints                    12

  Number of observations per group         
  Female                                           101
  Male                                             221
  Number of missing patterns per group     
  Female                                             4
  Male                                               2

  Estimator                                         ML
  Model Fit Test Statistic                      36.362
  Degrees of freedom                                24
  P-value (Chi-square)                           0.051

Chi-square for each group:

  Female                                        22.546
  Male                                          13.815

Model test baseline model:

  Minimum Function Test Statistic             1905.113
  Degrees of freedom                                30
  P-value                                        0.000

User model versus baseline model:

  Comparative Fit Index (CFI)                    0.993
  Tucker-Lewis Index (TLI)                       0.992

Loglikelihood and Information Criteria:

  Loglikelihood user model (H0)              -5120.981
  Loglikelihood unrestricted model (H1)      -5102.800

  Number of free parameters                         30
  Akaike (AIC)                               10301.961
  Bayesian (BIC)                             10415.198
  Sample-size adjusted Bayesian (BIC)        10320.042

Root Mean Square Error of Approximation:

  RMSEA                                          0.057
  90 Percent Confidence Interval          0.000  0.092
  P-value RMSEA <= 0.05                          0.356

Standardized Root Mean Square Residual:

  SRMR                                           0.053

Parameter Estimates:

  Information                                 Observed
  Observed information based on                Hessian
  Standard Errors                             Standard


Group 1 [Female]:

Latent Variables:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
  MATH =~                                                               
    wratclc (.p1.)    5.907    0.317   18.658    0.000    6.381    0.967
    wjcalc  (.p2.)    4.017    0.232   17.352    0.000    4.340    0.913
    waisclc (.p3.)    2.341    0.175   13.388    0.000    2.529    0.750
  SPELL =~                                                              
    wratspl (.p6.)    6.385    0.332   19.249    0.000    6.751    0.943
    wjspl   (.p7.)    6.634    0.346   19.183    0.000    7.015    0.969
    waisspl (.p8.)    6.221    0.326   19.064    0.000    6.578    0.946

Covariances:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
  MATH ~~                                                               
    SPELL             0.731    0.151    4.855    0.000    0.640    0.640

Intercepts:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
    MATH             -0.160    0.131   -1.223    0.221   -0.148   -0.148
    SPELL             0.165    0.127    1.296    0.195    0.156    0.156
   .wratclc (.18.)   39.217    0.419   93.583    0.000   39.217    5.942
   .wjcalc  (.19.)   24.016    0.295   81.470    0.000   24.016    5.054
   .waisclc (.20.)   11.125    0.207   53.742    0.000   11.125    3.299
   .wratspl (.21.)   36.157    0.449   80.484    0.000   36.157    5.050
   .wjspl   (.22.)   41.317    0.466   88.688    0.000   41.317    5.705
   .waisspl (.23.)   36.843    0.440   83.721    0.000   36.843    5.301

Variances:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
    MATH              1.167    0.212    5.502    0.000    1.000    1.000
    SPELL             1.118    0.197    5.676    0.000    1.000    1.000
   .wratcalc          2.841    1.424    1.995    0.046    2.841    0.065
   .wjcalc            3.743    0.793    4.723    0.000    3.743    0.166
   .waiscalc          4.977    0.766    6.496    0.000    4.977    0.438
   .wratspl           5.681    1.123    5.056    0.000    5.681    0.111
   .wjspl             3.237    0.930    3.481    0.000    3.237    0.062
   .waisspl           5.035    1.032    4.880    0.000    5.035    0.104


Group 2 [Male]:

Latent Variables:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
  MATH =~                                                               
    wratclc (.p1.)    5.907    0.317   18.658    0.000    5.907    0.941
    wjcalc  (.p2.)    4.017    0.232   17.352    0.000    4.017    0.897
    waisclc (.p3.)    2.341    0.175   13.388    0.000    2.341    0.709
  SPELL =~                                                              
    wratspl (.p6.)    6.385    0.332   19.249    0.000    6.385    0.946
    wjspl   (.p7.)    6.634    0.346   19.183    0.000    6.634    0.946
    waisspl (.p8.)    6.221    0.326   19.064    0.000    6.221    0.939

Covariances:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
  MATH ~~                                                               
    SPELL             0.519    0.053    9.732    0.000    0.519    0.519

Intercepts:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
    MATH              0.000                               0.000    0.000
    SPELL             0.000                               0.000    0.000
   .wratclc (.18.)   39.217    0.419   93.583    0.000   39.217    6.247
   .wjcalc  (.19.)   24.016    0.295   81.470    0.000   24.016    5.363
   .waisclc (.20.)   11.125    0.207   53.742    0.000   11.125    3.368
   .wratspl (.21.)   36.157    0.449   80.484    0.000   36.157    5.359
   .wjspl   (.22.)   41.317    0.466   88.688    0.000   41.317    5.892
   .waisspl (.23.)   36.843    0.440   83.721    0.000   36.843    5.558

Variances:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
    MATH              1.000                               1.000    1.000
    SPELL             1.000                               1.000    1.000
   .wratcalc          4.518    1.204    3.753    0.000    4.518    0.115
   .wjcalc            3.911    0.655    5.970    0.000    3.911    0.195
   .waiscalc          5.431    0.576    9.435    0.000    5.431    0.498
   .wratspl           4.761    0.721    6.603    0.000    4.761    0.105
   .wjspl             5.173    0.791    6.541    0.000    5.173    0.105
   .waisspl           5.235    0.734    7.134    0.000    5.235    0.119

Nested Model Comparisons

Now the models can be compared via chi-square difference testing.

anova(ConfigOutput, metricOutput)
Chi Square Difference Test

             Df   AIC   BIC  Chisq Chisq diff Df diff Pr(>Chisq)
ConfigOutput 16 10301 10444 19.215                              
metricOutput 20 10300 10428 25.871     6.6558       4     0.1552

Here the metric model does not fit significantly worse than the configural model, so metric invariance is supported.

Now we can test for scalar invariance.

anova(metricOutput, scalarOutput)
Chi Square Difference Test

             Df   AIC   BIC  Chisq Chisq diff Df diff Pr(>Chisq)  
metricOutput 20 10300 10428 25.871                                
scalarOutput 24 10302 10415 36.361     10.491       4    0.03293 *
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Here the scalar model fits significantly worse, so scalar invariance is not supported.

Strict Factorial Invariance (also Known as Equal Residuals)

In addition to the constraints specified for the scalar invariance model (i.e., euqal factor loadings, equal indicator intercepts), indicator residual variances can also be equated between groups. However, strict factorial invariance is an optional test - this level of invariance is not necessary for conducting latent parameter comparisons.

strictModel <- 'MATH =~ c(NA, NA)*wratcalc + wjcalc + waiscalc
                MATH ~~ c(NA, 1)*MATH
                MATH ~ c(NA, 0)*1

                SPELL =~ c(NA, NA)*wratspl + wjspl + waisspl
                SPELL ~~ c(NA, 1)*SPELL
                SPELL ~ c(NA, 0)*1'
strictOutput <- cfa(model = strictModel, data = dat,
                    missing = "fiml", mimic = "Mplus",
                    group = "gender",
                    group.equal = c("loadings", "intercepts", "residuals"))
summary(strictOutput, standardized = TRUE, fit.measures = TRUE)
lavaan 0.6-3 ended normally after 68 iterations

  Optimization method                           NLMINB
  Number of free parameters                         42
  Number of equality constraints                    18

  Number of observations per group         
  Female                                           101
  Male                                             221
  Number of missing patterns per group     
  Female                                             4
  Male                                               2

  Estimator                                         ML
  Model Fit Test Statistic                      40.717
  Degrees of freedom                                30
  P-value (Chi-square)                           0.092

Chi-square for each group:

  Female                                        26.601
  Male                                          14.115

Model test baseline model:

  Minimum Function Test Statistic             1905.113
  Degrees of freedom                                30
  P-value                                        0.000

User model versus baseline model:

  Comparative Fit Index (CFI)                    0.994
  Tucker-Lewis Index (TLI)                       0.994

Loglikelihood and Information Criteria:

  Loglikelihood user model (H0)              -5123.158
  Loglikelihood unrestricted model (H1)      -5102.800

  Number of free parameters                         24
  Akaike (AIC)                               10294.316
  Bayesian (BIC)                             10384.905
  Sample-size adjusted Bayesian (BIC)        10308.781

Root Mean Square Error of Approximation:

  RMSEA                                          0.047
  90 Percent Confidence Interval          0.000  0.081
  P-value RMSEA <= 0.05                          0.521

Standardized Root Mean Square Residual:

  SRMR                                           0.056

Parameter Estimates:

  Information                                 Observed
  Observed information based on                Hessian
  Standard Errors                             Standard


Group 1 [Female]:

Latent Variables:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
  MATH =~                                                               
    wratclc (.p1.)    5.905    0.316   18.706    0.000    6.300    0.952
    wjcalc  (.p2.)    4.040    0.231   17.469    0.000    4.310    0.911
    waisclc (.p3.)    2.358    0.175   13.463    0.000    2.516    0.738
  SPELL =~                                                              
    wratspl (.p6.)    6.392    0.333   19.208    0.000    6.770    0.949
    wjspl   (.p7.)    6.663    0.345   19.316    0.000    7.057    0.957
    waisspl (.p8.)    6.219    0.326   19.073    0.000    6.586    0.946

Covariances:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
  MATH ~~                                                               
    SPELL             0.730    0.150    4.860    0.000    0.646    0.646

Intercepts:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
    MATH             -0.159    0.130   -1.221    0.222   -0.149   -0.149
    SPELL             0.166    0.128    1.298    0.194    0.156    0.156
   .wratclc (.18.)   39.217    0.417   93.947    0.000   39.217    5.926
   .wjcalc  (.19.)   24.012    0.296   81.184    0.000   24.012    5.073
   .waisclc (.20.)   11.139    0.206   54.146    0.000   11.139    3.269
   .wratspl (.21.)   36.153    0.451   80.244    0.000   36.153    5.068
   .wjspl   (.22.)   41.328    0.466   88.600    0.000   41.328    5.606
   .waisspl (.23.)   36.840    0.440   83.781    0.000   36.840    5.289

Variances:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
    MATH              1.138    0.206    5.512    0.000    1.000    1.000
    SPELL             1.122    0.198    5.672    0.000    1.000    1.000
   .wratclc (.11.)    4.104    0.998    4.111    0.000    4.104    0.094
   .wjcalc  (.12.)    3.827    0.530    7.224    0.000    3.827    0.171
   .waisclc (.13.)    5.283    0.457   11.562    0.000    5.283    0.455
   .wratspl (.14.)    5.057    0.612    8.266    0.000    5.057    0.099
   .wjspl   (.15.)    4.554    0.616    7.388    0.000    4.554    0.084
   .waisspl (.16.)    5.140    0.598    8.588    0.000    5.140    0.106


Group 2 [Male]:

Latent Variables:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
  MATH =~                                                               
    wratclc (.p1.)    5.905    0.316   18.706    0.000    5.905    0.946
    wjcalc  (.p2.)    4.040    0.231   17.469    0.000    4.040    0.900
    waisclc (.p3.)    2.358    0.175   13.463    0.000    2.358    0.716
  SPELL =~                                                              
    wratspl (.p6.)    6.392    0.333   19.208    0.000    6.392    0.943
    wjspl   (.p7.)    6.663    0.345   19.316    0.000    6.663    0.952
    waisspl (.p8.)    6.219    0.326   19.073    0.000    6.219    0.940

Covariances:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
  MATH ~~                                                               
    SPELL             0.517    0.053    9.710    0.000    0.517    0.517

Intercepts:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
    MATH              0.000                               0.000    0.000
    SPELL             0.000                               0.000    0.000
   .wratclc (.18.)   39.217    0.417   93.947    0.000   39.217    6.282
   .wjcalc  (.19.)   24.012    0.296   81.184    0.000   24.012    5.350
   .waisclc (.20.)   11.139    0.206   54.146    0.000   11.139    3.383
   .wratspl (.21.)   36.153    0.451   80.244    0.000   36.153    5.335
   .wjspl   (.22.)   41.328    0.466   88.600    0.000   41.328    5.907
   .waisspl (.23.)   36.840    0.440   83.781    0.000   36.840    5.565

Variances:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
    MATH              1.000                               1.000    1.000
    SPELL             1.000                               1.000    1.000
   .wratclc (.11.)    4.104    0.998    4.111    0.000    4.104    0.105
   .wjcalc  (.12.)    3.827    0.530    7.224    0.000    3.827    0.190
   .waisclc (.13.)    5.283    0.457   11.562    0.000    5.283    0.487
   .wratspl (.14.)    5.057    0.612    8.266    0.000    5.057    0.110
   .wjspl   (.15.)    4.554    0.616    7.388    0.000    4.554    0.093
   .waisspl (.16.)    5.140    0.598    8.588    0.000    5.140    0.117
anova(scalarOutput, strictOutput)
Chi Square Difference Test

             Df   AIC   BIC  Chisq Chisq diff Df diff Pr(>Chisq)
scalarOutput 24 10302 10415 36.361                              
strictOutput 30 10294 10385 40.717     4.3551       6     0.6287

Session Info

R version 3.5.1 (2018-07-02)
Platform: x86_64-redhat-linux-gnu (64-bit)
Running under: CentOS Linux 7 (Core)

Matrix products: default
BLAS/LAPACK: /usr/lib64/R/lib/libRblas.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] lavaan_0.6-3        stationery_0.98.5.7

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.0      digest_0.6.18   MASS_7.3-51.1   plyr_1.8.4     
 [5] xtable_1.8-3    magrittr_1.5    stats4_3.5.1    evaluate_0.12  
 [9] zip_1.0.0       stringi_1.2.4   pbivnorm_0.6.0  openxlsx_4.1.0 
[13] rmarkdown_1.11  tools_3.5.1     stringr_1.3.1   foreign_0.8-71 
[17] kutils_1.59     yaml_2.2.0      xfun_0.4        compiler_3.5.1 
[21] mnormt_1.5-5    htmltools_0.3.6 knitr_1.21     

Available under Created Commons license 3.0 CC BY