\begin{Schunk}
\begin{Sinput}
 metricModel <- "
    MATH =~ wratcalc + wjcalc + waiscalc
    SPELL =~ wratspl + wjspl + waisspl
    MATH ~~ c(1, NA)*MATH
    SPELL ~~ c(1, NA)*SPELL
  "
 metricOutput <- cfa(model = metricModel, data = dat, std.lv = TRUE,
                      group = "female", group.equal = "loadings",
                      missing = "fiml")
 summary(metricOutput)
\end{Sinput}
\begin{Soutput}
lavaan 0.6-3 ended normally after 71 iterations

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

  Number of observations per group         
  1                                                101
  0                                                221
  Number of missing patterns per group     
  1                                                  4
  0                                                  2

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

Chi-square for each group:

  1                                             15.581
  0                                             10.290

Parameter Estimates:

  Information                                 Observed
  Observed information based on                Hessian
  Standard Errors                             Standard


Group 1 [1]:

Latent Variables:
                   Estimate  Std.Err  z-value  P(>|z|)
  MATH =~                                             
    wratclc (.p1.)    6.359    0.490   12.972    0.000
    wjcalc  (.p2.)    4.354    0.342   12.729    0.000
    waisclc (.p3.)    2.502    0.229   10.909    0.000
  SPELL =~                                            
    wratspl (.p4.)    6.751    0.508   13.295    0.000
    wjspl   (.p5.)    7.020    0.516   13.592    0.000
    waisspl (.p6.)    6.568    0.493   13.326    0.000

Covariances:
                   Estimate  Std.Err  z-value  P(>|z|)
  MATH ~~                                             
    SPELL             0.641    0.063   10.164    0.000

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

Variances:
                   Estimate  Std.Err  z-value  P(>|z|)
    MATH              1.000                           
    SPELL             1.000                           
   .wratcalc          3.047    1.413    2.157    0.031
   .wjcalc            3.603    0.778    4.632    0.000
   .waiscalc          4.700    0.714    6.586    0.000
   .wratspl           5.686    1.123    5.061    0.000
   .wjspl             3.230    0.929    3.478    0.001
   .waisspl           4.995    1.023    4.883    0.000


Group 2 [0]:

Latent Variables:
                   Estimate  Std.Err  z-value  P(>|z|)
  MATH =~                                             
    wratclc (.p1.)    6.359    0.490   12.972    0.000
    wjcalc  (.p2.)    4.354    0.342   12.729    0.000
    waisclc (.p3.)    2.502    0.229   10.909    0.000
  SPELL =~                                            
    wratspl (.p4.)    6.751    0.508   13.295    0.000
    wjspl   (.p5.)    7.020    0.516   13.592    0.000
    waisspl (.p6.)    6.568    0.493   13.326    0.000

Covariances:
                   Estimate  Std.Err  z-value  P(>|z|)
  MATH ~~                                             
    SPELL             0.456    0.089    5.103    0.000

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

Variances:
                   Estimate  Std.Err  z-value  P(>|z|)
    MATH              0.860    0.156    5.501    0.000
    SPELL             0.895    0.158    5.676    0.000
   .wratcalc          4.619    1.205    3.834    0.000
   .wjcalc            3.835    0.654    5.864    0.000
   .waiscalc          5.370    0.564    9.525    0.000
   .wratspl           4.764    0.721    6.607    0.000
   .wjspl             5.154    0.790    6.526    0.000
   .waisspl           5.233    0.732    7.153    0.000
\end{Soutput}
\begin{Sinput}
 anova(configOutput, metricOutput)
\end{Sinput}
\begin{Soutput}
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
\end{Soutput}
\end{Schunk}
