\begin{Schunk}
\begin{Sinput}
 scalarModel <- "
    MATH =~ wratcalc + wjcalc + waiscalc
    SPELL =~ wratspl + wjspl + waisspl
    MATH ~~ c(1, NA)*MATH
    SPELL ~~ c(1, NA)*SPELL
    MATH ~ c(0, NA)*1
    SPELL ~ c(0, NA)*1
  "
 scalarOutput <- cfa(model = scalarModel, data = dat, std.lv = TRUE,
                      group = "female",
                      group.equal = c("loadings", "intercepts"),
                      missing = "fiml")
 summary(scalarOutput)
\end{Sinput}
\begin{Soutput}
lavaan (0.5-23.1097) converged normally after  95 iterations

  Number of observations per group         
  1                                                101
  0                                                221

  Number of missing patterns per group     
  1                                                  4
  0                                                  2

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

Chi-square for each group:

  1                                             22.546
  0                                             13.815

Parameter Estimates:

  Information                                 Observed
  Standard Errors                             Standard


Group 1 [1]:

Latent Variables:
                   Estimate  Std.Err  z-value  P(>|z|)
  MATH =~                                             
    wratclc (.p1.)    6.381    0.491   12.994    0.000
    wjcalc  (.p2.)    4.340    0.342   12.699    0.000
    waisclc (.p3.)    2.529    0.232   10.895    0.000
  SPELL =~                                            
    wratspl (.p4.)    6.751    0.508   13.299    0.000
    wjspl   (.p5.)    7.015    0.516   13.592    0.000
    waisspl (.p6.)    6.578    0.494   13.329    0.000

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

Intercepts:
                   Estimate  Std.Err  z-value  P(>|z|)
    MATH              0.000                           
    SPELL             0.000                           
   .wratclc (.18.)   38.273    0.653   58.628    0.000
   .wjcalc  (.19.)   23.374    0.454   51.465    0.000
   .waisclc (.20.)   10.751    0.289   37.239    0.000
   .wratspl (.21.)   37.211    0.692   53.771    0.000
   .wjspl   (.22.)   42.411    0.713   59.443    0.000
   .waisspl (.23.)   37.869    0.675   56.144    0.000

Variances:
                   Estimate  Std.Err  z-value  P(>|z|)
    MATH              1.000                           
    SPELL             1.000                           
   .wratcalc          2.841    1.424    1.995    0.046
   .wjcalc            3.743    0.793    4.723    0.000
   .waiscalc          4.977    0.766    6.496    0.000
   .wratspl           5.681    1.123    5.056    0.000
   .wjspl             3.237    0.930    3.481    0.000
   .waisspl           5.035    1.032    4.880    0.000


Group 2 [0]:

Latent Variables:
                   Estimate  Std.Err  z-value  P(>|z|)
  MATH =~                                             
    wratclc (.p1.)    6.381    0.491   12.994    0.000
    wjcalc  (.p2.)    4.340    0.342   12.699    0.000
    waisclc (.p3.)    2.529    0.232   10.895    0.000
  SPELL =~                                            
    wratspl (.p4.)    6.751    0.508   13.299    0.000
    wjspl   (.p5.)    7.015    0.516   13.592    0.000
    waisspl (.p6.)    6.578    0.494   13.329    0.000

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

Intercepts:
                   Estimate  Std.Err  z-value  P(>|z|)
    MATH              0.148    0.121    1.220    0.222
    SPELL            -0.156    0.121   -1.293    0.196
   .wratclc (.18.)   38.273    0.653   58.628    0.000
   .wjcalc  (.19.)   23.374    0.454   51.465    0.000
   .waisclc (.20.)   10.751    0.289   37.239    0.000
   .wratspl (.21.)   37.211    0.692   53.771    0.000
   .wjspl   (.22.)   42.411    0.713   59.443    0.000
   .waisspl (.23.)   37.869    0.675   56.144    0.000

Variances:
                   Estimate  Std.Err  z-value  P(>|z|)
    MATH              0.857    0.156    5.502    0.000
    SPELL             0.894    0.158    5.676    0.000
   .wratcalc          4.518    1.204    3.753    0.000
   .wjcalc            3.911    0.655    5.970    0.000
   .waiscalc          5.431    0.576    9.435    0.000
   .wratspl           4.762    0.721    6.603    0.000
   .wjspl             5.173    0.791    6.541    0.000
   .waisspl           5.235    0.734    7.134    0.000
\end{Soutput}
\begin{Sinput}
 anova(metricOutput, scalarOutput)
\end{Sinput}
\begin{Soutput}
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
\end{Soutput}
\end{Schunk}
