SUPPLEMENTARY ANALYSIS FOR PROJECT TALENT - REMOVING ALL KNOWLEDGE ITEMS

Sys.setenv(LANG = "en") # make R environment in english

require(MASS)
require(lavaan) # get SEM, CFA, MGCFA programs
require(psych) # get fa.parallel() and VSS() functions
require(GPArotation) # get quartimax rotation
require(survey)
require(psy)
require(dplyr)
require(semTools)
require(MVN) # get mvn
require(RVAideMemoire) # get qqnorm

Mc<-function(object, digits=3){ # McDonald's NC Index, from Beaujean
fit<-inspect(object, "fit")
chisq=unlist(fit["chisq"])
df<-unlist(fit["df"])
n<-object@SampleStats@ntotal
ncp<-max(chisq-df,0)
d<-ncp/(n-1)
Mc=exp((d)*-.5)
Mc
}

# RMSEAd functions taken from Savalei et al. (2023) : https://osf.io/ne5ar for RMSEA CI and https://osf.io/cfubt for RMSEAd
# make sure you DO NOT FORGET TO ADJUST the sample size in the N function or it will produce wrong numbers


RMSEA.CI<-function(T,df,N,G){

#functions taken from lavaan (lav_fit_measures.R)
lower.lambda <- function(lambda) {
(pchisq(T, df=df, ncp=lambda) - 0.95)
}
upper.lambda <- function(lambda) {
(pchisq(T, df=df, ncp=lambda) - 0.05)
}

#RMSEA CI
lambda.l <- try(uniroot(f=lower.lambda, lower=0, upper=T)$root,silent=TRUE)
if(inherits(lambda.l, "try-error")) { lambda.l <- NA; RMSEA.CI.l<-NA
} else { if(lambda.l<0){
RMSEA.CI.l=0
} else {
RMSEA.CI.l<-sqrt(lambda.l*G/((N-1)*df))
}
}

N.RMSEA <- max(N, T*4)
lambda.u <- try(uniroot(f=upper.lambda, lower=0,upper=N.RMSEA)$root,silent=TRUE)
if(inherits(lambda.u, "try-error")) { lambda.u <- NA; RMSEA.CI.u<-NA
} else { if(lambda.u<0){
RMSEA.CI.u=0
} else {
RMSEA.CI.u<-sqrt(lambda.u*G/((N-1)*df))
}
}
RMSEA.CI<-c(RMSEA.CI.l,RMSEA.CI.u)
return(RMSEA.CI)
}

#p-values associated with the critical values of the RMSEA for most common cutoffs
pvals<-function(T,df,N,G){
RMSEA0<-c(0,.01,.05,.06,.08,.1)
eps0<-df*RMSEA0^2/G
nonc<-eps0*(N-G)
pvals<-pchisq(T,df=df,ncp=nonc)
names(pvals)<-c("RMSEA>0","RMSEA>.01","RMSEA>.05","RMSEA>.06","RMSEA>.08","RMSEA>.10")
return(pvals)
}

#based on Yuan & Chan (2016)
min.tol<-function(T,df,N,G){

lower.lambda.mintol <- function(lambda) {
(pchisq(T, df=df, ncp=lambda) - 0.05)
}

l.min.tol<-try(uniroot(f=lower.lambda.mintol, lower=0, upper=T)$root)
l.min.tol
RMSEA.mintol<-sqrt(l.min.tol*G/((N-1)*df))
RMSEA.mintol
out<-c(l.min.tol,RMSEA.mintol)
names(out)<-c("ncp(T)","RMSEA.pop")
return(out)
}

BEGIN HERE IF WORKING WITH MY IMPUTED DATA

d<-read.csv(file = "C:\\Users\\mh198\\OneDrive\\Documents\\Data\\Project Talent\\TALENTimpute.csv")
table(d$age)
## 
##  9.04 12.01 12.04 12.05 12.06 12.07 12.08 12.09  12.1 12.11    13 13.01 
##     1     1     1     1     2     4     4    15    44    42    58    55 
## 13.02 13.03 13.04 13.05 13.06 13.07 13.08 13.09  13.1 13.11    14 14.01 
##    84    89    93    86    90   113   135   191   319   391   579   830 
## 14.02 14.03 14.04 14.05 14.06 14.07 14.08 14.09  14.1 14.11    15 15.01 
##  1422  1840  2226  2471  2666  2716  2592  2552  2463  2483  2726  2687 
## 15.02 15.03 15.04 15.05 15.06 15.07 15.08 15.09  15.1 15.11    16 16.01 
##  2881  2927  2969  3131  3355  3171  3115  2916  2865  2960  2992  3118 
## 16.02 16.03 16.04 16.05 16.06 16.07 16.08 16.09  16.1 16.11    17 17.01 
##  3171  3122  3223  3485  3553  3519  3306  3182  3233  3291  3295  3555 
## 17.02 17.03 17.04 17.05 17.06 17.07 17.08 17.09  17.1 17.11 17.99    18 
##  3520  3563  3576  3377  3192  2988  2771  2510  2450  2324     5  2022 
## 18.01 18.02 18.03 18.04 18.05 18.06 18.07 18.08 18.09  18.1 18.11 18.99 
##  1776  1047   816   578   478   392   370   327   243   227   219     2 
##    19 19.01 19.02 19.03 19.04 19.05 19.06 19.07 19.08 19.09  19.1 19.11 
##   164   142   105    96    80    63    58    44    43    34    36    25 
##    20 20.01 20.02 20.03 20.04 20.05 20.06 20.07 20.08 20.09  20.1 20.11 
##    20    20    24    15    13    10    10     8     9     9     3     4 
##    21 21.01 21.03 21.04 21.05 21.06 21.08  21.1 21.11 
##     5     6     4     2     3     3     2     1     1
describeBy(d$age)
## Warning in describeBy(d$age): no grouping variable requested
##    vars      n  mean   sd median trimmed  mad  min   max range skew
## X1    1 148242 15.83 1.23  16.03   15.82 1.48 9.04 21.11 12.07 0.03
##    kurtosis se
## X1    -0.59  0
d$age<- d$age-16
d$age2<- d$age^2
describeBy(d$age, d$sex) # no difference in age
## 
##  Descriptive statistics by group 
## group: 0
##    vars     n  mean   sd median trimmed  mad   min  max range skew
## X1    1 73219 -0.12 1.26   0.04   -0.13 1.48 -3.99 5.11   9.1 0.06
##    kurtosis se
## X1    -0.53  0
## ------------------------------------------------------ 
## group: 1
##    vars     n  mean  sd median trimmed  mad   min  max range  skew
## X1    1 75023 -0.22 1.2   0.03   -0.22 1.47 -6.96 5.06 12.02 -0.02
##    kurtosis se
## X1    -0.69  0
d$Stest5math<- log(d$Stest5math)
d$Stest8aeronautics<- log10(d$Stest8aeronautics)
d$Stest9electronics<- log(d$Stest9electronics)
d$Stest25wordfunctions<- sqrt(d$Stest25wordfunctions)
d$Stest21capitalization<- (d$Stest21capitalization^8) # a bunch of extreme low scores
d$Stest35tablereading<- log(d$Stest35tablereading)
hist(d$Stest5math)

hist(d$Stest8aeronautics)

hist(d$Stest9electronics)

hist(d$Stest21capitalization)

hist(d$Stest25wordfunctions)

hist(d$Stest35tablereading)

describeBy(d)
## Warning in describeBy(d): no grouping variable requested
##                             vars      n          mean           sd
## Stest1vocab                    1 148850  1.316000e+01 3.950000e+00
## Stest2literature               2 148850  1.328000e+01 4.560000e+00
## Stest3music                    3 148850  6.850000e+00 2.930000e+00
## Stest4socialstudies            4 148850  1.558000e+01 5.100000e+00
## Stest5math                     5 148850  2.080000e+00 6.700000e-01
## Stest6physicalscience          6 148850  9.180000e+00 4.110000e+00
## Stest7biologicalscience        7 148850  6.330000e+00 2.340000e+00
## Stest8aeronautics              8 148850  5.400000e-01 2.700000e-01
## Stest9electronics              9 148850  1.910000e+00 6.000000e-01
## Stest10mechanics              10 148850  1.037000e+01 3.870000e+00
## Stest11art                    11 148850  6.690000e+00 2.480000e+00
## Stest12law                    12 148850  4.890000e+00 1.780000e+00
## Stest13health                 13 148850  6.210000e+00 1.870000e+00
## Stest14bible                  14 148850  7.590000e+00 3.300000e+00
## Stest15theater                15 148850  4.550000e+00 1.770000e+00
## Stest16miscellaneous          16 148850  4.970000e+00 1.710000e+00
## Stest17memsentences           17 148850  9.360000e+00 2.980000e+00
## Stest18memwords               18 148850  1.236000e+01 5.460000e+00
## Stest19disguisedwords         19 148850  1.605000e+01 6.840000e+00
## Stest20spelling               20 148850  9.780000e+00 2.980000e+00
## Stest21capitalization         21 148850  7.769234e+11 3.511487e+11
## Stest22punctuation            22 148850  1.861000e+01 4.390000e+00
## Stest23english                23 148850  1.721000e+01 3.130000e+00
## Stest24expression             24 148850  8.950000e+00 2.180000e+00
## Stest25wordfunctions          25 148850  3.250000e+00 8.600000e-01
## Stest26readingcomprehension   26 148850  3.253000e+01 9.980000e+00
## Stest27creativity             27 148850  9.510000e+00 3.900000e+00
## Stest28mechanicalreasoning    28 148850  1.120000e+01 4.220000e+00
## Stest29visualization2D        29 148850  1.348000e+01 5.470000e+00
## Stest30visualization3D        30 148850  9.070000e+00 3.180000e+00
## Stest31abstractreasoning      31 148850  9.500000e+00 2.790000e+00
## Stest32arithreasoning         32 148850  9.130000e+00 3.490000e+00
## Stest33highschoolmath         33 148850  1.157000e+01 4.920000e+00
## Stest34arithcomputation       34 148850  3.962000e+01 9.800000e+00
## Stest35tablereading           35 148850  2.440000e+00 5.100000e-01
## Stest36clericalchecking       36 148850  3.772000e+01 1.380000e+01
## Stest37objectinspection       37 148850  2.353000e+01 6.860000e+00
## wb                            38 148850  4.000000e-02 2.000000e-01
## sex                           39 148850  5.100000e-01 5.000000e-01
## age                           40 148242 -1.700000e-01 1.230000e+00
## BY_ID_RE                      41 148850  4.999295e+07 2.886691e+07
## BY_TESTG                      42 148850  1.052000e+01 1.100000e+00
## BY_WTA                        43 148850  2.140200e+02 7.610000e+01
## age2                          44 148242  1.540000e+00 1.840000e+00
##                                   median       trimmed          mad
## Stest1vocab                 1.300000e+01  1.332000e+01 4.450000e+00
## Stest2literature            1.300000e+01  1.324000e+01 4.450000e+00
## Stest3music                 7.000000e+00  6.850000e+00 2.970000e+00
## Stest4socialstudies         1.600000e+01  1.584000e+01 5.930000e+00
## Stest5math                  2.200000e+00  2.130000e+00 6.600000e-01
## Stest6physicalscience       9.000000e+00  9.120000e+00 4.450000e+00
## Stest7biologicalscience     6.000000e+00  6.370000e+00 2.970000e+00
## Stest8aeronautics           6.000000e-01  5.600000e-01 2.600000e-01
## Stest9electronics           1.950000e+00  1.950000e+00 5.300000e-01
## Stest10mechanics            1.000000e+01  1.036000e+01 4.450000e+00
## Stest11art                  7.000000e+00  6.740000e+00 2.970000e+00
## Stest12law                  5.000000e+00  4.880000e+00 1.480000e+00
## Stest13health               6.000000e+00  6.340000e+00 1.480000e+00
## Stest14bible                7.000000e+00  7.510000e+00 2.970000e+00
## Stest15theater              5.000000e+00  4.560000e+00 1.480000e+00
## Stest16miscellaneous        5.000000e+00  4.990000e+00 1.480000e+00
## Stest17memsentences         9.000000e+00  9.390000e+00 2.970000e+00
## Stest18memwords             1.200000e+01  1.209000e+01 5.930000e+00
## Stest19disguisedwords       1.600000e+01  1.598000e+01 7.410000e+00
## Stest20spelling             1.000000e+01  9.830000e+00 2.970000e+00
## Stest21capitalization       8.528910e+11  7.854755e+11 3.656397e+11
## Stest22punctuation          1.900000e+01  1.879000e+01 4.450000e+00
## Stest23english              1.700000e+01  1.735000e+01 2.970000e+00
## Stest24expression           9.000000e+00  9.140000e+00 1.480000e+00
## Stest25wordfunctions        3.320000e+00  3.270000e+00 1.010000e+00
## Stest26readingcomprehension 3.400000e+01  3.329000e+01 1.038000e+01
## Stest27creativity           9.000000e+00  9.450000e+00 4.450000e+00
## Stest28mechanicalreasoning  1.100000e+01  1.119000e+01 4.450000e+00
## Stest29visualization2D      1.400000e+01  1.368000e+01 5.930000e+00
## Stest30visualization3D      9.000000e+00  9.090000e+00 2.970000e+00
## Stest31abstractreasoning    1.000000e+01  9.690000e+00 2.970000e+00
## Stest32arithreasoning       9.000000e+00  9.170000e+00 4.450000e+00
## Stest33highschoolmath       1.100000e+01  1.134000e+01 5.930000e+00
## Stest34arithcomputation     4.000000e+01  3.975000e+01 8.900000e+00
## Stest35tablereading         2.480000e+00  2.460000e+00 4.300000e-01
## Stest36clericalchecking     3.500000e+01  3.611000e+01 1.186000e+01
## Stest37objectinspection     2.300000e+01  2.319000e+01 5.930000e+00
## wb                          0.000000e+00  0.000000e+00 0.000000e+00
## sex                         1.000000e+00  5.100000e-01 0.000000e+00
## age                         3.000000e-02 -1.800000e-01 1.480000e+00
## BY_ID_RE                    5.005785e+07  4.999712e+07 3.698814e+07
## BY_TESTG                    1.100000e+01  1.053000e+01 1.480000e+00
## BY_WTA                      2.100000e+02  2.053900e+02 1.483000e+01
## age2                        1.000000e+00  1.290000e+00 1.460000e+00
##                               min          max        range  skew
## Stest1vocab                  1.00 2.100000e+01 2.000000e+01 -0.34
## Stest2literature             1.00 2.400000e+01 2.300000e+01  0.07
## Stest3music                  1.00 1.300000e+01 1.200000e+01 -0.02
## Stest4socialstudies          1.00 2.400000e+01 2.300000e+01 -0.39
## Stest5math                   0.00 3.140000e+00 3.140000e+00 -0.76
## Stest6physicalscience        1.00 1.800000e+01 1.700000e+01  0.10
## Stest7biologicalscience      1.00 1.100000e+01 1.000000e+01 -0.15
## Stest8aeronautics            0.00 1.000000e+00 1.000000e+00 -0.46
## Stest9electronics            0.00 3.000000e+00 3.000000e+00 -0.69
## Stest10mechanics             1.00 1.900000e+01 1.800000e+01  0.01
## Stest11art                   1.00 1.200000e+01 1.100000e+01 -0.16
## Stest12law                   1.00 9.000000e+00 8.000000e+00  0.05
## Stest13health                1.00 9.000000e+00 8.000000e+00 -0.60
## Stest14bible                 1.00 1.500000e+01 1.400000e+01  0.20
## Stest15theater               1.00 8.000000e+00 7.000000e+00 -0.01
## Stest16miscellaneous         1.00 1.000000e+01 9.000000e+00 -0.06
## Stest17memsentences          1.00 1.600000e+01 1.500000e+01 -0.10
## Stest18memwords              1.00 2.400000e+01 2.300000e+01  0.37
## Stest19disguisedwords        1.00 3.000000e+01 2.900000e+01  0.07
## Stest20spelling              1.00 1.600000e+01 1.500000e+01 -0.17
## Stest21capitalization        1.00 1.406409e+12 1.406409e+12 -0.19
## Stest22punctuation           1.00 2.700000e+01 2.600000e+01 -0.36
## Stest23english               1.00 2.500000e+01 2.400000e+01 -0.51
## Stest24expression            1.00 1.200000e+01 1.100000e+01 -0.83
## Stest25wordfunctions         1.00 4.900000e+00 3.900000e+00 -0.12
## Stest26readingcomprehension  1.00 4.800000e+01 4.700000e+01 -0.58
## Stest27creativity            1.00 2.000000e+01 1.900000e+01  0.14
## Stest28mechanicalreasoning   1.00 2.000000e+01 1.900000e+01  0.02
## Stest29visualization2D       1.00 2.400000e+01 2.300000e+01 -0.27
## Stest30visualization3D       1.00 1.600000e+01 1.500000e+01 -0.05
## Stest31abstractreasoning     1.00 1.500000e+01 1.400000e+01 -0.58
## Stest32arithreasoning        1.00 1.600000e+01 1.500000e+01 -0.08
## Stest33highschoolmath        1.00 2.400000e+01 2.300000e+01  0.39
## Stest34arithcomputation      1.00 7.200000e+01 7.100000e+01 -0.14
## Stest35tablereading          0.00 4.280000e+00 4.280000e+00 -0.62
## Stest36clericalchecking      1.00 7.400000e+01 7.300000e+01  0.95
## Stest37objectinspection      1.00 4.000000e+01 3.900000e+01  0.36
## wb                           0.00 1.000000e+00 1.000000e+00  4.61
## sex                          0.00 1.000000e+00 1.000000e+00 -0.02
## age                         -6.96 5.110000e+00 1.207000e+01  0.03
## BY_ID_RE                    70.00 9.999902e+07 9.999895e+07  0.00
## BY_TESTG                     9.00 1.200000e+01 3.000000e+00 -0.04
## BY_WTA                       9.00 7.500000e+02 7.410000e+02  2.84
## age2                         0.00 4.844000e+01 4.844000e+01  2.70
##                             kurtosis           se
## Stest1vocab                    -0.45         0.01
## Stest2literature               -0.60         0.01
## Stest3music                    -0.86         0.01
## Stest4socialstudies            -0.61         0.01
## Stest5math                      0.40         0.00
## Stest6physicalscience          -0.84         0.01
## Stest7biologicalscience        -0.70         0.01
## Stest8aeronautics              -0.55         0.00
## Stest9electronics               0.66         0.00
## Stest10mechanics               -0.70         0.01
## Stest11art                     -0.57         0.01
## Stest12law                     -0.49         0.00
## Stest13health                  -0.17         0.00
## Stest14bible                   -0.74         0.01
## Stest15theater                 -0.72         0.00
## Stest16miscellaneous           -0.34         0.00
## Stest17memsentences            -0.48         0.01
## Stest18memwords                -0.67         0.01
## Stest19disguisedwords          -0.82         0.02
## Stest20spelling                -0.47         0.01
## Stest21capitalization          -0.58 910157730.80
## Stest22punctuation             -0.29         0.01
## Stest23english                  0.63         0.01
## Stest24expression               0.45         0.01
## Stest25wordfunctions           -0.84         0.00
## Stest26readingcomprehension    -0.46         0.03
## Stest27creativity              -0.54         0.01
## Stest28mechanicalreasoning     -0.82         0.01
## Stest29visualization2D         -0.56         0.01
## Stest30visualization3D         -0.69         0.01
## Stest31abstractreasoning        0.04         0.01
## Stest32arithreasoning          -0.82         0.01
## Stest33highschoolmath          -0.54         0.01
## Stest34arithcomputation         0.29         0.03
## Stest35tablereading             3.93         0.00
## Stest36clericalchecking         0.39         0.04
## Stest37objectinspection        -0.11         0.02
## wb                             19.29         0.00
## sex                            -2.00         0.00
## age                            -0.59         0.00
## BY_ID_RE                       -1.20     74821.40
## BY_TESTG                       -1.32         0.00
## BY_WTA                         12.55         0.20
## age2                           16.52         0.00
d <- d %>% mutate(across(starts_with("Stest"), ~scale(.x, center = TRUE, scale = TRUE)))

# since log10 reduces variance so much and power8 increases variance so much, scale() is needed to stabilize variance across variables, or else cfa won't converge or estimate properly
# d <- d %>% mutate(across(starts_with("Stest"), ~scale(.x, center = TRUE, scale = TRUE)))
# d <- d %>% mutate(across(starts_with("Stest"), ~ . * 15 + 100)) ## if you need to convert into IQ scale after scaling
d<- na.omit(d)
dw<- filter(d, wb==0) # white
db<- filter(d, wb==1) # black

MGCFA FOR WHITES

dmale<- subset(dw, sex==0)
dfemale<- subset(dw, sex==1)

datamale<- select(dmale, starts_with("Stest"), -Stest2literature, -Stest3music, -Stest4socialstudies, -Stest6physicalscience, -Stest7biologicalscience, -Stest8aeronautics, -Stest9electronics, -Stest10mechanics, -Stest11art, -Stest12law, -Stest13health, -Stest14bible, -Stest15theater, -Stest16miscellaneous, -Stest17memsentences, -Stest18memwords, -Stest27creativity)
datafemale<- select(dfemale, starts_with("Stest"), -Stest2literature, -Stest3music, -Stest4socialstudies, -Stest6physicalscience, -Stest7biologicalscience, -Stest8aeronautics, -Stest9electronics, -Stest10mechanics, -Stest11art, -Stest12law, -Stest13health, -Stest14bible, -Stest15theater, -Stest16miscellaneous, -Stest17memsentences, -Stest18memwords, -Stest27creativity)
datagroup<- select(dw, starts_with("Stest"), -Stest2literature, -Stest3music, -Stest4socialstudies, -Stest6physicalscience, -Stest7biologicalscience, -Stest8aeronautics, -Stest9electronics, -Stest10mechanics, -Stest11art, -Stest12law, -Stest13health, -Stest14bible, -Stest15theater, -Stest16miscellaneous, -Stest17memsentences, -Stest18memwords, -Stest27creativity)
dgroup<- select(dw, starts_with("Stest"), wb, age, age2, sex, BY_WTA, -Stest2literature, -Stest3music, -Stest4socialstudies, -Stest6physicalscience, -Stest7biologicalscience, -Stest8aeronautics, -Stest9electronics, -Stest10mechanics, -Stest11art, -Stest12law, -Stest13health, -Stest14bible, -Stest15theater, -Stest16miscellaneous, -Stest17memsentences, -Stest18memwords, -Stest27creativity)
describeBy(dgroup$age) 
## Warning in describeBy(dgroup$age): no grouping variable requested
##    vars      n  mean   sd median trimmed  mad   min max range skew
## X1    1 142157 -0.17 1.22   0.03   -0.18 1.47 -6.96 5.1 12.06 0.01
##    kurtosis se
## X1    -0.63  0
dgroup_design <- svydesign(ids = ~1, weights = ~BY_WTA, data = dgroup)
weighted_mean <- svymean(~age, dgroup_design)
weighted_variance <- svyvar(~age, dgroup_design)
weighted_sd <- sqrt(weighted_variance)
weighted_mean # prior to mean centering
##         mean     SE
## age -0.16191 0.0034
weighted_sd # 1.22
##     variance     SE
## age   1.2208 0.0048
describeBy(datamale)
## Warning in describeBy(datamale): no grouping variable requested
##                             vars     n  mean   sd median trimmed  mad
## Stest1vocab                    1 70776  0.19 0.93   0.21    0.23 1.13
## Stest5math                     2 70776  0.22 0.94   0.33    0.30 0.90
## Stest19disguisedwords          3 70776 -0.09 0.98  -0.15   -0.12 1.08
## Stest20spelling                4 70776 -0.24 1.00  -0.26   -0.24 1.00
## Stest21capitalization          5 70776 -0.20 0.98  -0.34   -0.18 0.83
## Stest22punctuation             6 70776 -0.20 0.99  -0.14   -0.18 1.01
## Stest23english                 7 70776 -0.13 1.02  -0.07   -0.09 0.95
## Stest24expression              8 70776 -0.11 1.04   0.02   -0.01 0.68
## Stest25wordfunctions           9 70776 -0.13 0.97  -0.10   -0.13 1.22
## Stest26readingcomprehension   10 70776 -0.01 1.02   0.15    0.07 1.04
## Stest28mechanicalreasoning    11 70776  0.53 0.89   0.66    0.58 1.05
## Stest29visualization2D        12 70776  0.22 0.97   0.28    0.28 1.08
## Stest30visualization3D        13 70776  0.20 1.02   0.29    0.23 0.93
## Stest31abstractreasoning      14 70776  0.07 0.98   0.18    0.13 1.06
## Stest32arithreasoning         15 70776  0.13 0.99   0.25    0.15 1.27
## Stest33highschoolmath         16 70776  0.14 1.04   0.09    0.10 1.20
## Stest34arithcomputation       17 70776 -0.07 0.99  -0.06   -0.07 0.91
## Stest35tablereading           18 70776 -0.05 1.03   0.08   -0.03 0.84
## Stest36clericalchecking       19 70776 -0.13 1.01  -0.41   -0.27 0.75
## Stest37objectinspection       20 70776 -0.08 1.03  -0.22   -0.14 0.86
##                               min  max range  skew kurtosis se
## Stest1vocab                 -3.08 1.99  5.07 -0.45    -0.19  0
## Stest5math                  -3.10 1.58  4.68 -0.88     0.70  0
## Stest19disguisedwords       -2.20 2.04  4.24  0.19    -0.75  0
## Stest20spelling             -2.95 2.09  5.04 -0.02    -0.47  0
## Stest21capitalization       -2.21 1.79  4.01 -0.02    -0.60  0
## Stest22punctuation          -4.01 1.91  5.92 -0.21    -0.32  0
## Stest23english              -5.18 2.49  7.66 -0.46     0.57  0
## Stest24expression           -3.65 1.40  5.06 -0.78     0.29  0
## Stest25wordfunctions        -2.61 1.91  4.52 -0.02    -0.75  0
## Stest26readingcomprehension -3.16 1.55  4.71 -0.58    -0.50  0
## Stest28mechanicalreasoning  -2.41 2.08  4.50 -0.43    -0.41  0
## Stest29visualization2D      -2.28 1.92  4.21 -0.48    -0.29  0
## Stest30visualization3D      -2.54 2.18  4.72 -0.24    -0.69  0
## Stest31abstractreasoning    -3.05 1.97  5.03 -0.56     0.09  0
## Stest32arithreasoning       -2.33 1.97  4.30 -0.16    -0.78  0
## Stest33highschoolmath       -2.15 2.52  4.67  0.29    -0.73  0
## Stest34arithcomputation     -3.94 3.30  7.24  0.04     0.19  0
## Stest35tablereading         -4.82 3.61  8.43 -0.35     3.20  0
## Stest36clericalchecking     -2.66 2.63  5.29  1.11     0.68  0
## Stest37objectinspection     -3.28 2.40  5.69  0.49    -0.12  0
describeBy(datafemale)
## Warning in describeBy(datafemale): no grouping variable requested
##                             vars     n  mean   sd median trimmed  mad
## Stest1vocab                    1 71381 -0.08 0.98  -0.04   -0.06 1.13
## Stest5math                     2 71381 -0.14 0.99   0.00   -0.06 1.04
## Stest19disguisedwords          3 71381  0.17 0.97   0.14    0.18 1.08
## Stest20spelling                4 71381  0.29 0.91   0.41    0.32 1.00
## Stest21capitalization          5 71381  0.28 0.92   0.22    0.31 1.04
## Stest22punctuation             6 71381  0.28 0.90   0.32    0.33 1.01
## Stest23english                 7 71381  0.20 0.91   0.25    0.23 0.95
## Stest24expression              8 71381  0.17 0.89   0.48    0.25 0.68
## Stest25wordfunctions           9 71381  0.20 0.99   0.25    0.24 1.13
## Stest26readingcomprehension   10 71381  0.12 0.91   0.25    0.18 1.04
## Stest28mechanicalreasoning    11 71381 -0.43 0.82  -0.52   -0.46 0.70
## Stest29visualization2D        12 71381 -0.15 0.96  -0.09   -0.13 1.08
## Stest30visualization3D        13 71381 -0.12 0.93  -0.02   -0.13 0.93
## Stest31abstractreasoning      14 71381  0.03 0.95   0.18    0.09 1.06
## Stest32arithreasoning         15 71381 -0.04 0.97  -0.04   -0.03 1.27
## Stest33highschoolmath         16 71381 -0.06 0.93  -0.12   -0.11 0.90
## Stest34arithcomputation       17 71381  0.16 0.93   0.14    0.18 0.91
## Stest35tablereading           18 71381  0.10 0.87   0.08    0.12 0.65
## Stest36clericalchecking       19 71381  0.11 0.94  -0.05    0.01 0.75
## Stest37objectinspection       20 71381  0.09 0.94   0.07    0.06 0.86
##                               min  max range  skew kurtosis se
## Stest1vocab                 -3.08 1.99  5.07 -0.18    -0.61  0
## Stest5math                  -3.10 1.58  4.68 -0.73     0.37  0
## Stest19disguisedwords       -2.20 2.04  4.24 -0.06    -0.79  0
## Stest20spelling             -2.95 2.09  5.04 -0.26    -0.41  0
## Stest21capitalization       -2.21 1.79  4.01 -0.34    -0.29  0
## Stest22punctuation          -4.01 1.91  5.92 -0.47    -0.18  0
## Stest23english              -5.18 2.49  7.66 -0.42     0.49  0
## Stest24expression           -3.65 1.40  5.06 -0.83     0.57  0
## Stest25wordfunctions        -2.61 1.91  4.52 -0.31    -0.79  0
## Stest26readingcomprehension -3.16 1.55  4.71 -0.57    -0.38  0
## Stest28mechanicalreasoning  -2.41 2.08  4.50  0.27    -0.40  0
## Stest29visualization2D      -2.28 1.92  4.21 -0.15    -0.53  0
## Stest30visualization3D      -2.54 2.18  4.72  0.05    -0.55  0
## Stest31abstractreasoning    -3.05 1.97  5.03 -0.57     0.10  0
## Stest32arithreasoning       -2.33 1.97  4.30 -0.05    -0.80  0
## Stest33highschoolmath       -2.15 2.52  4.67  0.43    -0.38  0
## Stest34arithcomputation     -3.94 3.30  7.24 -0.17     0.44  0
## Stest35tablereading         -4.82 3.61  8.43 -0.56     4.58  0
## Stest36clericalchecking     -2.66 2.63  5.29  0.93     0.47  0
## Stest37objectinspection     -3.28 2.40  5.69  0.29    -0.02  0
scree(datamale)

VSS.scree(datafemale)

scree(datamale)

VSS.scree(datafemale)

malecor<- cor(datamale) # fa.parallel requires cor matrix if n.obs is to be used
femalecor<- cor(datafemale) # fa.parallel requires cor matrix if n.obs is to be used

eigen(malecor) 
## eigen() decomposition
## $values
##  [1] 8.5396339 1.9845448 1.5383661 0.8133725 0.6539512 0.6373901
##  [7] 0.5960808 0.5427751 0.5064525 0.4969972 0.4858162 0.4643757
## [13] 0.4456274 0.4054590 0.3885191 0.3739552 0.3482104 0.3216457
## [19] 0.2311029 0.2257241
## 
## $vectors
##              [,1]          [,2]         [,3]         [,4]         [,5]
##  [1,] -0.27098000 -1.093056e-01  0.006286144 -0.135527901 -0.168620247
##  [2,] -0.27274201 -6.885167e-02  0.002832519  0.250188427 -0.128450035
##  [3,] -0.23293037  1.354194e-01  0.177630984 -0.361325249  0.238327776
##  [4,] -0.21756609 -5.458943e-03  0.346390987 -0.090345519  0.366776182
##  [5,] -0.22619723 -6.289444e-02  0.159556921 -0.006620043  0.176205431
##  [6,] -0.27167503 -9.881283e-02  0.120404748  0.033723082  0.132590808
##  [7,] -0.23490503 -1.033638e-01  0.117589740 -0.353053839 -0.004933944
##  [8,] -0.21283303 -1.152906e-01  0.071768663 -0.400643270 -0.397305332
##  [9,] -0.25718694 -8.591291e-02  0.075043221  0.139104098  0.083410799
## [10,] -0.28288611 -1.201889e-01  0.068783597 -0.145719282 -0.162281607
## [11,] -0.21024694 -3.769939e-02 -0.445840736 -0.113197434 -0.036607466
## [12,] -0.15562812  2.069733e-01 -0.407928365 -0.092212886  0.539987714
## [13,] -0.18962320  4.200204e-06 -0.490723994  0.024373328  0.083871309
## [14,] -0.22819625 -3.585847e-02 -0.264279575  0.085402863 -0.036098937
## [15,] -0.26572438 -1.034584e-01 -0.050334933  0.231140212 -0.151303389
## [16,] -0.27976537 -7.072512e-02  0.004302615  0.372164023 -0.050647477
## [17,] -0.20837378  2.239348e-01  0.215897579  0.448195241  0.028017138
## [18,] -0.13209276  4.867586e-01  0.054137184  0.068448133 -0.327392572
## [19,] -0.07822059  5.419773e-01  0.168946510 -0.033119394  0.123579723
## [20,] -0.08155087  5.131770e-01 -0.150484628 -0.159984565 -0.271993790
##              [,6]         [,7]        [,8]        [,9]       [,10]
##  [1,] -0.39103753  0.019282340  0.23200616  0.09544724 -0.15946453
##  [2,] -0.26761518 -0.023227279  0.11607108 -0.07540119 -0.08983110
##  [3,] -0.33767816  0.012158912 -0.10015134  0.12633752 -0.11815103
##  [4,] -0.03893303  0.044700787 -0.31908354  0.05943108 -0.20965719
##  [5,]  0.46767004  0.458729229  0.48975994  0.34424732 -0.10173741
##  [6,]  0.17923721  0.141000808 -0.02228076 -0.15619432  0.12088628
##  [7,]  0.07554269 -0.009045989  0.08896613 -0.35513232  0.60230626
##  [8,]  0.42090130 -0.456384359 -0.19071384  0.05343221 -0.21516740
##  [9,]  0.04859948  0.116090288 -0.15847386 -0.38106411  0.19831333
## [10,] -0.15648952 -0.031671698  0.11120853  0.09580640 -0.10864795
## [11,] -0.19389177  0.070607618  0.11334058  0.18109718  0.07538826
## [12,]  0.14554029 -0.481922677  0.29352695 -0.11005754 -0.07952436
## [13,]  0.03993348  0.163091506 -0.25566652  0.08365681  0.13520231
## [14,]  0.22412477  0.190280246 -0.52318518  0.21837396 -0.08556917
## [15,] -0.07802379 -0.113111955  0.02904112  0.01894068  0.01213942
## [16,] -0.08409047 -0.055238854  0.00548858 -0.15067139 -0.01656663
## [17,]  0.16695452 -0.310696876  0.03583327 -0.01930687 -0.13860884
## [18,]  0.08605143 -0.072922114  0.10145493  0.35173132  0.42711507
## [19,] -0.17850136  0.020887910 -0.20375246  0.13566450  0.15331950
## [20,]  0.09203156  0.354412104  0.08166282 -0.52373470 -0.40030188
##               [,11]         [,12]       [,13]        [,14]        [,15]
##  [1,]  5.407706e-02 -0.0277901327 -0.04530118  0.169846113 -0.108584213
##  [2,] -1.511061e-02 -0.0777537425  0.04678720  0.351249409 -0.269058762
##  [3,]  2.458054e-03 -0.1423554997 -0.10006928 -0.527710431 -0.268749571
##  [4,]  3.641461e-01  0.4395288708  0.03901941  0.305857639  0.278108602
##  [5,] -1.635575e-01 -0.0662296724  0.09838300  0.018377001 -0.057170156
##  [6,] -8.278547e-02  0.0912837966 -0.09704420 -0.033052950  0.139128590
##  [7,]  3.097402e-01 -0.2667605316  0.30791046  0.083404263 -0.003999085
##  [8,] -2.798660e-01  0.1078992066  0.10338492  0.025119859 -0.032993093
##  [9,] -3.773982e-01  0.1783958256 -0.46071775 -0.223543513 -0.066822341
## [10,] -7.985040e-06  0.0009451502 -0.15852082  0.059877460 -0.073047558
## [11,]  1.247268e-02  0.1114963680  0.15632370 -0.322394930  0.485311544
## [12,]  6.218592e-03 -0.0842798624 -0.24010532  0.200682352 -0.004515200
## [13,] -6.340294e-02  0.4257973182  0.37391240  0.018357940 -0.440822506
## [14,]  2.433767e-01 -0.5664293942 -0.23377954  0.083987245  0.012453926
## [15,] -1.156392e-01 -0.0202485985  0.03840833 -0.057729763  0.505398654
## [16,] -5.819908e-02 -0.0506038571  0.07218769  0.097468143 -0.057223506
## [17,]  2.528072e-01 -0.0633085924  0.34195619 -0.426630159 -0.111126437
## [18,]  2.438814e-01  0.2675950897 -0.38103677  0.047390410 -0.060112026
## [19,] -5.421620e-01 -0.2249563811  0.27672040  0.253909026  0.146420466
## [20,]  1.280852e-01  0.0388776679  0.01743801 -0.003159859  0.081142709
##             [,16]        [,17]        [,18]        [,19]        [,20]
##  [1,]  0.03670990 -0.364959226  0.223924911 -0.242767874  0.579763203
##  [2,] -0.33899397  0.283296431 -0.153886968 -0.386360854 -0.412338744
##  [3,]  0.08898063  0.397137527 -0.084762031 -0.014758057  0.018517308
##  [4,] -0.04145095 -0.050292847 -0.186144004 -0.003640335  0.005543828
##  [5,]  0.03610886  0.006105459 -0.208552971 -0.022670848  0.026210680
##  [6,] -0.19701377  0.272033095  0.795341697 -0.032910529 -0.013382349
##  [7,]  0.06231000 -0.048669261 -0.133207027 -0.011591682 -0.005529726
##  [8,] -0.14900782  0.087439412 -0.080277324 -0.046651183  0.077971235
##  [9,] -0.06006522 -0.346867946 -0.286140496 -0.147328890  0.024177525
## [10,]  0.23525779 -0.338714451  0.171525827  0.494519170 -0.562398240
## [11,] -0.48751753 -0.096092833 -0.117195200  0.059409676 -0.082950853
## [12,]  0.05686738 -0.002789169  0.004773671 -0.002148022  0.008058075
## [13,]  0.26376199 -0.010974506  0.081297678 -0.025597645 -0.004108626
## [14,] -0.02514166 -0.086591259  0.002172608 -0.044919402  0.030671729
## [15,]  0.64641157  0.245824004 -0.070820075 -0.247586446 -0.031515301
## [16,] -0.10307734  0.284638577 -0.176681395  0.664386818  0.392819094
## [17,] -0.05455175 -0.325584401  0.105708814 -0.103739782 -0.052431270
## [18,] -0.01921824  0.124159358 -0.026173129  0.002180911  0.055223788
## [19,] -0.03849675 -0.158375312  0.063968935  0.038034085 -0.019319933
## [20,]  0.06731805  0.048884379 -0.015449570  0.016306956 -0.015805705
eigen(femalecor)
## eigen() decomposition
## $values
##  [1] 8.0369714 1.9508864 1.4432300 0.9030562 0.7021201 0.6774020
##  [7] 0.6340137 0.5748603 0.5467003 0.5249176 0.5026568 0.4954461
## [13] 0.4693188 0.4606989 0.4355252 0.4132046 0.3726155 0.3432385
## [19] 0.2798137 0.2333240
## 
## $vectors
##              [,1]         [,2]         [,3]        [,4]        [,5]
##  [1,] -0.27697963 -0.121071551 -0.028932353 -0.07117637  0.31220781
##  [2,] -0.25576652 -0.104551197  0.009938376  0.37833177  0.28940945
##  [3,] -0.23605751  0.162013222 -0.205448381 -0.26437763  0.13885603
##  [4,] -0.21903300  0.011034418 -0.365498682 -0.08053695 -0.16952428
##  [5,] -0.21372758 -0.056813964 -0.167363428 -0.07039273 -0.65089474
##  [6,] -0.27869045 -0.095223937 -0.113004272 -0.02195230 -0.16799753
##  [7,] -0.23067858 -0.093155440 -0.159187897 -0.28717460  0.05269258
##  [8,] -0.20117477 -0.100928170 -0.096943802 -0.46462916  0.13373606
##  [9,] -0.27120052 -0.096208454 -0.054171959  0.11447566 -0.01209509
## [10,] -0.28927576 -0.126155238 -0.058605282 -0.12939345  0.17163724
## [11,] -0.21008735 -0.021629861  0.441096016 -0.09732313  0.11727469
## [12,] -0.15802022  0.199854474  0.411640313 -0.08797744 -0.31334620
## [13,] -0.19705365  0.004898562  0.477128658 -0.05176858 -0.11427510
## [14,] -0.23526849 -0.023479685  0.249575235 -0.05691795 -0.15750915
## [15,] -0.26595883 -0.116885168  0.057698204  0.17453112  0.04973001
## [16,] -0.26607563 -0.101244186  0.038159921  0.43614613  0.13180747
## [17,] -0.20713278  0.203865958 -0.188409742  0.42400482 -0.23158538
## [18,] -0.12459148  0.492582263 -0.074283445  0.05993902  0.01089409
## [19,] -0.08531216  0.538602787 -0.145241121  0.02270050  0.16284008
## [20,] -0.09685675  0.502514239  0.143275158 -0.11865608  0.13665136
##               [,6]        [,7]        [,8]         [,9]       [,10]
##  [1,]  0.068808993  0.13360283  0.15894691  0.146144917  0.10144041
##  [2,]  0.043470777  0.04110537  0.26540797  0.080028328 -0.12068754
##  [3,]  0.378835198  0.05857916 -0.12670163  0.162012794  0.04032020
##  [4,]  0.319126340  0.01110599 -0.38874439 -0.003427988 -0.15224967
##  [5,] -0.188933513  0.38350060  0.38581531  0.300373428  0.08727126
##  [6,]  0.002124482  0.05903030 -0.03991343 -0.107677554 -0.06529660
##  [7,]  0.118792433  0.02281642  0.22460056 -0.762848729  0.05796628
##  [8,] -0.443511995 -0.57836918  0.03877278  0.269634075 -0.08738214
##  [9,] -0.041046078  0.05194881 -0.07251732 -0.036959686 -0.10423793
## [10,] -0.054431523  0.07734028  0.04878054  0.102964187  0.09607588
## [11,]  0.101841691  0.15290717 -0.01934297  0.068058298  0.27273859
## [12,]  0.441400977 -0.45265239  0.37490559  0.022198523 -0.08859067
## [13,]  0.007265906  0.09684215 -0.33853558 -0.031745659  0.13605133
## [14,] -0.231921989  0.08061416 -0.44352802 -0.060191788 -0.22673260
## [15,] -0.109088274 -0.06745781 -0.08597722  0.029708994  0.09490045
## [16,] -0.016578639 -0.05904816  0.11624914  0.003561801 -0.09700386
## [17,] -0.067247706 -0.38863881 -0.13283881 -0.119620382 -0.03134980
## [18,] -0.329157614 -0.03523809  0.01625973 -0.193369348  0.61544000
## [19,]  0.189617100  0.07238718 -0.07041724  0.306297165  0.02658601
## [20,] -0.277148886  0.27004807  0.17623439 -0.146221313 -0.59694453
##             [,11]         [,12]       [,13]        [,14]        [,15]
##  [1,] -0.28006235 -0.1065939382 -0.00603337  0.019695330  0.293259999
##  [2,]  0.09061784 -0.0008005108 -0.11227072 -0.458366884 -0.025191501
##  [3,] -0.05939183 -0.1048034395  0.28012250 -0.019283116 -0.025818762
##  [4,] -0.33726548  0.1525709877 -0.26671197 -0.271398503 -0.071348117
##  [5,]  0.08936519  0.0973271379  0.09783867 -0.082280804  0.094580406
##  [6,]  0.05763033 -0.0077797696 -0.14759559  0.168109927 -0.307257715
##  [7,]  0.32274838  0.1061899003  0.11595967 -0.036070287  0.152256197
##  [8,]  0.12713301  0.2086447481 -0.03250368 -0.130357314 -0.088155557
##  [9,]  0.13876600 -0.0885896549 -0.28067218  0.368119421 -0.512026772
## [10,] -0.19606799 -0.1853527281 -0.04712368  0.147676387  0.218361207
## [11,] -0.11246844  0.2927711877  0.46697266 -0.007340183 -0.459059262
## [12,] -0.07964151 -0.2695806969 -0.16199957  0.028527275  0.005106173
## [13,]  0.10495734  0.4502953658 -0.37551198 -0.092174523  0.332688926
## [14,]  0.20138832 -0.5806476382  0.26572344 -0.262553863  0.081426958
## [15,] -0.03217749 -0.0673975417 -0.02617714  0.564015206  0.274312586
## [16,]  0.13765191  0.0619890187 -0.00844360 -0.190236340 -0.055465575
## [17,] -0.16958130  0.2527502432  0.44787353  0.092621090  0.160805331
## [18,] -0.18047601 -0.2259877608 -0.22992049 -0.192043457 -0.147541341
## [19,]  0.60896993  0.0625915193 -0.02178826  0.127077296  0.097056023
## [20,] -0.28986251  0.1492226708 -0.01692806  0.103092881  0.001846721
##             [,16]       [,17]        [,18]        [,19]        [,20]
##  [1,] -0.07229264 -0.39794274  0.043849114 -0.086035127  0.613691881
##  [2,] -0.03664166  0.07720971  0.034650106  0.587536803 -0.128118702
##  [3,] -0.44779055  0.54840415  0.009809835 -0.007481705  0.018283874
##  [4,]  0.43823540 -0.05277908 -0.158113876 -0.003000514 -0.007493957
##  [5,]  0.01540246  0.07019562 -0.126412162  0.006717569  0.032619833
##  [6,] -0.05890731 -0.07440295  0.832658148  0.017640969  0.019431117
##  [7,]  0.08513191 -0.02107956 -0.125405092  0.016867053  0.008473672
##  [8,]  0.04161732  0.04698808 -0.018496898  0.009407914  0.056888826
##  [9,] -0.31549337 -0.14690503 -0.490987186  0.054662815  0.101965378
## [10,] -0.07545642 -0.26705409 -0.024151618 -0.154124545 -0.757465285
## [11,]  0.27952188 -0.11192656 -0.038082427  0.042826489 -0.057433232
## [12,]  0.05303169 -0.03819505 -0.023717540 -0.009390686 -0.008228244
## [13,] -0.31258741  0.04854736  0.012361868  0.002522213 -0.001963826
## [14,]  0.06501716 -0.08355653 -0.027106997  0.026832198  0.071973185
## [15,]  0.43366053  0.44489689 -0.019682401  0.231157519  0.078545358
## [16,]  0.09099293  0.24273095 -0.003677225 -0.744063680  0.015235335
## [17,] -0.24389142 -0.24702928 -0.010539343  0.097480307 -0.018330464
## [18,]  0.01469004  0.09746964 -0.001247739 -0.012805410  0.039560822
## [19,]  0.20864089 -0.25950730  0.036648166 -0.012493675 -0.025381511
## [20,]  0.02222771  0.08993726  0.001854358 -0.018057903 -0.013416533
mpa<- fa.parallel(malecor, n.obs=70776, n.iter=1000) 

## Parallel analysis suggests that the number of factors =  6  and the number of components =  3
fpa<- fa.parallel(femalecor, n.obs=71381, n.iter=1000)

## Parallel analysis suggests that the number of factors =  6  and the number of components =  3
mqqnorm(datafemale, main = "Multi-normal Q-Q Plot") # serious departure

## 135135  72667 
##  64359   1891
mqqnorm(datamale, main = "Multi-normal Q-Q Plot") # serious departure

## [1] 51628  6849
mqqnorm(datagroup, main = "Multi-normal Q-Q Plot") # serious departure

## [1] 51628  6849
#mvn(data = datamale, mvnTest = "mardia")
#mvn(data = datafemale, mvnTest = "mardia")
#mvn(data = datagroup, mvnTest = "mardia")
#mvn(data = datamale, mvnTest = "hz", multivariatePlot = "qq", multivariateOutlierMethod = "quan") # time consuming
#mvn(data = datafemale, mvnTest = "hz", multivariatePlot = "qq", multivariateOutlierMethod = "quan") # time consuming
#mvn(data = datagroup, mvnTest = "hz", multivariatePlot = "qq", multivariateOutlierMethod = "quan") # time consuming

# standardized loadings for Jensen's MCV

FAmale<-fa(r=datamale, nfactors=4, max.iter=100, warnings=TRUE, rotate="none", fm="pa", weight=dmale$BY_WTA)
print(FAmale, digits=2, cutoff=.10)
## Factor Analysis using method =  pa
## Call: fa(r = datamale, nfactors = 4, rotate = "none", max.iter = 100, 
##     warnings = TRUE, fm = "pa", weight = dmale$BY_WTA)
## Standardized loadings (pattern matrix) based upon correlation matrix
##                              PA1   PA2   PA3   PA4   h2   u2 com
## Stest1vocab                 0.78 -0.14 -0.01  0.13 0.64 0.36 1.1
## Stest5math                  0.78 -0.09 -0.01 -0.17 0.65 0.35 1.1
## Stest19disguisedwords       0.66  0.18 -0.18  0.24 0.56 0.44 1.6
## Stest20spelling             0.61  0.01 -0.35  0.07 0.51 0.49 1.6
## Stest21capitalization       0.64 -0.06 -0.16  0.02 0.43 0.57 1.1
## Stest22punctuation          0.78 -0.12 -0.14 -0.01 0.64 0.36 1.1
## Stest23english              0.66 -0.12 -0.12  0.18 0.50 0.50 1.3
## Stest24expression           0.60 -0.12 -0.07  0.15 0.40 0.60 1.3
## Stest25wordfunctions        0.73 -0.09 -0.09 -0.07 0.55 0.45 1.1
## Stest26readingcomprehension 0.82 -0.16 -0.09  0.16 0.73 0.27 1.2
## Stest28mechanicalreasoning  0.60 -0.06  0.50  0.10 0.63 0.37 2.0
## Stest29visualization2D      0.43  0.22  0.38  0.04 0.38 0.62 2.5
## Stest30visualization3D      0.54 -0.01  0.52  0.00 0.56 0.44 2.0
## Stest31abstractreasoning    0.64 -0.05  0.26 -0.03 0.49 0.51 1.3
## Stest32arithreasoning       0.76 -0.13  0.05 -0.14 0.62 0.38 1.1
## Stest33highschoolmath       0.82 -0.10 -0.01 -0.36 0.81 0.19 1.4
## Stest34arithcomputation     0.59  0.30 -0.21 -0.25 0.54 0.46 2.2
## Stest35tablereading         0.38  0.59 -0.03 -0.03 0.49 0.51 1.7
## Stest36clericalchecking     0.22  0.68 -0.14  0.02 0.53 0.47 1.3
## Stest37objectinspection     0.23  0.60  0.17  0.06 0.44 0.56 1.5
## 
##                        PA1  PA2  PA3  PA4
## SS loadings           8.15 1.47 1.07 0.42
## Proportion Var        0.41 0.07 0.05 0.02
## Cumulative Var        0.41 0.48 0.53 0.55
## Proportion Explained  0.73 0.13 0.10 0.04
## Cumulative Proportion 0.73 0.87 0.96 1.00
## 
## Mean item complexity =  1.5
## Test of the hypothesis that 4 factors are sufficient.
## 
## df null model =  190  with the objective function =  10.6 0.1 with Chi Square =  750359.4
## df of  the model are 116  and the objective function was  0.29 
##  0.1
## The root mean square of the residuals (RMSR) is  0.02 
## The df corrected root mean square of the residuals is  0.02 
##  0.1
## The harmonic n.obs is  70776 with the empirical chi square  7197.46  with prob <  0 
##  0.1The total n.obs was  70776  with Likelihood Chi Square =  20266.68  with prob <  0 
##  0.1
## Tucker Lewis Index of factoring reliability =  0.956
## RMSEA index =  0.05  and the 90 % confidence intervals are  0.049 0.05 0.1
## BIC =  18971.28
## Fit based upon off diagonal values = 1
## Measures of factor score adequacy             
##                                                    PA1  PA2  PA3  PA4
## Correlation of (regression) scores with factors   0.98 0.87 0.84 0.76
## Multiple R square of scores with factors          0.96 0.75 0.70 0.57
## Minimum correlation of possible factor scores     0.91 0.50 0.41 0.14
FAfemale<-fa(r=datafemale, nfactors=4, max.iter=100, warnings=TRUE, rotate="none", fm="pa", weight=dfemale$BY_WTA)
print(FAfemale, digits=2, cutoff=.10)
## Factor Analysis using method =  pa
## Call: fa(r = datafemale, nfactors = 4, rotate = "none", max.iter = 100, 
##     warnings = TRUE, fm = "pa", weight = dfemale$BY_WTA)
## Standardized loadings (pattern matrix) based upon correlation matrix
##                              PA1   PA2   PA3   PA4   h2   u2 com
## Stest1vocab                 0.77 -0.15 -0.04  0.09 0.63 0.37 1.1
## Stest5math                  0.71 -0.13  0.01 -0.27 0.59 0.41 1.4
## Stest19disguisedwords       0.65  0.21 -0.20  0.19 0.54 0.46 1.6
## Stest20spelling             0.60  0.03 -0.35  0.07 0.49 0.51 1.7
## Stest21capitalization       0.58 -0.05 -0.14  0.05 0.36 0.64 1.2
## Stest22punctuation          0.78 -0.11 -0.13  0.04 0.63 0.37 1.1
## Stest23english              0.63 -0.10 -0.15  0.16 0.45 0.55 1.3
## Stest24expression           0.54 -0.10 -0.08  0.19 0.35 0.65 1.4
## Stest25wordfunctions        0.75 -0.11 -0.07 -0.05 0.58 0.42 1.1
## Stest26readingcomprehension 0.81 -0.17 -0.08  0.15 0.72 0.28 1.2
## Stest28mechanicalreasoning  0.58 -0.03  0.45  0.09 0.55 0.45 2.0
## Stest29visualization2D      0.42  0.22  0.35  0.05 0.35 0.65 2.5
## Stest30visualization3D      0.54  0.00  0.48  0.06 0.53 0.47 2.0
## Stest31abstractreasoning    0.64 -0.03  0.24  0.06 0.47 0.53 1.3
## Stest32arithreasoning       0.74 -0.14  0.06 -0.09 0.57 0.43 1.1
## Stest33highschoolmath       0.75 -0.14  0.05 -0.43 0.78 0.22 1.7
## Stest34arithcomputation     0.56  0.25 -0.17 -0.23 0.46 0.54 2.0
## Stest35tablereading         0.35  0.58 -0.04 -0.04 0.46 0.54 1.7
## Stest36clericalchecking     0.24  0.66 -0.12 -0.04 0.50 0.50 1.3
## Stest37objectinspection     0.26  0.58  0.15  0.04 0.43 0.57 1.6
## 
##                        PA1  PA2  PA3  PA4
## SS loadings           7.61 1.42 0.93 0.48
## Proportion Var        0.38 0.07 0.05 0.02
## Cumulative Var        0.38 0.45 0.50 0.52
## Proportion Explained  0.73 0.14 0.09 0.05
## Cumulative Proportion 0.73 0.86 0.95 1.00
## 
## Mean item complexity =  1.5
## Test of the hypothesis that 4 factors are sufficient.
## 
## df null model =  190  with the objective function =  9.4 0.1 with Chi Square =  670968.9
## df of  the model are 116  and the objective function was  0.26 
##  0.1
## The root mean square of the residuals (RMSR) is  0.02 
## The df corrected root mean square of the residuals is  0.02 
##  0.1
## The harmonic n.obs is  71381 with the empirical chi square  7319.94  with prob <  0 
##  0.1The total n.obs was  71381  with Likelihood Chi Square =  18380.34  with prob <  0 
##  0.1
## Tucker Lewis Index of factoring reliability =  0.955
## RMSEA index =  0.047  and the 90 % confidence intervals are  0.046 0.048 0.1
## BIC =  17083.95
## Fit based upon off diagonal values = 1
## Measures of factor score adequacy             
##                                                    PA1  PA2  PA3  PA4
## Correlation of (regression) scores with factors   0.97 0.86 0.81 0.77
## Multiple R square of scores with factors          0.95 0.74 0.65 0.59
## Minimum correlation of possible factor scores     0.90 0.47 0.31 0.18
FA<-fa(r=datagroup, nfactors=4, max.iter=100, warnings=TRUE, rotate="none", fm="pa", weight=dgroup$BY_WTA)
print(FA, digits=2, cutoff=.10)
## Factor Analysis using method =  pa
## Call: fa(r = datagroup, nfactors = 4, rotate = "none", max.iter = 100, 
##     warnings = TRUE, fm = "pa", weight = dgroup$BY_WTA)
## Standardized loadings (pattern matrix) based upon correlation matrix
##                              PA1   PA2   PA3   PA4   h2   u2 com
## Stest1vocab                 0.76 -0.19 -0.04  0.03 0.61 0.39 1.1
## Stest5math                  0.72 -0.21  0.03 -0.26 0.64 0.36 1.4
## Stest19disguisedwords       0.65  0.27 -0.02  0.14 0.52 0.48 1.4
## Stest20spelling             0.60  0.31 -0.29  0.03 0.54 0.46 2.0
## Stest21capitalization       0.60  0.15 -0.22  0.06 0.44 0.56 1.4
## Stest22punctuation          0.77  0.10 -0.25  0.06 0.66 0.34 1.3
## Stest23english              0.65  0.07 -0.22  0.17 0.50 0.50 1.4
## Stest24expression           0.57  0.03 -0.18  0.18 0.39 0.61 1.4
## Stest25wordfunctions        0.74  0.03 -0.16 -0.03 0.57 0.43 1.1
## Stest26readingcomprehension 0.82 -0.06 -0.17  0.12 0.72 0.28 1.1
## Stest28mechanicalreasoning  0.49 -0.49  0.41  0.08 0.65 0.35 3.0
## Stest29visualization2D      0.40 -0.13  0.44  0.10 0.39 0.61 2.3
## Stest30visualization3D      0.52 -0.33  0.35  0.14 0.52 0.48 2.7
## Stest31abstractreasoning    0.64 -0.17  0.14  0.10 0.46 0.54 1.3
## Stest32arithreasoning       0.74 -0.19 -0.01 -0.10 0.60 0.40 1.2
## Stest33highschoolmath       0.78 -0.19  0.01 -0.38 0.79 0.21 1.6
## Stest34arithcomputation     0.58  0.32  0.05 -0.25 0.51 0.49 2.0
## Stest35tablereading         0.37  0.46  0.37 -0.05 0.48 0.52 2.9
## Stest36clericalchecking     0.24  0.58  0.35 -0.05 0.52 0.48 2.0
## Stest37objectinspection     0.25  0.37  0.47  0.09 0.43 0.57 2.5
## 
##                        PA1  PA2  PA3  PA4
## SS loadings           7.61 1.54 1.32 0.45
## Proportion Var        0.38 0.08 0.07 0.02
## Cumulative Var        0.38 0.46 0.52 0.55
## Proportion Explained  0.70 0.14 0.12 0.04
## Cumulative Proportion 0.70 0.84 0.96 1.00
## 
## Mean item complexity =  1.8
## Test of the hypothesis that 4 factors are sufficient.
## 
## df null model =  190  with the objective function =  10.11 0.1 with Chi Square =  1436471
## df of  the model are 116  and the objective function was  0.35 
##  0.1
## The root mean square of the residuals (RMSR) is  0.02 
## The df corrected root mean square of the residuals is  0.02 
##  0.1
## The harmonic n.obs is  142157 with the empirical chi square  20145.9  with prob <  0 
##  0.1The total n.obs was  142157  with Likelihood Chi Square =  50400.21  with prob <  0 
##  0.1
## Tucker Lewis Index of factoring reliability =  0.943
## RMSEA index =  0.055  and the 90 % confidence intervals are  0.055 0.056 0.1
## BIC =  49023.91
## Fit based upon off diagonal values = 1
## Measures of factor score adequacy             
##                                                    PA1  PA2  PA3  PA4
## Correlation of (regression) scores with factors   0.98 0.88 0.86 0.76
## Multiple R square of scores with factors          0.95 0.77 0.73 0.57
## Minimum correlation of possible factor scores     0.90 0.55 0.47 0.14
# EFA: The rotate options "promax" and "Promax" differ slightly. Because unlike "Promax", the "promax" performs a Kaiser normalization before rotation, which is recommended according to Kaizer.

male3<-fa(datamale, nfactors=3, rotate="promax", fm="minres", weight=dmale$BY_WTA)
print(male3, digits=2, cutoff=.10)
## Factor Analysis using method =  minres
## Call: fa(r = datamale, nfactors = 3, rotate = "promax", fm = "minres", 
##     weight = dmale$BY_WTA)
## Standardized loadings (pattern matrix) based upon correlation matrix
##                               MR1   MR3   MR2   h2   u2 com
## Stest1vocab                  0.71  0.17 -0.07 0.63 0.37 1.1
## Stest5math                   0.68  0.17 -0.02 0.62 0.38 1.1
## Stest19disguisedwords        0.61 -0.05  0.25 0.49 0.51 1.3
## Stest20spelling              0.80 -0.28  0.09 0.50 0.50 1.3
## Stest21capitalization        0.68 -0.04  0.01 0.44 0.56 1.0
## Stest22punctuation           0.81  0.01 -0.04 0.65 0.35 1.0
## Stest23english               0.69  0.01 -0.05 0.46 0.54 1.0
## Stest24expression            0.60  0.06 -0.07 0.37 0.63 1.0
## Stest25wordfunctions         0.71  0.07 -0.03 0.55 0.45 1.0
## Stest26readingcomprehension  0.81  0.08 -0.09 0.71 0.29 1.0
## Stest28mechanicalreasoning   0.10  0.73 -0.05 0.61 0.39 1.1
## Stest29visualization2D      -0.06  0.55  0.24 0.38 0.62 1.4
## Stest30visualization3D       0.00  0.76 -0.01 0.57 0.43 1.0
## Stest31abstractreasoning     0.32  0.47 -0.02 0.49 0.51 1.8
## Stest32arithreasoning        0.63  0.24 -0.07 0.60 0.40 1.3
## Stest33highschoolmath        0.70  0.18 -0.02 0.65 0.35 1.1
## Stest34arithcomputation      0.53 -0.11  0.36 0.46 0.54 1.9
## Stest35tablereading          0.08  0.05  0.65 0.49 0.51 1.0
## Stest36clericalchecking      0.02 -0.14  0.75 0.54 0.46 1.1
## Stest37objectinspection     -0.21  0.25  0.63 0.43 0.57 1.5
## 
##                        MR1  MR3  MR2
## SS loadings           6.71 2.24 1.69
## Proportion Var        0.34 0.11 0.08
## Cumulative Var        0.34 0.45 0.53
## Proportion Explained  0.63 0.21 0.16
## Cumulative Proportion 0.63 0.84 1.00
## 
##  With factor correlations of 
##      MR1  MR3  MR2
## MR1 1.00 0.57 0.32
## MR3 0.57 1.00 0.24
## MR2 0.32 0.24 1.00
## 
## Mean item complexity =  1.2
## Test of the hypothesis that 3 factors are sufficient.
## 
## df null model =  190  with the objective function =  10.6 0.1 with Chi Square =  750359.4
## df of  the model are 133  and the objective function was  0.59 
##  0.1
## The root mean square of the residuals (RMSR) is  0.03 
## The df corrected root mean square of the residuals is  0.03 
##  0.1
## The harmonic n.obs is  70776 with the empirical chi square  17359.93  with prob <  0 
##  0.1The total n.obs was  70776  with Likelihood Chi Square =  42001.3  with prob <  0 
##  0.1
## Tucker Lewis Index of factoring reliability =  0.92
## RMSEA index =  0.067  and the 90 % confidence intervals are  0.066 0.067 0.1
## BIC =  40516.05
## Fit based upon off diagonal values = 1
## Measures of factor score adequacy             
##                                                    MR1  MR3  MR2
## Correlation of (regression) scores with factors   0.97 0.91 0.88
## Multiple R square of scores with factors          0.94 0.83 0.77
## Minimum correlation of possible factor scores     0.88 0.66 0.55
male4<-fa(datamale, nfactors=4, rotate="promax", fm="minres", weight=dmale$BY_WTA)
print(male4, digits=2, cutoff=.10)
## Factor Analysis using method =  minres
## Call: fa(r = datamale, nfactors = 4, rotate = "promax", fm = "minres", 
##     weight = dmale$BY_WTA)
## Standardized loadings (pattern matrix) based upon correlation matrix
##                               MR1   MR3   MR4   MR2   h2   u2 com
## Stest1vocab                  0.71  0.19 -0.01 -0.07 0.64 0.36 1.2
## Stest5math                   0.38  0.15  0.40 -0.04 0.65 0.35 2.3
## Stest19disguisedwords        0.75 -0.02 -0.17  0.27 0.56 0.44 1.4
## Stest20spelling              0.75 -0.26  0.07  0.09 0.51 0.49 1.3
## Stest21capitalization        0.59 -0.03  0.12  0.01 0.43 0.57 1.1
## Stest22punctuation           0.66  0.01  0.19 -0.04 0.64 0.36 1.2
## Stest23english               0.76  0.04 -0.10 -0.04 0.50 0.50 1.0
## Stest24expression            0.65  0.08 -0.08 -0.06 0.40 0.60 1.1
## Stest25wordfunctions         0.52  0.06  0.26 -0.03 0.55 0.45 1.5
## Stest26readingcomprehension  0.83  0.11 -0.03 -0.08 0.73 0.27 1.1
## Stest28mechanicalreasoning   0.14  0.75 -0.07 -0.04 0.63 0.37 1.1
## Stest29visualization2D      -0.05  0.55 -0.01  0.24 0.38 0.62 1.4
## Stest30visualization3D      -0.04  0.75  0.05 -0.01 0.56 0.44 1.0
## Stest31abstractreasoning     0.21  0.46  0.15 -0.02 0.49 0.51 1.6
## Stest32arithreasoning        0.37  0.22  0.34 -0.08 0.62 0.38 2.7
## Stest33highschoolmath        0.22  0.12  0.67 -0.06 0.81 0.19 1.3
## Stest34arithcomputation      0.20 -0.16  0.49  0.35 0.54 0.46 2.5
## Stest35tablereading          0.03  0.04  0.11  0.64 0.49 0.51 1.1
## Stest36clericalchecking      0.03 -0.13  0.03  0.73 0.53 0.47 1.1
## Stest37objectinspection     -0.13  0.26 -0.07  0.62 0.44 0.56 1.5
## 
##                        MR1  MR3  MR4  MR2
## SS loadings           5.47 2.24 1.73 1.66
## Proportion Var        0.27 0.11 0.09 0.08
## Cumulative Var        0.27 0.39 0.47 0.55
## Proportion Explained  0.49 0.20 0.16 0.15
## Cumulative Proportion 0.49 0.69 0.85 1.00
## 
##  With factor correlations of 
##      MR1  MR3  MR4  MR2
## MR1 1.00 0.56 0.69 0.26
## MR3 0.56 1.00 0.50 0.21
## MR4 0.69 0.50 1.00 0.23
## MR2 0.26 0.21 0.23 1.00
## 
## Mean item complexity =  1.4
## Test of the hypothesis that 4 factors are sufficient.
## 
## df null model =  190  with the objective function =  10.6 0.1 with Chi Square =  750359.4
## df of  the model are 116  and the objective function was  0.29 
##  0.1
## The root mean square of the residuals (RMSR) is  0.02 
## The df corrected root mean square of the residuals is  0.02 
##  0.1
## The harmonic n.obs is  70776 with the empirical chi square  7197.14  with prob <  0 
##  0.1The total n.obs was  70776  with Likelihood Chi Square =  20254.15  with prob <  0 
##  0.1
## Tucker Lewis Index of factoring reliability =  0.956
## RMSEA index =  0.05  and the 90 % confidence intervals are  0.049 0.05 0.1
## BIC =  18958.75
## Fit based upon off diagonal values = 1
## Measures of factor score adequacy             
##                                                    MR1  MR3  MR4  MR2
## Correlation of (regression) scores with factors   0.96 0.91 0.91 0.88
## Multiple R square of scores with factors          0.93 0.83 0.83 0.77
## Minimum correlation of possible factor scores     0.86 0.66 0.67 0.54
male5<-fa(datamale, nfactors=5, rotate="promax", fm="minres", weight=dmale$BY_WTA)
print(male5, digits=2, cutoff=.10)
## Factor Analysis using method =  minres
## Call: fa(r = datamale, nfactors = 5, rotate = "promax", fm = "minres", 
##     weight = dmale$BY_WTA)
## Standardized loadings (pattern matrix) based upon correlation matrix
##                               MR1   MR3   MR4   MR2   MR5   h2   u2 com
## Stest1vocab                  0.40  0.01  0.14  0.02  0.52 0.78 0.22 2.0
## Stest5math                   0.18  0.05  0.54  0.01  0.23 0.68 0.32 1.6
## Stest19disguisedwords        0.67 -0.03 -0.16  0.28  0.15 0.55 0.45 1.6
## Stest20spelling              0.77 -0.21  0.02  0.07 -0.02 0.51 0.49 1.2
## Stest21capitalization        0.64  0.03  0.06 -0.02 -0.06 0.45 0.55 1.0
## Stest22punctuation           0.78  0.10  0.10 -0.10 -0.14 0.69 0.31 1.2
## Stest23english               0.74  0.07 -0.12 -0.06  0.05 0.50 0.50 1.1
## Stest24expression            0.62  0.10 -0.08 -0.07  0.07 0.40 0.60 1.1
## Stest25wordfunctions         0.55  0.10  0.23 -0.06 -0.05 0.57 0.43 1.5
## Stest26readingcomprehension  0.63  0.02  0.06 -0.04  0.32 0.76 0.24 1.5
## Stest28mechanicalreasoning   0.04  0.70 -0.01 -0.03  0.15 0.62 0.38 1.1
## Stest29visualization2D      -0.01  0.58 -0.04  0.22 -0.05 0.39 0.61 1.3
## Stest30visualization3D      -0.01  0.78  0.03 -0.03 -0.05 0.58 0.42 1.0
## Stest31abstractreasoning     0.24  0.50  0.12 -0.04 -0.05 0.50 0.50 1.6
## Stest32arithreasoning        0.29  0.18  0.40 -0.07  0.10 0.62 0.38 2.5
## Stest33highschoolmath        0.14  0.09  0.74 -0.04  0.05 0.81 0.19 1.1
## Stest34arithcomputation      0.22 -0.14  0.47  0.35 -0.07 0.54 0.46 2.6
## Stest35tablereading          0.01  0.02  0.12  0.65  0.03 0.49 0.51 1.1
## Stest36clericalchecking      0.04 -0.13  0.01  0.74 -0.01 0.53 0.47 1.1
## Stest37objectinspection     -0.13  0.24 -0.07  0.63  0.01 0.44 0.56 1.4
## 
##                        MR1  MR3  MR4  MR2  MR5
## SS loadings           4.86 2.13 1.96 1.67 0.81
## Proportion Var        0.24 0.11 0.10 0.08 0.04
## Cumulative Var        0.24 0.35 0.45 0.53 0.57
## Proportion Explained  0.43 0.19 0.17 0.15 0.07
## Cumulative Proportion 0.43 0.61 0.78 0.93 1.00
## 
##  With factor correlations of 
##      MR1  MR3  MR4  MR2  MR5
## MR1 1.00 0.53 0.73 0.30 0.43
## MR3 0.53 1.00 0.53 0.24 0.46
## MR4 0.73 0.53 1.00 0.25 0.30
## MR2 0.30 0.24 0.25 1.00 0.01
## MR5 0.43 0.46 0.30 0.01 1.00
## 
## Mean item complexity =  1.4
## Test of the hypothesis that 5 factors are sufficient.
## 
## df null model =  190  with the objective function =  10.6 0.1 with Chi Square =  750359.4
## df of  the model are 100  and the objective function was  0.12 
##  0.1
## The root mean square of the residuals (RMSR) is  0.01 
## The df corrected root mean square of the residuals is  0.02 
##  0.1
## The harmonic n.obs is  70776 with the empirical chi square  3185.6  with prob <  0 
##  0.1The total n.obs was  70776  with Likelihood Chi Square =  8390.97  with prob <  0 
##  0.1
## Tucker Lewis Index of factoring reliability =  0.979
## RMSEA index =  0.034  and the 90 % confidence intervals are  0.034 0.035 0.1
## BIC =  7274.24
## Fit based upon off diagonal values = 1
## Measures of factor score adequacy             
##                                                    MR1  MR3  MR4  MR2
## Correlation of (regression) scores with factors   0.96 0.91 0.93 0.88
## Multiple R square of scores with factors          0.92 0.83 0.86 0.77
## Minimum correlation of possible factor scores     0.84 0.66 0.72 0.54
##                                                    MR5
## Correlation of (regression) scores with factors   0.83
## Multiple R square of scores with factors          0.69
## Minimum correlation of possible factor scores     0.37
female3<-fa(datafemale, nfactors=3, rotate="promax", fm="minres", weight=dfemale$BY_WTA)
print(female3, digits=2, cutoff=.10)
## Factor Analysis using method =  minres
## Call: fa(r = datafemale, nfactors = 3, rotate = "promax", fm = "minres", 
##     weight = dfemale$BY_WTA)
## Standardized loadings (pattern matrix) based upon correlation matrix
##                               MR1   MR3   MR2   h2   u2 com
## Stest1vocab                  0.72  0.14 -0.09 0.62 0.38 1.1
## Stest5math                   0.61  0.17 -0.07 0.50 0.50 1.2
## Stest19disguisedwords        0.60 -0.08  0.29 0.50 0.50 1.5
## Stest20spelling              0.77 -0.28  0.12 0.49 0.51 1.3
## Stest21capitalization        0.61 -0.04  0.02 0.36 0.64 1.0
## Stest22punctuation           0.79  0.03 -0.03 0.64 0.36 1.0
## Stest23english               0.68 -0.03 -0.03 0.42 0.58 1.0
## Stest24expression            0.55  0.03 -0.05 0.31 0.69 1.0
## Stest25wordfunctions         0.71  0.10 -0.04 0.58 0.42 1.0
## Stest26readingcomprehension  0.79  0.11 -0.09 0.70 0.30 1.1
## Stest28mechanicalreasoning   0.09  0.69 -0.03 0.54 0.46 1.0
## Stest29visualization2D      -0.06  0.53  0.23 0.35 0.65 1.4
## Stest30visualization3D       0.01  0.72  0.00 0.53 0.47 1.0
## Stest31abstractreasoning     0.32  0.45  0.01 0.47 0.53 1.8
## Stest32arithreasoning        0.61  0.24 -0.09 0.57 0.43 1.4
## Stest33highschoolmath        0.61  0.22 -0.07 0.55 0.45 1.3
## Stest34arithcomputation      0.48 -0.06  0.33 0.40 0.60 1.8
## Stest35tablereading          0.05  0.03  0.65 0.46 0.54 1.0
## Stest36clericalchecking      0.00 -0.09  0.73 0.51 0.49 1.0
## Stest37objectinspection     -0.18  0.25  0.61 0.42 0.58 1.5
## 
##                        MR1  MR3  MR2
## SS loadings           6.15 2.11 1.65
## Proportion Var        0.31 0.11 0.08
## Cumulative Var        0.31 0.41 0.50
## Proportion Explained  0.62 0.21 0.17
## Cumulative Proportion 0.62 0.83 1.00
## 
##  With factor correlations of 
##      MR1  MR3  MR2
## MR1 1.00 0.58 0.33
## MR3 0.58 1.00 0.25
## MR2 0.33 0.25 1.00
## 
## Mean item complexity =  1.2
## Test of the hypothesis that 3 factors are sufficient.
## 
## df null model =  190  with the objective function =  9.4 0.1 with Chi Square =  670968.9
## df of  the model are 133  and the objective function was  0.55 
##  0.1
## The root mean square of the residuals (RMSR) is  0.03 
## The df corrected root mean square of the residuals is  0.03 
##  0.1
## The harmonic n.obs is  71381 with the empirical chi square  19950.35  with prob <  0 
##  0.1The total n.obs was  71381  with Likelihood Chi Square =  39548.86  with prob <  0 
##  0.1
## Tucker Lewis Index of factoring reliability =  0.916
## RMSEA index =  0.064  and the 90 % confidence intervals are  0.064 0.065 0.1
## BIC =  38062.48
## Fit based upon off diagonal values = 0.99
## Measures of factor score adequacy             
##                                                    MR1  MR3  MR2
## Correlation of (regression) scores with factors   0.97 0.90 0.87
## Multiple R square of scores with factors          0.93 0.81 0.76
## Minimum correlation of possible factor scores     0.86 0.61 0.52
female4<-fa(datafemale, nfactors=4, rotate="promax", fm="minres", weight=dfemale$BY_WTA)
print(female4, digits=2, cutoff=.10)
## Factor Analysis using method =  minres
## Call: fa(r = datafemale, nfactors = 4, rotate = "promax", fm = "minres", 
##     weight = dfemale$BY_WTA)
## Standardized loadings (pattern matrix) based upon correlation matrix
##                               MR1   MR3   MR4   MR2   h2   u2 com
## Stest1vocab                  0.66  0.16  0.08 -0.09 0.63 0.37 1.2
## Stest5math                   0.17  0.08  0.60 -0.05 0.59 0.41 1.2
## Stest19disguisedwords        0.72 -0.03 -0.16  0.29 0.54 0.46 1.4
## Stest20spelling              0.74 -0.26  0.04  0.12 0.49 0.51 1.3
## Stest21capitalization        0.55 -0.02  0.07  0.01 0.36 0.64 1.0
## Stest22punctuation           0.68  0.03  0.14 -0.03 0.63 0.37 1.1
## Stest23english               0.73  0.01 -0.07 -0.04 0.45 0.55 1.0
## Stest24expression            0.65  0.09 -0.14 -0.06 0.34 0.66 1.2
## Stest25wordfunctions         0.50  0.08  0.28 -0.03 0.58 0.42 1.6
## Stest26readingcomprehension  0.79  0.14 -0.01 -0.10 0.72 0.28 1.1
## Stest28mechanicalreasoning   0.07  0.70  0.01 -0.04 0.55 0.45 1.0
## Stest29visualization2D      -0.06  0.53  0.00  0.22 0.35 0.65 1.4
## Stest30visualization3D      -0.02  0.71  0.04  0.00 0.53 0.47 1.0
## Stest31abstractreasoning     0.26  0.45  0.07  0.00 0.47 0.53 1.7
## Stest32arithreasoning        0.35  0.20  0.33 -0.08 0.57 0.43 2.7
## Stest33highschoolmath       -0.02  0.08  0.87 -0.05 0.78 0.22 1.0
## Stest34arithcomputation      0.16 -0.14  0.44  0.35 0.46 0.54 2.4
## Stest35tablereading          0.03  0.02  0.05  0.65 0.46 0.54 1.0
## Stest36clericalchecking      0.00 -0.09  0.00  0.73 0.51 0.49 1.0
## Stest37objectinspection     -0.10  0.27 -0.10  0.61 0.43 0.57 1.5
## 
##                        MR1  MR3  MR4  MR2
## SS loadings           4.81 2.03 1.96 1.64
## Proportion Var        0.24 0.10 0.10 0.08
## Cumulative Var        0.24 0.34 0.44 0.52
## Proportion Explained  0.46 0.19 0.19 0.16
## Cumulative Proportion 0.46 0.65 0.84 1.00
## 
##  With factor correlations of 
##      MR1  MR3  MR4  MR2
## MR1 1.00 0.56 0.74 0.32
## MR3 0.56 1.00 0.54 0.25
## MR4 0.74 0.54 1.00 0.26
## MR2 0.32 0.25 0.26 1.00
## 
## Mean item complexity =  1.3
## Test of the hypothesis that 4 factors are sufficient.
## 
## df null model =  190  with the objective function =  9.4 0.1 with Chi Square =  670968.9
## df of  the model are 116  and the objective function was  0.26 
##  0.1
## The root mean square of the residuals (RMSR) is  0.02 
## The df corrected root mean square of the residuals is  0.02 
##  0.1
## The harmonic n.obs is  71381 with the empirical chi square  7319.28  with prob <  0 
##  0.1The total n.obs was  71381  with Likelihood Chi Square =  18371.41  with prob <  0 
##  0.1
## Tucker Lewis Index of factoring reliability =  0.955
## RMSEA index =  0.047  and the 90 % confidence intervals are  0.046 0.048 0.1
## BIC =  17075.02
## Fit based upon off diagonal values = 1
## Measures of factor score adequacy             
##                                                    MR1  MR3  MR4  MR2
## Correlation of (regression) scores with factors   0.96 0.90 0.93 0.87
## Multiple R square of scores with factors          0.92 0.80 0.87 0.76
## Minimum correlation of possible factor scores     0.84 0.61 0.74 0.53
female5<-fa(datafemale, nfactors=5, rotate="promax", fm="minres", weight=dfemale$BY_WTA)
print(female5, digits=2, cutoff=.10)
## Factor Analysis using method =  minres
## Call: fa(r = datafemale, nfactors = 5, rotate = "promax", fm = "minres", 
##     weight = dfemale$BY_WTA)
## Standardized loadings (pattern matrix) based upon correlation matrix
##                               MR1   MR4   MR3   MR2   MR5   h2   u2 com
## Stest1vocab                  0.50  0.24  0.00  0.04  0.46 0.76 0.24 2.5
## Stest5math                   0.06  0.72  0.00  0.01  0.19 0.62 0.38 1.2
## Stest19disguisedwords        0.68 -0.12 -0.06  0.31  0.14 0.55 0.45 1.6
## Stest20spelling              0.78 -0.01 -0.22  0.08 -0.02 0.50 0.50 1.2
## Stest21capitalization        0.61  0.00  0.04 -0.04 -0.08 0.38 0.62 1.0
## Stest22punctuation           0.75  0.05  0.11 -0.10 -0.09 0.67 0.33 1.1
## Stest23english               0.71 -0.07  0.02 -0.05  0.07 0.45 0.55 1.0
## Stest24expression            0.63 -0.14  0.09 -0.06  0.08 0.34 0.66 1.2
## Stest25wordfunctions         0.51  0.25  0.10 -0.06  0.00 0.59 0.41 1.6
## Stest26readingcomprehension  0.70  0.08  0.06 -0.03  0.29 0.75 0.25 1.4
## Stest28mechanicalreasoning   0.02  0.06  0.66 -0.01  0.12 0.55 0.45 1.1
## Stest29visualization2D      -0.05 -0.02  0.55  0.20 -0.04 0.35 0.65 1.3
## Stest30visualization3D      -0.01  0.01  0.75 -0.04 -0.04 0.54 0.46 1.0
## Stest31abstractreasoning     0.29  0.03  0.50 -0.04 -0.05 0.49 0.51 1.6
## Stest32arithreasoning        0.34  0.33  0.21 -0.09  0.04 0.57 0.43 2.8
## Stest33highschoolmath       -0.05  0.88  0.07 -0.04  0.05 0.77 0.23 1.0
## Stest34arithcomputation      0.21  0.38 -0.09  0.30 -0.13 0.48 0.52 2.9
## Stest35tablereading          0.04  0.03  0.02  0.64 -0.03 0.46 0.54 1.0
## Stest36clericalchecking     -0.01  0.02 -0.12  0.75  0.03 0.52 0.48 1.1
## Stest37objectinspection     -0.11 -0.08  0.24  0.62  0.03 0.43 0.57 1.4
## 
##                        MR1  MR4  MR3  MR2  MR5
## SS loadings           4.59 2.08 1.98 1.64 0.46
## Proportion Var        0.23 0.10 0.10 0.08 0.02
## Cumulative Var        0.23 0.33 0.43 0.51 0.54
## Proportion Explained  0.43 0.19 0.18 0.15 0.04
## Cumulative Proportion 0.43 0.62 0.80 0.96 1.00
## 
##  With factor correlations of 
##      MR1   MR4  MR3   MR2   MR5
## MR1 1.00  0.76 0.56  0.35  0.08
## MR4 0.76  1.00 0.56  0.27 -0.01
## MR3 0.56  0.56 1.00  0.29  0.24
## MR2 0.35  0.27 0.29  1.00 -0.19
## MR5 0.08 -0.01 0.24 -0.19  1.00
## 
## Mean item complexity =  1.5
## Test of the hypothesis that 5 factors are sufficient.
## 
## df null model =  190  with the objective function =  9.4 0.1 with Chi Square =  670968.9
## df of  the model are 100  and the objective function was  0.11 
##  0.1
## The root mean square of the residuals (RMSR) is  0.01 
## The df corrected root mean square of the residuals is  0.02 
##  0.1
## The harmonic n.obs is  71381 with the empirical chi square  3369.98  with prob <  0 
##  0.1The total n.obs was  71381  with Likelihood Chi Square =  7920.46  with prob <  0 
##  0.1
## Tucker Lewis Index of factoring reliability =  0.978
## RMSEA index =  0.033  and the 90 % confidence intervals are  0.032 0.034 0.1
## BIC =  6802.88
## Fit based upon off diagonal values = 1
## Measures of factor score adequacy             
##                                                    MR1  MR4  MR3  MR2
## Correlation of (regression) scores with factors   0.96 0.93 0.90 0.88
## Multiple R square of scores with factors          0.91 0.87 0.81 0.77
## Minimum correlation of possible factor scores     0.83 0.74 0.62 0.53
##                                                    MR5
## Correlation of (regression) scores with factors   0.74
## Multiple R square of scores with factors          0.55
## Minimum correlation of possible factor scores     0.09

CHC common factor model

chc.factor.model <-'
english =~ Stest1vocab + Stest19disguisedwords + Stest20spelling + Stest21capitalization + Stest22punctuation + Stest23english + Stest24expression + Stest25wordfunctions + Stest26readingcomprehension + Stest31abstractreasoning + Stest32arithreasoning
math =~ Stest5math + Stest25wordfunctions + Stest32arithreasoning + Stest33highschoolmath + Stest34arithcomputation
speed =~ Stest19disguisedwords + Stest29visualization2D + Stest34arithcomputation + Stest35tablereading + Stest36clericalchecking + Stest37objectinspection
spatial =~ Stest28mechanicalreasoning + Stest29visualization2D + Stest30visualization3D + Stest31abstractreasoning + Stest37objectinspection
'

baseline<-cfa(chc.factor.model, data=dgroup, meanstructure=TRUE, sampling.weights="BY_WTA")
fitMeasures(baseline, c("chisq", "df", "pvalue", "cfi", "rmsea", "srmr", "aic", "bic"))
##       chisq          df      pvalue         cfi       rmsea        srmr 
##  125267.631     157.000       0.000       0.913       0.075       0.051 
##         aic         bic 
## 6635984.941 6636705.063
Mc(baseline)
## [1] 0.6440062
configural<-cfa(chc.factor.model, data=dgroup, group="sex", meanstructure=TRUE, sampling.weights="BY_WTA", std.lv=T)
fitMeasures(configural, c("chisq", "df", "pvalue", "cfi", "rmsea", "srmr", "aic", "bic"))
##       chisq          df      pvalue         cfi       rmsea        srmr 
##   82009.186     314.000       0.000       0.943       0.061       0.041 
##         aic         bic 
## 6488872.722 6490312.967
Mc(configural)
## [1] 0.750254
summary(configural, standardized=T, ci=T)
## lavaan 0.6-18 ended normally after 39 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                       146
## 
##   Number of observations per group:                   
##     0                                            70776
##     1                                            71381
##   Sampling weights variable                     BY_WTA
## 
## Model Test User Model:
##                                                Standard      Scaled
##   Test Statistic                              82009.186   69636.869
##   Degrees of freedom                                314         314
##   P-value (Chi-square)                            0.000       0.000
##   Scaling correction factor                                   1.178
##     Yuan-Bentler correction (Mplus variant)                        
##   Test statistic for each group:
##     0                                         46113.207   39156.337
##     1                                         35895.979   30480.532
## 
## Parameter Estimates:
## 
##   Standard errors                             Sandwich
##   Information bread                           Observed
##   Observed information based on                Hessian
## 
## 
## Group 1 [0]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english =~                                                   
##     Stest1vocab       0.751    0.003  236.610    0.000    0.744
##     Stst19dsgsdwrd    0.575    0.003  176.852    0.000    0.568
##     Stest20spellng    0.639    0.004  178.362    0.000    0.632
##     Stest21cptlztn    0.643    0.003  190.651    0.000    0.636
##     Stest22puncttn    0.785    0.003  244.705    0.000    0.779
##     Stest23english    0.706    0.004  175.390    0.000    0.698
##     Stest24exprssn    0.655    0.004  162.702    0.000    0.647
##     Stst25wrdfnctn    0.442    0.008   56.793    0.000    0.427
##     Stst26rdngcmpr    0.873    0.003  295.671    0.000    0.867
##     Stst31bstrctrs    0.293    0.005   61.856    0.000    0.284
##     Stst32rthrsnng    0.259    0.009   30.356    0.000    0.243
##   math =~                                                      
##     Stest5math        0.785    0.003  278.143    0.000    0.779
##     Stst25wrdfnctn    0.304    0.008   38.742    0.000    0.289
##     Stst32rthrsnng    0.534    0.009   62.477    0.000    0.517
##     Stst33hghschlm    0.921    0.003  319.850    0.000    0.915
##     Stst34rthcmptt    0.491    0.004  131.645    0.000    0.484
##   speed =~                                                     
##     Stst19dsgsdwrd    0.273    0.004   73.324    0.000    0.266
##     Stst29vslztn2D    0.225    0.004   55.111    0.000    0.217
##     Stst34rthcmptt    0.376    0.004   91.724    0.000    0.368
##     Stest35tblrdng    0.730    0.006  131.869    0.000    0.719
##     Stst36clrclchc    0.712    0.005  146.945    0.000    0.703
##     Stst37bjctnspc    0.587    0.005  122.687    0.000    0.578
##   spatial =~                                                   
##     Stst28mchnclrs    0.696    0.003  213.440    0.000    0.689
##     Stst29vslztn2D    0.511    0.004  128.199    0.000    0.503
##     Stst30vslztn3D    0.771    0.004  217.726    0.000    0.764
##     Stst31bstrctrs    0.469    0.005   93.081    0.000    0.459
##     Stst37bjctnspc    0.142    0.005   31.346    0.000    0.133
##  ci.upper   Std.lv  Std.all
##                            
##     0.757    0.751    0.803
##     0.581    0.575    0.588
##     0.646    0.639    0.639
##     0.649    0.643    0.657
##     0.791    0.785    0.793
##     0.714    0.706    0.691
##     0.663    0.655    0.625
##     0.458    0.442    0.455
##     0.879    0.873    0.856
##     0.303    0.293    0.299
##     0.276    0.259    0.263
##                            
##     0.790    0.785    0.834
##     0.320    0.304    0.313
##     0.550    0.534    0.540
##     0.926    0.921    0.885
##     0.499    0.491    0.496
##                            
##     0.280    0.273    0.279
##     0.233    0.225    0.231
##     0.384    0.376    0.379
##     0.741    0.730    0.706
##     0.722    0.712    0.713
##     0.597    0.587    0.572
##                            
##     0.702    0.696    0.785
##     0.519    0.511    0.525
##     0.778    0.771    0.756
##     0.478    0.469    0.477
##     0.151    0.142    0.138
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english ~~                                                   
##     math              0.866    0.002  485.567    0.000    0.863
##     speed             0.238    0.006   41.909    0.000    0.227
##     spatial           0.609    0.004  165.416    0.000    0.602
##   math ~~                                                      
##     speed             0.231    0.005   42.022    0.000    0.220
##     spatial           0.652    0.004  185.143    0.000    0.646
##   speed ~~                                                     
##     spatial           0.160    0.006   25.989    0.000    0.148
##  ci.upper   Std.lv  Std.all
##                            
##     0.870    0.866    0.866
##     0.249    0.238    0.238
##     0.616    0.609    0.609
##                            
##     0.241    0.231    0.231
##     0.659    0.652    0.652
##                            
##     0.172    0.160    0.160
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stest1vocab       0.167    0.004   44.518    0.000    0.160
##    .Stst19dsgsdwrd   -0.119    0.004  -30.513    0.000   -0.126
##    .Stest20spellng   -0.258    0.004  -64.136    0.000   -0.265
##    .Stest21cptlztn   -0.212    0.004  -54.084    0.000   -0.220
##    .Stest22puncttn   -0.208    0.004  -52.316    0.000   -0.216
##    .Stest23english   -0.144    0.004  -35.041    0.000   -0.152
##    .Stest24exprssn   -0.118    0.004  -28.047    0.000   -0.126
##    .Stst25wrdfnctn   -0.139    0.004  -35.813    0.000   -0.147
##    .Stst26rdngcmpr   -0.032    0.004   -7.896    0.000   -0.041
##    .Stst31bstrctrs    0.055    0.004   13.853    0.000    0.047
##    .Stst32rthrsnng    0.121    0.004   30.651    0.000    0.114
##    .Stest5math        0.193    0.004   51.128    0.000    0.186
##    .Stst33hghschlm    0.117    0.004   28.152    0.000    0.109
##    .Stst34rthcmptt   -0.078    0.004  -19.713    0.000   -0.086
##    .Stst29vslztn2D    0.212    0.004   54.436    0.000    0.204
##    .Stest35tblrdng   -0.068    0.004  -16.347    0.000   -0.076
##    .Stst36clrclchc   -0.147    0.004  -37.322    0.000   -0.155
##    .Stst37bjctnspc   -0.095    0.004  -23.187    0.000   -0.103
##    .Stst28mchnclrs    0.536    0.004  151.033    0.000    0.529
##    .Stst30vslztn3D    0.190    0.004   46.616    0.000    0.182
##  ci.upper   Std.lv  Std.all
##     0.175    0.167    0.179
##    -0.111   -0.119   -0.122
##    -0.250   -0.258   -0.257
##    -0.204   -0.212   -0.217
##    -0.200   -0.208   -0.210
##    -0.136   -0.144   -0.141
##    -0.110   -0.118   -0.113
##    -0.132   -0.139   -0.143
##    -0.024   -0.032   -0.032
##     0.063    0.055    0.056
##     0.129    0.121    0.123
##     0.201    0.193    0.205
##     0.125    0.117    0.113
##    -0.070   -0.078   -0.079
##     0.219    0.212    0.217
##    -0.060   -0.068   -0.066
##    -0.140   -0.147   -0.148
##    -0.087   -0.095   -0.092
##     0.543    0.536    0.605
##     0.198    0.190    0.186
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stest1vocab       0.311    0.002  140.394    0.000    0.307
##    .Stst19dsgsdwrd    0.475    0.003  156.570    0.000    0.469
##    .Stest20spellng    0.593    0.004  168.091    0.000    0.586
##    .Stest21cptlztn    0.543    0.003  168.866    0.000    0.537
##    .Stest22puncttn    0.363    0.003  139.914    0.000    0.358
##    .Stest23english    0.544    0.004  143.444    0.000    0.537
##    .Stest24exprssn    0.667    0.004  154.214    0.000    0.659
##    .Stst25wrdfnctn    0.424    0.003  157.664    0.000    0.419
##    .Stst26rdngcmpr    0.277    0.002  119.890    0.000    0.273
##    .Stst31bstrctrs    0.493    0.003  150.266    0.000    0.486
##    .Stst32rthrsnng    0.383    0.003  153.304    0.000    0.378
##    .Stest5math        0.269    0.003   90.742    0.000    0.263
##    .Stst33hghschlm    0.234    0.002   98.470    0.000    0.229
##    .Stst34rthcmptt    0.514    0.004  139.231    0.000    0.507
##    .Stst29vslztn2D    0.599    0.004  139.839    0.000    0.591
##    .Stest35tblrdng    0.536    0.008   64.704    0.000    0.520
##    .Stst36clrclchc    0.490    0.006   80.917    0.000    0.478
##    .Stst37bjctnspc    0.663    0.005  128.638    0.000    0.653
##    .Stst28mchnclrs    0.301    0.003  101.432    0.000    0.295
##    .Stst30vslztn3D    0.445    0.004  112.426    0.000    0.437
##     english           1.000                               1.000
##     math              1.000                               1.000
##     speed             1.000                               1.000
##     spatial           1.000                               1.000
##  ci.upper   Std.lv  Std.all
##     0.316    0.311    0.356
##     0.481    0.475    0.498
##     0.600    0.593    0.592
##     0.550    0.543    0.568
##     0.369    0.363    0.371
##     0.552    0.544    0.522
##     0.676    0.667    0.609
##     0.429    0.424    0.448
##     0.282    0.277    0.266
##     0.499    0.493    0.510
##     0.388    0.383    0.393
##     0.275    0.269    0.304
##     0.238    0.234    0.216
##     0.521    0.514    0.523
##     0.608    0.599    0.632
##     0.552    0.536    0.501
##     0.502    0.490    0.491
##     0.673    0.663    0.629
##     0.307    0.301    0.384
##     0.453    0.445    0.428
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
## 
## 
## Group 2 [1]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english =~                                                   
##     Stest1vocab       0.784    0.003  265.362    0.000    0.778
##     Stst19dsgsdwrd    0.547    0.003  163.871    0.000    0.540
##     Stest20spellng    0.561    0.003  169.562    0.000    0.554
##     Stest21cptlztn    0.548    0.004  154.897    0.000    0.541
##     Stest22puncttn    0.713    0.003  239.954    0.000    0.707
##     Stest23english    0.593    0.004  169.021    0.000    0.587
##     Stest24exprssn    0.511    0.004  143.687    0.000    0.504
##     Stst25wrdfnctn    0.509    0.006   82.379    0.000    0.497
##     Stst26rdngcmpr    0.776    0.003  283.956    0.000    0.771
##     Stst31bstrctrs    0.301    0.005   62.945    0.000    0.291
##     Stst32rthrsnng    0.395    0.006   60.998    0.000    0.383
##   math =~                                                      
##     Stest5math        0.787    0.003  261.466    0.000    0.781
##     Stst25wrdfnctn    0.278    0.006   44.726    0.000    0.266
##     Stst32rthrsnng    0.366    0.007   55.168    0.000    0.353
##     Stst33hghschlm    0.793    0.003  269.073    0.000    0.787
##     Stst34rthcmptt    0.440    0.004  123.544    0.000    0.433
##   speed =~                                                     
##     Stst19dsgsdwrd    0.303    0.004   82.798    0.000    0.295
##     Stst29vslztn2D    0.202    0.004   48.407    0.000    0.194
##     Stst34rthcmptt    0.346    0.004   86.139    0.000    0.338
##     Stest35tblrdng    0.596    0.005  127.673    0.000    0.587
##     Stst36clrclchc    0.656    0.004  149.494    0.000    0.647
##     Stst37bjctnspc    0.527    0.004  122.518    0.000    0.518
##   spatial =~                                                   
##     Stst28mchnclrs    0.615    0.003  202.814    0.000    0.609
##     Stst29vslztn2D    0.479    0.004  124.703    0.000    0.472
##     Stst30vslztn3D    0.682    0.003  202.231    0.000    0.675
##     Stst31bstrctrs    0.425    0.005   86.338    0.000    0.415
##     Stst37bjctnspc    0.142    0.004   36.133    0.000    0.134
##  ci.upper   Std.lv  Std.all
##                            
##     0.790    0.784    0.803
##     0.553    0.547    0.563
##     0.567    0.561    0.616
##     0.555    0.548    0.594
##     0.719    0.713    0.789
##     0.600    0.593    0.654
##     0.518    0.511    0.570
##     0.521    0.509    0.516
##     0.781    0.776    0.854
##     0.310    0.301    0.316
##     0.408    0.395    0.410
##                            
##     0.793    0.787    0.795
##     0.291    0.278    0.282
##     0.379    0.366    0.380
##     0.799    0.793    0.860
##     0.447    0.440    0.473
##                            
##     0.310    0.303    0.312
##     0.210    0.202    0.211
##     0.353    0.346    0.372
##     0.605    0.596    0.691
##     0.664    0.656    0.703
##     0.535    0.527    0.567
##                            
##     0.620    0.615    0.748
##     0.487    0.479    0.501
##     0.688    0.682    0.733
##     0.434    0.425    0.446
##     0.150    0.142    0.153
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english ~~                                                   
##     math              0.802    0.002  359.409    0.000    0.798
##     speed             0.247    0.006   44.077    0.000    0.236
##     spatial           0.624    0.003  179.833    0.000    0.617
##   math ~~                                                      
##     speed             0.182    0.005   34.458    0.000    0.172
##     spatial           0.633    0.004  168.817    0.000    0.625
##   speed ~~                                                     
##     spatial           0.195    0.006   33.518    0.000    0.183
##  ci.upper   Std.lv  Std.all
##                            
##     0.807    0.802    0.802
##     0.258    0.247    0.247
##     0.631    0.624    0.624
##                            
##     0.192    0.182    0.182
##     0.640    0.633    0.633
##                            
##     0.206    0.195    0.195
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stest1vocab      -0.095    0.004  -24.615    0.000   -0.103
##    .Stst19dsgsdwrd    0.150    0.004   38.967    0.000    0.142
##    .Stest20spellng    0.280    0.004   77.302    0.000    0.273
##    .Stest21cptlztn    0.276    0.004   74.784    0.000    0.268
##    .Stest22puncttn    0.278    0.004   76.957    0.000    0.271
##    .Stest23english    0.190    0.004   52.481    0.000    0.183
##    .Stest24exprssn    0.165    0.004   46.240    0.000    0.158
##    .Stst25wrdfnctn    0.196    0.004   50.126    0.000    0.189
##    .Stst26rdngcmpr    0.105    0.004   29.044    0.000    0.098
##    .Stst31bstrctrs    0.026    0.004    6.799    0.000    0.018
##    .Stst32rthrsnng   -0.040    0.004  -10.549    0.000   -0.048
##    .Stest5math       -0.155    0.004  -39.596    0.000   -0.163
##    .Stst33hghschlm   -0.072    0.004  -19.964    0.000   -0.080
##    .Stst34rthcmptt    0.165    0.004   44.491    0.000    0.158
##    .Stst29vslztn2D   -0.150    0.004  -39.724    0.000   -0.157
##    .Stest35tblrdng    0.085    0.003   24.796    0.000    0.078
##    .Stst36clrclchc    0.094    0.004   25.710    0.000    0.087
##    .Stst37bjctnspc    0.084    0.004   22.827    0.000    0.076
##    .Stst28mchnclrs   -0.428    0.003 -131.000    0.000   -0.434
##    .Stst30vslztn3D   -0.115    0.004  -31.342    0.000   -0.122
##  ci.upper   Std.lv  Std.all
##    -0.088   -0.095   -0.097
##     0.158    0.150    0.155
##     0.287    0.280    0.308
##     0.283    0.276    0.299
##     0.285    0.278    0.307
##     0.197    0.190    0.209
##     0.172    0.165    0.184
##     0.204    0.196    0.199
##     0.112    0.105    0.116
##     0.033    0.026    0.027
##    -0.033   -0.040   -0.042
##    -0.147   -0.155   -0.157
##    -0.065   -0.072   -0.079
##     0.172    0.165    0.177
##    -0.143   -0.150   -0.157
##     0.091    0.085    0.098
##     0.101    0.094    0.100
##     0.091    0.084    0.090
##    -0.422   -0.428   -0.521
##    -0.108   -0.115   -0.124
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stest1vocab       0.340    0.002  144.791    0.000    0.335
##    .Stst19dsgsdwrd    0.470    0.003  153.982    0.000    0.464
##    .Stest20spellng    0.515    0.003  171.911    0.000    0.509
##    .Stest21cptlztn    0.552    0.003  170.231    0.000    0.545
##    .Stest22puncttn    0.309    0.002  138.966    0.000    0.304
##    .Stest23english    0.472    0.003  146.391    0.000    0.466
##    .Stest24exprssn    0.542    0.004  151.515    0.000    0.535
##    .Stst25wrdfnctn    0.408    0.003  149.003    0.000    0.403
##    .Stst26rdngcmpr    0.223    0.002  117.452    0.000    0.220
##    .Stst31bstrctrs    0.478    0.003  154.488    0.000    0.472
##    .Stst32rthrsnng    0.409    0.002  163.664    0.000    0.404
##    .Stest5math        0.360    0.004  100.754    0.000    0.353
##    .Stst33hghschlm    0.221    0.002   95.135    0.000    0.217
##    .Stst34rthcmptt    0.496    0.004  133.887    0.000    0.489
##    .Stst29vslztn2D    0.609    0.004  156.840    0.000    0.601
##    .Stest35tblrdng    0.388    0.005   71.943    0.000    0.377
##    .Stst36clrclchc    0.439    0.005   87.985    0.000    0.429
##    .Stst37bjctnspc    0.538    0.004  133.041    0.000    0.530
##    .Stst28mchnclrs    0.298    0.003  115.211    0.000    0.293
##    .Stst30vslztn3D    0.400    0.003  118.855    0.000    0.393
##     english           1.000                               1.000
##     math              1.000                               1.000
##     speed             1.000                               1.000
##     spatial           1.000                               1.000
##  ci.upper   Std.lv  Std.all
##     0.344    0.340    0.356
##     0.476    0.470    0.498
##     0.521    0.515    0.621
##     0.558    0.552    0.647
##     0.313    0.309    0.378
##     0.479    0.472    0.573
##     0.549    0.542    0.675
##     0.413    0.408    0.420
##     0.227    0.223    0.270
##     0.484    0.478    0.526
##     0.414    0.409    0.439
##     0.367    0.360    0.368
##     0.226    0.221    0.260
##     0.503    0.496    0.574
##     0.616    0.609    0.664
##     0.398    0.388    0.522
##     0.449    0.439    0.505
##     0.546    0.538    0.622
##     0.303    0.298    0.441
##     0.406    0.400    0.462
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
modificationIndices(configural, sort=T, maximum.number=30)
##                       lhs op                         rhs block group
## 466           Stest1vocab ~~ Stest26readingcomprehension     2     2
## 223           Stest1vocab ~~ Stest26readingcomprehension     1     1
## 182                  math =~         Stest35tablereading     1     1
## 203               spatial =~             Stest20spelling     1     1
## 214               spatial =~         Stest35tablereading     1     1
## 167               english =~         Stest35tablereading     1     1
## 226           Stest1vocab ~~                  Stest5math     1     1
## 184                  math =~     Stest37objectinspection     1     1
## 446               spatial =~             Stest20spelling     2     2
## 169               english =~     Stest37objectinspection     1     1
## 213               spatial =~     Stest34arithcomputation     1     1
## 219           Stest1vocab ~~          Stest22punctuation     1     1
## 289    Stest22punctuation ~~ Stest26readingcomprehension     1     1
## 233           Stest1vocab ~~  Stest28mechanicalreasoning     1     1
## 478 Stest19disguisedwords ~~             Stest20spelling     2     2
## 469           Stest1vocab ~~                  Stest5math     2     2
## 425                  math =~         Stest35tablereading     2     2
## 170               english =~  Stest28mechanicalreasoning     1     1
## 506       Stest20spelling ~~     Stest34arithcomputation     2     2
## 263       Stest20spelling ~~     Stest34arithcomputation     1     1
## 462           Stest1vocab ~~          Stest22punctuation     2     2
## 431                 speed =~             Stest20spelling     2     2
## 235 Stest19disguisedwords ~~             Stest20spelling     1     1
## 410               english =~         Stest35tablereading     2     2
## 532    Stest22punctuation ~~ Stest26readingcomprehension     2     2
## 457               spatial =~         Stest35tablereading     2     2
## 412               english =~     Stest37objectinspection     2     2
## 288    Stest22punctuation ~~        Stest25wordfunctions     1     1
## 427                  math =~     Stest37objectinspection     2     2
## 164               english =~       Stest33highschoolmath     1     1
##     level       mi    epc sepc.lv sepc.all sepc.nox
## 466     1 5114.694  0.099   0.099    0.360    0.360
## 223     1 4983.954  0.101   0.101    0.345    0.345
## 182     1 4295.231  0.267   0.267    0.259    0.259
## 203     1 3837.075 -0.285  -0.285   -0.285   -0.285
## 214     1 3818.138  0.263   0.263    0.255    0.255
## 167     1 3607.096  0.240   0.240    0.233    0.233
## 226     1 3031.351  0.072   0.072    0.250    0.250
## 184     1 2905.976 -0.291  -0.291   -0.283   -0.283
## 446     1 2856.374 -0.241  -0.241   -0.265   -0.265
## 169     1 2795.607 -0.264  -0.264   -0.257   -0.257
## 213     1 2708.566 -0.251  -0.251   -0.253   -0.253
## 219     1 2435.393 -0.075  -0.075   -0.222   -0.222
## 289     1 2376.516 -0.075  -0.075   -0.235   -0.235
## 233     1 2376.186  0.071   0.071    0.233    0.233
## 478     1 2195.566  0.094   0.094    0.191    0.191
## 469     1 2136.186  0.074   0.074    0.212    0.212
## 425     1 2024.141  0.155   0.155    0.180    0.180
## 170     1 1851.075  0.208   0.208    0.235    0.235
## 506     1 1840.673  0.088   0.088    0.174    0.174
## 263     1 1806.266  0.095   0.095    0.173    0.173
## 462     1 1802.311 -0.063  -0.063   -0.195   -0.195
## 431     1 1794.126  0.143   0.143    0.157    0.157
## 235     1 1791.161  0.091   0.091    0.171    0.171
## 410     1 1756.921  0.143   0.143    0.166    0.166
## 532     1 1721.842 -0.054  -0.054   -0.206   -0.206
## 457     1 1683.270  0.153   0.153    0.177    0.177
## 412     1 1644.252 -0.191  -0.191   -0.205   -0.205
## 288     1 1619.565  0.068   0.068    0.172    0.172
## 427     1 1597.304 -0.195  -0.195   -0.209   -0.209
## 164     1 1543.050 -0.403  -0.403   -0.387   -0.387
metric<-cfa(chc.factor.model, data=dgroup, group="sex", meanstructure=TRUE, sampling.weights="BY_WTA", std.lv=T, group.equal=c("loadings"))
fitMeasures(metric, c("chisq", "df", "pvalue", "cfi", "rmsea", "srmr", "aic", "bic"))
##       chisq          df      pvalue         cfi       rmsea        srmr 
##   86406.629     337.000       0.000       0.939       0.060       0.046 
##         aic         bic 
## 6493224.165 6494437.522
Mc(metric)
## [1] 0.7387989
summary(metric, standardized=T, ci=T)
## lavaan 0.6-18 ended normally after 54 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                       150
##   Number of equality constraints                    27
## 
##   Number of observations per group:                   
##     0                                            70776
##     1                                            71381
##   Sampling weights variable                     BY_WTA
## 
## Model Test User Model:
##                                                Standard      Scaled
##   Test Statistic                              86406.629   73397.341
##   Degrees of freedom                                337         337
##   P-value (Chi-square)                            0.000       0.000
##   Scaling correction factor                                   1.177
##     Yuan-Bentler correction (Mplus variant)                        
##   Test statistic for each group:
##     0                                         48172.831   40919.982
##     1                                         38233.798   32477.359
## 
## Parameter Estimates:
## 
##   Standard errors                             Sandwich
##   Information bread                           Observed
##   Observed information based on                Hessian
## 
## 
## Group 1 [0]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english =~                                                   
##     Stst1vc (.p1.)    0.791    0.003  289.927    0.000    0.785
##     Stst19d (.p2.)    0.583    0.003  219.676    0.000    0.578
##     Stst20s (.p3.)    0.622    0.003  216.015    0.000    0.616
##     Stst21c (.p4.)    0.619    0.003  217.387    0.000    0.614
##     Stst22p (.p5.)    0.777    0.003  278.223    0.000    0.772
##     Stst23n (.p6.)    0.673    0.003  210.744    0.000    0.667
##     Stst24x (.p7.)    0.601    0.003  190.323    0.000    0.595
##     Stst25w (.p8.)    0.502    0.005   97.725    0.000    0.492
##     Stst26r (.p9.)    0.854    0.003  307.379    0.000    0.848
##     Stst31b (.10.)    0.309    0.004   87.848    0.000    0.302
##     Stst32r (.11.)    0.354    0.006   63.773    0.000    0.343
##   math =~                                                      
##     Stst5mt (.12.)    0.810    0.003  320.529    0.000    0.805
##     Stst25w (.13.)    0.292    0.005   56.284    0.000    0.282
##     Stst32r (.14.)    0.453    0.006   79.661    0.000    0.441
##     Stst33h (.15.)    0.892    0.003  318.703    0.000    0.886
##     Stst34r (.16.)    0.486    0.003  169.476    0.000    0.480
##   speed =~                                                     
##     Stst19d (.17.)    0.302    0.003  107.312    0.000    0.296
##     Sts292D (.18.)    0.227    0.003   72.368    0.000    0.220
##     Stst34r (.19.)    0.381    0.003  118.283    0.000    0.375
##     Stst35t (.20.)    0.697    0.005  153.882    0.000    0.688
##     Stst36c (.21.)    0.724    0.004  181.328    0.000    0.716
##     Stst37b (.22.)    0.589    0.004  153.560    0.000    0.582
##   spatial =~                                                   
##     Stst28m (.23.)    0.691    0.003  241.879    0.000    0.686
##     Sts292D (.24.)    0.522    0.003  165.439    0.000    0.516
##     Sts303D (.25.)    0.766    0.003  246.463    0.000    0.760
##     Stst31b (.26.)    0.469    0.004  122.056    0.000    0.462
##     Stst37b (.27.)    0.151    0.003   47.835    0.000    0.145
##  ci.upper   Std.lv  Std.all
##                            
##     0.796    0.791    0.819
##     0.588    0.583    0.588
##     0.628    0.622    0.627
##     0.625    0.619    0.642
##     0.783    0.777    0.789
##     0.679    0.673    0.672
##     0.607    0.601    0.590
##     0.512    0.502    0.498
##     0.859    0.854    0.850
##     0.316    0.309    0.312
##     0.365    0.354    0.355
##                            
##     0.815    0.810    0.847
##     0.302    0.292    0.290
##     0.464    0.453    0.454
##     0.897    0.892    0.876
##     0.492    0.486    0.492
##                            
##     0.307    0.302    0.305
##     0.233    0.227    0.232
##     0.387    0.381    0.385
##     0.706    0.697    0.681
##     0.732    0.724    0.724
##     0.597    0.589    0.573
##                            
##     0.697    0.691    0.783
##     0.528    0.522    0.534
##     0.772    0.766    0.754
##     0.477    0.469    0.473
##     0.158    0.151    0.147
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english ~~                                                   
##     math              0.866    0.002  507.060    0.000    0.862
##     speed             0.226    0.005   42.444    0.000    0.216
##     spatial           0.610    0.004  170.802    0.000    0.603
##   math ~~                                                      
##     speed             0.221    0.005   42.706    0.000    0.211
##     spatial           0.648    0.003  190.220    0.000    0.641
##   speed ~~                                                     
##     spatial           0.148    0.006   25.945    0.000    0.137
##  ci.upper   Std.lv  Std.all
##                            
##     0.869    0.866    0.866
##     0.237    0.226    0.226
##     0.617    0.610    0.610
##                            
##     0.231    0.221    0.221
##     0.654    0.648    0.648
##                            
##     0.159    0.148    0.148
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stest1vocab       0.167    0.004   44.518    0.000    0.160
##    .Stst19dsgsdwrd   -0.119    0.004  -30.513    0.000   -0.126
##    .Stest20spellng   -0.258    0.004  -64.136    0.000   -0.265
##    .Stest21cptlztn   -0.212    0.004  -54.084    0.000   -0.220
##    .Stest22puncttn   -0.208    0.004  -52.316    0.000   -0.216
##    .Stest23english   -0.144    0.004  -35.041    0.000   -0.152
##    .Stest24exprssn   -0.118    0.004  -28.047    0.000   -0.126
##    .Stst25wrdfnctn   -0.139    0.004  -35.813    0.000   -0.147
##    .Stst26rdngcmpr   -0.032    0.004   -7.896    0.000   -0.041
##    .Stst31bstrctrs    0.055    0.004   13.853    0.000    0.047
##    .Stst32rthrsnng    0.121    0.004   30.651    0.000    0.114
##    .Stest5math        0.193    0.004   51.128    0.000    0.186
##    .Stst33hghschlm    0.117    0.004   28.152    0.000    0.109
##    .Stst34rthcmptt   -0.078    0.004  -19.713    0.000   -0.086
##    .Stst29vslztn2D    0.212    0.004   54.436    0.000    0.204
##    .Stest35tblrdng   -0.068    0.004  -16.347    0.000   -0.076
##    .Stst36clrclchc   -0.147    0.004  -37.322    0.000   -0.155
##    .Stst37bjctnspc   -0.095    0.004  -23.187    0.000   -0.103
##    .Stst28mchnclrs    0.536    0.004  151.033    0.000    0.529
##    .Stst30vslztn3D    0.190    0.004   46.616    0.000    0.182
##  ci.upper   Std.lv  Std.all
##     0.175    0.167    0.173
##    -0.111   -0.119   -0.120
##    -0.250   -0.258   -0.260
##    -0.204   -0.212   -0.220
##    -0.200   -0.208   -0.211
##    -0.136   -0.144   -0.144
##    -0.110   -0.118   -0.116
##    -0.132   -0.139   -0.138
##    -0.024   -0.032   -0.032
##     0.063    0.055    0.055
##     0.129    0.121    0.122
##     0.201    0.193    0.202
##     0.125    0.117    0.115
##    -0.070   -0.078   -0.079
##     0.219    0.212    0.217
##    -0.060   -0.068   -0.066
##    -0.140   -0.147   -0.147
##    -0.087   -0.095   -0.092
##     0.543    0.536    0.607
##     0.198    0.190    0.187
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stest1vocab       0.307    0.002  141.258    0.000    0.303
##    .Stst19dsgsdwrd    0.471    0.003  158.377    0.000    0.465
##    .Stest20spellng    0.597    0.003  170.861    0.000    0.590
##    .Stest21cptlztn    0.547    0.003  171.968    0.000    0.541
##    .Stest22puncttn    0.365    0.003  142.323    0.000    0.360
##    .Stest23english    0.551    0.004  143.205    0.000    0.543
##    .Stest24exprssn    0.676    0.004  154.647    0.000    0.668
##    .Stst25wrdfnctn    0.424    0.003  156.727    0.000    0.418
##    .Stst26rdngcmpr    0.279    0.002  123.133    0.000    0.275
##    .Stst31bstrctrs    0.492    0.003  152.614    0.000    0.486
##    .Stst32rthrsnng    0.388    0.002  157.581    0.000    0.383
##    .Stest5math        0.259    0.003   87.212    0.000    0.253
##    .Stst33hghschlm    0.242    0.002  108.616    0.000    0.238
##    .Stst34rthcmptt    0.514    0.004  141.079    0.000    0.507
##    .Stst29vslztn2D    0.596    0.004  141.971    0.000    0.588
##    .Stest35tblrdng    0.561    0.008   69.447    0.000    0.545
##    .Stst36clrclchc    0.475    0.006   86.314    0.000    0.464
##    .Stst37bjctnspc    0.663    0.005  134.667    0.000    0.653
##    .Stst28mchnclrs    0.302    0.003  109.943    0.000    0.297
##    .Stst30vslztn3D    0.446    0.004  121.123    0.000    0.439
##     english           1.000                               1.000
##     math              1.000                               1.000
##     speed             1.000                               1.000
##     spatial           1.000                               1.000
##  ci.upper   Std.lv  Std.all
##     0.311    0.307    0.329
##     0.477    0.471    0.480
##     0.604    0.597    0.607
##     0.554    0.547    0.588
##     0.370    0.365    0.377
##     0.558    0.551    0.549
##     0.685    0.676    0.652
##     0.429    0.424    0.418
##     0.283    0.279    0.277
##     0.498    0.492    0.499
##     0.393    0.388    0.389
##     0.265    0.259    0.283
##     0.246    0.242    0.233
##     0.521    0.514    0.526
##     0.604    0.596    0.625
##     0.577    0.561    0.536
##     0.486    0.475    0.475
##     0.672    0.663    0.626
##     0.308    0.302    0.388
##     0.453    0.446    0.432
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
## 
## 
## Group 2 [1]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english =~                                                   
##     Stst1vc (.p1.)    0.791    0.003  289.927    0.000    0.785
##     Stst19d (.p2.)    0.583    0.003  219.676    0.000    0.578
##     Stst20s (.p3.)    0.622    0.003  216.015    0.000    0.616
##     Stst21c (.p4.)    0.619    0.003  217.387    0.000    0.614
##     Stst22p (.p5.)    0.777    0.003  278.223    0.000    0.772
##     Stst23n (.p6.)    0.673    0.003  210.744    0.000    0.667
##     Stst24x (.p7.)    0.601    0.003  190.323    0.000    0.595
##     Stst25w (.p8.)    0.502    0.005   97.725    0.000    0.492
##     Stst26r (.p9.)    0.854    0.003  307.379    0.000    0.848
##     Stst31b (.10.)    0.309    0.004   87.848    0.000    0.302
##     Stst32r (.11.)    0.354    0.006   63.773    0.000    0.343
##   math =~                                                      
##     Stst5mt (.12.)    0.810    0.003  320.529    0.000    0.805
##     Stst25w (.13.)    0.292    0.005   56.284    0.000    0.282
##     Stst32r (.14.)    0.453    0.006   79.661    0.000    0.441
##     Stst33h (.15.)    0.892    0.003  318.703    0.000    0.886
##     Stst34r (.16.)    0.486    0.003  169.476    0.000    0.480
##   speed =~                                                     
##     Stst19d (.17.)    0.302    0.003  107.312    0.000    0.296
##     Sts292D (.18.)    0.227    0.003   72.368    0.000    0.220
##     Stst34r (.19.)    0.381    0.003  118.283    0.000    0.375
##     Stst35t (.20.)    0.697    0.005  153.882    0.000    0.688
##     Stst36c (.21.)    0.724    0.004  181.328    0.000    0.716
##     Stst37b (.22.)    0.589    0.004  153.560    0.000    0.582
##   spatial =~                                                   
##     Stst28m (.23.)    0.691    0.003  241.879    0.000    0.686
##     Sts292D (.24.)    0.522    0.003  165.439    0.000    0.516
##     Sts303D (.25.)    0.766    0.003  246.463    0.000    0.760
##     Stst31b (.26.)    0.469    0.004  122.056    0.000    0.462
##     Stst37b (.27.)    0.151    0.003   47.835    0.000    0.145
##  ci.upper   Std.lv  Std.all
##                            
##     0.796    0.733    0.778
##     0.588    0.540    0.565
##     0.628    0.577    0.628
##     0.625    0.574    0.613
##     0.783    0.721    0.793
##     0.679    0.624    0.674
##     0.607    0.557    0.605
##     0.512    0.465    0.489
##     0.859    0.792    0.859
##     0.316    0.287    0.304
##     0.365    0.328    0.344
##                            
##     0.815    0.746    0.772
##     0.302    0.269    0.283
##     0.464    0.417    0.437
##     0.897    0.822    0.872
##     0.492    0.448    0.481
##                            
##     0.307    0.269    0.281
##     0.233    0.202    0.212
##     0.387    0.339    0.364
##     0.706    0.621    0.714
##     0.732    0.645    0.693
##     0.597    0.525    0.566
##                            
##     0.697    0.620    0.751
##     0.528    0.468    0.491
##     0.772    0.687    0.736
##     0.477    0.421    0.446
##     0.158    0.136    0.146
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english ~~                                                   
##     math              0.687    0.005  130.782    0.000    0.676
##     speed             0.212    0.005   44.811    0.000    0.203
##     spatial           0.519    0.005  104.982    0.000    0.509
##   math ~~                                                      
##     speed             0.155    0.004   36.035    0.000    0.147
##     spatial           0.527    0.005  104.806    0.000    0.517
##   speed ~~                                                     
##     spatial           0.162    0.005   35.197    0.000    0.153
##  ci.upper   Std.lv  Std.all
##                            
##     0.697    0.804    0.804
##     0.221    0.256    0.256
##     0.529    0.624    0.624
##                            
##     0.164    0.189    0.189
##     0.537    0.638    0.638
##                            
##     0.171    0.203    0.203
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stest1vocab      -0.095    0.004  -24.615    0.000   -0.103
##    .Stst19dsgsdwrd    0.150    0.004   38.967    0.000    0.142
##    .Stest20spellng    0.280    0.004   77.302    0.000    0.273
##    .Stest21cptlztn    0.276    0.004   74.784    0.000    0.268
##    .Stest22puncttn    0.278    0.004   76.957    0.000    0.271
##    .Stest23english    0.190    0.004   52.481    0.000    0.183
##    .Stest24exprssn    0.165    0.004   46.240    0.000    0.158
##    .Stst25wrdfnctn    0.196    0.004   50.126    0.000    0.189
##    .Stst26rdngcmpr    0.105    0.004   29.044    0.000    0.098
##    .Stst31bstrctrs    0.026    0.004    6.799    0.000    0.018
##    .Stst32rthrsnng   -0.040    0.004  -10.549    0.000   -0.048
##    .Stest5math       -0.155    0.004  -39.596    0.000   -0.163
##    .Stst33hghschlm   -0.072    0.004  -19.964    0.000   -0.080
##    .Stst34rthcmptt    0.165    0.004   44.491    0.000    0.158
##    .Stst29vslztn2D   -0.150    0.004  -39.724    0.000   -0.157
##    .Stest35tblrdng    0.085    0.003   24.796    0.000    0.078
##    .Stst36clrclchc    0.094    0.004   25.710    0.000    0.087
##    .Stst37bjctnspc    0.084    0.004   22.827    0.000    0.076
##    .Stst28mchnclrs   -0.428    0.003 -131.000    0.000   -0.434
##    .Stst30vslztn3D   -0.115    0.004  -31.342    0.000   -0.122
##  ci.upper   Std.lv  Std.all
##    -0.088   -0.095   -0.101
##     0.158    0.150    0.157
##     0.287    0.280    0.305
##     0.283    0.276    0.294
##     0.285    0.278    0.306
##     0.197    0.190    0.205
##     0.172    0.165    0.179
##     0.204    0.196    0.206
##     0.112    0.105    0.114
##     0.033    0.026    0.027
##    -0.033   -0.040   -0.042
##    -0.147   -0.155   -0.160
##    -0.065   -0.072   -0.077
##     0.172    0.165    0.177
##    -0.143   -0.150   -0.157
##     0.091    0.085    0.097
##     0.101    0.094    0.101
##     0.091    0.084    0.090
##    -0.422   -0.428   -0.519
##    -0.108   -0.115   -0.124
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stest1vocab       0.350    0.002  152.078    0.000    0.346
##    .Stst19dsgsdwrd    0.477    0.003  161.748    0.000    0.471
##    .Stest20spellng    0.512    0.003  172.959    0.000    0.506
##    .Stest21cptlztn    0.548    0.003  170.549    0.000    0.542
##    .Stest22puncttn    0.306    0.002  140.102    0.000    0.302
##    .Stest23english    0.469    0.003  146.051    0.000    0.462
##    .Stest24exprssn    0.539    0.004  150.849    0.000    0.532
##    .Stst25wrdfnctn    0.415    0.003  151.637    0.000    0.410
##    .Stst26rdngcmpr    0.224    0.002  119.141    0.000    0.220
##    .Stst31bstrctrs    0.480    0.003  157.218    0.000    0.474
##    .Stst32rthrsnng    0.408    0.002  165.560    0.000    0.404
##    .Stest5math        0.377    0.004  102.161    0.000    0.369
##    .Stst33hghschlm    0.213    0.002   94.398    0.000    0.208
##    .Stst34rthcmptt    0.495    0.004  135.960    0.000    0.488
##    .Stst29vslztn2D    0.612    0.004  162.117    0.000    0.605
##    .Stest35tblrdng    0.371    0.005   69.489    0.000    0.361
##    .Stst36clrclchc    0.451    0.005   96.478    0.000    0.442
##    .Stst37bjctnspc    0.538    0.004  139.154    0.000    0.531
##    .Stst28mchnclrs    0.296    0.002  123.238    0.000    0.292
##    .Stst30vslztn3D    0.399    0.003  126.953    0.000    0.392
##     english           0.860    0.007  122.035    0.000    0.846
##     math              0.849    0.007  127.740    0.000    0.836
##     speed             0.794    0.010   80.682    0.000    0.774
##     spatial           0.804    0.008  106.150    0.000    0.790
##  ci.upper   Std.lv  Std.all
##     0.355    0.350    0.395
##     0.482    0.477    0.521
##     0.518    0.512    0.606
##     0.555    0.548    0.625
##     0.311    0.306    0.371
##     0.475    0.469    0.546
##     0.546    0.539    0.634
##     0.420    0.415    0.459
##     0.227    0.224    0.263
##     0.486    0.480    0.539
##     0.413    0.408    0.449
##     0.384    0.377    0.403
##     0.217    0.213    0.240
##     0.503    0.495    0.570
##     0.619    0.612    0.672
##     0.382    0.371    0.490
##     0.460    0.451    0.520
##     0.546    0.538    0.625
##     0.301    0.296    0.435
##     0.405    0.399    0.458
##     0.874    1.000    1.000
##     0.863    1.000    1.000
##     0.813    1.000    1.000
##     0.819    1.000    1.000
lavTestScore(metric, release = 1:27) 
## Warning: lavaan->lavTestScore():  
##    se is not `standard'; not implemented yet; falling back to 
##    ordinary score test
## $test
## 
## total score test:
## 
##    test       X2 df p.value
## 1 score 4340.637 27       0
## 
## $uni
## 
## univariate score tests:
## 
##      lhs op    rhs      X2 df p.value
## 1   .p1. ==  .p82. 962.202  1   0.000
## 2   .p2. ==  .p83.  62.158  1   0.000
## 3   .p3. ==  .p84.  54.552  1   0.000
## 4   .p4. ==  .p85. 141.224  1   0.000
## 5   .p5. ==  .p86.  21.873  1   0.000
## 6   .p6. ==  .p87. 262.985  1   0.000
## 7   .p7. ==  .p88. 557.393  1   0.000
## 8   .p8. ==  .p89. 850.152  1   0.000
## 9   .p9. ==  .p90. 254.357  1   0.000
## 10 .p10. ==  .p91.  76.289  1   0.000
## 11 .p11. ==  .p92. 164.434  1   0.000
## 12 .p12. ==  .p93. 489.658  1   0.000
## 13 .p13. ==  .p94. 729.790  1   0.000
## 14 .p14. ==  .p95.  35.128  1   0.000
## 15 .p15. ==  .p96. 997.064  1   0.000
## 16 .p16. ==  .p97.  18.325  1   0.000
## 17 .p17. ==  .p98. 205.498  1   0.000
## 18 .p18. ==  .p99.   0.361  1   0.548
## 19 .p19. == .p100.   3.187  1   0.074
## 20 .p20. == .p101. 151.159  1   0.000
## 21 .p21. == .p102.   1.572  1   0.210
## 22 .p22. == .p103.   3.552  1   0.059
## 23 .p23. == .p104.  18.697  1   0.000
## 24 .p24. == .p105.  15.274  1   0.000
## 25 .p25. == .p106.  16.716  1   0.000
## 26 .p26. == .p107.  56.852  1   0.000
## 27 .p27. == .p108.   1.005  1   0.316
scalar<-cfa(chc.factor.model, data=dgroup, group="sex", meanstructure=TRUE, sampling.weights="BY_WTA", std.lv=T, group.equal=c("loadings", "intercepts"))
fitMeasures(scalar, c("chisq", "df", "pvalue", "cfi", "rmsea", "srmr", "aic", "bic"))
##       chisq          df      pvalue         cfi       rmsea        srmr 
##  163169.161     353.000       0.000       0.885       0.081       0.061 
##         aic         bic 
## 6569954.696 6571010.218
Mc(scalar)
## [1] 0.5640191
summary(scalar, standardized=T, ci=T)
## lavaan 0.6-18 ended normally after 63 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                       154
##   Number of equality constraints                    47
## 
##   Number of observations per group:                   
##     0                                            70776
##     1                                            71381
##   Sampling weights variable                     BY_WTA
## 
## Model Test User Model:
##                                                 Standard      Scaled
##   Test Statistic                              163169.161  138849.214
##   Degrees of freedom                                 353         353
##   P-value (Chi-square)                             0.000       0.000
##   Scaling correction factor                                    1.175
##     Yuan-Bentler correction (Mplus variant)                         
##   Test statistic for each group:
##     0                                         84815.830   72174.247
##     1                                         78353.330   66674.967
## 
## Parameter Estimates:
## 
##   Standard errors                             Sandwich
##   Information bread                           Observed
##   Observed information based on                Hessian
## 
## 
## Group 1 [0]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english =~                                                   
##     Stst1vc (.p1.)    0.717    0.003  251.333    0.000    0.711
##     Stst19d (.p2.)    0.573    0.003  215.858    0.000    0.568
##     Stst20s (.p3.)    0.657    0.003  225.661    0.000    0.651
##     Stst21c (.p4.)    0.651    0.003  227.562    0.000    0.645
##     Stst22p (.p5.)    0.807    0.003  288.657    0.000    0.802
##     Stst23n (.p6.)    0.684    0.003  214.665    0.000    0.678
##     Stst24x (.p7.)    0.608    0.003  192.721    0.000    0.602
##     Stst25w (.p8.)    0.666    0.004  156.562    0.000    0.657
##     Stst26r (.p9.)    0.826    0.003  295.591    0.000    0.821
##     Stst31b (.10.)    0.435    0.003  146.916    0.000    0.429
##     Stst32r (.11.)    0.240    0.005   49.429    0.000    0.230
##   math =~                                                      
##     Stst5mt (.12.)    0.818    0.002  329.665    0.000    0.813
##     Stst25w (.13.)    0.128    0.004   28.979    0.000    0.119
##     Stst32r (.14.)    0.566    0.005  113.663    0.000    0.557
##     Stst33h (.15.)    0.882    0.003  310.826    0.000    0.876
##     Stst34r (.16.)    0.451    0.003  155.542    0.000    0.445
##   speed =~                                                     
##     Stst19d (.17.)    0.289    0.003  103.748    0.000    0.284
##     Sts292D (.18.)    0.252    0.003   84.096    0.000    0.246
##     Stst34r (.19.)    0.420    0.003  133.476    0.000    0.413
##     Stst35t (.20.)    0.681    0.004  155.397    0.000    0.672
##     Stst36c (.21.)    0.712    0.004  185.373    0.000    0.704
##     Stst37b (.22.)    0.608    0.004  165.450    0.000    0.601
##   spatial =~                                                   
##     Stst28m (.23.)    0.791    0.003  303.811    0.000    0.786
##     Sts292D (.24.)    0.483    0.003  164.700    0.000    0.478
##     Sts303D (.25.)    0.600    0.003  174.652    0.000    0.593
##     Stst31b (.26.)    0.307    0.003  102.522    0.000    0.301
##     Stst37b (.27.)    0.112    0.003   42.921    0.000    0.107
##  ci.upper   Std.lv  Std.all
##                            
##     0.723    0.717    0.754
##     0.578    0.573    0.581
##     0.663    0.657    0.642
##     0.656    0.651    0.658
##     0.813    0.807    0.802
##     0.691    0.684    0.678
##     0.614    0.608    0.594
##     0.674    0.666    0.656
##     0.832    0.826    0.829
##     0.441    0.435    0.440
##     0.249    0.240    0.240
##                            
##     0.823    0.818    0.847
##     0.136    0.128    0.126
##     0.576    0.566    0.566
##     0.887    0.882    0.868
##     0.457    0.451    0.453
##                            
##     0.295    0.289    0.293
##     0.258    0.252    0.260
##     0.426    0.420    0.421
##     0.689    0.681    0.670
##     0.719    0.712    0.714
##     0.615    0.608    0.589
##                            
##     0.796    0.791    0.860
##     0.489    0.483    0.497
##     0.606    0.600    0.615
##     0.313    0.307    0.310
##     0.117    0.112    0.108
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english ~~                                                   
##     math              0.880    0.002  522.492    0.000    0.877
##     speed             0.251    0.005   47.702    0.000    0.241
##     spatial           0.604    0.004  171.557    0.000    0.597
##   math ~~                                                      
##     speed             0.235    0.005   45.615    0.000    0.225
##     spatial           0.636    0.003  181.852    0.000    0.629
##   speed ~~                                                     
##     spatial           0.148    0.006   26.523    0.000    0.137
##  ci.upper   Std.lv  Std.all
##                            
##     0.883    0.880    0.880
##     0.262    0.251    0.251
##     0.611    0.604    0.604
##                            
##     0.245    0.235    0.235
##     0.643    0.636    0.636
##                            
##     0.159    0.148    0.148
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stst1vc (.58.)   -0.072    0.004  -17.547    0.000   -0.080
##    .Stst19d (.59.)   -0.148    0.003  -42.474    0.000   -0.155
##    .Stst20s (.60.)   -0.101    0.004  -27.187    0.000   -0.109
##    .Stst21c (.61.)   -0.091    0.004  -24.815    0.000   -0.099
##    .Stst22p (.62.)   -0.109    0.004  -27.778    0.000   -0.117
##    .Stst23n (.63.)   -0.103    0.004  -27.732    0.000   -0.110
##    .Stst24x (.64.)   -0.088    0.004  -24.080    0.000   -0.095
##    .Stst25w (.65.)   -0.078    0.004  -20.891    0.000   -0.086
##    .Stst26r (.66.)   -0.128    0.004  -31.965    0.000   -0.136
##    .Stst31b (.67.)    0.120    0.004   32.917    0.000    0.113
##    .Stst32r (.68.)    0.077    0.004   19.566    0.000    0.069
##    .Stst5mt (.69.)    0.145    0.004   38.100    0.000    0.138
##    .Stst33h (.70.)    0.148    0.004   36.255    0.000    0.140
##    .Stst34r (.71.)    0.027    0.004    7.275    0.000    0.020
##    .Sts292D (.72.)    0.235    0.003   69.759    0.000    0.228
##    .Stst35t (.73.)   -0.135    0.004  -35.057    0.000   -0.142
##    .Stst36c (.74.)   -0.165    0.004  -46.088    0.000   -0.172
##    .Stst37b (.75.)   -0.062    0.004  -16.567    0.000   -0.069
##    .Stst28m (.76.)    0.470    0.004  111.840    0.000    0.462
##    .Sts303D (.77.)    0.363    0.003  104.860    0.000    0.356
##  ci.upper   Std.lv  Std.all
##    -0.064   -0.072   -0.075
##    -0.141   -0.148   -0.150
##    -0.094   -0.101   -0.099
##    -0.084   -0.091   -0.092
##    -0.101   -0.109   -0.108
##    -0.096   -0.103   -0.102
##    -0.081   -0.088   -0.086
##    -0.071   -0.078   -0.077
##    -0.121   -0.128   -0.129
##     0.127    0.120    0.122
##     0.084    0.077    0.077
##     0.153    0.145    0.150
##     0.156    0.148    0.145
##     0.034    0.027    0.027
##     0.241    0.235    0.242
##    -0.127   -0.135   -0.133
##    -0.158   -0.165   -0.166
##    -0.054   -0.062   -0.060
##     0.479    0.470    0.512
##     0.369    0.363    0.372
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stest1vocab       0.391    0.003  132.151    0.000    0.385
##    .Stst19dsgsdwrd    0.478    0.003  160.405    0.000    0.472
##    .Stest20spellng    0.617    0.004  163.070    0.000    0.610
##    .Stest21cptlztn    0.555    0.003  167.218    0.000    0.549
##    .Stest22puncttn    0.362    0.003  136.182    0.000    0.356
##    .Stest23english    0.550    0.004  142.713    0.000    0.543
##    .Stest24exprssn    0.678    0.004  154.263    0.000    0.669
##    .Stst25wrdfnctn    0.421    0.003  150.746    0.000    0.416
##    .Stst26rdngcmpr    0.310    0.002  127.342    0.000    0.306
##    .Stst31bstrctrs    0.533    0.003  157.993    0.000    0.527
##    .Stst32rthrsnng    0.383    0.003  152.251    0.000    0.378
##    .Stest5math        0.263    0.003   87.616    0.000    0.257
##    .Stst33hghschlm    0.253    0.002  111.745    0.000    0.249
##    .Stst34rthcmptt    0.525    0.004  136.548    0.000    0.518
##    .Stst29vslztn2D    0.611    0.004  141.259    0.000    0.603
##    .Stest35tblrdng    0.569    0.008   74.405    0.000    0.554
##    .Stst36clrclchc    0.488    0.006   86.828    0.000    0.477
##    .Stst37bjctnspc    0.662    0.005  132.987    0.000    0.653
##    .Stst28mchnclrs    0.219    0.004   61.283    0.000    0.212
##    .Stst30vslztn3D    0.591    0.004  138.670    0.000    0.583
##     english           1.000                               1.000
##     math              1.000                               1.000
##     speed             1.000                               1.000
##     spatial           1.000                               1.000
##  ci.upper   Std.lv  Std.all
##     0.397    0.391    0.432
##     0.484    0.478    0.491
##     0.625    0.617    0.588
##     0.562    0.555    0.567
##     0.367    0.362    0.357
##     0.558    0.550    0.540
##     0.686    0.678    0.647
##     0.427    0.421    0.409
##     0.315    0.310    0.313
##     0.540    0.533    0.545
##     0.388    0.383    0.383
##     0.269    0.263    0.282
##     0.258    0.253    0.246
##     0.533    0.525    0.528
##     0.620    0.611    0.647
##     0.584    0.569    0.551
##     0.499    0.488    0.490
##     0.672    0.662    0.622
##     0.226    0.219    0.260
##     0.600    0.591    0.622
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
## 
## 
## Group 2 [1]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english =~                                                   
##     Stst1vc (.p1.)    0.717    0.003  251.333    0.000    0.711
##     Stst19d (.p2.)    0.573    0.003  215.858    0.000    0.568
##     Stst20s (.p3.)    0.657    0.003  225.661    0.000    0.651
##     Stst21c (.p4.)    0.651    0.003  227.562    0.000    0.645
##     Stst22p (.p5.)    0.807    0.003  288.657    0.000    0.802
##     Stst23n (.p6.)    0.684    0.003  214.665    0.000    0.678
##     Stst24x (.p7.)    0.608    0.003  192.721    0.000    0.602
##     Stst25w (.p8.)    0.666    0.004  156.562    0.000    0.657
##     Stst26r (.p9.)    0.826    0.003  295.591    0.000    0.821
##     Stst31b (.10.)    0.435    0.003  146.916    0.000    0.429
##     Stst32r (.11.)    0.240    0.005   49.429    0.000    0.230
##   math =~                                                      
##     Stst5mt (.12.)    0.818    0.002  329.665    0.000    0.813
##     Stst25w (.13.)    0.128    0.004   28.979    0.000    0.119
##     Stst32r (.14.)    0.566    0.005  113.663    0.000    0.557
##     Stst33h (.15.)    0.882    0.003  310.826    0.000    0.876
##     Stst34r (.16.)    0.451    0.003  155.542    0.000    0.445
##   speed =~                                                     
##     Stst19d (.17.)    0.289    0.003  103.748    0.000    0.284
##     Sts292D (.18.)    0.252    0.003   84.096    0.000    0.246
##     Stst34r (.19.)    0.420    0.003  133.476    0.000    0.413
##     Stst35t (.20.)    0.681    0.004  155.397    0.000    0.672
##     Stst36c (.21.)    0.712    0.004  185.373    0.000    0.704
##     Stst37b (.22.)    0.608    0.004  165.450    0.000    0.601
##   spatial =~                                                   
##     Stst28m (.23.)    0.791    0.003  303.811    0.000    0.786
##     Sts292D (.24.)    0.483    0.003  164.700    0.000    0.478
##     Sts303D (.25.)    0.600    0.003  174.652    0.000    0.593
##     Stst31b (.26.)    0.307    0.003  102.522    0.000    0.301
##     Stst37b (.27.)    0.112    0.003   42.921    0.000    0.107
##  ci.upper   Std.lv  Std.all
##                            
##     0.723    0.661    0.691
##     0.578    0.528    0.555
##     0.663    0.606    0.641
##     0.656    0.600    0.626
##     0.813    0.744    0.804
##     0.691    0.631    0.678
##     0.614    0.560    0.606
##     0.674    0.613    0.639
##     0.832    0.761    0.836
##     0.441    0.401    0.426
##     0.249    0.221    0.231
##                            
##     0.823    0.752    0.772
##     0.136    0.117    0.122
##     0.576    0.521    0.544
##     0.887    0.811    0.863
##     0.457    0.415    0.442
##                            
##     0.295    0.259    0.272
##     0.258    0.225    0.237
##     0.426    0.375    0.399
##     0.689    0.608    0.703
##     0.719    0.636    0.685
##     0.615    0.543    0.584
##                            
##     0.796    0.710    0.827
##     0.489    0.434    0.457
##     0.606    0.539    0.602
##     0.313    0.276    0.293
##     0.117    0.100    0.108
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english ~~                                                   
##     math              0.696    0.005  129.618    0.000    0.686
##     speed             0.232    0.005   48.870    0.000    0.223
##     spatial           0.507    0.005  103.551    0.000    0.498
##   math ~~                                                      
##     speed             0.167    0.004   38.169    0.000    0.158
##     spatial           0.521    0.005  103.010    0.000    0.511
##   speed ~~                                                     
##     spatial           0.162    0.005   35.345    0.000    0.153
##  ci.upper   Std.lv  Std.all
##                            
##     0.707    0.822    0.822
##     0.242    0.282    0.282
##     0.517    0.613    0.613
##                            
##     0.175    0.203    0.203
##     0.530    0.630    0.630
##                            
##     0.171    0.201    0.201
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stst1vc (.58.)   -0.072    0.004  -17.547    0.000   -0.080
##    .Stst19d (.59.)   -0.148    0.003  -42.474    0.000   -0.155
##    .Stst20s (.60.)   -0.101    0.004  -27.187    0.000   -0.109
##    .Stst21c (.61.)   -0.091    0.004  -24.815    0.000   -0.099
##    .Stst22p (.62.)   -0.109    0.004  -27.778    0.000   -0.117
##    .Stst23n (.63.)   -0.103    0.004  -27.732    0.000   -0.110
##    .Stst24x (.64.)   -0.088    0.004  -24.080    0.000   -0.095
##    .Stst25w (.65.)   -0.078    0.004  -20.891    0.000   -0.086
##    .Stst26r (.66.)   -0.128    0.004  -31.965    0.000   -0.136
##    .Stst31b (.67.)    0.120    0.004   32.917    0.000    0.113
##    .Stst32r (.68.)    0.077    0.004   19.566    0.000    0.069
##    .Stst5mt (.69.)    0.145    0.004   38.100    0.000    0.138
##    .Stst33h (.70.)    0.148    0.004   36.255    0.000    0.140
##    .Stst34r (.71.)    0.027    0.004    7.275    0.000    0.020
##    .Sts292D (.72.)    0.235    0.003   69.759    0.000    0.228
##    .Stst35t (.73.)   -0.135    0.004  -35.057    0.000   -0.142
##    .Stst36c (.74.)   -0.165    0.004  -46.088    0.000   -0.172
##    .Stst37b (.75.)   -0.062    0.004  -16.567    0.000   -0.069
##    .Stst28m (.76.)    0.470    0.004  111.840    0.000    0.462
##    .Sts303D (.77.)    0.363    0.003  104.860    0.000    0.356
##     english           0.376    0.006   62.029    0.000    0.364
##     math             -0.281    0.006  -46.570    0.000   -0.293
##     speed             0.388    0.007   55.007    0.000    0.374
##     spatial          -1.048    0.008 -123.536    0.000   -1.064
##  ci.upper   Std.lv  Std.all
##    -0.064   -0.072   -0.075
##    -0.141   -0.148   -0.156
##    -0.094   -0.101   -0.107
##    -0.084   -0.091   -0.095
##    -0.101   -0.109   -0.118
##    -0.096   -0.103   -0.111
##    -0.081   -0.088   -0.095
##    -0.071   -0.078   -0.082
##    -0.121   -0.128   -0.141
##     0.127    0.120    0.128
##     0.084    0.077    0.080
##     0.153    0.145    0.149
##     0.156    0.148    0.157
##     0.034    0.027    0.029
##     0.241    0.235    0.247
##    -0.127   -0.135   -0.156
##    -0.158   -0.165   -0.178
##    -0.054   -0.062   -0.066
##     0.479    0.470    0.547
##     0.369    0.363    0.405
##     0.388    0.408    0.408
##    -0.269   -0.305   -0.305
##     0.401    0.434    0.434
##    -1.031   -1.166   -1.166
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stest1vocab       0.478    0.004  131.723    0.000    0.470
##    .Stst19dsgsdwrd    0.483    0.003  163.278    0.000    0.477
##    .Stest20spellng    0.527    0.003  168.469    0.000    0.521
##    .Stest21cptlztn    0.559    0.003  166.243    0.000    0.553
##    .Stest22puncttn    0.302    0.002  135.931    0.000    0.298
##    .Stest23english    0.468    0.003  146.271    0.000    0.462
##    .Stest24exprssn    0.541    0.004  151.532    0.000    0.534
##    .Stst25wrdfnctn    0.413    0.003  147.777    0.000    0.408
##    .Stst26rdngcmpr    0.249    0.002  120.348    0.000    0.245
##    .Stst31bstrctrs    0.512    0.003  163.928    0.000    0.506
##    .Stst32rthrsnng    0.408    0.003  158.324    0.000    0.403
##    .Stest5math        0.384    0.004  100.043    0.000    0.376
##    .Stst33hghschlm    0.225    0.002   98.930    0.000    0.221
##    .Stst34rthcmptt    0.505    0.004  133.870    0.000    0.498
##    .Stst29vslztn2D    0.623    0.004  163.615    0.000    0.616
##    .Stest35tblrdng    0.378    0.005   70.060    0.000    0.367
##    .Stst36clrclchc    0.459    0.004  104.092    0.000    0.450
##    .Stst37bjctnspc    0.538    0.004  137.870    0.000    0.530
##    .Stst28mchnclrs    0.234    0.003   75.563    0.000    0.228
##    .Stst30vslztn3D    0.511    0.003  149.046    0.000    0.505
##     english           0.849    0.007  121.469    0.000    0.835
##     math              0.845    0.007  127.156    0.000    0.832
##     speed             0.799    0.010   81.222    0.000    0.780
##     spatial           0.808    0.008  105.469    0.000    0.792
##  ci.upper   Std.lv  Std.all
##     0.485    0.478    0.522
##     0.489    0.483    0.533
##     0.533    0.527    0.590
##     0.566    0.559    0.609
##     0.307    0.302    0.353
##     0.475    0.468    0.541
##     0.548    0.541    0.633
##     0.419    0.413    0.448
##     0.253    0.249    0.300
##     0.519    0.512    0.579
##     0.413    0.408    0.445
##     0.391    0.384    0.404
##     0.230    0.225    0.255
##     0.513    0.505    0.574
##     0.631    0.623    0.691
##     0.388    0.378    0.505
##     0.467    0.459    0.531
##     0.545    0.538    0.622
##     0.240    0.234    0.316
##     0.518    0.511    0.638
##     0.863    1.000    1.000
##     0.858    1.000    1.000
##     0.818    1.000    1.000
##     0.823    1.000    1.000
lavTestScore(scalar, release = 28:47) 
## Warning: lavaan->lavTestScore():  
##    se is not `standard'; not implemented yet; falling back to 
##    ordinary score test
## $test
## 
## total score test:
## 
##    test       X2 df p.value
## 1 score 71731.63 20       0
## 
## $uni
## 
## univariate score tests:
## 
##      lhs op    rhs        X2 df p.value
## 1  .p58. == .p139. 27364.523  1       0
## 2  .p59. == .p140.   316.148  1       0
## 3  .p60. == .p141.  5908.498  1       0
## 4  .p61. == .p142.  4234.861  1       0
## 5  .p62. == .p143.  4608.171  1       0
## 6  .p63. == .p144.   466.978  1       0
## 7  .p64. == .p145.   191.731  1       0
## 8  .p65. == .p146.  2481.586  1       0
## 9  .p66. == .p147.  5256.827  1       0
## 10 .p67. == .p148.  2750.767  1       0
## 11 .p68. == .p149.  1678.587  1       0
## 12 .p69. == .p150.  2395.331  1       0
## 13 .p70. == .p151.  1115.089  1       0
## 14 .p71. == .p152.  3927.351  1       0
## 15 .p72. == .p153.   227.174  1       0
## 16 .p73. == .p154.  1499.977  1       0
## 17 .p74. == .p155.   154.363  1       0
## 18 .p75. == .p156.   405.333  1       0
## 19 .p76. == .p157. 16769.018  1       0
## 20 .p77. == .p158. 12013.381  1       0
scalar2<-cfa(chc.factor.model, data=dgroup, group="sex", meanstructure=TRUE, sampling.weights="BY_WTA", std.lv=T, group.equal=c("loadings", "intercepts"), group.partial=c("Stest1vocab~1", "Stest28mechanicalreasoning~1", "Stest26readingcomprehension~1", "Stest34arithcomputation~1", "Stest33highschoolmath~1", "Stest19disguisedwords~1", "Stest29visualization2D~1"))
fitMeasures(scalar2, c("chisq", "df", "pvalue", "cfi", "rmsea", "srmr", "aic", "bic"))
##       chisq          df      pvalue         cfi       rmsea        srmr 
##   91276.094     346.000       0.000       0.936       0.061       0.047 
##         aic         bic 
## 6498075.629 6499200.204
Mc(scalar2)
## [1] 0.7262761
summary(scalar2, standardized=T, ci=T)
## lavaan 0.6-18 ended normally after 66 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                       154
##   Number of equality constraints                    40
## 
##   Number of observations per group:                   
##     0                                            70776
##     1                                            71381
##   Sampling weights variable                     BY_WTA
## 
## Model Test User Model:
##                                                Standard      Scaled
##   Test Statistic                              91276.094   77577.303
##   Degrees of freedom                                346         346
##   P-value (Chi-square)                            0.000       0.000
##   Scaling correction factor                                   1.177
##     Yuan-Bentler correction (Mplus variant)                        
##   Test statistic for each group:
##     0                                         50517.102   42935.454
##     1                                         40758.991   34641.849
## 
## Parameter Estimates:
## 
##   Standard errors                             Sandwich
##   Information bread                           Observed
##   Observed information based on                Hessian
## 
## 
## Group 1 [0]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english =~                                                   
##     Stst1vc (.p1.)    0.789    0.003  290.400    0.000    0.784
##     Stst19d (.p2.)    0.583    0.003  220.647    0.000    0.578
##     Stst20s (.p3.)    0.645    0.003  234.504    0.000    0.640
##     Stst21c (.p4.)    0.634    0.003  230.780    0.000    0.628
##     Stst22p (.p5.)    0.775    0.003  283.415    0.000    0.770
##     Stst23n (.p6.)    0.655    0.003  210.630    0.000    0.649
##     Stst24x (.p7.)    0.581    0.003  189.548    0.000    0.575
##     Stst25w (.p8.)    0.585    0.003  184.056    0.000    0.579
##     Stst26r (.p9.)    0.852    0.003  307.957    0.000    0.847
##     Stst31b (.10.)    0.293    0.003  100.164    0.000    0.288
##     Stst32r (.11.)    0.236    0.004   65.252    0.000    0.229
##   math =~                                                      
##     Stst5mt (.12.)    0.806    0.003  322.093    0.000    0.801
##     Stst25w (.13.)    0.207    0.003   63.724    0.000    0.201
##     Stst32r (.14.)    0.571    0.004  148.183    0.000    0.563
##     Stst33h (.15.)    0.889    0.003  322.502    0.000    0.884
##     Stst34r (.16.)    0.487    0.003  170.070    0.000    0.482
##   speed =~                                                     
##     Stst19d (.17.)    0.301    0.003  107.869    0.000    0.296
##     Sts292D (.18.)    0.227    0.003   72.568    0.000    0.221
##     Stst34r (.19.)    0.379    0.003  118.064    0.000    0.373
##     Stst35t (.20.)    0.687    0.004  152.932    0.000    0.678
##     Stst36c (.21.)    0.728    0.004  187.917    0.000    0.720
##     Stst37b (.22.)    0.598    0.004  159.975    0.000    0.591
##   spatial =~                                                   
##     Stst28m (.23.)    0.690    0.003  241.994    0.000    0.685
##     Sts292D (.24.)    0.521    0.003  165.147    0.000    0.514
##     Sts303D (.25.)    0.764    0.003  246.115    0.000    0.758
##     Stst31b (.26.)    0.486    0.003  149.822    0.000    0.479
##     Stst37b (.27.)    0.141    0.003   45.998    0.000    0.135
##  ci.upper   Std.lv  Std.all
##                            
##     0.795    0.789    0.818
##     0.588    0.583    0.589
##     0.651    0.645    0.641
##     0.639    0.634    0.651
##     0.780    0.775    0.789
##     0.661    0.655    0.660
##     0.587    0.581    0.575
##     0.591    0.585    0.579
##     0.857    0.852    0.849
##     0.299    0.293    0.296
##     0.243    0.236    0.236
##                            
##     0.811    0.806    0.844
##     0.214    0.207    0.205
##     0.578    0.571    0.572
##     0.895    0.889    0.873
##     0.493    0.487    0.493
##                            
##     0.307    0.301    0.304
##     0.233    0.227    0.232
##     0.385    0.379    0.383
##     0.696    0.687    0.673
##     0.735    0.728    0.727
##     0.605    0.598    0.580
##                            
##     0.696    0.690    0.782
##     0.527    0.521    0.533
##     0.770    0.764    0.752
##     0.492    0.486    0.489
##     0.147    0.141    0.136
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english ~~                                                   
##     math              0.872    0.002  521.134    0.000    0.869
##     speed             0.227    0.005   42.832    0.000    0.216
##     spatial           0.610    0.004  172.849    0.000    0.603
##   math ~~                                                      
##     speed             0.219    0.005   42.406    0.000    0.209
##     spatial           0.656    0.003  197.593    0.000    0.649
##   speed ~~                                                     
##     spatial           0.149    0.006   26.278    0.000    0.138
##  ci.upper   Std.lv  Std.all
##                            
##     0.876    0.872    0.872
##     0.237    0.227    0.227
##     0.617    0.610    0.610
##                            
##     0.229    0.219    0.219
##     0.662    0.656    0.656
##                            
##     0.160    0.149    0.149
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stst1vc           0.167    0.004   44.518    0.000    0.160
##    .Stst19d          -0.119    0.004  -30.513    0.000   -0.126
##    .Stst20s (.60.)   -0.194    0.004  -53.312    0.000   -0.201
##    .Stst21c (.61.)   -0.174    0.004  -48.436    0.000   -0.182
##    .Stst22p (.62.)   -0.218    0.004  -57.107    0.000   -0.225
##    .Stst23n (.63.)   -0.194    0.004  -51.825    0.000   -0.201
##    .Stst24x (.64.)   -0.171    0.004  -45.736    0.000   -0.178
##    .Stst25w (.65.)   -0.114    0.004  -30.347    0.000   -0.121
##    .Stst26r          -0.032    0.004   -7.897    0.000   -0.041
##    .Stst31b (.67.)    0.044    0.004   11.574    0.000    0.036
##    .Stst32r (.68.)    0.095    0.004   24.316    0.000    0.088
##    .Stst5mt (.69.)    0.202    0.004   54.641    0.000    0.195
##    .Stst33h           0.117    0.004   28.152    0.000    0.109
##    .Stst34r          -0.078    0.004  -19.713    0.000   -0.086
##    .Sts292D           0.212    0.004   54.436    0.000    0.204
##    .Stst35t (.73.)   -0.102    0.004  -27.125    0.000   -0.110
##    .Stst36c (.74.)   -0.138    0.004  -37.187    0.000   -0.145
##    .Stst37b (.75.)   -0.065    0.004  -18.249    0.000   -0.072
##    .Stst28m           0.536    0.004  151.033    0.000    0.529
##    .Sts303D (.77.)    0.193    0.004   48.466    0.000    0.185
##  ci.upper   Std.lv  Std.all
##     0.175    0.167    0.173
##    -0.111   -0.119   -0.120
##    -0.187   -0.194   -0.193
##    -0.167   -0.174   -0.179
##    -0.210   -0.218   -0.222
##    -0.187   -0.194   -0.195
##    -0.164   -0.171   -0.169
##    -0.107   -0.114   -0.113
##    -0.024   -0.032   -0.032
##     0.051    0.044    0.044
##     0.103    0.095    0.096
##     0.209    0.202    0.211
##     0.125    0.117    0.115
##    -0.070   -0.078   -0.079
##     0.219    0.212    0.217
##    -0.095   -0.102   -0.100
##    -0.130   -0.138   -0.138
##    -0.058   -0.065   -0.063
##     0.543    0.536    0.607
##     0.201    0.193    0.190
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stest1vocab       0.309    0.002  141.702    0.000    0.305
##    .Stst19dsgsdwrd    0.470    0.003  158.327    0.000    0.464
##    .Stest20spellng    0.597    0.004  168.511    0.000    0.590
##    .Stest21cptlztn    0.546    0.003  170.953    0.000    0.540
##    .Stest22puncttn    0.364    0.003  142.881    0.000    0.359
##    .Stest23english    0.557    0.004  144.401    0.000    0.549
##    .Stest24exprssn    0.685    0.004  158.391    0.000    0.676
##    .Stst25wrdfnctn    0.424    0.003  155.175    0.000    0.419
##    .Stst26rdngcmpr    0.281    0.002  124.152    0.000    0.277
##    .Stst31bstrctrs    0.489    0.003  151.526    0.000    0.483
##    .Stst32rthrsnng    0.381    0.002  153.986    0.000    0.376
##    .Stest5math        0.262    0.003   87.937    0.000    0.256
##    .Stst33hghschlm    0.248    0.002  112.573    0.000    0.243
##    .Stst34rthcmptt    0.516    0.004  141.536    0.000    0.509
##    .Stst29vslztn2D    0.597    0.004  142.137    0.000    0.589
##    .Stest35tblrdng    0.569    0.008   72.091    0.000    0.554
##    .Stst36clrclchc    0.472    0.006   84.180    0.000    0.461
##    .Stst37bjctnspc    0.661    0.005  133.550    0.000    0.651
##    .Stst28mchnclrs    0.304    0.003  111.159    0.000    0.298
##    .Stst30vslztn3D    0.448    0.004  121.985    0.000    0.440
##     english           1.000                               1.000
##     math              1.000                               1.000
##     speed             1.000                               1.000
##     spatial           1.000                               1.000
##  ci.upper   Std.lv  Std.all
##     0.313    0.309    0.331
##     0.476    0.470    0.479
##     0.604    0.597    0.589
##     0.553    0.546    0.576
##     0.369    0.364    0.377
##     0.564    0.557    0.565
##     0.693    0.685    0.669
##     0.429    0.424    0.415
##     0.286    0.281    0.279
##     0.496    0.489    0.497
##     0.386    0.381    0.382
##     0.268    0.262    0.287
##     0.252    0.248    0.238
##     0.523    0.516    0.527
##     0.605    0.597    0.625
##     0.585    0.569    0.547
##     0.483    0.472    0.471
##     0.671    0.661    0.621
##     0.309    0.304    0.389
##     0.455    0.448    0.434
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
## 
## 
## Group 2 [1]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english =~                                                   
##     Stst1vc (.p1.)    0.789    0.003  290.400    0.000    0.784
##     Stst19d (.p2.)    0.583    0.003  220.647    0.000    0.578
##     Stst20s (.p3.)    0.645    0.003  234.504    0.000    0.640
##     Stst21c (.p4.)    0.634    0.003  230.780    0.000    0.628
##     Stst22p (.p5.)    0.775    0.003  283.415    0.000    0.770
##     Stst23n (.p6.)    0.655    0.003  210.630    0.000    0.649
##     Stst24x (.p7.)    0.581    0.003  189.548    0.000    0.575
##     Stst25w (.p8.)    0.585    0.003  184.056    0.000    0.579
##     Stst26r (.p9.)    0.852    0.003  307.957    0.000    0.847
##     Stst31b (.10.)    0.293    0.003  100.164    0.000    0.288
##     Stst32r (.11.)    0.236    0.004   65.252    0.000    0.229
##   math =~                                                      
##     Stst5mt (.12.)    0.806    0.003  322.093    0.000    0.801
##     Stst25w (.13.)    0.207    0.003   63.724    0.000    0.201
##     Stst32r (.14.)    0.571    0.004  148.183    0.000    0.563
##     Stst33h (.15.)    0.889    0.003  322.502    0.000    0.884
##     Stst34r (.16.)    0.487    0.003  170.070    0.000    0.482
##   speed =~                                                     
##     Stst19d (.17.)    0.301    0.003  107.869    0.000    0.296
##     Sts292D (.18.)    0.227    0.003   72.568    0.000    0.221
##     Stst34r (.19.)    0.379    0.003  118.064    0.000    0.373
##     Stst35t (.20.)    0.687    0.004  152.932    0.000    0.678
##     Stst36c (.21.)    0.728    0.004  187.917    0.000    0.720
##     Stst37b (.22.)    0.598    0.004  159.975    0.000    0.591
##   spatial =~                                                   
##     Stst28m (.23.)    0.690    0.003  241.994    0.000    0.685
##     Sts292D (.24.)    0.521    0.003  165.147    0.000    0.514
##     Sts303D (.25.)    0.764    0.003  246.115    0.000    0.758
##     Stst31b (.26.)    0.486    0.003  149.822    0.000    0.479
##     Stst37b (.27.)    0.141    0.003   45.998    0.000    0.135
##  ci.upper   Std.lv  Std.all
##                            
##     0.795    0.733    0.777
##     0.588    0.541    0.565
##     0.651    0.599    0.641
##     0.639    0.588    0.622
##     0.780    0.719    0.793
##     0.661    0.608    0.663
##     0.587    0.540    0.591
##     0.591    0.543    0.568
##     0.857    0.791    0.857
##     0.299    0.272    0.289
##     0.243    0.219    0.229
##                            
##     0.811    0.740    0.767
##     0.214    0.190    0.199
##     0.578    0.524    0.548
##     0.895    0.816    0.865
##     0.493    0.447    0.480
##                            
##     0.307    0.269    0.281
##     0.233    0.202    0.212
##     0.385    0.338    0.363
##     0.696    0.613    0.707
##     0.735    0.649    0.697
##     0.605    0.534    0.574
##                            
##     0.696    0.619    0.750
##     0.527    0.467    0.490
##     0.770    0.686    0.735
##     0.492    0.436    0.462
##     0.147    0.126    0.136
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english ~~                                                   
##     math              0.696    0.005  131.716    0.000    0.685
##     speed             0.213    0.005   45.130    0.000    0.204
##     spatial           0.521    0.005  104.625    0.000    0.511
##   math ~~                                                      
##     speed             0.156    0.004   36.191    0.000    0.148
##     spatial           0.533    0.005  106.164    0.000    0.523
##   speed ~~                                                     
##     spatial           0.164    0.005   35.443    0.000    0.155
##  ci.upper   Std.lv  Std.all
##                            
##     0.706    0.817    0.817
##     0.222    0.257    0.257
##     0.530    0.625    0.625
##                            
##     0.165    0.191    0.191
##     0.543    0.648    0.648
##                            
##     0.173    0.205    0.205
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stst1vc          -0.609    0.005 -120.226    0.000   -0.618
##    .Stst19d          -0.321    0.005  -69.676    0.000   -0.330
##    .Stst20s (.60.)   -0.194    0.004  -53.312    0.000   -0.201
##    .Stst21c (.61.)   -0.174    0.004  -48.436    0.000   -0.182
##    .Stst22p (.62.)   -0.218    0.004  -57.107    0.000   -0.225
##    .Stst23n (.63.)   -0.194    0.004  -51.825    0.000   -0.201
##    .Stst24x (.64.)   -0.171    0.004  -45.736    0.000   -0.178
##    .Stst25w (.65.)   -0.114    0.004  -30.347    0.000   -0.121
##    .Stst26r          -0.449    0.005  -87.332    0.000   -0.459
##    .Stst31b (.67.)    0.044    0.004   11.574    0.000    0.036
##    .Stst32r (.68.)    0.095    0.004   24.316    0.000    0.088
##    .Stst5mt (.69.)    0.202    0.004   54.641    0.000    0.195
##    .Stst33h           0.335    0.005   60.988    0.000    0.324
##    .Stst34r           0.272    0.005   55.913    0.000    0.263
##    .Sts292D          -0.008    0.005   -1.581    0.114   -0.017
##    .Stst35t (.73.)   -0.102    0.004  -27.125    0.000   -0.110
##    .Stst36c (.74.)   -0.138    0.004  -37.187    0.000   -0.145
##    .Stst37b (.75.)   -0.065    0.004  -18.249    0.000   -0.072
##    .Stst28m          -0.147    0.005  -30.471    0.000   -0.157
##    .Sts303D (.77.)    0.193    0.004   48.466    0.000    0.185
##     english           0.650    0.006  103.439    0.000    0.638
##     math             -0.458    0.007  -65.929    0.000   -0.472
##     speed             0.305    0.007   44.745    0.000    0.292
##     spatial          -0.407    0.007  -56.099    0.000   -0.421
##  ci.upper   Std.lv  Std.all
##    -0.599   -0.609   -0.646
##    -0.312   -0.321   -0.336
##    -0.187   -0.194   -0.208
##    -0.167   -0.174   -0.184
##    -0.210   -0.218   -0.240
##    -0.187   -0.194   -0.212
##    -0.164   -0.171   -0.187
##    -0.107   -0.114   -0.119
##    -0.439   -0.449   -0.487
##     0.051    0.044    0.046
##     0.103    0.095    0.100
##     0.209    0.202    0.209
##     0.346    0.335    0.355
##     0.282    0.272    0.292
##     0.002   -0.008   -0.008
##    -0.095   -0.102   -0.118
##    -0.130   -0.138   -0.148
##    -0.058   -0.065   -0.070
##    -0.138   -0.147   -0.179
##     0.201    0.193    0.207
##     0.663    0.701    0.701
##    -0.445   -0.499   -0.499
##     0.318    0.342    0.342
##    -0.393   -0.453   -0.453
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stest1vocab       0.352    0.002  152.194    0.000    0.347
##    .Stst19dsgsdwrd    0.476    0.003  161.915    0.000    0.470
##    .Stest20spellng    0.513    0.003  171.616    0.000    0.507
##    .Stest21cptlztn    0.549    0.003  169.621    0.000    0.543
##    .Stest22puncttn    0.305    0.002  139.799    0.000    0.301
##    .Stest23english    0.472    0.003  145.233    0.000    0.465
##    .Stest24exprssn    0.542    0.004  149.220    0.000    0.535
##    .Stst25wrdfnctn    0.415    0.003  150.590    0.000    0.409
##    .Stst26rdngcmpr    0.226    0.002  120.010    0.000    0.222
##    .Stst31bstrctrs    0.478    0.003  157.695    0.000    0.472
##    .Stst32rthrsnng    0.405    0.003  160.525    0.000    0.400
##    .Stest5math        0.382    0.004  104.018    0.000    0.375
##    .Stst33hghschlm    0.224    0.002  101.162    0.000    0.219
##    .Stst34rthcmptt    0.496    0.004  136.194    0.000    0.489
##    .Stst29vslztn2D    0.612    0.004  162.277    0.000    0.605
##    .Stest35tblrdng    0.377    0.005   69.453    0.000    0.366
##    .Stst36clrclchc    0.448    0.005   98.704    0.000    0.439
##    .Stst37bjctnspc    0.536    0.004  138.443    0.000    0.529
##    .Stst28mchnclrs    0.297    0.002  124.221    0.000    0.293
##    .Stst30vslztn3D    0.400    0.003  128.198    0.000    0.394
##     english           0.861    0.007  122.908    0.000    0.848
##     math              0.842    0.007  128.335    0.000    0.829
##     speed             0.796    0.010   80.779    0.000    0.777
##     spatial           0.805    0.008  106.004    0.000    0.790
##  ci.upper   Std.lv  Std.all
##     0.356    0.352    0.396
##     0.482    0.476    0.520
##     0.519    0.513    0.589
##     0.555    0.549    0.613
##     0.309    0.305    0.371
##     0.478    0.472    0.561
##     0.549    0.542    0.651
##     0.420    0.415    0.454
##     0.230    0.226    0.265
##     0.484    0.478    0.537
##     0.410    0.405    0.443
##     0.389    0.382    0.411
##     0.228    0.224    0.252
##     0.503    0.496    0.572
##     0.620    0.612    0.673
##     0.388    0.377    0.501
##     0.456    0.448    0.515
##     0.544    0.536    0.620
##     0.302    0.297    0.437
##     0.406    0.400    0.460
##     0.875    1.000    1.000
##     0.854    1.000    1.000
##     0.815    1.000    1.000
##     0.820    1.000    1.000
lavTestScore(scalar2, release = 28:40) 
## Warning: lavaan->lavTestScore():  
##    se is not `standard'; not implemented yet; falling back to 
##    ordinary score test
## $test
## 
## total score test:
## 
##    test       X2 df p.value
## 1 score 4827.481 13       0
## 
## $uni
## 
## univariate score tests:
## 
##      lhs op    rhs       X2 df p.value
## 1  .p60. == .p141. 1182.761  1       0
## 2  .p61. == .p142.  486.611  1       0
## 3  .p62. == .p143.   60.294  1       0
## 4  .p63. == .p144.  787.315  1       0
## 5  .p64. == .p145.  658.106  1       0
## 6  .p65. == .p146.  730.939  1       0
## 7  .p67. == .p148.   77.641  1       0
## 8  .p68. == .p149. 1050.482  1       0
## 9  .p69. == .p150.  466.131  1       0
## 10 .p73. == .p154.  408.909  1       0
## 11 .p74. == .p155.   51.648  1       0
## 12 .p75. == .p156.  242.578  1       0
## 13 .p77. == .p158.   14.313  1       0
strict<-cfa(chc.factor.model, data=dgroup, group="sex", meanstructure=TRUE, sampling.weights="BY_WTA", std.lv=T, group.equal=c("loadings", "intercepts", "residuals"), group.partial=c("Stest1vocab~1", "Stest28mechanicalreasoning~1", "Stest26readingcomprehension~1", "Stest34arithcomputation~1", "Stest33highschoolmath~1", "Stest19disguisedwords~1", "Stest29visualization2D~1"))
fitMeasures(strict, c("chisq", "df", "pvalue", "cfi", "rmsea", "srmr", "aic", "bic"))
##       chisq          df      pvalue         cfi       rmsea        srmr 
##   98543.621     366.000       0.000       0.931       0.061       0.050 
##         aic         bic 
## 6505303.157 6506230.437
Mc(strict)
## [1] 0.7079962
chc.cov<-cfa(chc.factor.model, data=dgroup, group="sex", meanstructure=TRUE, sampling.weights="BY_WTA", std.lv=T, group.equal=c("loadings", "intercepts", "lv.covariances"), group.partial=c("Stest1vocab~1", "Stest28mechanicalreasoning~1", "Stest26readingcomprehension~1", "Stest34arithcomputation~1", "Stest33highschoolmath~1", "Stest19disguisedwords~1", "Stest29visualization2D~1"))
fitMeasures(chc.cov, c("chisq", "df", "pvalue", "cfi", "rmsea", "srmr", "aic", "bic"))
##       chisq          df      pvalue         cfi       rmsea        srmr 
##   92146.630     352.000       0.000       0.935       0.061       0.058 
##         aic         bic 
## 6498934.165 6499999.552
Mc(chc.cov)
## [1] 0.724071
chc.vcov<-cfa(chc.factor.model, data=dgroup, group="sex", meanstructure=TRUE, sampling.weights="BY_WTA", std.lv=T, group.equal=c("loadings", "intercepts", "lv.variances", "lv.covariances"), group.partial=c("Stest1vocab~1", "Stest28mechanicalreasoning~1", "Stest26readingcomprehension~1", "Stest34arithcomputation~1", "Stest33highschoolmath~1", "Stest19disguisedwords~1", "Stest29visualization2D~1"))
fitMeasures(chc.vcov, c("chisq", "df", "pvalue", "cfi", "rmsea", "srmr", "aic", "bic"))
##       chisq          df      pvalue         cfi       rmsea        srmr 
##   93205.386     356.000       0.000       0.935       0.061       0.059 
##         aic         bic 
## 6499984.922 6501010.849
Mc(chc.vcov)
## [1] 0.7213898
summary(chc.vcov, standardized=T, ci=T)
## lavaan 0.6-18 ended normally after 43 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                       150
##   Number of equality constraints                    46
## 
##   Number of observations per group:                   
##     0                                            70776
##     1                                            71381
##   Sampling weights variable                     BY_WTA
## 
## Model Test User Model:
##                                                Standard      Scaled
##   Test Statistic                              93205.386   79252.605
##   Degrees of freedom                                356         356
##   P-value (Chi-square)                            0.000       0.000
##   Scaling correction factor                                   1.176
##     Yuan-Bentler correction (Mplus variant)                        
##   Test statistic for each group:
##     0                                         51512.873   43801.432
##     1                                         41692.513   35451.173
## 
## Parameter Estimates:
## 
##   Standard errors                             Sandwich
##   Information bread                           Observed
##   Observed information based on                Hessian
## 
## 
## Group 1 [0]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english =~                                                   
##     Stst1vc (.p1.)    0.762    0.002  347.165    0.000    0.758
##     Stst19d (.p2.)    0.562    0.002  242.063    0.000    0.558
##     Stst20s (.p3.)    0.622    0.002  271.272    0.000    0.618
##     Stst21c (.p4.)    0.611    0.002  264.837    0.000    0.607
##     Stst22p (.p5.)    0.747    0.002  348.075    0.000    0.743
##     Stst23n (.p6.)    0.632    0.003  239.770    0.000    0.627
##     Stst24x (.p7.)    0.561    0.003  212.541    0.000    0.555
##     Stst25w (.p8.)    0.563    0.003  184.383    0.000    0.557
##     Stst26r (.p9.)    0.822    0.002  404.656    0.000    0.818
##     Stst31b (.10.)    0.282    0.003  101.860    0.000    0.277
##     Stst32r (.11.)    0.224    0.003   64.726    0.000    0.217
##   math =~                                                      
##     Stst5mt (.12.)    0.775    0.002  371.989    0.000    0.770
##     Stst25w (.13.)    0.201    0.003   64.707    0.000    0.195
##     Stst32r (.14.)    0.552    0.003  157.978    0.000    0.545
##     Stst33h (.15.)    0.852    0.002  408.518    0.000    0.848
##     Stst34r (.16.)    0.468    0.003  181.348    0.000    0.463
##   speed =~                                                     
##     Stst19d (.17.)    0.287    0.003  110.588    0.000    0.282
##     Sts292D (.18.)    0.215    0.003   73.742    0.000    0.209
##     Stst34r (.19.)    0.358    0.003  125.271    0.000    0.352
##     Stst35t (.20.)    0.646    0.004  180.101    0.000    0.639
##     Stst36c (.21.)    0.689    0.003  217.750    0.000    0.683
##     Stst37b (.22.)    0.565    0.003  181.221    0.000    0.559
##   spatial =~                                                   
##     Stst28m (.23.)    0.655    0.002  294.134    0.000    0.651
##     Sts292D (.24.)    0.495    0.003  178.619    0.000    0.489
##     Sts303D (.25.)    0.725    0.002  297.363    0.000    0.720
##     Stst31b (.26.)    0.462    0.003  155.701    0.000    0.456
##     Stst37b (.27.)    0.134    0.003   46.434    0.000    0.128
##  ci.upper   Std.lv  Std.all
##                            
##     0.766    0.762    0.808
##     0.567    0.562    0.578
##     0.627    0.622    0.627
##     0.616    0.611    0.637
##     0.752    0.747    0.778
##     0.637    0.632    0.646
##     0.566    0.561    0.561
##     0.569    0.563    0.570
##     0.826    0.822    0.840
##     0.288    0.282    0.291
##     0.231    0.224    0.231
##                            
##     0.779    0.775    0.834
##     0.207    0.201    0.204
##     0.559    0.552    0.568
##     0.856    0.852    0.865
##     0.473    0.468    0.484
##                            
##     0.292    0.287    0.295
##     0.221    0.215    0.223
##     0.364    0.358    0.370
##     0.653    0.646    0.648
##     0.695    0.689    0.705
##     0.571    0.565    0.557
##                            
##     0.660    0.655    0.763
##     0.500    0.495    0.514
##     0.729    0.725    0.732
##     0.467    0.462    0.475
##     0.139    0.134    0.132
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english ~~                                                   
##     math    (.52.)    0.848    0.001  602.720    0.000    0.845
##     speed   (.53.)    0.241    0.004   60.753    0.000    0.233
##     spatial (.54.)    0.618    0.003  245.848    0.000    0.613
##   math ~~                                                      
##     speed   (.55.)    0.207    0.004   54.069    0.000    0.199
##     spatial (.56.)    0.653    0.002  262.876    0.000    0.649
##   speed ~~                                                     
##     spatial (.57.)    0.175    0.004   41.354    0.000    0.167
##  ci.upper   Std.lv  Std.all
##                            
##     0.851    0.848    0.848
##     0.249    0.241    0.241
##     0.623    0.618    0.618
##                            
##     0.214    0.207    0.207
##     0.658    0.653    0.653
##                            
##     0.183    0.175    0.175
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stst1vc           0.167    0.004   44.519    0.000    0.160
##    .Stst19d          -0.119    0.004  -30.513    0.000   -0.126
##    .Stst20s (.60.)   -0.194    0.004  -53.434    0.000   -0.202
##    .Stst21c (.61.)   -0.175    0.004  -48.528    0.000   -0.182
##    .Stst22p (.62.)   -0.218    0.004  -57.230    0.000   -0.226
##    .Stst23n (.63.)   -0.194    0.004  -51.933    0.000   -0.202
##    .Stst24x (.64.)   -0.171    0.004  -45.825    0.000   -0.179
##    .Stst25w (.65.)   -0.113    0.004  -30.162    0.000   -0.121
##    .Stst26r          -0.032    0.004   -7.896    0.000   -0.041
##    .Stst31b (.67.)    0.044    0.004   11.626    0.000    0.036
##    .Stst32r (.68.)    0.097    0.004   24.590    0.000    0.089
##    .Stst5mt (.69.)    0.201    0.004   54.512    0.000    0.194
##    .Stst33h           0.117    0.004   28.153    0.000    0.109
##    .Stst34r          -0.078    0.004  -19.713    0.000   -0.086
##    .Sts292D           0.212    0.004   54.436    0.000    0.204
##    .Stst35t (.73.)   -0.102    0.004  -27.151    0.000   -0.109
##    .Stst36c (.74.)   -0.138    0.004  -37.226    0.000   -0.145
##    .Stst37b (.75.)   -0.065    0.004  -18.236    0.000   -0.073
##    .Stst28m           0.536    0.004  151.033    0.000    0.529
##    .Sts303D (.77.)    0.193    0.004   48.456    0.000    0.185
##  ci.upper   Std.lv  Std.all
##     0.175    0.167    0.177
##    -0.111   -0.119   -0.122
##    -0.187   -0.194   -0.196
##    -0.168   -0.175   -0.182
##    -0.211   -0.218   -0.227
##    -0.187   -0.194   -0.199
##    -0.164   -0.171   -0.171
##    -0.106   -0.113   -0.115
##    -0.024   -0.032   -0.033
##     0.051    0.044    0.045
##     0.104    0.097    0.100
##     0.208    0.201    0.217
##     0.125    0.117    0.119
##    -0.070   -0.078   -0.081
##     0.219    0.212    0.220
##    -0.095   -0.102   -0.102
##    -0.131   -0.138   -0.141
##    -0.058   -0.065   -0.065
##     0.543    0.536    0.624
##     0.201    0.193    0.195
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stest1vocab       0.308    0.002  141.564    0.000    0.304
##    .Stst19dsgsdwrd    0.468    0.003  158.398    0.000    0.462
##    .Stest20spellng    0.597    0.004  168.703    0.000    0.590
##    .Stest21cptlztn    0.546    0.003  171.031    0.000    0.540
##    .Stest22puncttn    0.365    0.003  142.852    0.000    0.360
##    .Stest23english    0.556    0.004  144.179    0.000    0.549
##    .Stest24exprssn    0.684    0.004  158.243    0.000    0.676
##    .Stst25wrdfnctn    0.424    0.003  155.380    0.000    0.419
##    .Stst26rdngcmpr    0.281    0.002  124.386    0.000    0.276
##    .Stst31bstrctrs    0.490    0.003  151.602    0.000    0.484
##    .Stst32rthrsnng    0.381    0.002  153.943    0.000    0.376
##    .Stest5math        0.262    0.003   87.021    0.000    0.256
##    .Stst33hghschlm    0.245    0.002  114.185    0.000    0.240
##    .Stst34rthcmptt    0.518    0.004  142.075    0.000    0.511
##    .Stst29vslztn2D    0.600    0.004  143.156    0.000    0.591
##    .Stest35tblrdng    0.576    0.008   72.649    0.000    0.560
##    .Stst36clrclchc    0.480    0.006   85.608    0.000    0.469
##    .Stst37bjctnspc    0.664    0.005  134.722    0.000    0.655
##    .Stst28mchnclrs    0.308    0.003  114.977    0.000    0.302
##    .Stst30vslztn3D    0.456    0.004  126.376    0.000    0.449
##     english           1.000                               1.000
##     math              1.000                               1.000
##     speed             1.000                               1.000
##     spatial           1.000                               1.000
##  ci.upper   Std.lv  Std.all
##     0.313    0.308    0.347
##     0.474    0.468    0.496
##     0.604    0.597    0.607
##     0.553    0.546    0.594
##     0.370    0.365    0.395
##     0.564    0.556    0.582
##     0.693    0.684    0.685
##     0.429    0.424    0.436
##     0.285    0.281    0.294
##     0.497    0.490    0.519
##     0.385    0.381    0.403
##     0.267    0.262    0.304
##     0.249    0.245    0.252
##     0.525    0.518    0.554
##     0.608    0.600    0.646
##     0.591    0.576    0.580
##     0.491    0.480    0.503
##     0.674    0.664    0.646
##     0.313    0.308    0.417
##     0.463    0.456    0.465
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
## 
## 
## Group 2 [1]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english =~                                                   
##     Stst1vc (.p1.)    0.762    0.002  347.165    0.000    0.758
##     Stst19d (.p2.)    0.562    0.002  242.063    0.000    0.558
##     Stst20s (.p3.)    0.622    0.002  271.272    0.000    0.618
##     Stst21c (.p4.)    0.611    0.002  264.837    0.000    0.607
##     Stst22p (.p5.)    0.747    0.002  348.075    0.000    0.743
##     Stst23n (.p6.)    0.632    0.003  239.770    0.000    0.627
##     Stst24x (.p7.)    0.561    0.003  212.541    0.000    0.555
##     Stst25w (.p8.)    0.563    0.003  184.383    0.000    0.557
##     Stst26r (.p9.)    0.822    0.002  404.656    0.000    0.818
##     Stst31b (.10.)    0.282    0.003  101.860    0.000    0.277
##     Stst32r (.11.)    0.224    0.003   64.726    0.000    0.217
##   math =~                                                      
##     Stst5mt (.12.)    0.775    0.002  371.989    0.000    0.770
##     Stst25w (.13.)    0.201    0.003   64.707    0.000    0.195
##     Stst32r (.14.)    0.552    0.003  157.978    0.000    0.545
##     Stst33h (.15.)    0.852    0.002  408.518    0.000    0.848
##     Stst34r (.16.)    0.468    0.003  181.348    0.000    0.463
##   speed =~                                                     
##     Stst19d (.17.)    0.287    0.003  110.588    0.000    0.282
##     Sts292D (.18.)    0.215    0.003   73.742    0.000    0.209
##     Stst34r (.19.)    0.358    0.003  125.271    0.000    0.352
##     Stst35t (.20.)    0.646    0.004  180.101    0.000    0.639
##     Stst36c (.21.)    0.689    0.003  217.750    0.000    0.683
##     Stst37b (.22.)    0.565    0.003  181.221    0.000    0.559
##   spatial =~                                                   
##     Stst28m (.23.)    0.655    0.002  294.134    0.000    0.651
##     Sts292D (.24.)    0.495    0.003  178.619    0.000    0.489
##     Sts303D (.25.)    0.725    0.002  297.363    0.000    0.720
##     Stst31b (.26.)    0.462    0.003  155.701    0.000    0.456
##     Stst37b (.27.)    0.134    0.003   46.434    0.000    0.128
##  ci.upper   Std.lv  Std.all
##                            
##     0.766    0.762    0.789
##     0.567    0.562    0.576
##     0.627    0.622    0.656
##     0.616    0.611    0.636
##     0.752    0.747    0.804
##     0.637    0.632    0.677
##     0.566    0.561    0.606
##     0.569    0.563    0.573
##     0.826    0.822    0.866
##     0.288    0.282    0.293
##     0.231    0.224    0.228
##                            
##     0.779    0.775    0.782
##     0.207    0.201    0.205
##     0.559    0.552    0.561
##     0.856    0.852    0.870
##     0.473    0.468    0.490
##                            
##     0.292    0.287    0.294
##     0.221    0.215    0.222
##     0.364    0.358    0.375
##     0.653    0.646    0.725
##     0.695    0.689    0.721
##     0.571    0.565    0.596
##                            
##     0.660    0.655    0.771
##     0.500    0.495    0.511
##     0.729    0.725    0.756
##     0.467    0.462    0.478
##     0.139    0.134    0.141
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english ~~                                                   
##     math    (.52.)    0.848    0.001  602.720    0.000    0.845
##     speed   (.53.)    0.241    0.004   60.753    0.000    0.233
##     spatial (.54.)    0.618    0.003  245.848    0.000    0.613
##   math ~~                                                      
##     speed   (.55.)    0.207    0.004   54.069    0.000    0.199
##     spatial (.56.)    0.653    0.002  262.876    0.000    0.649
##   speed ~~                                                     
##     spatial (.57.)    0.175    0.004   41.354    0.000    0.167
##  ci.upper   Std.lv  Std.all
##                            
##     0.851    0.848    0.848
##     0.249    0.241    0.241
##     0.623    0.618    0.618
##                            
##     0.214    0.207    0.207
##     0.658    0.653    0.653
##                            
##     0.183    0.175    0.175
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stst1vc          -0.610    0.005 -120.213    0.000   -0.620
##    .Stst19d          -0.322    0.005  -69.819    0.000   -0.331
##    .Stst20s (.60.)   -0.194    0.004  -53.434    0.000   -0.202
##    .Stst21c (.61.)   -0.175    0.004  -48.528    0.000   -0.182
##    .Stst22p (.62.)   -0.218    0.004  -57.230    0.000   -0.226
##    .Stst23n (.63.)   -0.194    0.004  -51.933    0.000   -0.202
##    .Stst24x (.64.)   -0.171    0.004  -45.825    0.000   -0.179
##    .Stst25w (.65.)   -0.113    0.004  -30.162    0.000   -0.121
##    .Stst26r          -0.450    0.005  -87.585    0.000   -0.460
##    .Stst31b (.67.)    0.044    0.004   11.626    0.000    0.036
##    .Stst32r (.68.)    0.097    0.004   24.590    0.000    0.089
##    .Stst5mt (.69.)    0.201    0.004   54.512    0.000    0.194
##    .Stst33h           0.332    0.005   60.984    0.000    0.321
##    .Stst34r           0.271    0.005   55.865    0.000    0.262
##    .Sts292D          -0.008    0.005   -1.581    0.114   -0.017
##    .Stst35t (.73.)   -0.102    0.004  -27.151    0.000   -0.109
##    .Stst36c (.74.)   -0.138    0.004  -37.226    0.000   -0.145
##    .Stst37b (.75.)   -0.065    0.004  -18.236    0.000   -0.073
##    .Stst28m          -0.147    0.005  -30.377    0.000   -0.157
##    .Sts303D (.77.)    0.193    0.004   48.456    0.000    0.185
##     english           0.675    0.007  100.943    0.000    0.662
##     math             -0.475    0.007  -66.581    0.000   -0.489
##     speed             0.324    0.007   46.947    0.000    0.310
##     spatial          -0.429    0.008  -56.991    0.000   -0.444
##  ci.upper   Std.lv  Std.all
##    -0.600   -0.610   -0.632
##    -0.313   -0.322   -0.330
##    -0.187   -0.194   -0.205
##    -0.168   -0.175   -0.182
##    -0.211   -0.218   -0.235
##    -0.187   -0.194   -0.208
##    -0.164   -0.171   -0.185
##    -0.106   -0.113   -0.116
##    -0.440   -0.450   -0.474
##     0.051    0.044    0.045
##     0.104    0.097    0.098
##     0.208    0.201    0.203
##     0.343    0.332    0.339
##     0.281    0.271    0.284
##     0.002   -0.008   -0.008
##    -0.095   -0.102   -0.114
##    -0.131   -0.138   -0.144
##    -0.058   -0.065   -0.069
##    -0.138   -0.147   -0.173
##     0.201    0.193    0.201
##     0.688    0.675    0.675
##    -0.461   -0.475   -0.475
##     0.337    0.324    0.324
##    -0.414   -0.429   -0.429
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stest1vocab       0.351    0.002  152.766    0.000    0.347
##    .Stst19dsgsdwrd    0.476    0.003  162.284    0.000    0.470
##    .Stest20spellng    0.513    0.003  171.951    0.000    0.508
##    .Stest21cptlztn    0.549    0.003  169.744    0.000    0.543
##    .Stest22puncttn    0.305    0.002  139.942    0.000    0.301
##    .Stest23english    0.472    0.003  145.295    0.000    0.466
##    .Stest24exprssn    0.543    0.004  149.323    0.000    0.536
##    .Stst25wrdfnctn    0.414    0.003  150.608    0.000    0.409
##    .Stst26rdngcmpr    0.226    0.002  120.584    0.000    0.223
##    .Stst31bstrctrs    0.477    0.003  157.513    0.000    0.471
##    .Stst32rthrsnng    0.404    0.003  160.874    0.000    0.399
##    .Stest5math        0.382    0.004  104.566    0.000    0.375
##    .Stst33hghschlm    0.232    0.002  109.190    0.000    0.228
##    .Stst34rthcmptt    0.494    0.004  136.040    0.000    0.487
##    .Stst29vslztn2D    0.609    0.004  162.013    0.000    0.602
##    .Stest35tblrdng    0.377    0.005   69.487    0.000    0.366
##    .Stst36clrclchc    0.439    0.004   97.667    0.000    0.430
##    .Stst37bjctnspc    0.534    0.004  138.188    0.000    0.526
##    .Stst28mchnclrs    0.294    0.002  121.552    0.000    0.289
##    .Stst30vslztn3D    0.394    0.003  126.210    0.000    0.388
##     english           1.000                               1.000
##     math              1.000                               1.000
##     speed             1.000                               1.000
##     spatial           1.000                               1.000
##  ci.upper   Std.lv  Std.all
##     0.356    0.351    0.377
##     0.482    0.476    0.500
##     0.519    0.513    0.570
##     0.556    0.549    0.595
##     0.309    0.305    0.353
##     0.478    0.472    0.542
##     0.550    0.543    0.633
##     0.419    0.414    0.430
##     0.230    0.226    0.251
##     0.483    0.477    0.513
##     0.409    0.404    0.417
##     0.389    0.382    0.389
##     0.236    0.232    0.242
##     0.502    0.494    0.543
##     0.617    0.609    0.650
##     0.387    0.377    0.475
##     0.448    0.439    0.480
##     0.541    0.534    0.595
##     0.298    0.294    0.406
##     0.400    0.394    0.429
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
tests<-lavTestLRT(configural, metric, scalar2, chc.cov, chc.vcov)
Td=tests[2:5,"Chisq diff"]
Td
## [1] 3753.8426 4227.7525  790.9207  851.4462
dfd=tests[2:5,"Df diff"]
dfd
## [1] 23  9  6  4
lambda<-Td-dfd
ld<-lambda/dfd
G<-2 # number of groups
N<-71381 + 70776 # sample size
RMSEAD<-sqrt((ld)*G/(N-G))
RMSEAD
## [1] 0.04777201 0.08120910 0.04290137 0.05459590
RMSEA.CI(T=Td[1],df=dfd[1],N=N,G=2)
## [1] 0.04648984 0.04906655
RMSEA.CI(T=Td[2],df=dfd[2],N=N,G=2)
## [1] 0.07916090 0.08327594
RMSEA.CI(T=Td[3],df=dfd[3],N=N,G=2)
## [1] 0.04040560 0.04545111
RMSEA.CI(T=Td[4],df=dfd[4],N=N,G=2)
## [1] 0.05154023 0.05771534
round(pvals(T=Td[1],df=dfd[1],N=N,G=2),3)
##   RMSEA>0 RMSEA>.01 RMSEA>.05 RMSEA>.06 RMSEA>.08 RMSEA>.10 
##     1.000     1.000     0.002     0.000     0.000     0.000
round(pvals(T=Td[2],df=dfd[2],N=N,G=2),3)
##   RMSEA>0 RMSEA>.01 RMSEA>.05 RMSEA>.06 RMSEA>.08 RMSEA>.10 
##     1.000     1.000     1.000     1.000     0.835     0.000
round(pvals(T=Td[3],df=dfd[3],N=N,G=2),3)
##   RMSEA>0 RMSEA>.01 RMSEA>.05 RMSEA>.06 RMSEA>.08 RMSEA>.10 
##         1         1         0         0         0         0
round(pvals(T=Td[4],df=dfd[4],N=N,G=2),3)
##   RMSEA>0 RMSEA>.01 RMSEA>.05 RMSEA>.06 RMSEA>.08 RMSEA>.10 
##     1.000     1.000     0.993     0.002     0.000     0.000
tests<-lavTestLRT(configural, metric, scalar)
Td=tests[2:3,"Chisq diff"]
Td
## [1]  3753.843 67864.707
dfd=tests[2:3,"Df diff"]
dfd
## [1] 23 16
lambda<-Td-dfd
ld<-lambda/dfd
G<-2 # number of groups
N<-71381 + 70776 # sample size
RMSEAD<-sqrt((ld)*G/(N-G))
RMSEAD
## [1] 0.04777201 0.24425571
RMSEA.CI(T=Td[1],df=dfd[1],N=N,G=2)
## [1] 0.04648984 0.04906655
RMSEA.CI(T=Td[2],df=dfd[2],N=N,G=2)
## [1] 0.2427142 0.2457991
round(pvals(T=Td[1],df=dfd[1],N=N,G=2),3)
##   RMSEA>0 RMSEA>.01 RMSEA>.05 RMSEA>.06 RMSEA>.08 RMSEA>.10 
##     1.000     1.000     0.002     0.000     0.000     0.000
round(pvals(T=Td[2],df=dfd[2],N=N,G=2),3)
##   RMSEA>0 RMSEA>.01 RMSEA>.05 RMSEA>.06 RMSEA>.08 RMSEA>.10 
##         1         1         1         1         1         1
tests<-lavTestLRT(configural, metric, scalar2, strict)
Td=tests[2:4,"Chisq diff"]
Td
## [1] 3753.843 4227.753 5010.892
dfd=tests[2:4,"Df diff"]
dfd
## [1] 23  9 20
lambda<-Td-dfd
ld<-lambda/dfd
G<-2 # number of groups
N<-71381 + 70776 # sample size
RMSEAD<-sqrt((ld)*G/(N-G))
RMSEAD
## [1] 0.04777201 0.08120910 0.05925268
RMSEA.CI(T=Td[1],df=dfd[1],N=N,G=2)
## [1] 0.04648984 0.04906655
RMSEA.CI(T=Td[2],df=dfd[2],N=N,G=2)
## [1] 0.07916090 0.08327594
RMSEA.CI(T=Td[3],df=dfd[3],N=N,G=2)
## [1] 0.05787750 0.06063927
round(pvals(T=Td[1],df=dfd[1],N=N,G=2),3)
##   RMSEA>0 RMSEA>.01 RMSEA>.05 RMSEA>.06 RMSEA>.08 RMSEA>.10 
##     1.000     1.000     0.002     0.000     0.000     0.000
round(pvals(T=Td[2],df=dfd[2],N=N,G=2),3)
##   RMSEA>0 RMSEA>.01 RMSEA>.05 RMSEA>.06 RMSEA>.08 RMSEA>.10 
##     1.000     1.000     1.000     1.000     0.835     0.000
round(pvals(T=Td[3],df=dfd[3],N=N,G=2),3)
##   RMSEA>0 RMSEA>.01 RMSEA>.05 RMSEA>.06 RMSEA>.08 RMSEA>.10 
##     1.000     1.000     1.000     0.189     0.000     0.000

CHC higher order models

chc.hof.model <-'
english =~ Stest1vocab + Stest19disguisedwords + Stest20spelling + Stest21capitalization + Stest22punctuation + Stest23english + Stest24expression + Stest25wordfunctions + Stest26readingcomprehension + Stest31abstractreasoning + Stest32arithreasoning
math =~ Stest5math + Stest25wordfunctions + Stest32arithreasoning + Stest33highschoolmath + Stest34arithcomputation
speed =~ Stest19disguisedwords + Stest29visualization2D + Stest34arithcomputation + Stest35tablereading + Stest36clericalchecking + Stest37objectinspection
spatial =~ Stest28mechanicalreasoning + Stest29visualization2D + Stest30visualization3D + Stest31abstractreasoning + Stest37objectinspection
g =~ english + math + speed + spatial
'

baseline<-cfa(chc.hof.model, data=dgroup, meanstructure=TRUE, sampling.weights="BY_WTA")
## Warning: lavaan->lav_object_post_check():  
##    some estimated lv variances are negative
fitMeasures(baseline, c("chisq", "df", "pvalue", "cfi", "rmsea", "srmr", "aic", "bic"))
##       chisq          df      pvalue         cfi       rmsea        srmr 
##  129206.654     159.000       0.000       0.910       0.076       0.056 
##         aic         bic 
## 6639919.964 6640620.357
Mc(baseline)
## [1] 0.6351497
configural<-cfa(chc.hof.model, data=dgroup, group="sex", meanstructure=TRUE, sampling.weights="BY_WTA", std.lv=T)
fitMeasures(configural, c("chisq", "df", "pvalue", "cfi", "rmsea", "srmr", "aic", "bic"))
##       chisq          df      pvalue         cfi       rmsea        srmr 
##   82423.073     318.000       0.000       0.942       0.060       0.041 
##         aic         bic 
## 6489278.609 6490679.394
Mc(configural)
## [1] 0.7491732
summary(configural, standardized=T, ci=T)
## lavaan 0.6-18 ended normally after 91 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                       142
## 
##   Number of observations per group:                   
##     0                                            70776
##     1                                            71381
##   Sampling weights variable                     BY_WTA
## 
## Model Test User Model:
##                                                Standard      Scaled
##   Test Statistic                              82423.073   69998.907
##   Degrees of freedom                                318         318
##   P-value (Chi-square)                            0.000       0.000
##   Scaling correction factor                                   1.177
##     Yuan-Bentler correction (Mplus variant)                        
##   Test statistic for each group:
##     0                                         46168.817   39209.491
##     1                                         36254.256   30789.416
## 
## Parameter Estimates:
## 
##   Standard errors                             Sandwich
##   Information bread                           Observed
##   Observed information based on                Hessian
## 
## 
## Group 1 [0]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english =~                                                   
##     Stest1vocab       0.323    0.004   89.166    0.000    0.315
##     Stst19dsgsdwrd    0.247    0.003   78.899    0.000    0.241
##     Stest20spellng    0.274    0.003   79.644    0.000    0.267
##     Stest21cptlztn    0.276    0.003   83.901    0.000    0.270
##     Stest22puncttn    0.337    0.004   87.771    0.000    0.330
##     Stest23english    0.303    0.004   81.741    0.000    0.296
##     Stest24exprssn    0.281    0.003   80.453    0.000    0.275
##     Stst25wrdfnctn    0.190    0.004   49.182    0.000    0.182
##     Stst26rdngcmpr    0.375    0.004   88.557    0.000    0.367
##     Stst31bstrctrs    0.126    0.002   55.366    0.000    0.121
##     Stst32rthrsnng    0.113    0.003   32.631    0.000    0.106
##   math =~                                                      
##     Stest5math        0.221    0.007   32.777    0.000    0.208
##     Stst25wrdfnctn    0.086    0.003   26.402    0.000    0.080
##     Stst32rthrsnng    0.149    0.004   37.564    0.000    0.142
##     Stst33hghschlm    0.259    0.008   32.213    0.000    0.244
##     Stst34rthcmptt    0.139    0.004   31.342    0.000    0.130
##   speed =~                                                     
##     Stst19dsgsdwrd    0.266    0.004   71.527    0.000    0.258
##     Stst29vslztn2D    0.217    0.004   53.904    0.000    0.209
##     Stst34rthcmptt    0.361    0.004   92.773    0.000    0.353
##     Stest35tblrdng    0.707    0.005  140.549    0.000    0.698
##     Stst36clrclchc    0.690    0.005  134.847    0.000    0.680
##     Stst37bjctnspc    0.569    0.005  117.637    0.000    0.560
##   spatial =~                                                   
##     Stst28mchnclrs    0.512    0.003  178.857    0.000    0.506
##     Stst29vslztn2D    0.375    0.003  109.179    0.000    0.369
##     Stst30vslztn3D    0.567    0.004  160.081    0.000    0.560
##     Stst31bstrctrs    0.345    0.004   96.600    0.000    0.338
##     Stst37bjctnspc    0.103    0.003   30.367    0.000    0.096
##   g =~                                                         
##     english           2.102    0.029   72.622    0.000    2.046
##     math              3.407    0.113   30.210    0.000    3.186
##     speed             0.258    0.006   40.991    0.000    0.245
##     spatial           0.922    0.009  106.989    0.000    0.905
##  ci.upper   Std.lv  Std.all
##                            
##     0.330    0.751    0.803
##     0.253    0.575    0.589
##     0.281    0.638    0.638
##     0.282    0.643    0.657
##     0.345    0.785    0.793
##     0.311    0.706    0.691
##     0.288    0.655    0.626
##     0.197    0.441    0.454
##     0.384    0.874    0.857
##     0.130    0.293    0.298
##     0.119    0.262    0.266
##                            
##     0.234    0.785    0.834
##     0.092    0.305    0.314
##     0.157    0.530    0.537
##     0.275    0.921    0.885
##     0.147    0.492    0.496
##                            
##     0.273    0.274    0.281
##     0.225    0.224    0.230
##     0.368    0.372    0.376
##     0.717    0.731    0.707
##     0.700    0.712    0.713
##     0.579    0.588    0.572
##                            
##     0.517    0.696    0.785
##     0.382    0.511    0.524
##     0.574    0.771    0.756
##     0.352    0.469    0.477
##     0.110    0.140    0.136
##                            
##     2.159    0.903    0.903
##     3.628    0.960    0.960
##     0.270    0.249    0.249
##     0.939    0.678    0.678
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stest1vocab       0.167    0.004   44.518    0.000    0.160
##    .Stst19dsgsdwrd   -0.119    0.004  -30.513    0.000   -0.126
##    .Stest20spellng   -0.258    0.004  -64.136    0.000   -0.265
##    .Stest21cptlztn   -0.212    0.004  -54.084    0.000   -0.220
##    .Stest22puncttn   -0.208    0.004  -52.316    0.000   -0.216
##    .Stest23english   -0.144    0.004  -35.041    0.000   -0.152
##    .Stest24exprssn   -0.118    0.004  -28.047    0.000   -0.126
##    .Stst25wrdfnctn   -0.139    0.004  -35.813    0.000   -0.147
##    .Stst26rdngcmpr   -0.032    0.004   -7.896    0.000   -0.041
##    .Stst31bstrctrs    0.055    0.004   13.853    0.000    0.047
##    .Stst32rthrsnng    0.121    0.004   30.651    0.000    0.114
##    .Stest5math        0.193    0.004   51.128    0.000    0.186
##    .Stst33hghschlm    0.117    0.004   28.152    0.000    0.109
##    .Stst34rthcmptt   -0.078    0.004  -19.713    0.000   -0.086
##    .Stst29vslztn2D    0.212    0.004   54.436    0.000    0.204
##    .Stest35tblrdng   -0.068    0.004  -16.347    0.000   -0.076
##    .Stst36clrclchc   -0.147    0.004  -37.322    0.000   -0.155
##    .Stst37bjctnspc   -0.095    0.004  -23.187    0.000   -0.103
##    .Stst28mchnclrs    0.536    0.004  151.033    0.000    0.529
##    .Stst30vslztn3D    0.190    0.004   46.616    0.000    0.182
##  ci.upper   Std.lv  Std.all
##     0.175    0.167    0.179
##    -0.111   -0.119   -0.122
##    -0.250   -0.258   -0.257
##    -0.204   -0.212   -0.217
##    -0.200   -0.208   -0.210
##    -0.136   -0.144   -0.141
##    -0.110   -0.118   -0.113
##    -0.132   -0.139   -0.143
##    -0.024   -0.032   -0.032
##     0.063    0.055    0.056
##     0.129    0.121    0.123
##     0.201    0.193    0.205
##     0.125    0.117    0.113
##    -0.070   -0.078   -0.079
##     0.219    0.212    0.217
##    -0.060   -0.068   -0.066
##    -0.140   -0.147   -0.148
##    -0.087   -0.095   -0.092
##     0.543    0.536    0.605
##     0.198    0.190    0.186
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stest1vocab       0.311    0.002  140.617    0.000    0.306
##    .Stst19dsgsdwrd    0.476    0.003  157.154    0.000    0.470
##    .Stest20spellng    0.594    0.004  168.491    0.000    0.587
##    .Stest21cptlztn    0.544    0.003  168.949    0.000    0.537
##    .Stest22puncttn    0.364    0.003  139.880    0.000    0.359
##    .Stest23english    0.544    0.004  143.400    0.000    0.537
##    .Stest24exprssn    0.667    0.004  154.217    0.000    0.659
##    .Stst25wrdfnctn    0.424    0.003  157.668    0.000    0.419
##    .Stst26rdngcmpr    0.277    0.002  119.891    0.000    0.272
##    .Stst31bstrctrs    0.493    0.003  150.235    0.000    0.487
##    .Stst32rthrsnng    0.384    0.002  153.768    0.000    0.379
##    .Stest5math        0.269    0.003   90.745    0.000    0.263
##    .Stst33hghschlm    0.234    0.002   98.807    0.000    0.229
##    .Stst34rthcmptt    0.514    0.004  140.040    0.000    0.507
##    .Stst29vslztn2D    0.599    0.004  139.890    0.000    0.591
##    .Stest35tblrdng    0.535    0.008   64.815    0.000    0.519
##    .Stst36clrclchc    0.490    0.006   82.042    0.000    0.479
##    .Stst37bjctnspc    0.662    0.005  129.669    0.000    0.652
##    .Stst28mchnclrs    0.301    0.003  101.840    0.000    0.295
##    .Stst30vslztn3D    0.446    0.004  112.713    0.000    0.438
##    .english           1.000                               1.000
##    .math              1.000                               1.000
##    .speed             1.000                               1.000
##    .spatial           1.000                               1.000
##     g                 1.000                               1.000
##  ci.upper   Std.lv  Std.all
##     0.315    0.311    0.355
##     0.482    0.476    0.500
##     0.601    0.594    0.593
##     0.550    0.544    0.568
##     0.369    0.364    0.371
##     0.552    0.544    0.522
##     0.676    0.667    0.609
##     0.429    0.424    0.448
##     0.281    0.277    0.266
##     0.499    0.493    0.510
##     0.389    0.384    0.394
##     0.275    0.269    0.304
##     0.238    0.234    0.216
##     0.521    0.514    0.523
##     0.608    0.599    0.632
##     0.551    0.535    0.501
##     0.502    0.490    0.492
##     0.672    0.662    0.627
##     0.307    0.301    0.383
##     0.453    0.446    0.429
##     1.000    0.184    0.184
##     1.000    0.079    0.079
##     1.000    0.938    0.938
##     1.000    0.541    0.541
##     1.000    1.000    1.000
## 
## 
## Group 2 [1]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english =~                                                   
##     Stest1vocab       0.342    0.004   80.107    0.000    0.333
##     Stst19dsgsdwrd    0.238    0.003   71.225    0.000    0.232
##     Stest20spellng    0.243    0.003   73.326    0.000    0.237
##     Stest21cptlztn    0.238    0.003   74.382    0.000    0.232
##     Stest22puncttn    0.310    0.004   79.903    0.000    0.303
##     Stest23english    0.258    0.003   74.080    0.000    0.251
##     Stest24exprssn    0.222    0.003   71.249    0.000    0.216
##     Stst25wrdfnctn    0.220    0.004   62.515    0.000    0.213
##     Stst26rdngcmpr    0.338    0.004   79.648    0.000    0.330
##     Stst31bstrctrs    0.131    0.002   53.906    0.000    0.126
##     Stst32rthrsnng    0.174    0.003   58.536    0.000    0.168
##   math =~                                                      
##     Stest5math        0.356    0.005   78.781    0.000    0.347
##     Stst25wrdfnctn    0.127    0.003   43.056    0.000    0.122
##     Stst32rthrsnng    0.164    0.003   58.117    0.000    0.159
##     Stst33hghschlm    0.358    0.005   75.839    0.000    0.349
##     Stst34rthcmptt    0.199    0.003   69.473    0.000    0.194
##   speed =~                                                     
##     Stst19dsgsdwrd    0.296    0.004   81.443    0.000    0.289
##     Stst29vslztn2D    0.199    0.004   49.012    0.000    0.191
##     Stst34rthcmptt    0.327    0.004   86.413    0.000    0.319
##     Stest35tblrdng    0.576    0.004  131.620    0.000    0.568
##     Stst36clrclchc    0.638    0.005  138.661    0.000    0.629
##     Stst37bjctnspc    0.510    0.004  118.372    0.000    0.501
##   spatial =~                                                   
##     Stst28mchnclrs    0.439    0.003  160.764    0.000    0.433
##     Stst29vslztn2D    0.342    0.003  104.388    0.000    0.335
##     Stst30vslztn3D    0.486    0.003  148.098    0.000    0.480
##     Stst31bstrctrs    0.303    0.004   85.580    0.000    0.296
##     Stst37bjctnspc    0.103    0.003   35.490    0.000    0.098
##   g =~                                                         
##     english           2.068    0.031   65.813    0.000    2.007
##     math              1.971    0.031   63.943    0.000    1.910
##     speed             0.255    0.006   40.495    0.000    0.243
##     spatial           0.983    0.010  103.075    0.000    0.964
##  ci.upper   Std.lv  Std.all
##                            
##     0.350    0.785    0.803
##     0.245    0.548    0.565
##     0.250    0.559    0.614
##     0.245    0.548    0.593
##     0.318    0.713    0.789
##     0.265    0.593    0.653
##     0.229    0.511    0.570
##     0.227    0.506    0.513
##     0.346    0.777    0.855
##     0.135    0.300    0.315
##     0.179    0.399    0.413
##                            
##     0.365    0.787    0.795
##     0.133    0.281    0.285
##     0.170    0.363    0.376
##     0.368    0.792    0.859
##     0.205    0.441    0.473
##                            
##     0.303    0.305    0.315
##     0.207    0.206    0.215
##     0.334    0.337    0.362
##     0.585    0.595    0.690
##     0.647    0.659    0.707
##     0.518    0.526    0.566
##                            
##     0.444    0.615    0.748
##     0.348    0.479    0.501
##     0.493    0.682    0.733
##     0.309    0.424    0.445
##     0.109    0.145    0.156
##                            
##     2.130    0.900    0.900
##     2.031    0.892    0.892
##     0.267    0.247    0.247
##     1.002    0.701    0.701
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stest1vocab      -0.095    0.004  -24.615    0.000   -0.103
##    .Stst19dsgsdwrd    0.150    0.004   38.967    0.000    0.142
##    .Stest20spellng    0.280    0.004   77.302    0.000    0.273
##    .Stest21cptlztn    0.276    0.004   74.784    0.000    0.268
##    .Stest22puncttn    0.278    0.004   76.957    0.000    0.271
##    .Stest23english    0.190    0.004   52.481    0.000    0.183
##    .Stest24exprssn    0.165    0.004   46.240    0.000    0.158
##    .Stst25wrdfnctn    0.196    0.004   50.126    0.000    0.189
##    .Stst26rdngcmpr    0.105    0.004   29.044    0.000    0.098
##    .Stst31bstrctrs    0.026    0.004    6.799    0.000    0.018
##    .Stst32rthrsnng   -0.040    0.004  -10.549    0.000   -0.048
##    .Stest5math       -0.155    0.004  -39.596    0.000   -0.163
##    .Stst33hghschlm   -0.072    0.004  -19.964    0.000   -0.080
##    .Stst34rthcmptt    0.165    0.004   44.491    0.000    0.158
##    .Stst29vslztn2D   -0.150    0.004  -39.724    0.000   -0.157
##    .Stest35tblrdng    0.085    0.003   24.796    0.000    0.078
##    .Stst36clrclchc    0.094    0.004   25.710    0.000    0.087
##    .Stst37bjctnspc    0.084    0.004   22.827    0.000    0.076
##    .Stst28mchnclrs   -0.428    0.003 -131.000    0.000   -0.434
##    .Stst30vslztn3D   -0.115    0.004  -31.342    0.000   -0.122
##  ci.upper   Std.lv  Std.all
##    -0.088   -0.095   -0.097
##     0.158    0.150    0.155
##     0.287    0.280    0.308
##     0.283    0.276    0.299
##     0.285    0.278    0.307
##     0.197    0.190    0.209
##     0.172    0.165    0.184
##     0.204    0.196    0.199
##     0.112    0.105    0.116
##     0.033    0.026    0.027
##    -0.033   -0.040   -0.042
##    -0.147   -0.155   -0.157
##    -0.065   -0.072   -0.079
##     0.172    0.165    0.177
##    -0.143   -0.150   -0.157
##     0.091    0.085    0.098
##     0.101    0.094    0.100
##     0.091    0.084    0.090
##    -0.422   -0.428   -0.521
##    -0.108   -0.115   -0.124
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stest1vocab       0.339    0.002  144.902    0.000    0.334
##    .Stst19dsgsdwrd    0.471    0.003  154.753    0.000    0.465
##    .Stest20spellng    0.517    0.003  172.374    0.000    0.511
##    .Stest21cptlztn    0.552    0.003  170.315    0.000    0.546
##    .Stest22puncttn    0.309    0.002  138.893    0.000    0.305
##    .Stest23english    0.472    0.003  146.394    0.000    0.466
##    .Stest24exprssn    0.541    0.004  151.502    0.000    0.534
##    .Stst25wrdfnctn    0.408    0.003  149.065    0.000    0.403
##    .Stst26rdngcmpr    0.222    0.002  117.245    0.000    0.218
##    .Stst31bstrctrs    0.478    0.003  154.372    0.000    0.472
##    .Stst32rthrsnng    0.409    0.002  163.932    0.000    0.404
##    .Stest5math        0.360    0.004  100.819    0.000    0.353
##    .Stst33hghschlm    0.223    0.002   95.780    0.000    0.218
##    .Stst34rthcmptt    0.495    0.004  133.958    0.000    0.488
##    .Stst29vslztn2D    0.609    0.004  156.963    0.000    0.602
##    .Stest35tblrdng    0.389    0.005   71.602    0.000    0.378
##    .Stst36clrclchc    0.435    0.005   87.297    0.000    0.425
##    .Stst37bjctnspc    0.539    0.004  134.283    0.000    0.531
##    .Stst28mchnclrs    0.297    0.003  114.914    0.000    0.292
##    .Stst30vslztn3D    0.400    0.003  118.681    0.000    0.393
##    .english           1.000                               1.000
##    .math              1.000                               1.000
##    .speed             1.000                               1.000
##    .spatial           1.000                               1.000
##     g                 1.000                               1.000
##  ci.upper   Std.lv  Std.all
##     0.343    0.339    0.355
##     0.477    0.471    0.502
##     0.523    0.517    0.623
##     0.559    0.552    0.648
##     0.314    0.309    0.378
##     0.479    0.472    0.573
##     0.548    0.541    0.675
##     0.413    0.408    0.420
##     0.226    0.222    0.269
##     0.484    0.478    0.526
##     0.414    0.409    0.439
##     0.367    0.360    0.368
##     0.227    0.223    0.262
##     0.502    0.495    0.570
##     0.617    0.609    0.666
##     0.399    0.389    0.524
##     0.445    0.435    0.501
##     0.547    0.539    0.624
##     0.302    0.297    0.440
##     0.406    0.400    0.462
##     1.000    0.189    0.189
##     1.000    0.205    0.205
##     1.000    0.939    0.939
##     1.000    0.509    0.509
##     1.000    1.000    1.000
modificationIndices(configural, sort=T, maximum.number=30)
##                       lhs op                         rhs block group
## 516           Stest1vocab ~~ Stest26readingcomprehension     2     2
## 243           Stest1vocab ~~ Stest26readingcomprehension     1     1
## 231                     g =~         Stest35tablereading     1     1
## 182                  math =~         Stest35tablereading     1     1
## 203               spatial =~             Stest20spelling     1     1
## 167               english =~         Stest35tablereading     1     1
## 214               spatial =~         Stest35tablereading     1     1
## 246           Stest1vocab ~~                  Stest5math     1     1
## 233                     g =~     Stest37objectinspection     1     1
## 476               spatial =~             Stest20spelling     2     2
## 184                  math =~     Stest37objectinspection     1     1
## 213               spatial =~     Stest34arithcomputation     1     1
## 169               english =~     Stest37objectinspection     1     1
## 239           Stest1vocab ~~          Stest22punctuation     1     1
## 309    Stest22punctuation ~~ Stest26readingcomprehension     1     1
## 253           Stest1vocab ~~  Stest28mechanicalreasoning     1     1
## 528 Stest19disguisedwords ~~             Stest20spelling     2     2
## 519           Stest1vocab ~~                  Stest5math     2     2
## 504                     g =~         Stest35tablereading     2     2
## 461                 speed =~             Stest20spelling     2     2
## 506                     g =~     Stest37objectinspection     2     2
## 455                  math =~         Stest35tablereading     2     2
## 440               english =~         Stest35tablereading     2     2
## 556       Stest20spelling ~~     Stest34arithcomputation     2     2
## 512           Stest1vocab ~~          Stest22punctuation     2     2
## 283       Stest20spelling ~~     Stest34arithcomputation     1     1
## 255 Stest19disguisedwords ~~             Stest20spelling     1     1
## 170               english =~  Stest28mechanicalreasoning     1     1
## 582    Stest22punctuation ~~ Stest26readingcomprehension     2     2
## 457                  math =~     Stest37objectinspection     2     2
##     level       mi    epc sepc.lv sepc.all sepc.nox
## 516     1 4980.882  0.098   0.098    0.357    0.357
## 243     1 4930.099  0.101   0.101    0.343    0.343
## 231     1 4392.812  0.276   0.276    0.267    0.267
## 182     1 4238.437  0.075   0.266    0.257    0.257
## 203     1 3821.040 -0.210  -0.285   -0.285   -0.285
## 167     1 3625.388  0.102   0.238    0.230    0.230
## 214     1 3383.515  0.174   0.237    0.229    0.229
## 246     1 3054.402  0.073   0.073    0.251    0.251
## 233     1 2945.660 -0.307  -0.307   -0.299   -0.299
## 476     1 2942.278 -0.176  -0.247   -0.271   -0.271
## 184     1 2802.219 -0.079  -0.280   -0.273   -0.273
## 213     1 2619.678 -0.178  -0.243   -0.245   -0.245
## 169     1 2608.765 -0.108  -0.250   -0.244   -0.244
## 239     1 2454.672 -0.075  -0.075   -0.223   -0.223
## 309     1 2397.709 -0.075  -0.075   -0.237   -0.237
## 253     1 2363.009  0.071   0.071    0.233    0.233
## 528     1 2227.170  0.095   0.095    0.192    0.192
## 519     1 2191.064  0.075   0.075    0.215    0.215
## 504     1 2185.706  0.169   0.169    0.196    0.196
## 461     1 1926.621  0.142   0.147    0.161    0.161
## 506     1 1890.746 -0.247  -0.247   -0.266   -0.266
## 455     1 1883.979  0.068   0.150    0.174    0.174
## 440     1 1881.398  0.064   0.146    0.169    0.169
## 556     1 1840.209  0.088   0.088    0.174    0.174
## 512     1 1829.308 -0.064  -0.064   -0.197   -0.197
## 283     1 1826.700  0.096   0.096    0.173    0.173
## 255     1 1820.337  0.092   0.092    0.173    0.173
## 170     1 1778.686  0.088   0.204    0.231    0.231
## 582     1 1763.746 -0.055  -0.055   -0.208   -0.208
## 457     1 1721.969 -0.090  -0.199   -0.214   -0.214
metric<-cfa(chc.hof.model, data=dgroup, group="sex", meanstructure=TRUE, sampling.weights="BY_WTA", std.lv=T, group.equal=c("loadings"))
fitMeasures(metric, c("chisq", "df", "pvalue", "cfi", "rmsea", "srmr", "aic", "bic"))
##       chisq          df      pvalue         cfi       rmsea        srmr 
##   86982.717     344.000       0.000       0.939       0.060       0.047 
##         aic         bic 
## 6493786.253 6494930.557
Mc(metric)
## [1] 0.7373216
summary(metric, standardized=T, ci=T)
## lavaan 0.6-18 ended normally after 85 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                       147
##   Number of equality constraints                    31
## 
##   Number of observations per group:                   
##     0                                            70776
##     1                                            71381
##   Sampling weights variable                     BY_WTA
## 
## Model Test User Model:
##                                                Standard      Scaled
##   Test Statistic                              86982.717   73915.505
##   Degrees of freedom                                344         344
##   P-value (Chi-square)                            0.000       0.000
##   Scaling correction factor                                   1.177
##     Yuan-Bentler correction (Mplus variant)                        
##   Test statistic for each group:
##     0                                         48305.405   41048.596
##     1                                         38677.312   32866.910
## 
## Parameter Estimates:
## 
##   Standard errors                             Sandwich
##   Information bread                           Observed
##   Observed information based on                Hessian
## 
## 
## Group 1 [0]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english =~                                                   
##     Stst1vc (.p1.)    0.322    0.004   88.816    0.000    0.315
##     Stst19d (.p2.)    0.237    0.003   82.544    0.000    0.232
##     Stst20s (.p3.)    0.253    0.003   82.846    0.000    0.247
##     Stst21c (.p4.)    0.252    0.003   85.218    0.000    0.246
##     Stst22p (.p5.)    0.316    0.004   88.011    0.000    0.309
##     Stst23n (.p6.)    0.274    0.003   83.462    0.000    0.268
##     Stst24x (.p7.)    0.245    0.003   82.226    0.000    0.239
##     Stst25w (.p8.)    0.202    0.003   72.573    0.000    0.197
##     Stst26r (.p9.)    0.348    0.004   87.880    0.000    0.340
##     Stst31b (.10.)    0.126    0.002   69.223    0.000    0.122
##     Stst32r (.11.)    0.145    0.002   64.321    0.000    0.140
##   math =~                                                      
##     Stst5mt (.12.)    0.259    0.005   51.609    0.000    0.249
##     Stst25w (.13.)    0.095    0.002   41.453    0.000    0.090
##     Stst32r (.14.)    0.144    0.003   52.033    0.000    0.139
##     Stst33h (.15.)    0.285    0.006   50.428    0.000    0.274
##     Stst34r (.16.)    0.156    0.003   48.909    0.000    0.149
##   speed =~                                                     
##     Stst19d (.17.)    0.295    0.003  104.880    0.000    0.290
##     Sts292D (.18.)    0.221    0.003   71.609    0.000    0.215
##     Stst34r (.19.)    0.364    0.003  117.565    0.000    0.358
##     Stst35t (.20.)    0.677    0.004  156.985    0.000    0.668
##     Stst36c (.21.)    0.704    0.004  168.538    0.000    0.696
##     Stst37b (.22.)    0.572    0.004  147.412    0.000    0.564
##   spatial =~                                                   
##     Stst28m (.23.)    0.508    0.003  193.624    0.000    0.503
##     Sts292D (.24.)    0.383    0.003  137.128    0.000    0.378
##     Sts303D (.25.)    0.563    0.003  181.625    0.000    0.556
##     Stst31b (.26.)    0.344    0.003  121.094    0.000    0.339
##     Stst37b (.27.)    0.112    0.002   46.383    0.000    0.107
##   g =~                                                         
##     english (.28.)    2.251    0.029   76.962    0.000    2.193
##     math    (.29.)    2.943    0.063   46.682    0.000    2.819
##     speed   (.30.)    0.253    0.004   56.521    0.000    0.244
##     spatial (.31.)    0.939    0.007  132.253    0.000    0.925
##  ci.upper   Std.lv  Std.all
##                            
##     0.329    0.793    0.820
##     0.243    0.585    0.589
##     0.259    0.623    0.627
##     0.258    0.621    0.642
##     0.324    0.779    0.790
##     0.281    0.675    0.673
##     0.251    0.603    0.591
##     0.208    0.498    0.495
##     0.356    0.857    0.852
##     0.129    0.310    0.311
##     0.149    0.357    0.358
##                            
##     0.269    0.806    0.846
##     0.099    0.295    0.293
##     0.150    0.448    0.450
##     0.296    0.886    0.874
##     0.162    0.484    0.490
##                            
##     0.301    0.304    0.307
##     0.227    0.228    0.232
##     0.370    0.375    0.380
##     0.685    0.698    0.682
##     0.712    0.726    0.725
##     0.580    0.590    0.572
##                            
##     0.514    0.697    0.786
##     0.389    0.526    0.535
##     0.569    0.772    0.756
##     0.350    0.472    0.474
##     0.116    0.153    0.148
##                            
##     2.308    0.914    0.914
##     3.067    0.947    0.947
##     0.262    0.245    0.245
##     0.953    0.685    0.685
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stest1vocab       0.167    0.004   44.518    0.000    0.160
##    .Stst19dsgsdwrd   -0.119    0.004  -30.513    0.000   -0.126
##    .Stest20spellng   -0.258    0.004  -64.136    0.000   -0.265
##    .Stest21cptlztn   -0.212    0.004  -54.084    0.000   -0.220
##    .Stest22puncttn   -0.208    0.004  -52.316    0.000   -0.216
##    .Stest23english   -0.144    0.004  -35.041    0.000   -0.152
##    .Stest24exprssn   -0.118    0.004  -28.047    0.000   -0.126
##    .Stst25wrdfnctn   -0.139    0.004  -35.813    0.000   -0.147
##    .Stst26rdngcmpr   -0.032    0.004   -7.896    0.000   -0.041
##    .Stst31bstrctrs    0.055    0.004   13.853    0.000    0.047
##    .Stst32rthrsnng    0.121    0.004   30.651    0.000    0.114
##    .Stest5math        0.193    0.004   51.128    0.000    0.186
##    .Stst33hghschlm    0.117    0.004   28.152    0.000    0.109
##    .Stst34rthcmptt   -0.078    0.004  -19.713    0.000   -0.086
##    .Stst29vslztn2D    0.212    0.004   54.436    0.000    0.204
##    .Stest35tblrdng   -0.068    0.004  -16.347    0.000   -0.076
##    .Stst36clrclchc   -0.147    0.004  -37.322    0.000   -0.155
##    .Stst37bjctnspc   -0.095    0.004  -23.187    0.000   -0.103
##    .Stst28mchnclrs    0.536    0.004  151.033    0.000    0.529
##    .Stst30vslztn3D    0.190    0.004   46.616    0.000    0.182
##  ci.upper   Std.lv  Std.all
##     0.175    0.167    0.173
##    -0.111   -0.119   -0.120
##    -0.250   -0.258   -0.259
##    -0.204   -0.212   -0.220
##    -0.200   -0.208   -0.211
##    -0.136   -0.144   -0.144
##    -0.110   -0.118   -0.116
##    -0.132   -0.139   -0.138
##    -0.024   -0.032   -0.032
##     0.063    0.055    0.055
##     0.129    0.121    0.122
##     0.201    0.193    0.203
##     0.125    0.117    0.115
##    -0.070   -0.078   -0.079
##     0.219    0.212    0.216
##    -0.060   -0.068   -0.066
##    -0.140   -0.147   -0.147
##    -0.087   -0.095   -0.092
##     0.543    0.536    0.604
##     0.198    0.190    0.186
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stest1vocab       0.306    0.002  141.423    0.000    0.302
##    .Stst19dsgsdwrd    0.471    0.003  158.819    0.000    0.465
##    .Stest20spellng    0.598    0.003  171.246    0.000    0.591
##    .Stest21cptlztn    0.548    0.003  172.038    0.000    0.542
##    .Stest22puncttn    0.366    0.003  142.328    0.000    0.361
##    .Stest23english    0.551    0.004  143.194    0.000    0.543
##    .Stest24exprssn    0.676    0.004  154.639    0.000    0.667
##    .Stst25wrdfnctn    0.424    0.003  156.791    0.000    0.418
##    .Stst26rdngcmpr    0.278    0.002  123.125    0.000    0.274
##    .Stst31bstrctrs    0.492    0.003  152.626    0.000    0.486
##    .Stst32rthrsnng    0.388    0.002  157.798    0.000    0.383
##    .Stest5math        0.259    0.003   86.976    0.000    0.253
##    .Stst33hghschlm    0.243    0.002  109.082    0.000    0.239
##    .Stst34rthcmptt    0.515    0.004  141.780    0.000    0.508
##    .Stst29vslztn2D    0.596    0.004  142.099    0.000    0.588
##    .Stest35tblrdng    0.561    0.008   69.590    0.000    0.545
##    .Stst36clrclchc    0.475    0.005   86.770    0.000    0.464
##    .Stst37bjctnspc    0.662    0.005  135.532    0.000    0.652
##    .Stst28mchnclrs    0.301    0.003  110.435    0.000    0.296
##    .Stst30vslztn3D    0.447    0.004  121.608    0.000    0.440
##    .english           1.000                               1.000
##    .math              1.000                               1.000
##    .speed             1.000                               1.000
##    .spatial           1.000                               1.000
##     g                 1.000                               1.000
##  ci.upper   Std.lv  Std.all
##     0.311    0.306    0.327
##     0.477    0.471    0.478
##     0.605    0.598    0.607
##     0.554    0.548    0.587
##     0.371    0.366    0.376
##     0.558    0.551    0.547
##     0.685    0.676    0.650
##     0.429    0.424    0.418
##     0.283    0.278    0.275
##     0.499    0.492    0.495
##     0.393    0.388    0.391
##     0.265    0.259    0.285
##     0.247    0.243    0.237
##     0.522    0.515    0.528
##     0.604    0.596    0.618
##     0.576    0.561    0.535
##     0.486    0.475    0.474
##     0.671    0.662    0.622
##     0.307    0.301    0.382
##     0.454    0.447    0.429
##     1.000    0.165    0.165
##     1.000    0.104    0.104
##     1.000    0.940    0.940
##     1.000    0.531    0.531
##     1.000    1.000    1.000
## 
## 
## Group 2 [1]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english =~                                                   
##     Stst1vc (.p1.)    0.322    0.004   88.816    0.000    0.315
##     Stst19d (.p2.)    0.237    0.003   82.544    0.000    0.232
##     Stst20s (.p3.)    0.253    0.003   82.846    0.000    0.247
##     Stst21c (.p4.)    0.252    0.003   85.218    0.000    0.246
##     Stst22p (.p5.)    0.316    0.004   88.011    0.000    0.309
##     Stst23n (.p6.)    0.274    0.003   83.462    0.000    0.268
##     Stst24x (.p7.)    0.245    0.003   82.226    0.000    0.239
##     Stst25w (.p8.)    0.202    0.003   72.573    0.000    0.197
##     Stst26r (.p9.)    0.348    0.004   87.880    0.000    0.340
##     Stst31b (.10.)    0.126    0.002   69.223    0.000    0.122
##     Stst32r (.11.)    0.145    0.002   64.321    0.000    0.140
##   math =~                                                      
##     Stst5mt (.12.)    0.259    0.005   51.609    0.000    0.249
##     Stst25w (.13.)    0.095    0.002   41.453    0.000    0.090
##     Stst32r (.14.)    0.144    0.003   52.033    0.000    0.139
##     Stst33h (.15.)    0.285    0.006   50.428    0.000    0.274
##     Stst34r (.16.)    0.156    0.003   48.909    0.000    0.149
##   speed =~                                                     
##     Stst19d (.17.)    0.295    0.003  104.880    0.000    0.290
##     Sts292D (.18.)    0.221    0.003   71.609    0.000    0.215
##     Stst34r (.19.)    0.364    0.003  117.565    0.000    0.358
##     Stst35t (.20.)    0.677    0.004  156.985    0.000    0.668
##     Stst36c (.21.)    0.704    0.004  168.538    0.000    0.696
##     Stst37b (.22.)    0.572    0.004  147.412    0.000    0.564
##   spatial =~                                                   
##     Stst28m (.23.)    0.508    0.003  193.624    0.000    0.503
##     Sts292D (.24.)    0.383    0.003  137.128    0.000    0.378
##     Sts303D (.25.)    0.563    0.003  181.625    0.000    0.556
##     Stst31b (.26.)    0.344    0.003  121.094    0.000    0.339
##     Stst37b (.27.)    0.112    0.002   46.383    0.000    0.107
##   g =~                                                         
##     english (.28.)    2.251    0.029   76.962    0.000    2.193
##     math    (.29.)    2.943    0.063   46.682    0.000    2.819
##     speed   (.30.)    0.253    0.004   56.521    0.000    0.244
##     spatial (.31.)    0.939    0.007  132.253    0.000    0.925
##  ci.upper   Std.lv  Std.all
##                            
##     0.329    0.731    0.778
##     0.243    0.539    0.566
##     0.259    0.574    0.625
##     0.258    0.572    0.611
##     0.324    0.718    0.792
##     0.281    0.622    0.673
##     0.251    0.556    0.604
##     0.208    0.459    0.483
##     0.356    0.790    0.859
##     0.129    0.285    0.304
##     0.149    0.329    0.344
##                            
##     0.269    0.753    0.776
##     0.099    0.276    0.290
##     0.150    0.419    0.438
##     0.296    0.828    0.872
##     0.162    0.452    0.483
##                            
##     0.301    0.270    0.284
##     0.227    0.202    0.213
##     0.370    0.333    0.356
##     0.685    0.620    0.713
##     0.712    0.645    0.694
##     0.580    0.524    0.566
##                            
##     0.514    0.616    0.749
##     0.389    0.464    0.489
##     0.569    0.681    0.734
##     0.350    0.417    0.444
##     0.116    0.135    0.146
##                            
##     2.308    0.889    0.889
##     3.067    0.908    0.908
##     0.262    0.247    0.247
##     0.953    0.695    0.695
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stest1vocab      -0.095    0.004  -24.615    0.000   -0.103
##    .Stst19dsgsdwrd    0.150    0.004   38.967    0.000    0.142
##    .Stest20spellng    0.280    0.004   77.302    0.000    0.273
##    .Stest21cptlztn    0.276    0.004   74.784    0.000    0.268
##    .Stest22puncttn    0.278    0.004   76.957    0.000    0.271
##    .Stest23english    0.190    0.004   52.481    0.000    0.183
##    .Stest24exprssn    0.165    0.004   46.240    0.000    0.158
##    .Stst25wrdfnctn    0.196    0.004   50.126    0.000    0.189
##    .Stst26rdngcmpr    0.105    0.004   29.044    0.000    0.098
##    .Stst31bstrctrs    0.026    0.004    6.799    0.000    0.018
##    .Stst32rthrsnng   -0.040    0.004  -10.549    0.000   -0.048
##    .Stest5math       -0.155    0.004  -39.596    0.000   -0.163
##    .Stst33hghschlm   -0.072    0.004  -19.964    0.000   -0.080
##    .Stst34rthcmptt    0.165    0.004   44.491    0.000    0.158
##    .Stst29vslztn2D   -0.150    0.004  -39.724    0.000   -0.157
##    .Stest35tblrdng    0.085    0.003   24.796    0.000    0.078
##    .Stst36clrclchc    0.094    0.004   25.710    0.000    0.087
##    .Stst37bjctnspc    0.084    0.004   22.827    0.000    0.076
##    .Stst28mchnclrs   -0.428    0.003 -131.000    0.000   -0.434
##    .Stst30vslztn3D   -0.115    0.004  -31.342    0.000   -0.122
##  ci.upper   Std.lv  Std.all
##    -0.088   -0.095   -0.101
##     0.158    0.150    0.158
##     0.287    0.280    0.305
##     0.283    0.276    0.294
##     0.285    0.278    0.306
##     0.197    0.190    0.205
##     0.172    0.165    0.179
##     0.204    0.196    0.206
##     0.112    0.105    0.114
##     0.033    0.026    0.027
##    -0.033   -0.040   -0.042
##    -0.147   -0.155   -0.160
##    -0.065   -0.072   -0.076
##     0.172    0.165    0.176
##    -0.143   -0.150   -0.158
##     0.091    0.085    0.097
##     0.101    0.094    0.101
##     0.091    0.084    0.090
##    -0.422   -0.428   -0.521
##    -0.108   -0.115   -0.124
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stest1vocab       0.350    0.002  152.257    0.000    0.345
##    .Stst19dsgsdwrd    0.478    0.003  162.707    0.000    0.473
##    .Stest20spellng    0.513    0.003  173.410    0.000    0.508
##    .Stest21cptlztn    0.549    0.003  170.631    0.000    0.543
##    .Stest22puncttn    0.307    0.002  139.994    0.000    0.302
##    .Stest23english    0.469    0.003  146.080    0.000    0.462
##    .Stest24exprssn    0.539    0.004  150.854    0.000    0.532
##    .Stst25wrdfnctn    0.415    0.003  151.682    0.000    0.410
##    .Stst26rdngcmpr    0.222    0.002  118.864    0.000    0.219
##    .Stst31bstrctrs    0.480    0.003  157.168    0.000    0.474
##    .Stst32rthrsnng    0.409    0.002  165.708    0.000    0.404
##    .Stest5math        0.376    0.004  102.412    0.000    0.369
##    .Stst33hghschlm    0.215    0.002   96.113    0.000    0.211
##    .Stst34rthcmptt    0.494    0.004  135.979    0.000    0.487
##    .Stst29vslztn2D    0.612    0.004  162.490    0.000    0.605
##    .Stest35tblrdng    0.372    0.005   69.049    0.000    0.361
##    .Stst36clrclchc    0.448    0.005   96.116    0.000    0.439
##    .Stst37bjctnspc    0.539    0.004  139.952    0.000    0.532
##    .Stst28mchnclrs    0.296    0.002  122.880    0.000    0.291
##    .Stst30vslztn3D    0.398    0.003  126.596    0.000    0.392
##    .english           1.084    0.026   41.717    0.000    1.033
##    .math              1.484    0.055   26.949    0.000    1.376
##    .speed             0.789    0.010   75.861    0.000    0.768
##    .spatial           0.759    0.010   74.433    0.000    0.739
##     g                 0.803    0.006  125.385    0.000    0.790
##  ci.upper   Std.lv  Std.all
##     0.354    0.350    0.395
##     0.484    0.478    0.528
##     0.519    0.513    0.609
##     0.555    0.549    0.627
##     0.311    0.307    0.373
##     0.475    0.469    0.548
##     0.546    0.539    0.636
##     0.420    0.415    0.458
##     0.226    0.222    0.263
##     0.486    0.480    0.544
##     0.413    0.409    0.447
##     0.383    0.376    0.399
##     0.220    0.215    0.239
##     0.501    0.494    0.563
##     0.620    0.612    0.680
##     0.382    0.372    0.491
##     0.457    0.448    0.518
##     0.547    0.539    0.629
##     0.300    0.296    0.438
##     0.405    0.398    0.462
##     1.135    0.210    0.210
##     1.592    0.176    0.176
##     0.809    0.939    0.939
##     0.779    0.517    0.517
##     0.815    1.000    1.000
lavTestScore(metric, release = 1:31) 
## Warning: lavaan->lavTestScore():  
##    se is not `standard'; not implemented yet; falling back to 
##    ordinary score test
## $test
## 
## total score test:
## 
##    test       X2 df p.value
## 1 score 4481.753 31       0
## 
## $uni
## 
## univariate score tests:
## 
##      lhs op    rhs       X2 df p.value
## 1   .p1. ==  .p82.  993.106  1   0.000
## 2   .p2. ==  .p83.   74.925  1   0.000
## 3   .p3. ==  .p84.   49.907  1   0.000
## 4   .p4. ==  .p85.  132.830  1   0.000
## 5   .p5. ==  .p86.   16.297  1   0.000
## 6   .p6. ==  .p87.  248.162  1   0.000
## 7   .p7. ==  .p88.  539.406  1   0.000
## 8   .p8. ==  .p89.  820.232  1   0.000
## 9   .p9. ==  .p90.  216.989  1   0.000
## 10 .p10. ==  .p91.   99.002  1   0.000
## 11 .p11. ==  .p92.  135.475  1   0.000
## 12 .p12. ==  .p93.  360.526  1   0.000
## 13 .p13. ==  .p94.  711.081  1   0.000
## 14 .p14. ==  .p95.   25.954  1   0.000
## 15 .p15. ==  .p96. 1112.729  1   0.000
## 16 .p16. ==  .p97.   29.807  1   0.000
## 17 .p17. ==  .p98.  225.155  1   0.000
## 18 .p18. ==  .p99.    5.635  1   0.018
## 19 .p19. == .p100.    0.076  1   0.782
## 20 .p20. == .p101.  156.405  1   0.000
## 21 .p21. == .p102.    5.257  1   0.022
## 22 .p22. == .p103.    4.422  1   0.035
## 23 .p23. == .p104.    6.778  1   0.009
## 24 .p24. == .p105.   27.340  1   0.000
## 25 .p25. == .p106.    4.285  1   0.038
## 26 .p26. == .p107.   73.206  1   0.000
## 27 .p27. == .p108.    8.270  1   0.004
## 28 .p28. == .p109.   26.019  1   0.000
## 29 .p29. == .p110.  113.863  1   0.000
## 30 .p30. == .p111.    5.816  1   0.016
## 31 .p31. == .p112.   37.688  1   0.000
scalar<-cfa(chc.hof.model, data=dgroup, group="sex", meanstructure=TRUE, sampling.weights="BY_WTA", std.lv=T, group.equal=c("loadings", "intercepts"))
## Warning: lavaan->lav_model_vcov():  
##    The variance-covariance matrix of the estimated parameters (vcov) 
##    does not appear to be positive definite! The smallest eigenvalue 
##    (= 2.665942e-15) is close to zero. This may be a symptom that the 
##    model is not identified.
fitMeasures(scalar, c("chisq", "df", "pvalue", "cfi", "rmsea", "srmr", "aic", "bic"))
##       chisq          df      pvalue         cfi       rmsea        srmr 
##  163931.663     359.000       0.000       0.885       0.080       0.062 
##         aic         bic 
## 6570705.198 6571701.532
Mc(scalar)
## [1] 0.5625203
summary(scalar, standardized=T, ci=T)
## lavaan 0.6-18 ended normally after 104 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                       152
##   Number of equality constraints                    51
## 
##   Number of observations per group:                   
##     0                                            70776
##     1                                            71381
##   Sampling weights variable                     BY_WTA
## 
## Model Test User Model:
##                                                 Standard      Scaled
##   Test Statistic                              163931.663  139166.850
##   Degrees of freedom                                 359         359
##   P-value (Chi-square)                             0.000       0.000
##   Scaling correction factor                                    1.178
##     Yuan-Bentler correction (Mplus variant)                         
##   Test statistic for each group:
##     0                                         85015.943   72172.763
##     1                                         78915.719   66994.087
## 
## Parameter Estimates:
## 
##   Standard errors                             Sandwich
##   Information bread                           Observed
##   Observed information based on                Hessian
## 
## 
## Group 1 [0]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english =~                                                   
##     Stst1vc (.p1.)    0.272    0.003   79.120    0.000    0.266
##     Stst19d (.p2.)    0.217    0.003   73.384    0.000    0.212
##     Stst20s (.p3.)    0.249    0.003   73.447    0.000    0.242
##     Stst21c (.p4.)    0.247    0.003   74.988    0.000    0.240
##     Stst22p (.p5.)    0.306    0.004   76.726    0.000    0.298
##     Stst23n (.p6.)    0.260    0.004   74.032    0.000    0.253
##     Stst24x (.p7.)    0.231    0.003   73.218    0.000    0.225
##     Stst25w (.p8.)    0.252    0.003   76.303    0.000    0.246
##     Stst26r (.p9.)    0.314    0.004   77.873    0.000    0.306
##     Stst31b (.10.)    0.165    0.002   77.297    0.000    0.161
##     Stst32r (.11.)    0.092    0.002   47.316    0.000    0.088
##   math =~                                                      
##     Stst5mt (.12.)    0.254    0.005   48.474    0.000    0.244
##     Stst25w (.13.)    0.040    0.002   24.602    0.000    0.037
##     Stst32r (.14.)    0.175    0.003   51.808    0.000    0.168
##     Stst33h (.15.)    0.274    0.006   47.522    0.000    0.262
##     Stst34r (.16.)    0.140    0.003   45.809    0.000    0.134
##   speed =~                                                     
##     Stst19d (.17.)    0.282    0.003  101.940    0.000    0.277
##     Sts292D (.18.)    0.244    0.003   82.908    0.000    0.238
##     Stst34r (.19.)    0.399    0.003  133.535    0.000    0.393
##     Stst35t (.20.)    0.658    0.004  157.306    0.000    0.650
##     Stst36c (.21.)    0.688    0.004  170.789    0.000    0.680
##     Stst37b (.22.)    0.588    0.004  157.145    0.000    0.580
##   spatial =~                                                   
##     Stst28m (.23.)    0.592    0.003  209.794    0.000    0.587
##     Sts292D (.24.)    0.361    0.002  147.309    0.000    0.356
##     Sts303D (.25.)    0.448    0.003  165.695    0.000    0.443
##     Stst31b (.26.)    0.228    0.002   98.742    0.000    0.224
##     Stst37b (.27.)    0.083    0.002   41.712    0.000    0.079
##   g =~                                                         
##     english (.28.)    2.444    0.036   68.652    0.000    2.375
##     math    (.29.)    3.045    0.069   44.245    0.000    2.910
##     speed   (.30.)    0.275    0.005   60.678    0.000    0.266
##     spatial (.31.)    0.900    0.007  132.924    0.000    0.886
##  ci.upper   Std.lv  Std.all
##                            
##     0.279    0.719    0.755
##     0.223    0.574    0.581
##     0.255    0.657    0.641
##     0.253    0.652    0.658
##     0.314    0.809    0.802
##     0.267    0.686    0.679
##     0.237    0.609    0.595
##     0.258    0.666    0.655
##     0.322    0.829    0.830
##     0.169    0.436    0.440
##     0.096    0.242    0.243
##                            
##     0.265    0.815    0.847
##     0.043    0.128    0.126
##     0.182    0.561    0.562
##     0.285    0.877    0.867
##     0.146    0.449    0.451
##                            
##     0.288    0.293    0.296
##     0.249    0.253    0.259
##     0.404    0.413    0.415
##     0.667    0.683    0.672
##     0.696    0.714    0.714
##     0.595    0.610    0.590
##                            
##     0.598    0.797    0.862
##     0.366    0.486    0.497
##     0.454    0.603    0.617
##     0.233    0.307    0.310
##     0.087    0.111    0.108
##                            
##     2.514    0.926    0.926
##     3.180    0.950    0.950
##     0.284    0.265    0.265
##     0.913    0.669    0.669
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stst1vc (.57.)   -0.071    0.004  -17.474    0.000   -0.079
##    .Stst19d (.58.)   -0.148    0.003  -42.420    0.000   -0.155
##    .Stst20s (.59.)   -0.101    0.004  -27.031    0.000   -0.108
##    .Stst21c (.60.)   -0.091    0.004  -24.696    0.000   -0.098
##    .Stst22p (.61.)   -0.109    0.004  -27.641    0.000   -0.116
##    .Stst23n (.62.)   -0.103    0.004  -27.636    0.000   -0.110
##    .Stst24x (.63.)   -0.088    0.004  -24.005    0.000   -0.095
##    .Stst25w (.64.)   -0.078    0.004  -20.655    0.000   -0.085
##    .Stst26r (.65.)   -0.128    0.004  -31.912    0.000   -0.136
##    .Stst31b (.66.)    0.120    0.004   32.778    0.000    0.113
##    .Stst32r (.67.)    0.076    0.004   19.393    0.000    0.068
##    .Stst5mt (.68.)    0.145    0.004   38.060    0.000    0.138
##    .Stst33h (.69.)    0.148    0.004   36.204    0.000    0.140
##    .Stst34r (.70.)    0.029    0.004    7.802    0.000    0.022
##    .Sts292D (.71.)    0.235    0.003   69.756    0.000    0.228
##    .Stst35t (.72.)   -0.134    0.004  -34.949    0.000   -0.142
##    .Stst36c (.73.)   -0.165    0.004  -46.073    0.000   -0.172
##    .Stst37b (.74.)   -0.062    0.004  -16.624    0.000   -0.069
##    .Stst28m (.75.)    0.471    0.004  112.406    0.000    0.463
##    .Sts303D (.76.)    0.363    0.003  104.943    0.000    0.356
##  ci.upper   Std.lv  Std.all
##    -0.063   -0.071   -0.075
##    -0.141   -0.148   -0.150
##    -0.093   -0.101   -0.098
##    -0.084   -0.091   -0.092
##    -0.101   -0.109   -0.108
##    -0.095   -0.103   -0.102
##    -0.081   -0.088   -0.086
##    -0.070   -0.078   -0.076
##    -0.120   -0.128   -0.128
##     0.127    0.120    0.121
##     0.084    0.076    0.076
##     0.153    0.145    0.151
##     0.155    0.148    0.146
##     0.036    0.029    0.029
##     0.241    0.235    0.240
##    -0.127   -0.134   -0.132
##    -0.158   -0.165   -0.165
##    -0.055   -0.062   -0.060
##     0.479    0.471    0.509
##     0.369    0.363    0.371
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stest1vocab       0.390    0.003  132.453    0.000    0.384
##    .Stst19dsgsdwrd    0.479    0.003  160.900    0.000    0.473
##    .Stest20spellng    0.619    0.004  163.439    0.000    0.612
##    .Stest21cptlztn    0.556    0.003  167.267    0.000    0.550
##    .Stest22puncttn    0.362    0.003  136.094    0.000    0.357
##    .Stest23english    0.550    0.004  142.661    0.000    0.543
##    .Stest24exprssn    0.677    0.004  154.243    0.000    0.668
##    .Stst25wrdfnctn    0.422    0.003  150.747    0.000    0.416
##    .Stst26rdngcmpr    0.309    0.002  127.388    0.000    0.305
##    .Stst31bstrctrs    0.534    0.003  158.002    0.000    0.527
##    .Stst32rthrsnng    0.383    0.003  152.713    0.000    0.378
##    .Stest5math        0.263    0.003   87.375    0.000    0.257
##    .Stst33hghschlm    0.254    0.002  111.970    0.000    0.249
##    .Stst34rthcmptt    0.527    0.004  137.679    0.000    0.519
##    .Stst29vslztn2D    0.611    0.004  141.430    0.000    0.603
##    .Stest35tblrdng    0.568    0.008   74.449    0.000    0.553
##    .Stst36clrclchc    0.489    0.006   87.289    0.000    0.478
##    .Stst37bjctnspc    0.661    0.005  133.844    0.000    0.651
##    .Stst28mchnclrs    0.219    0.004   62.039    0.000    0.212
##    .Stst30vslztn3D    0.591    0.004  139.456    0.000    0.583
##    .english           1.000                               1.000
##    .math              1.000                               1.000
##    .speed             1.000                               1.000
##    .spatial           1.000                               1.000
##     g                 1.000                               1.000
##  ci.upper   Std.lv  Std.all
##     0.396    0.390    0.430
##     0.485    0.479    0.490
##     0.627    0.619    0.590
##     0.563    0.556    0.567
##     0.367    0.362    0.356
##     0.558    0.550    0.539
##     0.686    0.677    0.646
##     0.427    0.422    0.409
##     0.314    0.309    0.311
##     0.540    0.534    0.542
##     0.388    0.383    0.385
##     0.268    0.263    0.283
##     0.258    0.254    0.248
##     0.534    0.527    0.531
##     0.619    0.611    0.640
##     0.582    0.568    0.549
##     0.499    0.489    0.490
##     0.670    0.661    0.618
##     0.226    0.219    0.257
##     0.600    0.591    0.619
##     1.000    0.143    0.143
##     1.000    0.097    0.097
##     1.000    0.930    0.930
##     1.000    0.553    0.553
##     1.000    1.000    1.000
## 
## 
## Group 2 [1]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english =~                                                   
##     Stst1vc (.p1.)    0.272    0.003   79.120    0.000    0.266
##     Stst19d (.p2.)    0.217    0.003   73.384    0.000    0.212
##     Stst20s (.p3.)    0.249    0.003   73.447    0.000    0.242
##     Stst21c (.p4.)    0.247    0.003   74.988    0.000    0.240
##     Stst22p (.p5.)    0.306    0.004   76.726    0.000    0.298
##     Stst23n (.p6.)    0.260    0.004   74.032    0.000    0.253
##     Stst24x (.p7.)    0.231    0.003   73.218    0.000    0.225
##     Stst25w (.p8.)    0.252    0.003   76.303    0.000    0.246
##     Stst26r (.p9.)    0.314    0.004   77.873    0.000    0.306
##     Stst31b (.10.)    0.165    0.002   77.297    0.000    0.161
##     Stst32r (.11.)    0.092    0.002   47.316    0.000    0.088
##   math =~                                                      
##     Stst5mt (.12.)    0.254    0.005   48.474    0.000    0.244
##     Stst25w (.13.)    0.040    0.002   24.602    0.000    0.037
##     Stst32r (.14.)    0.175    0.003   51.808    0.000    0.168
##     Stst33h (.15.)    0.274    0.006   47.522    0.000    0.262
##     Stst34r (.16.)    0.140    0.003   45.809    0.000    0.134
##   speed =~                                                     
##     Stst19d (.17.)    0.282    0.003  101.940    0.000    0.277
##     Sts292D (.18.)    0.244    0.003   82.908    0.000    0.238
##     Stst34r (.19.)    0.399    0.003  133.535    0.000    0.393
##     Stst35t (.20.)    0.658    0.004  157.306    0.000    0.650
##     Stst36c (.21.)    0.688    0.004  170.789    0.000    0.680
##     Stst37b (.22.)    0.588    0.004  157.145    0.000    0.580
##   spatial =~                                                   
##     Stst28m (.23.)    0.592    0.003  209.794    0.000    0.587
##     Sts292D (.24.)    0.361    0.002  147.309    0.000    0.356
##     Sts303D (.25.)    0.448    0.003  165.695    0.000    0.443
##     Stst31b (.26.)    0.228    0.002   98.742    0.000    0.224
##     Stst37b (.27.)    0.083    0.002   41.712    0.000    0.079
##   g =~                                                         
##     english (.28.)    2.444    0.036   68.652    0.000    2.375
##     math    (.29.)    3.045    0.069   44.245    0.000    2.910
##     speed   (.30.)    0.275    0.005   60.678    0.000    0.266
##     spatial (.31.)    0.900    0.007  132.924    0.000    0.886
##  ci.upper   Std.lv  Std.all
##                            
##     0.279    0.660    0.691
##     0.223    0.527    0.556
##     0.255    0.603    0.638
##     0.253    0.598    0.624
##     0.314    0.742    0.803
##     0.267    0.629    0.677
##     0.237    0.559    0.605
##     0.258    0.611    0.636
##     0.322    0.760    0.837
##     0.169    0.400    0.427
##     0.096    0.222    0.232
##                            
##     0.265    0.758    0.774
##     0.043    0.119    0.124
##     0.182    0.522    0.544
##     0.285    0.816    0.864
##     0.146    0.417    0.443
##                            
##     0.288    0.261    0.275
##     0.249    0.225    0.238
##     0.404    0.368    0.390
##     0.667    0.608    0.703
##     0.696    0.635    0.685
##     0.595    0.543    0.585
##                            
##     0.598    0.706    0.826
##     0.366    0.430    0.455
##     0.454    0.534    0.598
##     0.233    0.272    0.290
##     0.087    0.099    0.106
##                            
##     2.514    0.902    0.902
##     3.180    0.914    0.914
##     0.284    0.266    0.266
##     0.913    0.675    0.675
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stst1vc (.57.)   -0.071    0.004  -17.474    0.000   -0.079
##    .Stst19d (.58.)   -0.148    0.003  -42.420    0.000   -0.155
##    .Stst20s (.59.)   -0.101    0.004  -27.031    0.000   -0.108
##    .Stst21c (.60.)   -0.091    0.004  -24.696    0.000   -0.098
##    .Stst22p (.61.)   -0.109    0.004  -27.641    0.000   -0.116
##    .Stst23n (.62.)   -0.103    0.004  -27.636    0.000   -0.110
##    .Stst24x (.63.)   -0.088    0.004  -24.005    0.000   -0.095
##    .Stst25w (.64.)   -0.078    0.004  -20.655    0.000   -0.085
##    .Stst26r (.65.)   -0.128    0.004  -31.912    0.000   -0.136
##    .Stst31b (.66.)    0.120    0.004   32.778    0.000    0.113
##    .Stst32r (.67.)    0.076    0.004   19.393    0.000    0.068
##    .Stst5mt (.68.)    0.145    0.004   38.060    0.000    0.138
##    .Stst33h (.69.)    0.148    0.004   36.204    0.000    0.140
##    .Stst34r (.70.)    0.029    0.004    7.802    0.000    0.022
##    .Sts292D (.71.)    0.235    0.003   69.756    0.000    0.228
##    .Stst35t (.72.)   -0.134    0.004  -34.949    0.000   -0.142
##    .Stst36c (.73.)   -0.165    0.004  -46.073    0.000   -0.172
##    .Stst37b (.74.)   -0.062    0.004  -16.624    0.000   -0.069
##    .Stst28m (.75.)    0.471    0.004  112.406    0.000    0.463
##    .Sts303D (.76.)    0.363    0.003  104.943    0.000    0.356
##    .english           1.267    0.011  114.717    0.000    1.245
##    .math             -0.557    0.009  -65.058    0.000   -0.574
##    .speed             0.431    0.007   58.673    0.000    0.417
##    .spatial          -1.299    0.011 -122.107    0.000   -1.319
##     g                -0.114    0.007  -17.449    0.000   -0.127
##  ci.upper   Std.lv  Std.all
##    -0.063   -0.071   -0.075
##    -0.141   -0.148   -0.156
##    -0.093   -0.101   -0.106
##    -0.084   -0.091   -0.095
##    -0.101   -0.109   -0.118
##    -0.095   -0.103   -0.111
##    -0.081   -0.088   -0.095
##    -0.070   -0.078   -0.081
##    -0.120   -0.128   -0.141
##     0.127    0.120    0.128
##     0.084    0.076    0.079
##     0.153    0.145    0.148
##     0.155    0.148    0.156
##     0.036    0.029    0.031
##     0.241    0.235    0.248
##    -0.127   -0.134   -0.155
##    -0.158   -0.165   -0.178
##    -0.055   -0.062   -0.067
##     0.479    0.471    0.551
##     0.369    0.363    0.406
##     1.289    0.523    0.523
##    -0.541   -0.187   -0.187
##     0.446    0.467    0.467
##    -1.278   -1.090   -1.090
##    -0.101   -0.127   -0.127
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stest1vocab       0.476    0.004  131.886    0.000    0.469
##    .Stst19dsgsdwrd    0.485    0.003  164.438    0.000    0.479
##    .Stest20spellng    0.529    0.003  169.055    0.000    0.523
##    .Stest21cptlztn    0.560    0.003  166.314    0.000    0.553
##    .Stest22puncttn    0.303    0.002  135.735    0.000    0.298
##    .Stest23english    0.468    0.003  146.298    0.000    0.462
##    .Stest24exprssn    0.540    0.004  151.537    0.000    0.533
##    .Stst25wrdfnctn    0.414    0.003  147.773    0.000    0.408
##    .Stst26rdngcmpr    0.247    0.002  119.996    0.000    0.243
##    .Stst31bstrctrs    0.513    0.003  163.971    0.000    0.507
##    .Stst32rthrsnng    0.408    0.003  158.893    0.000    0.403
##    .Stest5math        0.383    0.004  100.203    0.000    0.376
##    .Stst33hghschlm    0.227    0.002   99.964    0.000    0.222
##    .Stst34rthcmptt    0.504    0.004  133.956    0.000    0.497
##    .Stst29vslztn2D    0.624    0.004  164.217    0.000    0.617
##    .Stest35tblrdng    0.377    0.005   69.612    0.000    0.367
##    .Stst36clrclchc    0.457    0.004  103.744    0.000    0.448
##    .Stst37bjctnspc    0.538    0.004  138.659    0.000    0.530
##    .Stst28mchnclrs    0.231    0.003   75.363    0.000    0.225
##    .Stst30vslztn3D    0.513    0.003  149.852    0.000    0.506
##    .english           1.092    0.029   37.657    0.000    1.035
##    .math              1.462    0.057   25.821    0.000    1.351
##    .speed             0.792    0.010   75.996    0.000    0.772
##    .spatial           0.772    0.010   74.620    0.000    0.752
##     g                 0.800    0.006  125.357    0.000    0.788
##  ci.upper   Std.lv  Std.all
##     0.483    0.476    0.522
##     0.491    0.485    0.541
##     0.535    0.529    0.593
##     0.567    0.560    0.610
##     0.307    0.303    0.355
##     0.474    0.468    0.542
##     0.547    0.540    0.633
##     0.419    0.414    0.449
##     0.251    0.247    0.300
##     0.519    0.513    0.583
##     0.413    0.408    0.443
##     0.391    0.383    0.400
##     0.231    0.227    0.254
##     0.512    0.504    0.567
##     0.631    0.624    0.698
##     0.388    0.377    0.505
##     0.465    0.457    0.531
##     0.546    0.538    0.624
##     0.237    0.231    0.317
##     0.520    0.513    0.643
##     1.149    0.186    0.186
##     1.573    0.165    0.165
##     0.813    0.929    0.929
##     0.792    0.544    0.544
##     0.813    1.000    1.000
lavTestScore(scalar, release = 32:51) 
## Warning: lavaan->lavTestScore():  
##    se is not `standard'; not implemented yet; falling back to 
##    ordinary score test
## $test
## 
## total score test:
## 
##    test       X2 df p.value
## 1 score 71964.22 20       0
## 
## $uni
## 
## univariate score tests:
## 
##      lhs op    rhs        X2 df p.value
## 1  .p57. == .p138. 27396.393  1       0
## 2  .p58. == .p139.   315.460  1       0
## 3  .p59. == .p140.  5937.040  1       0
## 4  .p60. == .p141.  4260.986  1       0
## 5  .p61. == .p142.  4650.352  1       0
## 6  .p62. == .p143.   476.147  1       0
## 7  .p63. == .p144.   195.650  1       0
## 8  .p64. == .p145.  2558.878  1       0
## 9  .p65. == .p146.  5253.180  1       0
## 10 .p66. == .p147.  2729.921  1       0
## 11 .p67. == .p148.  1728.967  1       0
## 12 .p68. == .p149.  2400.227  1       0
## 13 .p69. == .p150.  1096.133  1       0
## 14 .p70. == .p151.  4040.069  1       0
## 15 .p71. == .p152.   226.634  1       0
## 16 .p72. == .p153.  1494.041  1       0
## 17 .p73. == .p154.   148.684  1       0
## 18 .p74. == .p155.   397.726  1       0
## 19 .p75. == .p156. 16668.585  1       0
## 20 .p76. == .p157. 11991.572  1       0
scalar2<-cfa(chc.hof.model, data=dgroup, group="sex", meanstructure=TRUE, sampling.weights="BY_WTA", std.lv=T, group.equal=c("loadings", "intercepts"), group.partial=c("Stest1vocab~1", "Stest28mechanicalreasoning~1", "Stest26readingcomprehension~1", "Stest34arithcomputation~1", "Stest33highschoolmath~1", "Stest19disguisedwords~1", "Stest29visualization2D~1"))
## Warning: lavaan->lav_model_vcov():  
##    The variance-covariance matrix of the estimated parameters (vcov) 
##    does not appear to be positive definite! The smallest eigenvalue 
##    (= 9.738754e-16) is close to zero. This may be a symptom that the 
##    model is not identified.
fitMeasures(scalar2, c("chisq", "df", "pvalue", "cfi", "rmsea", "srmr", "aic", "bic"))
##       chisq          df      pvalue         cfi       rmsea        srmr 
##   91930.232     352.000       0.000       0.936       0.061       0.048 
##         aic         bic 
## 6498717.768 6499783.154
Mc(scalar2)
## [1] 0.7246223
summary(scalar2, standardized=T, ci=T)
## lavaan 0.6-18 ended normally after 108 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                       152
##   Number of equality constraints                    44
## 
##   Number of observations per group:                   
##     0                                            70776
##     1                                            71381
##   Sampling weights variable                     BY_WTA
## 
## Model Test User Model:
##                                                Standard      Scaled
##   Test Statistic                              91930.232   77947.545
##   Degrees of freedom                                352         352
##   P-value (Chi-square)                            0.000       0.000
##   Scaling correction factor                                   1.179
##     Yuan-Bentler correction (Mplus variant)                        
##   Test statistic for each group:
##     0                                         50671.669   42964.453
##     1                                         41258.563   34983.091
## 
## Parameter Estimates:
## 
##   Standard errors                             Sandwich
##   Information bread                           Observed
##   Observed information based on                Hessian
## 
## 
## Group 1 [0]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english =~                                                   
##     Stst1vc (.p1.)    0.323    0.003   95.184    0.000    0.317
##     Stst19d (.p2.)    0.239    0.003   88.060    0.000    0.234
##     Stst20s (.p3.)    0.264    0.003   89.611    0.000    0.258
##     Stst21c (.p4.)    0.259    0.003   91.692    0.000    0.254
##     Stst22p (.p5.)    0.317    0.003   94.543    0.000    0.311
##     Stst23n (.p6.)    0.268    0.003   89.543    0.000    0.262
##     Stst24x (.p7.)    0.238    0.003   87.891    0.000    0.233
##     Stst25w (.p8.)    0.239    0.003   91.619    0.000    0.234
##     Stst26r (.p9.)    0.349    0.004   94.147    0.000    0.342
##     Stst31b (.10.)    0.120    0.002   74.741    0.000    0.117
##     Stst32r (.11.)    0.097    0.002   58.586    0.000    0.093
##   math =~                                                      
##     Stst5mt (.12.)    0.238    0.005   45.844    0.000    0.227
##     Stst25w (.13.)    0.061    0.002   38.320    0.000    0.058
##     Stst32r (.14.)    0.168    0.004   47.195    0.000    0.161
##     Stst33h (.15.)    0.261    0.006   44.773    0.000    0.250
##     Stst34r (.16.)    0.144    0.003   43.569    0.000    0.137
##   speed =~                                                     
##     Stst19d (.17.)    0.295    0.003  105.628    0.000    0.289
##     Sts292D (.18.)    0.222    0.003   71.966    0.000    0.216
##     Stst34r (.19.)    0.362    0.003  116.909    0.000    0.356
##     Stst35t (.20.)    0.667    0.004  155.688    0.000    0.659
##     Stst36c (.21.)    0.708    0.004  174.983    0.000    0.700
##     Stst37b (.22.)    0.581    0.004  153.774    0.000    0.574
##   spatial =~                                                   
##     Stst28m (.23.)    0.507    0.003  194.693    0.000    0.501
##     Sts292D (.24.)    0.381    0.003  137.697    0.000    0.376
##     Sts303D (.25.)    0.560    0.003  184.018    0.000    0.554
##     Stst31b (.26.)    0.355    0.003  140.960    0.000    0.350
##     Stst37b (.27.)    0.104    0.002   44.980    0.000    0.099
##   g =~                                                         
##     english (.28.)    2.238    0.027   82.466    0.000    2.184
##     math    (.29.)    3.227    0.077   41.903    0.000    3.076
##     speed   (.30.)    0.251    0.004   56.486    0.000    0.242
##     spatial (.31.)    0.943    0.007  134.391    0.000    0.929
##  ci.upper   Std.lv  Std.all
##                            
##     0.330    0.793    0.819
##     0.244    0.585    0.590
##     0.269    0.646    0.641
##     0.265    0.635    0.652
##     0.324    0.777    0.790
##     0.274    0.657    0.661
##     0.243    0.584    0.577
##     0.244    0.585    0.579
##     0.356    0.856    0.850
##     0.123    0.294    0.295
##     0.100    0.237    0.238
##                            
##     0.248    0.802    0.843
##     0.065    0.208    0.205
##     0.175    0.567    0.569
##     0.273    0.883    0.871
##     0.150    0.486    0.492
##                            
##     0.300    0.304    0.306
##     0.228    0.228    0.233
##     0.368    0.373    0.377
##     0.676    0.688    0.674
##     0.716    0.730    0.728
##     0.588    0.599    0.580
##                            
##     0.512    0.696    0.785
##     0.387    0.524    0.534
##     0.566    0.769    0.754
##     0.360    0.488    0.490
##     0.108    0.143    0.138
##                            
##     2.291    0.913    0.913
##     3.378    0.955    0.955
##     0.259    0.243    0.243
##     0.956    0.686    0.686
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stst1vc           0.167    0.004   44.518    0.000    0.160
##    .Stst19d          -0.119    0.004  -30.513    0.000   -0.126
##    .Stst20s (.59.)   -0.194    0.004  -53.260    0.000   -0.201
##    .Stst21c (.60.)   -0.174    0.004  -48.438    0.000   -0.182
##    .Stst22p (.61.)   -0.218    0.004  -57.136    0.000   -0.226
##    .Stst23n (.62.)   -0.194    0.004  -51.868    0.000   -0.202
##    .Stst24x (.63.)   -0.171    0.004  -45.798    0.000   -0.179
##    .Stst25w (.64.)   -0.113    0.004  -30.153    0.000   -0.121
##    .Stst26r          -0.032    0.004   -7.896    0.000   -0.041
##    .Stst31b (.66.)    0.044    0.004   11.578    0.000    0.036
##    .Stst32r (.67.)    0.095    0.004   24.212    0.000    0.087
##    .Stst5mt (.68.)    0.202    0.004   54.660    0.000    0.195
##    .Stst33h           0.117    0.004   28.152    0.000    0.109
##    .Stst34r          -0.078    0.004  -19.713    0.000   -0.086
##    .Sts292D           0.212    0.004   54.436    0.000    0.204
##    .Stst35t (.72.)   -0.102    0.004  -27.126    0.000   -0.109
##    .Stst36c (.73.)   -0.138    0.004  -37.260    0.000   -0.145
##    .Stst37b (.74.)   -0.065    0.004  -18.186    0.000   -0.072
##    .Stst28m           0.536    0.004  151.033    0.000    0.529
##    .Sts303D (.76.)    0.193    0.004   48.430    0.000    0.185
##  ci.upper   Std.lv  Std.all
##     0.175    0.167    0.173
##    -0.111   -0.119   -0.120
##    -0.187   -0.194   -0.192
##    -0.167   -0.174   -0.179
##    -0.211   -0.218   -0.222
##    -0.187   -0.194   -0.195
##    -0.164   -0.171   -0.169
##    -0.106   -0.113   -0.112
##    -0.024   -0.032   -0.032
##     0.051    0.044    0.044
##     0.103    0.095    0.095
##     0.209    0.202    0.212
##     0.125    0.117    0.115
##    -0.070   -0.078   -0.079
##     0.219    0.212    0.216
##    -0.095   -0.102   -0.100
##    -0.131   -0.138   -0.138
##    -0.058   -0.065   -0.063
##     0.543    0.536    0.604
##     0.201    0.193    0.189
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stest1vocab       0.308    0.002  141.871    0.000    0.304
##    .Stst19dsgsdwrd    0.471    0.003  158.801    0.000    0.465
##    .Stest20spellng    0.599    0.004  168.872    0.000    0.592
##    .Stest21cptlztn    0.547    0.003  171.015    0.000    0.541
##    .Stest22puncttn    0.364    0.003  142.857    0.000    0.359
##    .Stest23english    0.557    0.004  144.376    0.000    0.549
##    .Stest24exprssn    0.684    0.004  158.377    0.000    0.676
##    .Stst25wrdfnctn    0.424    0.003  155.190    0.000    0.419
##    .Stst26rdngcmpr    0.281    0.002  124.164    0.000    0.276
##    .Stst31bstrctrs    0.490    0.003  151.529    0.000    0.484
##    .Stst32rthrsnng    0.382    0.002  154.249    0.000    0.377
##    .Stest5math        0.262    0.003   87.717    0.000    0.256
##    .Stst33hghschlm    0.248    0.002  112.935    0.000    0.244
##    .Stst34rthcmptt    0.516    0.004  142.214    0.000    0.509
##    .Stst29vslztn2D    0.597    0.004  142.263    0.000    0.589
##    .Stest35tblrdng    0.569    0.008   72.247    0.000    0.553
##    .Stst36clrclchc    0.472    0.006   84.626    0.000    0.461
##    .Stst37bjctnspc    0.660    0.005  134.535    0.000    0.650
##    .Stst28mchnclrs    0.302    0.003  111.568    0.000    0.297
##    .Stst30vslztn3D    0.449    0.004  122.432    0.000    0.442
##    .english           1.000                               1.000
##    .math              1.000                               1.000
##    .speed             1.000                               1.000
##    .spatial           1.000                               1.000
##     g                 1.000                               1.000
##  ci.upper   Std.lv  Std.all
##     0.312    0.308    0.329
##     0.477    0.471    0.478
##     0.606    0.599    0.589
##     0.553    0.547    0.575
##     0.369    0.364    0.376
##     0.564    0.557    0.563
##     0.693    0.684    0.668
##     0.429    0.424    0.415
##     0.285    0.281    0.277
##     0.496    0.490    0.493
##     0.386    0.382    0.384
##     0.268    0.262    0.289
##     0.253    0.248    0.242
##     0.523    0.516    0.529
##     0.605    0.597    0.619
##     0.584    0.569    0.546
##     0.483    0.472    0.470
##     0.670    0.660    0.618
##     0.308    0.302    0.384
##     0.456    0.449    0.431
##     1.000    0.166    0.166
##     1.000    0.088    0.088
##     1.000    0.941    0.941
##     1.000    0.529    0.529
##     1.000    1.000    1.000
## 
## 
## Group 2 [1]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english =~                                                   
##     Stst1vc (.p1.)    0.323    0.003   95.184    0.000    0.317
##     Stst19d (.p2.)    0.239    0.003   88.060    0.000    0.234
##     Stst20s (.p3.)    0.264    0.003   89.611    0.000    0.258
##     Stst21c (.p4.)    0.259    0.003   91.692    0.000    0.254
##     Stst22p (.p5.)    0.317    0.003   94.543    0.000    0.311
##     Stst23n (.p6.)    0.268    0.003   89.543    0.000    0.262
##     Stst24x (.p7.)    0.238    0.003   87.891    0.000    0.233
##     Stst25w (.p8.)    0.239    0.003   91.619    0.000    0.234
##     Stst26r (.p9.)    0.349    0.004   94.147    0.000    0.342
##     Stst31b (.10.)    0.120    0.002   74.741    0.000    0.117
##     Stst32r (.11.)    0.097    0.002   58.586    0.000    0.093
##   math =~                                                      
##     Stst5mt (.12.)    0.238    0.005   45.844    0.000    0.227
##     Stst25w (.13.)    0.061    0.002   38.320    0.000    0.058
##     Stst32r (.14.)    0.168    0.004   47.195    0.000    0.161
##     Stst33h (.15.)    0.261    0.006   44.773    0.000    0.250
##     Stst34r (.16.)    0.144    0.003   43.569    0.000    0.137
##   speed =~                                                     
##     Stst19d (.17.)    0.295    0.003  105.628    0.000    0.289
##     Sts292D (.18.)    0.222    0.003   71.966    0.000    0.216
##     Stst34r (.19.)    0.362    0.003  116.909    0.000    0.356
##     Stst35t (.20.)    0.667    0.004  155.688    0.000    0.659
##     Stst36c (.21.)    0.708    0.004  174.983    0.000    0.700
##     Stst37b (.22.)    0.581    0.004  153.774    0.000    0.574
##   spatial =~                                                   
##     Stst28m (.23.)    0.507    0.003  194.693    0.000    0.501
##     Sts292D (.24.)    0.381    0.003  137.697    0.000    0.376
##     Sts303D (.25.)    0.560    0.003  184.018    0.000    0.554
##     Stst31b (.26.)    0.355    0.003  140.960    0.000    0.350
##     Stst37b (.27.)    0.104    0.002   44.980    0.000    0.099
##   g =~                                                         
##     english (.28.)    2.238    0.027   82.466    0.000    2.184
##     math    (.29.)    3.227    0.077   41.903    0.000    3.076
##     speed   (.30.)    0.251    0.004   56.486    0.000    0.242
##     spatial (.31.)    0.943    0.007  134.391    0.000    0.929
##  ci.upper   Std.lv  Std.all
##                            
##     0.330    0.730    0.777
##     0.244    0.539    0.567
##     0.269    0.595    0.639
##     0.265    0.585    0.620
##     0.324    0.716    0.792
##     0.274    0.605    0.661
##     0.243    0.538    0.590
##     0.244    0.539    0.564
##     0.356    0.788    0.857
##     0.123    0.271    0.288
##     0.100    0.218    0.228
##                            
##     0.248    0.746    0.770
##     0.065    0.193    0.202
##     0.175    0.527    0.550
##     0.273    0.821    0.865
##     0.150    0.452    0.482
##                            
##     0.300    0.271    0.284
##     0.228    0.203    0.214
##     0.368    0.332    0.354
##     0.676    0.612    0.706
##     0.716    0.650    0.698
##     0.588    0.533    0.575
##                            
##     0.512    0.615    0.749
##     0.387    0.463    0.488
##     0.566    0.680    0.733
##     0.360    0.432    0.460
##     0.108    0.126    0.136
##                            
##     2.291    0.889    0.889
##     3.378    0.921    0.921
##     0.259    0.245    0.245
##     0.956    0.696    0.696
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stst1vc          -0.609    0.005 -120.248    0.000   -0.619
##    .Stst19d          -0.322    0.005  -69.811    0.000   -0.331
##    .Stst20s (.59.)   -0.194    0.004  -53.260    0.000   -0.201
##    .Stst21c (.60.)   -0.174    0.004  -48.438    0.000   -0.182
##    .Stst22p (.61.)   -0.218    0.004  -57.136    0.000   -0.226
##    .Stst23n (.62.)   -0.194    0.004  -51.868    0.000   -0.202
##    .Stst24x (.63.)   -0.171    0.004  -45.798    0.000   -0.179
##    .Stst25w (.64.)   -0.113    0.004  -30.153    0.000   -0.121
##    .Stst26r          -0.450    0.005  -87.432    0.000   -0.460
##    .Stst31b (.66.)    0.044    0.004   11.578    0.000    0.036
##    .Stst32r (.67.)    0.095    0.004   24.212    0.000    0.087
##    .Stst5mt (.68.)    0.202    0.004   54.660    0.000    0.195
##    .Stst33h           0.334    0.005   61.175    0.000    0.323
##    .Stst34r           0.275    0.005   56.798    0.000    0.265
##    .Sts292D          -0.008    0.005   -1.682    0.093   -0.017
##    .Stst35t (.72.)   -0.102    0.004  -27.126    0.000   -0.109
##    .Stst36c (.73.)   -0.138    0.004  -37.260    0.000   -0.145
##    .Stst37b (.74.)   -0.065    0.004  -18.186    0.000   -0.072
##    .Stst28m          -0.147    0.005  -30.328    0.000   -0.156
##    .Sts303D (.76.)    0.193    0.004   48.430    0.000    0.185
##    .english           1.743    0.014  121.675    0.000    1.715
##    .math             -1.333    0.012 -114.203    0.000   -1.356
##    .speed             0.331    0.007   46.160    0.000    0.317
##    .spatial          -0.490    0.011  -45.218    0.000   -0.512
##     g                -0.069    0.009   -7.869    0.000   -0.086
##  ci.upper   Std.lv  Std.all
##    -0.599   -0.609   -0.648
##    -0.313   -0.322   -0.339
##    -0.187   -0.194   -0.208
##    -0.167   -0.174   -0.185
##    -0.211   -0.218   -0.241
##    -0.187   -0.194   -0.212
##    -0.164   -0.171   -0.188
##    -0.106   -0.113   -0.119
##    -0.440   -0.450   -0.489
##     0.051    0.044    0.046
##     0.103    0.095    0.099
##     0.209    0.202    0.208
##     0.345    0.334    0.352
##     0.284    0.275    0.294
##     0.001   -0.008   -0.008
##    -0.095   -0.102   -0.118
##    -0.131   -0.138   -0.148
##    -0.058   -0.065   -0.070
##    -0.137   -0.147   -0.179
##     0.201    0.193    0.208
##     1.771    0.772    0.772
##    -1.311   -0.424   -0.424
##     0.345    0.361    0.361
##    -0.469   -0.404   -0.404
##    -0.052   -0.077   -0.077
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stest1vocab       0.351    0.002  152.378    0.000    0.346
##    .Stst19dsgsdwrd    0.478    0.003  162.898    0.000    0.472
##    .Stest20spellng    0.515    0.003  172.089    0.000    0.509
##    .Stest21cptlztn    0.549    0.003  169.698    0.000    0.543
##    .Stest22puncttn    0.305    0.002  139.663    0.000    0.301
##    .Stest23english    0.472    0.003  145.240    0.000    0.465
##    .Stest24exprssn    0.542    0.004  149.194    0.000    0.535
##    .Stst25wrdfnctn    0.415    0.003  150.642    0.000    0.409
##    .Stst26rdngcmpr    0.225    0.002  119.700    0.000    0.221
##    .Stst31bstrctrs    0.479    0.003  157.650    0.000    0.473
##    .Stst32rthrsnng    0.405    0.003  160.858    0.000    0.401
##    .Stest5math        0.381    0.004  104.293    0.000    0.374
##    .Stst33hghschlm    0.226    0.002  102.492    0.000    0.222
##    .Stst34rthcmptt    0.495    0.004  136.193    0.000    0.487
##    .Stst29vslztn2D    0.613    0.004  162.669    0.000    0.605
##    .Stest35tblrdng    0.377    0.005   69.003    0.000    0.367
##    .Stst36clrclchc    0.445    0.005   98.344    0.000    0.436
##    .Stst37bjctnspc    0.537    0.004  139.336    0.000    0.530
##    .Stst28mchnclrs    0.297    0.002  123.818    0.000    0.292
##    .Stst30vslztn3D    0.400    0.003  127.849    0.000    0.393
##    .english           1.068    0.025   43.590    0.000    1.020
##    .math              1.489    0.063   23.622    0.000    1.366
##    .speed             0.791    0.010   76.015    0.000    0.771
##    .spatial           0.761    0.010   74.526    0.000    0.741
##     g                 0.805    0.006  126.329    0.000    0.792
##  ci.upper   Std.lv  Std.all
##     0.355    0.351    0.397
##     0.484    0.478    0.528
##     0.521    0.515    0.592
##     0.556    0.549    0.616
##     0.310    0.305    0.373
##     0.478    0.472    0.563
##     0.549    0.542    0.652
##     0.420    0.415    0.454
##     0.228    0.225    0.265
##     0.484    0.479    0.542
##     0.410    0.405    0.441
##     0.389    0.381    0.406
##     0.230    0.226    0.251
##     0.502    0.495    0.564
##     0.620    0.613    0.680
##     0.388    0.377    0.502
##     0.454    0.445    0.513
##     0.545    0.537    0.625
##     0.301    0.297    0.439
##     0.406    0.400    0.463
##     1.117    0.210    0.210
##     1.613    0.151    0.151
##     0.811    0.940    0.940
##     0.781    0.516    0.516
##     0.817    1.000    1.000
lavTestScore(scalar2, release = 32:44) 
## Warning: lavaan->lavTestScore():  
##    se is not `standard'; not implemented yet; falling back to 
##    ordinary score test
## $test
## 
## total score test:
## 
##    test       X2 df p.value
## 1 score 4915.808 13       0
## 
## $uni
## 
## univariate score tests:
## 
##      lhs op    rhs       X2 df p.value
## 1  .p59. == .p140. 1190.147  1       0
## 2  .p60. == .p141.  486.696  1       0
## 3  .p61. == .p142.   61.348  1       0
## 4  .p62. == .p143.  792.679  1       0
## 5  .p63. == .p144.  665.003  1       0
## 6  .p64. == .p145.  776.825  1       0
## 7  .p66. == .p147.   78.169  1       0
## 8  .p67. == .p148. 1084.094  1       0
## 9  .p68. == .p149.  470.245  1       0
## 10 .p72. == .p153.  407.627  1       0
## 11 .p73. == .p154.   49.995  1       0
## 12 .p74. == .p155.  245.356  1       0
## 13 .p76. == .p157.   13.836  1       0
strict<-cfa(chc.hof.model, data=dgroup, group="sex", meanstructure=TRUE, sampling.weights="BY_WTA", std.lv=T, group.equal=c("loadings", "intercepts", "residuals"), group.partial=c("Stest1vocab~1", "Stest28mechanicalreasoning~1", "Stest26readingcomprehension~1", "Stest34arithcomputation~1", "Stest33highschoolmath~1", "Stest19disguisedwords~1", "Stest29visualization2D~1"))
## Warning: lavaan->lav_model_vcov():  
##    The variance-covariance matrix of the estimated parameters (vcov) 
##    does not appear to be positive definite! The smallest eigenvalue 
##    (= 5.401808e-15) is close to zero. This may be a symptom that the 
##    model is not identified.
fitMeasures(strict, c("chisq", "df", "pvalue", "cfi", "rmsea", "srmr", "aic", "bic"))
##       chisq          df      pvalue         cfi       rmsea        srmr 
##   99208.213     372.000       0.000       0.930       0.061       0.050 
##         aic         bic 
## 6505955.749 6506823.842
Mc(strict)
## [1] 0.7063581
chc.hof<-cfa(chc.hof.model, data=dgroup, group="sex", meanstructure=TRUE, sampling.weights="BY_WTA", std.lv=T, group.equal=c("loadings", "intercepts", "lv.variances"), group.partial=c("Stest1vocab~1", "Stest28mechanicalreasoning~1", "Stest26readingcomprehension~1", "Stest34arithcomputation~1", "Stest33highschoolmath~1", "Stest19disguisedwords~1", "Stest29visualization2D~1"))
## Warning: lavaan->lav_model_vcov():  
##    The variance-covariance matrix of the estimated parameters (vcov) 
##    does not appear to be positive definite! The smallest eigenvalue 
##    (= 1.518892e-16) is close to zero. This may be a symptom that the 
##    model is not identified.
fitMeasures(chc.hof, c("chisq", "df", "pvalue", "cfi", "rmsea", "srmr", "aic", "bic"))
##       chisq          df      pvalue         cfi       rmsea        srmr 
##   93589.101     357.000       0.000       0.934       0.061       0.060 
##         aic         bic 
## 6500366.636 6501382.699
Mc(chc.hof)
## [1] 0.7204194
summary(chc.hof, standardized=T, ci=T)
## lavaan 0.6-18 ended normally after 72 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                       147
##   Number of equality constraints                    44
## 
##   Number of observations per group:                   
##     0                                            70776
##     1                                            71381
##   Sampling weights variable                     BY_WTA
## 
## Model Test User Model:
##                                                Standard      Scaled
##   Test Statistic                              93589.101   79368.082
##   Degrees of freedom                                357         357
##   P-value (Chi-square)                            0.000       0.000
##   Scaling correction factor                                   1.179
##     Yuan-Bentler correction (Mplus variant)                        
##   Test statistic for each group:
##     0                                         51534.698   43703.915
##     1                                         42054.403   35664.167
## 
## Parameter Estimates:
## 
##   Standard errors                             Sandwich
##   Information bread                           Observed
##   Observed information based on                Hessian
## 
## 
## Group 1 [0]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english =~                                                   
##     Stst1vc (.p1.)    0.328    0.003  125.191    0.000    0.323
##     Stst19d (.p2.)    0.242    0.002  110.659    0.000    0.238
##     Stst20s (.p3.)    0.267    0.002  115.362    0.000    0.263
##     Stst21c (.p4.)    0.263    0.002  118.777    0.000    0.259
##     Stst22p (.p5.)    0.321    0.003  124.649    0.000    0.316
##     Stst23n (.p6.)    0.272    0.002  115.430    0.000    0.267
##     Stst24x (.p7.)    0.241    0.002  111.911    0.000    0.237
##     Stst25w (.p8.)    0.242    0.002  111.672    0.000    0.238
##     Stst26r (.p9.)    0.354    0.003  124.633    0.000    0.348
##     Stst31b (.10.)    0.121    0.001   84.402    0.000    0.118
##     Stst32r (.11.)    0.097    0.002   61.098    0.000    0.094
##   math =~                                                      
##     Stst5mt (.12.)    0.264    0.004   69.759    0.000    0.257
##     Stst25w (.13.)    0.069    0.001   48.449    0.000    0.066
##     Stst32r (.14.)    0.188    0.002   75.489    0.000    0.183
##     Stst33h (.15.)    0.291    0.004   67.640    0.000    0.282
##     Stst34r (.16.)    0.160    0.002   64.589    0.000    0.155
##   speed =~                                                     
##     Stst19d (.17.)    0.281    0.003  108.632    0.000    0.276
##     Sts292D (.18.)    0.210    0.003   73.262    0.000    0.204
##     Stst34r (.19.)    0.342    0.003  125.694    0.000    0.336
##     Stst35t (.20.)    0.626    0.003  187.862    0.000    0.619
##     Stst36c (.21.)    0.670    0.003  201.597    0.000    0.663
##     Stst37b (.22.)    0.548    0.003  174.834    0.000    0.542
##   spatial =~                                                   
##     Stst28m (.23.)    0.475    0.002  241.475    0.000    0.471
##     Sts292D (.24.)    0.358    0.002  151.817    0.000    0.353
##     Sts303D (.25.)    0.524    0.002  221.691    0.000    0.519
##     Stst31b (.26.)    0.334    0.002  153.538    0.000    0.329
##     Stst37b (.27.)    0.097    0.002   45.612    0.000    0.093
##   g =~                                                         
##     english (.28.)    2.098    0.020  102.800    0.000    2.058
##     math    (.29.)    2.753    0.045   61.558    0.000    2.665
##     speed   (.30.)    0.250    0.004   56.694    0.000    0.242
##     spatial (.31.)    0.955    0.006  151.405    0.000    0.942
##  ci.upper   Std.lv  Std.all
##                            
##     0.333    0.763    0.809
##     0.246    0.563    0.580
##     0.272    0.621    0.626
##     0.267    0.611    0.637
##     0.327    0.747    0.778
##     0.276    0.632    0.646
##     0.246    0.561    0.561
##     0.246    0.562    0.570
##     0.359    0.823    0.841
##     0.124    0.282    0.290
##     0.100    0.226    0.232
##                            
##     0.272    0.774    0.835
##     0.072    0.201    0.204
##     0.193    0.550    0.566
##     0.299    0.852    0.865
##     0.165    0.469    0.485
##                            
##     0.286    0.289    0.298
##     0.215    0.216    0.224
##     0.347    0.352    0.364
##     0.633    0.645    0.648
##     0.676    0.691    0.707
##     0.554    0.565    0.557
##                            
##     0.478    0.656    0.764
##     0.362    0.495    0.514
##     0.529    0.724    0.731
##     0.338    0.461    0.475
##     0.102    0.135    0.133
##                            
##     2.138    0.903    0.903
##     2.841    0.940    0.940
##     0.259    0.243    0.243
##     0.967    0.690    0.690
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stst1vc           0.167    0.004   44.519    0.000    0.160
##    .Stst19d          -0.119    0.004  -30.513    0.000   -0.126
##    .Stst20s (.59.)   -0.194    0.004  -53.349    0.000   -0.201
##    .Stst21c (.60.)   -0.175    0.004  -48.504    0.000   -0.182
##    .Stst22p (.61.)   -0.218    0.004  -57.222    0.000   -0.226
##    .Stst23n (.62.)   -0.194    0.004  -51.935    0.000   -0.202
##    .Stst24x (.63.)   -0.171    0.004  -45.848    0.000   -0.179
##    .Stst25w (.64.)   -0.113    0.004  -30.068    0.000   -0.120
##    .Stst26r          -0.032    0.004   -7.896    0.000   -0.041
##    .Stst31b (.66.)    0.044    0.004   11.657    0.000    0.037
##    .Stst32r (.67.)    0.096    0.004   24.423    0.000    0.088
##    .Stst5mt (.68.)    0.201    0.004   54.589    0.000    0.194
##    .Stst33h           0.117    0.004   28.152    0.000    0.109
##    .Stst34r          -0.078    0.004  -19.713    0.000   -0.086
##    .Sts292D           0.212    0.004   54.436    0.000    0.204
##    .Stst35t (.72.)   -0.102    0.004  -27.155    0.000   -0.109
##    .Stst36c (.73.)   -0.138    0.004  -37.329    0.000   -0.146
##    .Stst37b (.74.)   -0.065    0.004  -18.173    0.000   -0.072
##    .Stst28m           0.536    0.004  151.033    0.000    0.529
##    .Sts303D (.76.)    0.193    0.004   48.414    0.000    0.185
##  ci.upper   Std.lv  Std.all
##     0.175    0.167    0.177
##    -0.111   -0.119   -0.122
##    -0.187   -0.194   -0.196
##    -0.168   -0.175   -0.182
##    -0.211   -0.218   -0.227
##    -0.187   -0.194   -0.199
##    -0.164   -0.171   -0.171
##    -0.106   -0.113   -0.115
##    -0.024   -0.032   -0.033
##     0.051    0.044    0.045
##     0.104    0.096    0.099
##     0.209    0.201    0.217
##     0.125    0.117    0.119
##    -0.070   -0.078   -0.081
##     0.219    0.212    0.220
##    -0.095   -0.102   -0.102
##    -0.131   -0.138   -0.142
##    -0.058   -0.065   -0.064
##     0.543    0.536    0.624
##     0.201    0.193    0.195
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stest1vocab       0.307    0.002  141.550    0.000    0.303
##    .Stst19dsgsdwrd    0.469    0.003  158.870    0.000    0.464
##    .Stest20spellng    0.599    0.004  168.990    0.000    0.592
##    .Stest21cptlztn    0.547    0.003  171.106    0.000    0.541
##    .Stest22puncttn    0.365    0.003  142.769    0.000    0.360
##    .Stest23english    0.556    0.004  144.116    0.000    0.549
##    .Stest24exprssn    0.684    0.004  158.238    0.000    0.675
##    .Stst25wrdfnctn    0.424    0.003  155.360    0.000    0.419
##    .Stst26rdngcmpr    0.280    0.002  124.195    0.000    0.276
##    .Stst31bstrctrs    0.491    0.003  151.535    0.000    0.484
##    .Stst32rthrsnng    0.381    0.002  154.277    0.000    0.376
##    .Stest5math        0.261    0.003   87.055    0.000    0.256
##    .Stst33hghschlm    0.245    0.002  114.509    0.000    0.241
##    .Stst34rthcmptt    0.517    0.004  142.242    0.000    0.510
##    .Stst29vslztn2D    0.600    0.004  143.260    0.000    0.592
##    .Stest35tblrdng    0.576    0.008   72.527    0.000    0.560
##    .Stst36clrclchc    0.478    0.006   85.747    0.000    0.467
##    .Stst37bjctnspc    0.665    0.005  135.642    0.000    0.655
##    .Stst28mchnclrs    0.307    0.003  114.882    0.000    0.301
##    .Stst30vslztn3D    0.456    0.004  126.529    0.000    0.449
##    .english           1.000                               1.000
##    .math              1.000                               1.000
##    .speed             1.000                               1.000
##    .spatial           1.000                               1.000
##     g                 1.000                               1.000
##  ci.upper   Std.lv  Std.all
##     0.312    0.307    0.346
##     0.475    0.469    0.499
##     0.606    0.599    0.608
##     0.553    0.547    0.594
##     0.370    0.365    0.395
##     0.564    0.556    0.582
##     0.692    0.684    0.685
##     0.430    0.424    0.436
##     0.284    0.280    0.293
##     0.497    0.491    0.519
##     0.386    0.381    0.403
##     0.267    0.261    0.304
##     0.249    0.245    0.252
##     0.524    0.517    0.552
##     0.608    0.600    0.647
##     0.591    0.576    0.580
##     0.489    0.478    0.501
##     0.674    0.665    0.647
##     0.312    0.307    0.416
##     0.464    0.456    0.465
##     1.000    0.185    0.185
##     1.000    0.117    0.117
##     1.000    0.941    0.941
##     1.000    0.523    0.523
##     1.000    1.000    1.000
## 
## 
## Group 2 [1]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english =~                                                   
##     Stst1vc (.p1.)    0.328    0.003  125.191    0.000    0.323
##     Stst19d (.p2.)    0.242    0.002  110.659    0.000    0.238
##     Stst20s (.p3.)    0.267    0.002  115.362    0.000    0.263
##     Stst21c (.p4.)    0.263    0.002  118.777    0.000    0.259
##     Stst22p (.p5.)    0.321    0.003  124.649    0.000    0.316
##     Stst23n (.p6.)    0.272    0.002  115.430    0.000    0.267
##     Stst24x (.p7.)    0.241    0.002  111.911    0.000    0.237
##     Stst25w (.p8.)    0.242    0.002  111.672    0.000    0.238
##     Stst26r (.p9.)    0.354    0.003  124.633    0.000    0.348
##     Stst31b (.10.)    0.121    0.001   84.402    0.000    0.118
##     Stst32r (.11.)    0.097    0.002   61.098    0.000    0.094
##   math =~                                                      
##     Stst5mt (.12.)    0.264    0.004   69.759    0.000    0.257
##     Stst25w (.13.)    0.069    0.001   48.449    0.000    0.066
##     Stst32r (.14.)    0.188    0.002   75.489    0.000    0.183
##     Stst33h (.15.)    0.291    0.004   67.640    0.000    0.282
##     Stst34r (.16.)    0.160    0.002   64.589    0.000    0.155
##   speed =~                                                     
##     Stst19d (.17.)    0.281    0.003  108.632    0.000    0.276
##     Sts292D (.18.)    0.210    0.003   73.262    0.000    0.204
##     Stst34r (.19.)    0.342    0.003  125.694    0.000    0.336
##     Stst35t (.20.)    0.626    0.003  187.862    0.000    0.619
##     Stst36c (.21.)    0.670    0.003  201.597    0.000    0.663
##     Stst37b (.22.)    0.548    0.003  174.834    0.000    0.542
##   spatial =~                                                   
##     Stst28m (.23.)    0.475    0.002  241.475    0.000    0.471
##     Sts292D (.24.)    0.358    0.002  151.817    0.000    0.353
##     Sts303D (.25.)    0.524    0.002  221.691    0.000    0.519
##     Stst31b (.26.)    0.334    0.002  153.538    0.000    0.329
##     Stst37b (.27.)    0.097    0.002   45.612    0.000    0.093
##   g =~                                                         
##     english (.28.)    2.098    0.020  102.800    0.000    2.058
##     math    (.29.)    2.753    0.045   61.558    0.000    2.665
##     speed   (.30.)    0.250    0.004   56.694    0.000    0.242
##     spatial (.31.)    0.955    0.006  151.405    0.000    0.942
##  ci.upper   Std.lv  Std.all
##                            
##     0.333    0.763    0.790
##     0.246    0.563    0.578
##     0.272    0.621    0.654
##     0.267    0.611    0.636
##     0.327    0.747    0.804
##     0.276    0.632    0.677
##     0.246    0.561    0.606
##     0.246    0.562    0.573
##     0.359    0.823    0.866
##     0.124    0.282    0.292
##     0.100    0.226    0.229
##                            
##     0.272    0.774    0.781
##     0.072    0.201    0.205
##     0.193    0.550    0.559
##     0.299    0.852    0.870
##     0.165    0.469    0.491
##                            
##     0.286    0.289    0.297
##     0.215    0.216    0.223
##     0.347    0.352    0.368
##     0.633    0.645    0.724
##     0.676    0.691    0.722
##     0.554    0.565    0.597
##                            
##     0.478    0.656    0.771
##     0.362    0.495    0.511
##     0.529    0.724    0.756
##     0.338    0.461    0.478
##     0.102    0.135    0.142
##                            
##     2.138    0.903    0.903
##     2.841    0.940    0.940
##     0.259    0.243    0.243
##     0.967    0.690    0.690
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stst1vc          -0.610    0.005 -120.199    0.000   -0.620
##    .Stst19d          -0.324    0.005  -69.953    0.000   -0.333
##    .Stst20s (.59.)   -0.194    0.004  -53.349    0.000   -0.201
##    .Stst21c (.60.)   -0.175    0.004  -48.504    0.000   -0.182
##    .Stst22p (.61.)   -0.218    0.004  -57.222    0.000   -0.226
##    .Stst23n (.62.)   -0.194    0.004  -51.935    0.000   -0.202
##    .Stst24x (.63.)   -0.171    0.004  -45.848    0.000   -0.179
##    .Stst25w (.64.)   -0.113    0.004  -30.068    0.000   -0.120
##    .Stst26r          -0.450    0.005  -87.594    0.000   -0.460
##    .Stst31b (.66.)    0.044    0.004   11.657    0.000    0.037
##    .Stst32r (.67.)    0.096    0.004   24.423    0.000    0.088
##    .Stst5mt (.68.)    0.201    0.004   54.589    0.000    0.194
##    .Stst33h           0.333    0.005   61.123    0.000    0.322
##    .Stst34r           0.274    0.005   56.722    0.000    0.265
##    .Sts292D          -0.008    0.005   -1.682    0.093   -0.017
##    .Stst35t (.72.)   -0.102    0.004  -27.155    0.000   -0.109
##    .Stst36c (.73.)   -0.138    0.004  -37.329    0.000   -0.146
##    .Stst37b (.74.)   -0.065    0.004  -18.173    0.000   -0.072
##    .Stst28m          -0.147    0.005  -30.302    0.000   -0.156
##    .Sts303D (.76.)    0.193    0.004   48.414    0.000    0.185
##    .english           1.675    0.011  153.280    0.000    1.653
##    .math             -1.255    0.009 -137.898    0.000   -1.272
##    .speed             0.346    0.007   49.480    0.000    0.333
##    .spatial          -0.545    0.010  -54.549    0.000   -0.564
##     g                -0.050    0.008   -6.554    0.000   -0.065
##  ci.upper   Std.lv  Std.all
##    -0.600   -0.610   -0.632
##    -0.315   -0.324   -0.332
##    -0.187   -0.194   -0.204
##    -0.168   -0.175   -0.182
##    -0.211   -0.218   -0.235
##    -0.187   -0.194   -0.208
##    -0.164   -0.171   -0.185
##    -0.106   -0.113   -0.115
##    -0.440   -0.450   -0.474
##     0.051    0.044    0.046
##     0.104    0.096    0.098
##     0.209    0.201    0.203
##     0.343    0.333    0.340
##     0.283    0.274    0.287
##     0.001   -0.008   -0.008
##    -0.095   -0.102   -0.114
##    -0.131   -0.138   -0.145
##    -0.058   -0.065   -0.069
##    -0.137   -0.147   -0.173
##     0.201    0.193    0.201
##     1.696    0.721    0.721
##    -1.237   -0.428   -0.428
##     0.360    0.336    0.336
##    -0.525   -0.394   -0.394
##    -0.035   -0.050   -0.050
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stest1vocab       0.350    0.002  152.770    0.000    0.346
##    .Stst19dsgsdwrd    0.477    0.003  162.773    0.000    0.471
##    .Stest20spellng    0.515    0.003  172.189    0.000    0.509
##    .Stest21cptlztn    0.550    0.003  169.793    0.000    0.543
##    .Stest22puncttn    0.305    0.002  139.870    0.000    0.301
##    .Stest23english    0.472    0.003  145.294    0.000    0.466
##    .Stest24exprssn    0.543    0.004  149.308    0.000    0.536
##    .Stst25wrdfnctn    0.414    0.003  150.622    0.000    0.409
##    .Stst26rdngcmpr    0.225    0.002  120.327    0.000    0.222
##    .Stst31bstrctrs    0.477    0.003  157.466    0.000    0.471
##    .Stst32rthrsnng    0.404    0.003  161.123    0.000    0.399
##    .Stest5math        0.382    0.004  104.604    0.000    0.375
##    .Stst33hghschlm    0.233    0.002  109.601    0.000    0.229
##    .Stst34rthcmptt    0.494    0.004  136.077    0.000    0.487
##    .Stst29vslztn2D    0.609    0.004  162.053    0.000    0.602
##    .Stest35tblrdng    0.377    0.005   69.336    0.000    0.367
##    .Stst36clrclchc    0.437    0.004   97.603    0.000    0.429
##    .Stst37bjctnspc    0.534    0.004  138.815    0.000    0.527
##    .Stst28mchnclrs    0.293    0.002  121.446    0.000    0.288
##    .Stst30vslztn3D    0.394    0.003  126.284    0.000    0.388
##    .english           1.000                               1.000
##    .math              1.000                               1.000
##    .speed             1.000                               1.000
##    .spatial           1.000                               1.000
##     g                 1.000                               1.000
##  ci.upper   Std.lv  Std.all
##     0.355    0.350    0.376
##     0.483    0.477    0.503
##     0.521    0.515    0.572
##     0.556    0.550    0.596
##     0.309    0.305    0.353
##     0.478    0.472    0.542
##     0.550    0.543    0.633
##     0.420    0.414    0.430
##     0.229    0.225    0.250
##     0.483    0.477    0.512
##     0.409    0.404    0.417
##     0.390    0.382    0.389
##     0.237    0.233    0.243
##     0.501    0.494    0.541
##     0.617    0.609    0.651
##     0.388    0.377    0.475
##     0.446    0.437    0.478
##     0.542    0.534    0.595
##     0.298    0.293    0.405
##     0.400    0.394    0.429
##     1.000    0.185    0.185
##     1.000    0.117    0.117
##     1.000    0.941    0.941
##     1.000    0.523    0.523
##     1.000    1.000    1.000
standardizedSolution(chc.hof) # get the correct SEs for standardized solution
##                            lhs op                         rhs group
## 1                      english =~                 Stest1vocab     1
## 2                      english =~       Stest19disguisedwords     1
## 3                      english =~             Stest20spelling     1
## 4                      english =~       Stest21capitalization     1
## 5                      english =~          Stest22punctuation     1
## 6                      english =~              Stest23english     1
## 7                      english =~           Stest24expression     1
## 8                      english =~        Stest25wordfunctions     1
## 9                      english =~ Stest26readingcomprehension     1
## 10                     english =~    Stest31abstractreasoning     1
## 11                     english =~       Stest32arithreasoning     1
## 12                        math =~                  Stest5math     1
## 13                        math =~        Stest25wordfunctions     1
## 14                        math =~       Stest32arithreasoning     1
## 15                        math =~       Stest33highschoolmath     1
## 16                        math =~     Stest34arithcomputation     1
## 17                       speed =~       Stest19disguisedwords     1
## 18                       speed =~      Stest29visualization2D     1
## 19                       speed =~     Stest34arithcomputation     1
## 20                       speed =~         Stest35tablereading     1
## 21                       speed =~     Stest36clericalchecking     1
## 22                       speed =~     Stest37objectinspection     1
## 23                     spatial =~  Stest28mechanicalreasoning     1
## 24                     spatial =~      Stest29visualization2D     1
## 25                     spatial =~      Stest30visualization3D     1
## 26                     spatial =~    Stest31abstractreasoning     1
## 27                     spatial =~     Stest37objectinspection     1
## 28                           g =~                     english     1
## 29                           g =~                        math     1
## 30                           g =~                       speed     1
## 31                           g =~                     spatial     1
## 32                 Stest1vocab ~~                 Stest1vocab     1
## 33       Stest19disguisedwords ~~       Stest19disguisedwords     1
## 34             Stest20spelling ~~             Stest20spelling     1
## 35       Stest21capitalization ~~       Stest21capitalization     1
## 36          Stest22punctuation ~~          Stest22punctuation     1
## 37              Stest23english ~~              Stest23english     1
## 38           Stest24expression ~~           Stest24expression     1
## 39        Stest25wordfunctions ~~        Stest25wordfunctions     1
## 40 Stest26readingcomprehension ~~ Stest26readingcomprehension     1
## 41    Stest31abstractreasoning ~~    Stest31abstractreasoning     1
## 42       Stest32arithreasoning ~~       Stest32arithreasoning     1
## 43                  Stest5math ~~                  Stest5math     1
## 44       Stest33highschoolmath ~~       Stest33highschoolmath     1
## 45     Stest34arithcomputation ~~     Stest34arithcomputation     1
## 46      Stest29visualization2D ~~      Stest29visualization2D     1
## 47         Stest35tablereading ~~         Stest35tablereading     1
## 48     Stest36clericalchecking ~~     Stest36clericalchecking     1
## 49     Stest37objectinspection ~~     Stest37objectinspection     1
## 50  Stest28mechanicalreasoning ~~  Stest28mechanicalreasoning     1
## 51      Stest30visualization3D ~~      Stest30visualization3D     1
## 52                     english ~~                     english     1
## 53                        math ~~                        math     1
## 54                       speed ~~                       speed     1
## 55                     spatial ~~                     spatial     1
## 56                           g ~~                           g     1
## 57                 Stest1vocab ~1                                 1
## 58       Stest19disguisedwords ~1                                 1
## 59             Stest20spelling ~1                                 1
## 60       Stest21capitalization ~1                                 1
## 61          Stest22punctuation ~1                                 1
## 62              Stest23english ~1                                 1
## 63           Stest24expression ~1                                 1
## 64        Stest25wordfunctions ~1                                 1
## 65 Stest26readingcomprehension ~1                                 1
## 66    Stest31abstractreasoning ~1                                 1
## 67       Stest32arithreasoning ~1                                 1
## 68                  Stest5math ~1                                 1
## 69       Stest33highschoolmath ~1                                 1
## 70     Stest34arithcomputation ~1                                 1
## 71      Stest29visualization2D ~1                                 1
## 72         Stest35tablereading ~1                                 1
## 73     Stest36clericalchecking ~1                                 1
## 74     Stest37objectinspection ~1                                 1
## 75  Stest28mechanicalreasoning ~1                                 1
## 76      Stest30visualization3D ~1                                 1
## 77                     english ~1                                 1
## 78                        math ~1                                 1
## 79                       speed ~1                                 1
## 80                     spatial ~1                                 1
## 81                           g ~1                                 1
## 82                     english =~                 Stest1vocab     2
## 83                     english =~       Stest19disguisedwords     2
## 84                     english =~             Stest20spelling     2
## 85                     english =~       Stest21capitalization     2
## 86                     english =~          Stest22punctuation     2
## 87                     english =~              Stest23english     2
## 88                     english =~           Stest24expression     2
## 89                     english =~        Stest25wordfunctions     2
## 90                     english =~ Stest26readingcomprehension     2
##    label est.std    se       z pvalue ci.lower ci.upper
## 1   .p1.   0.809 0.001 608.981      0    0.806    0.811
## 2   .p2.   0.580 0.002 272.763      0    0.576    0.584
## 3   .p3.   0.626 0.002 319.703      0    0.622    0.630
## 4   .p4.   0.637 0.002 314.222      0    0.633    0.641
## 5   .p5.   0.778 0.001 523.622      0    0.775    0.781
## 6   .p6.   0.646 0.002 317.832      0    0.642    0.650
## 7   .p7.   0.561 0.002 254.987      0    0.557    0.566
## 8   .p8.   0.570 0.003 195.364      0    0.564    0.575
## 9   .p9.   0.841 0.001 665.016      0    0.839    0.844
## 10 .p10.   0.290 0.003 106.875      0    0.284    0.295
## 11 .p11.   0.232 0.003  66.552      0    0.225    0.239
## 12 .p12.   0.835 0.001 577.183      0    0.832    0.837
## 13 .p13.   0.204 0.003  65.158      0    0.198    0.210
## 14 .p14.   0.566 0.003 162.885      0    0.559    0.573
## 15 .p15.   0.865 0.001 688.781      0    0.862    0.867
## 16 .p16.   0.485 0.002 198.155      0    0.480    0.490
## 17 .p17.   0.298 0.003 112.084      0    0.293    0.304
## 18 .p18.   0.224 0.003  72.996      0    0.218    0.230
## 19 .p19.   0.364 0.003 130.393      0    0.358    0.369
## 20 .p20.   0.648 0.004 180.849      0    0.641    0.655
## 21 .p21.   0.707 0.003 227.070      0    0.701    0.713
## 22 .p22.   0.557 0.003 192.411      0    0.552    0.563
## 23 .p23.   0.764 0.002 370.108      0    0.760    0.768
## 24 .p24.   0.514 0.003 194.152      0    0.509    0.519
## 25 .p25.   0.731 0.002 348.448      0    0.727    0.735
## 26 .p26.   0.475 0.003 163.490      0    0.469    0.480
## 27 .p27.   0.133 0.003  48.192      0    0.127    0.138
## 28 .p28.   0.903 0.002 555.320      0    0.900    0.906
## 29 .p29.   0.940 0.002 528.132      0    0.936    0.943
## 30 .p30.   0.243 0.004  60.248      0    0.235    0.251
## 31 .p31.   0.690 0.002 289.350      0    0.686    0.695
## 32         0.346 0.002 161.000      0    0.342    0.350
## 33         0.499 0.002 200.377      0    0.494    0.504
## 34         0.608 0.002 248.215      0    0.603    0.613
## 35         0.594 0.003 230.195      0    0.589    0.599
## 36         0.395 0.002 171.113      0    0.391    0.400
## 37         0.582 0.003 221.381      0    0.577    0.587
## 38         0.685 0.002 277.107      0    0.680    0.690
## 39         0.436 0.002 204.189      0    0.432    0.440
## 40         0.293 0.002 137.550      0    0.288    0.297
## 41         0.519 0.003 197.390      0    0.514    0.525
## 42         0.403 0.002 179.378      0    0.399    0.408
## 43         0.304 0.002 125.801      0    0.299    0.308
## 44         0.252 0.002 116.173      0    0.248    0.256
## 45         0.552 0.003 192.979      0    0.546    0.558
## 46         0.647 0.003 224.105      0    0.641    0.653
## 47         0.580 0.005 125.024      0    0.571    0.589
## 48         0.501 0.004 113.789      0    0.492    0.509
## 49         0.647 0.003 201.885      0    0.641    0.653
## 50         0.416 0.003 131.857      0    0.410    0.422
## 51         0.465 0.003 151.616      0    0.459    0.471
## 52         0.185 0.003  63.076      0    0.179    0.191
## 53         0.117 0.003  34.840      0    0.110    0.123
## 54         0.941 0.002 480.652      0    0.937    0.945
## 55         0.523 0.003 158.793      0    0.517    0.530
## 56         1.000 0.000      NA     NA    1.000    1.000
## 57         0.177 0.004  43.066      0    0.169    0.186
## 58        -0.122 0.004 -30.252      0   -0.130   -0.114
## 59 .p59.  -0.196 0.004 -53.593      0   -0.203   -0.188
## 60 .p60.  -0.182 0.004 -48.656      0   -0.189   -0.175
## 61 .p61.  -0.227 0.004 -58.266      0   -0.235   -0.220
## 62 .p62.  -0.199 0.004 -54.209      0   -0.206   -0.192
## 63 .p63.  -0.171 0.004 -48.501      0   -0.178   -0.165
## 64 .p64.  -0.115 0.004 -30.197      0   -0.122   -0.107
## 65        -0.033 0.004  -7.941      0   -0.041   -0.025
## 66 .p66.   0.045 0.004  11.540      0    0.038    0.053
## 67 .p67.   0.099 0.004  24.276      0    0.091    0.107
## 68 .p68.   0.217 0.004  50.150      0    0.208    0.225
## 69         0.119 0.004  28.348      0    0.111    0.127
## 70        -0.081 0.004 -19.687      0   -0.089   -0.073
## 71         0.220 0.004  51.704      0    0.212    0.228
## 72 .p72.  -0.102 0.004 -27.813      0   -0.109   -0.095
## 73 .p73.  -0.142 0.004 -35.156      0   -0.149   -0.134
## 74 .p74.  -0.064 0.004 -17.947      0   -0.071   -0.057
## 75         0.624 0.005 133.172      0    0.615    0.633
## 76 .p76.   0.195 0.004  47.374      0    0.187    0.203
## 77         0.000 0.000      NA     NA    0.000    0.000
## 78         0.000 0.000      NA     NA    0.000    0.000
## 79         0.000 0.000      NA     NA    0.000    0.000
## 80         0.000 0.000      NA     NA    0.000    0.000
## 81         0.000 0.000      NA     NA    0.000    0.000
## 82  .p1.   0.790 0.001 540.405      0    0.787    0.793
## 83  .p2.   0.578 0.002 274.011      0    0.573    0.582
## 84  .p3.   0.654 0.002 347.288      0    0.651    0.658
## 85  .p4.   0.636 0.002 329.508      0    0.632    0.640
## 86  .p5.   0.804 0.001 586.756      0    0.801    0.807
## 87  .p6.   0.677 0.002 341.193      0    0.673    0.681
## 88  .p7.   0.606 0.002 273.947      0    0.601    0.610
## 89  .p8.   0.573 0.003 181.348      0    0.567    0.579
## 90  .p9.   0.866 0.001 784.239      0    0.864    0.868
##  [ reached 'max' / getOption("max.print") -- omitted 72 rows ]
tests<-lavTestLRT(configural, metric, scalar2, chc.hof)
Td=tests[2:4,"Chisq diff"]
Td
## [1] 3903.262 3831.752 1424.473
dfd=tests[2:4,"Df diff"]
dfd
## [1] 26  8  5
lambda<-Td-dfd
ld<-lambda/dfd
G<-2 # number of groups
N<-71381 + 70776 # sample size
RMSEAD<-sqrt((ld)*G/(N-G))
RMSEAD
## [1] 0.04580468 0.08200377 0.06319934
RMSEA.CI(T=Td[1],df=dfd[1],N=N,G=2)
## [1] 0.04459847 0.04702230
RMSEA.CI(T=Td[2],df=dfd[2],N=N,G=2)
## [1] 0.07983189 0.08419648
RMSEA.CI(T=Td[3],df=dfd[3],N=N,G=2)
## [1] 0.06046022 0.06598240
round(pvals(T=Td[1],df=dfd[1],N=N,G=2),3)
##   RMSEA>0 RMSEA>.01 RMSEA>.05 RMSEA>.06 RMSEA>.08 RMSEA>.10 
##         1         1         0         0         0         0
round(pvals(T=Td[2],df=dfd[2],N=N,G=2),3)
##   RMSEA>0 RMSEA>.01 RMSEA>.05 RMSEA>.06 RMSEA>.08 RMSEA>.10 
##     1.000     1.000     1.000     1.000     0.936     0.000
round(pvals(T=Td[3],df=dfd[3],N=N,G=2),3)
##   RMSEA>0 RMSEA>.01 RMSEA>.05 RMSEA>.06 RMSEA>.08 RMSEA>.10 
##     1.000     1.000     1.000     0.973     0.000     0.000
tests<-lavTestLRT(configural, metric, scalar)
Td=tests[2:3,"Chisq diff"]
Td
## [1]  3903.262 63876.000
dfd=tests[2:3,"Df diff"]
dfd
## [1] 26 15
lambda<-Td-dfd
ld<-lambda/dfd
G<-2 # number of groups
N<-71381 + 70776 # sample size
RMSEAD<-sqrt((ld)*G/(N-G))
RMSEAD
## [1] 0.04580468 0.24474068
RMSEA.CI(T=Td[1],df=dfd[1],N=N,G=2)
## [1] 0.04459847 0.04702230
RMSEA.CI(T=Td[2],df=dfd[2],N=N,G=2)
## [1] 0.2431486 0.2463348
round(pvals(T=Td[1],df=dfd[1],N=N,G=2),3)
##   RMSEA>0 RMSEA>.01 RMSEA>.05 RMSEA>.06 RMSEA>.08 RMSEA>.10 
##         1         1         0         0         0         0
round(pvals(T=Td[2],df=dfd[2],N=N,G=2),3)
##   RMSEA>0 RMSEA>.01 RMSEA>.05 RMSEA>.06 RMSEA>.08 RMSEA>.10 
##         1         1         1         1         1         1
tests<-lavTestLRT(configural, metric, scalar2, strict)
Td=tests[2:4,"Chisq diff"]
Td
## [1] 3903.262 3831.752 5015.075
dfd=tests[2:4,"Df diff"]
dfd
## [1] 26  8 20
lambda<-Td-dfd
ld<-lambda/dfd
G<-2 # number of groups
N<-71381 + 70776 # sample size
RMSEAD<-sqrt((ld)*G/(N-G))
RMSEAD
## [1] 0.04580468 0.08200377 0.05927751
RMSEA.CI(T=Td[1],df=dfd[1],N=N,G=2)
## [1] 0.04459847 0.04702230
RMSEA.CI(T=Td[2],df=dfd[2],N=N,G=2)
## [1] 0.07983189 0.08419648
RMSEA.CI(T=Td[3],df=dfd[3],N=N,G=2)
## [1] 0.05790233 0.06066409
round(pvals(T=Td[1],df=dfd[1],N=N,G=2),3)
##   RMSEA>0 RMSEA>.01 RMSEA>.05 RMSEA>.06 RMSEA>.08 RMSEA>.10 
##         1         1         0         0         0         0
round(pvals(T=Td[2],df=dfd[2],N=N,G=2),3)
##   RMSEA>0 RMSEA>.01 RMSEA>.05 RMSEA>.06 RMSEA>.08 RMSEA>.10 
##     1.000     1.000     1.000     1.000     0.936     0.000
round(pvals(T=Td[3],df=dfd[3],N=N,G=2),3)
##   RMSEA>0 RMSEA>.01 RMSEA>.05 RMSEA>.06 RMSEA>.08 RMSEA>.10 
##     1.000     1.000     1.000     0.197     0.000     0.000
hof.age <-'
english =~ Stest1vocab + Stest19disguisedwords + Stest20spelling + Stest21capitalization + Stest22punctuation + Stest23english + Stest24expression + Stest25wordfunctions + Stest26readingcomprehension + Stest31abstractreasoning + Stest32arithreasoning
math =~ Stest5math + Stest25wordfunctions + Stest32arithreasoning + Stest33highschoolmath + Stest34arithcomputation
speed =~ Stest19disguisedwords + Stest29visualization2D + Stest34arithcomputation + Stest35tablereading + Stest36clericalchecking + Stest37objectinspection
spatial =~ Stest28mechanicalreasoning + Stest29visualization2D + Stest30visualization3D + Stest31abstractreasoning + Stest37objectinspection
g =~ english + math + speed + spatial
g ~ age
'

hof.age2 <-'
english =~ Stest1vocab + Stest19disguisedwords + Stest20spelling + Stest21capitalization + Stest22punctuation + Stest23english + Stest24expression + Stest25wordfunctions + Stest26readingcomprehension + Stest31abstractreasoning + Stest32arithreasoning
math =~ Stest5math + Stest25wordfunctions + Stest32arithreasoning + Stest33highschoolmath + Stest34arithcomputation
speed =~ Stest19disguisedwords + Stest29visualization2D + Stest34arithcomputation + Stest35tablereading + Stest36clericalchecking + Stest37objectinspection
spatial =~ Stest28mechanicalreasoning + Stest29visualization2D + Stest30visualization3D + Stest31abstractreasoning + Stest37objectinspection
g =~ english + math + speed + spatial
g ~ age + age2 
'

sem.age<-sem(hof.age, data=dgroup, group="sex", meanstructure=TRUE, sampling.weights="BY_WTA", std.lv=T, group.equal=c("loadings", "intercepts", "lv.variances"), group.partial=c("Stest1vocab~1", "Stest28mechanicalreasoning~1", "Stest26readingcomprehension~1", "Stest34arithcomputation~1", "Stest33highschoolmath~1", "Stest19disguisedwords~1", "Stest29visualization2D~1"))
## Warning: lavaan->lav_model_vcov():  
##    The variance-covariance matrix of the estimated parameters (vcov) 
##    does not appear to be positive definite! The smallest eigenvalue 
##    (= 1.135167e-16) is close to zero. This may be a symptom that the 
##    model is not identified.
fitMeasures(sem.age, c("chisq", "df", "pvalue", "cfi", "rmsea", "srmr", "ecvi", "aic", "bic"))
##       chisq          df      pvalue         cfi       rmsea        srmr 
##  102456.575     395.000       0.000       0.929       0.060       0.058 
##        ecvi         aic         bic 
##       0.722 6498832.490 6499868.283
Mc(sem.age)
## [1] 0.6983902
summary(sem.age, standardized=T, ci=T) 
## lavaan 0.6-18 ended normally after 71 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                       149
##   Number of equality constraints                    44
## 
##   Number of observations per group:                   
##     0                                            70776
##     1                                            71381
##   Sampling weights variable                     BY_WTA
## 
## Model Test User Model:
##                                                 Standard      Scaled
##   Test Statistic                              102456.575   87031.306
##   Degrees of freedom                                 395         395
##   P-value (Chi-square)                             0.000       0.000
##   Scaling correction factor                                    1.177
##     Yuan-Bentler correction (Mplus variant)                         
##   Test statistic for each group:
##     0                                         54711.648   46474.579
##     1                                         47744.927   40556.727
## 
## Parameter Estimates:
## 
##   Standard errors                             Sandwich
##   Information bread                           Observed
##   Observed information based on                Hessian
## 
## 
## Group 1 [0]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english =~                                                   
##     Stst1vc (.p1.)    0.319    0.003  115.706    0.000    0.314
##     Stst19d (.p2.)    0.235    0.002  103.298    0.000    0.231
##     Stst20s (.p3.)    0.260    0.002  107.936    0.000    0.255
##     Stst21c (.p4.)    0.256    0.002  110.334    0.000    0.251
##     Stst22p (.p5.)    0.313    0.003  115.042    0.000    0.308
##     Stst23n (.p6.)    0.265    0.002  107.687    0.000    0.260
##     Stst24x (.p7.)    0.235    0.002  104.979    0.000    0.231
##     Stst25w (.p8.)    0.235    0.002  105.031    0.000    0.231
##     Stst26r (.p9.)    0.345    0.003  114.997    0.000    0.339
##     Stst31b (.10.)    0.118    0.001   81.625    0.000    0.115
##     Stst32r (.11.)    0.095    0.002   60.550    0.000    0.092
##   math =~                                                      
##     Stst5mt (.12.)    0.276    0.004   74.421    0.000    0.269
##     Stst25w (.13.)    0.072    0.001   49.730    0.000    0.069
##     Stst32r (.14.)    0.196    0.002   80.488    0.000    0.191
##     Stst33h (.15.)    0.304    0.004   72.151    0.000    0.296
##     Stst34r (.16.)    0.167    0.002   68.418    0.000    0.163
##   speed =~                                                     
##     Stst19d (.17.)    0.280    0.003  108.270    0.000    0.275
##     Sts292D (.18.)    0.209    0.003   73.104    0.000    0.204
##     Stst34r (.19.)    0.341    0.003  125.657    0.000    0.336
##     Stst35t (.20.)    0.626    0.003  187.990    0.000    0.619
##     Stst36c (.21.)    0.669    0.003  201.018    0.000    0.663
##     Stst37b (.22.)    0.548    0.003  174.568    0.000    0.541
##   spatial =~                                                   
##     Stst28m (.23.)    0.475    0.002  240.863    0.000    0.471
##     Sts292D (.24.)    0.357    0.002  151.551    0.000    0.353
##     Sts303D (.25.)    0.524    0.002  221.793    0.000    0.519
##     Stst31b (.26.)    0.333    0.002  153.282    0.000    0.329
##     Stst37b (.27.)    0.097    0.002   45.487    0.000    0.093
##   g =~                                                         
##     english (.28.)    2.154    0.022   96.465    0.000    2.111
##     math    (.29.)    2.603    0.040   64.624    0.000    2.524
##     speed   (.30.)    0.252    0.004   57.348    0.000    0.243
##     spatial (.31.)    0.949    0.006  151.187    0.000    0.937
##  ci.upper   Std.lv  Std.all
##                            
##     0.325    0.764    0.809
##     0.240    0.563    0.580
##     0.265    0.622    0.626
##     0.260    0.611    0.637
##     0.318    0.748    0.778
##     0.269    0.633    0.647
##     0.239    0.562    0.562
##     0.240    0.563    0.570
##     0.350    0.824    0.841
##     0.121    0.282    0.290
##     0.098    0.226    0.233
##                            
##     0.283    0.775    0.835
##     0.075    0.201    0.204
##     0.201    0.550    0.565
##     0.312    0.853    0.865
##     0.172    0.470    0.486
##                            
##     0.285    0.289    0.298
##     0.215    0.216    0.224
##     0.347    0.352    0.364
##     0.632    0.646    0.648
##     0.676    0.690    0.706
##     0.554    0.565    0.557
##                            
##     0.479    0.657    0.765
##     0.362    0.495    0.513
##     0.528    0.725    0.731
##     0.338    0.461    0.474
##     0.101    0.134    0.133
##                            
##     2.198    0.908    0.908
##     2.682    0.934    0.934
##     0.261    0.246    0.246
##     0.961    0.691    0.691
## 
## Regressions:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   g ~                                                          
##     age               0.099    0.004   26.726    0.000    0.092
##  ci.upper   Std.lv  Std.all
##                            
##     0.106    0.098    0.123
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stst1vc           0.175    0.004   46.467    0.000    0.168
##    .Stst19d          -0.112    0.004  -28.639    0.000   -0.120
##    .Stst20s (.61.)   -0.188    0.004  -51.556    0.000   -0.195
##    .Stst21c (.62.)   -0.168    0.004  -46.646    0.000   -0.175
##    .Stst22p (.63.)   -0.211    0.004  -54.857    0.000   -0.218
##    .Stst23n (.64.)   -0.188    0.004  -50.110    0.000   -0.195
##    .Stst24x (.65.)   -0.166    0.004  -44.436    0.000   -0.173
##    .Stst25w (.66.)   -0.105    0.004  -27.802    0.000   -0.113
##    .Stst26r          -0.024    0.004   -5.853    0.000   -0.032
##    .Stst31b (.68.)    0.050    0.004   13.309    0.000    0.043
##    .Stst32r (.69.)    0.104    0.004   26.245    0.000    0.096
##    .Stst5mt (.70.)    0.210    0.004   56.454    0.000    0.202
##    .Stst33h           0.126    0.004   29.909    0.000    0.118
##    .Stst34r          -0.072    0.004  -18.199    0.000   -0.080
##    .Sts292D           0.216    0.004   55.515    0.000    0.209
##    .Stst35t (.74.)   -0.100    0.004  -26.789    0.000   -0.107
##    .Stst36c (.75.)   -0.136    0.004  -36.877    0.000   -0.144
##    .Stst37b (.76.)   -0.063    0.004  -17.502    0.000   -0.070
##    .Stst28m           0.541    0.004  152.544    0.000    0.534
##    .Sts303D (.78.)    0.198    0.004   49.818    0.000    0.191
##  ci.upper   Std.lv  Std.all
##     0.182    0.175    0.186
##    -0.105   -0.112   -0.116
##    -0.180   -0.188   -0.189
##    -0.161   -0.168   -0.175
##    -0.203   -0.211   -0.219
##    -0.181   -0.188   -0.192
##    -0.158   -0.166   -0.166
##    -0.098   -0.105   -0.107
##    -0.016   -0.024   -0.025
##     0.058    0.050    0.052
##     0.112    0.104    0.107
##     0.217    0.210    0.226
##     0.134    0.126    0.128
##    -0.065   -0.072   -0.075
##     0.224    0.216    0.224
##    -0.093   -0.100   -0.100
##    -0.129   -0.136   -0.139
##    -0.056   -0.063   -0.062
##     0.548    0.541    0.630
##     0.206    0.198    0.200
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stest1vocab       0.307    0.002  141.533    0.000    0.303
##    .Stst19dsgsdwrd    0.470    0.003  158.958    0.000    0.464
##    .Stest20spellng    0.599    0.004  169.014    0.000    0.592
##    .Stest21cptlztn    0.547    0.003  171.152    0.000    0.541
##    .Stest22puncttn    0.365    0.003  142.849    0.000    0.360
##    .Stest23english    0.556    0.004  144.078    0.000    0.549
##    .Stest24exprssn    0.683    0.004  158.211    0.000    0.675
##    .Stst25wrdfnctn    0.424    0.003  155.459    0.000    0.419
##    .Stst26rdngcmpr    0.280    0.002  124.216    0.000    0.275
##    .Stst31bstrctrs    0.491    0.003  151.532    0.000    0.485
##    .Stst32rthrsnng    0.381    0.002  154.218    0.000    0.376
##    .Stest5math        0.261    0.003   86.834    0.000    0.255
##    .Stst33hghschlm    0.245    0.002  114.317    0.000    0.241
##    .Stst34rthcmptt    0.516    0.004  142.182    0.000    0.509
##    .Stst29vslztn2D    0.600    0.004  143.313    0.000    0.592
##    .Stest35tblrdng    0.575    0.008   72.495    0.000    0.560
##    .Stst36clrclchc    0.478    0.006   85.780    0.000    0.468
##    .Stst37bjctnspc    0.665    0.005  135.658    0.000    0.655
##    .Stst28mchnclrs    0.306    0.003  114.670    0.000    0.301
##    .Stst30vslztn3D    0.457    0.004  126.532    0.000    0.450
##    .english           1.000                               1.000
##    .math              1.000                               1.000
##    .speed             1.000                               1.000
##    .spatial           1.000                               1.000
##    .g                 1.000                               1.000
##  ci.upper   Std.lv  Std.all
##     0.311    0.307    0.345
##     0.476    0.470    0.498
##     0.606    0.599    0.608
##     0.553    0.547    0.594
##     0.370    0.365    0.395
##     0.564    0.556    0.582
##     0.692    0.683    0.684
##     0.430    0.424    0.436
##     0.284    0.280    0.292
##     0.498    0.491    0.519
##     0.386    0.381    0.403
##     0.267    0.261    0.303
##     0.249    0.245    0.252
##     0.524    0.516    0.551
##     0.608    0.600    0.647
##     0.591    0.575    0.580
##     0.489    0.478    0.501
##     0.674    0.665    0.647
##     0.311    0.306    0.415
##     0.464    0.457    0.465
##     1.000    0.175    0.175
##     1.000    0.127    0.127
##     1.000    0.939    0.939
##     1.000    0.522    0.522
##     1.000    0.985    0.985
## 
## 
## Group 2 [1]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english =~                                                   
##     Stst1vc (.p1.)    0.319    0.003  115.706    0.000    0.314
##     Stst19d (.p2.)    0.235    0.002  103.298    0.000    0.231
##     Stst20s (.p3.)    0.260    0.002  107.936    0.000    0.255
##     Stst21c (.p4.)    0.256    0.002  110.334    0.000    0.251
##     Stst22p (.p5.)    0.313    0.003  115.042    0.000    0.308
##     Stst23n (.p6.)    0.265    0.002  107.687    0.000    0.260
##     Stst24x (.p7.)    0.235    0.002  104.979    0.000    0.231
##     Stst25w (.p8.)    0.235    0.002  105.031    0.000    0.231
##     Stst26r (.p9.)    0.345    0.003  114.997    0.000    0.339
##     Stst31b (.10.)    0.118    0.001   81.625    0.000    0.115
##     Stst32r (.11.)    0.095    0.002   60.550    0.000    0.092
##   math =~                                                      
##     Stst5mt (.12.)    0.276    0.004   74.421    0.000    0.269
##     Stst25w (.13.)    0.072    0.001   49.730    0.000    0.069
##     Stst32r (.14.)    0.196    0.002   80.488    0.000    0.191
##     Stst33h (.15.)    0.304    0.004   72.151    0.000    0.296
##     Stst34r (.16.)    0.167    0.002   68.418    0.000    0.163
##   speed =~                                                     
##     Stst19d (.17.)    0.280    0.003  108.270    0.000    0.275
##     Sts292D (.18.)    0.209    0.003   73.104    0.000    0.204
##     Stst34r (.19.)    0.341    0.003  125.657    0.000    0.336
##     Stst35t (.20.)    0.626    0.003  187.990    0.000    0.619
##     Stst36c (.21.)    0.669    0.003  201.018    0.000    0.663
##     Stst37b (.22.)    0.548    0.003  174.568    0.000    0.541
##   spatial =~                                                   
##     Stst28m (.23.)    0.475    0.002  240.863    0.000    0.471
##     Sts292D (.24.)    0.357    0.002  151.551    0.000    0.353
##     Sts303D (.25.)    0.524    0.002  221.793    0.000    0.519
##     Stst31b (.26.)    0.333    0.002  153.282    0.000    0.329
##     Stst37b (.27.)    0.097    0.002   45.487    0.000    0.093
##   g =~                                                         
##     english (.28.)    2.154    0.022   96.465    0.000    2.111
##     math    (.29.)    2.603    0.040   64.624    0.000    2.524
##     speed   (.30.)    0.252    0.004   57.348    0.000    0.243
##     spatial (.31.)    0.949    0.006  151.187    0.000    0.937
##  ci.upper   Std.lv  Std.all
##                            
##     0.325    0.762    0.790
##     0.240    0.562    0.577
##     0.265    0.620    0.654
##     0.260    0.610    0.635
##     0.318    0.746    0.804
##     0.269    0.631    0.677
##     0.239    0.561    0.606
##     0.240    0.562    0.573
##     0.350    0.822    0.866
##     0.121    0.281    0.291
##     0.098    0.226    0.230
##                            
##     0.283    0.774    0.781
##     0.075    0.201    0.205
##     0.201    0.549    0.558
##     0.312    0.851    0.869
##     0.172    0.469    0.491
##                            
##     0.285    0.289    0.297
##     0.215    0.216    0.223
##     0.347    0.352    0.368
##     0.632    0.646    0.725
##     0.676    0.690    0.722
##     0.554    0.565    0.596
##                            
##     0.479    0.656    0.771
##     0.362    0.494    0.510
##     0.528    0.724    0.755
##     0.338    0.460    0.477
##     0.101    0.134    0.142
##                            
##     2.198    0.908    0.908
##     2.682    0.934    0.934
##     0.261    0.246    0.246
##     0.961    0.690    0.690
## 
## Regressions:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   g ~                                                          
##     age               0.084    0.004   22.890    0.000    0.076
##  ci.upper   Std.lv  Std.all
##                            
##     0.091    0.083    0.099
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stst1vc          -0.602    0.005 -118.473    0.000   -0.612
##    .Stst19d          -0.317    0.005  -68.365    0.000   -0.326
##    .Stst20s (.61.)   -0.188    0.004  -51.556    0.000   -0.195
##    .Stst21c (.62.)   -0.168    0.004  -46.646    0.000   -0.175
##    .Stst22p (.63.)   -0.211    0.004  -54.857    0.000   -0.218
##    .Stst23n (.64.)   -0.188    0.004  -50.110    0.000   -0.195
##    .Stst24x (.65.)   -0.166    0.004  -44.436    0.000   -0.173
##    .Stst25w (.66.)   -0.105    0.004  -27.802    0.000   -0.113
##    .Stst26r          -0.442    0.005  -85.792    0.000   -0.452
##    .Stst31b (.68.)    0.050    0.004   13.309    0.000    0.043
##    .Stst32r (.69.)    0.104    0.004   26.245    0.000    0.096
##    .Stst5mt (.70.)    0.210    0.004   56.454    0.000    0.202
##    .Stst33h           0.342    0.005   62.502    0.000    0.331
##    .Stst34r           0.280    0.005   57.928    0.000    0.271
##    .Sts292D          -0.004    0.005   -0.767    0.443   -0.013
##    .Stst35t (.74.)   -0.100    0.004  -26.789    0.000   -0.107
##    .Stst36c (.75.)   -0.136    0.004  -36.877    0.000   -0.144
##    .Stst37b (.76.)   -0.063    0.004  -17.502    0.000   -0.070
##    .Stst28m          -0.142    0.005  -29.183    0.000   -0.151
##    .Sts303D (.78.)    0.198    0.004   49.818    0.000    0.191
##    .english           1.685    0.011  155.819    0.000    1.663
##    .math             -1.247    0.009 -133.768    0.000   -1.265
##    .speed             0.342    0.007   48.907    0.000    0.329
##    .spatial          -0.561    0.010  -56.315    0.000   -0.580
##    .g                -0.027    0.008   -3.427    0.001   -0.043
##  ci.upper   Std.lv  Std.all
##    -0.592   -0.602   -0.624
##    -0.307   -0.317   -0.325
##    -0.180   -0.188   -0.198
##    -0.161   -0.168   -0.175
##    -0.203   -0.211   -0.227
##    -0.181   -0.188   -0.201
##    -0.158   -0.166   -0.179
##    -0.098   -0.105   -0.107
##    -0.432   -0.442   -0.466
##     0.058    0.050    0.052
##     0.112    0.104    0.106
##     0.217    0.210    0.212
##     0.353    0.342    0.349
##     0.290    0.280    0.293
##     0.006   -0.004   -0.004
##    -0.093   -0.100   -0.112
##    -0.129   -0.136   -0.143
##    -0.056   -0.063   -0.066
##    -0.132   -0.142   -0.167
##     0.206    0.198    0.207
##     1.706    0.706    0.706
##    -1.228   -0.445   -0.445
##     0.356    0.332    0.332
##    -0.541   -0.406   -0.406
##    -0.012   -0.027   -0.027
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stest1vocab       0.350    0.002  152.778    0.000    0.345
##    .Stst19dsgsdwrd    0.478    0.003  162.862    0.000    0.472
##    .Stest20spellng    0.515    0.003  172.208    0.000    0.509
##    .Stest21cptlztn    0.550    0.003  169.817    0.000    0.543
##    .Stest22puncttn    0.305    0.002  139.922    0.000    0.301
##    .Stest23english    0.472    0.003  145.275    0.000    0.466
##    .Stest24exprssn    0.542    0.004  149.299    0.000    0.535
##    .Stst25wrdfnctn    0.414    0.003  150.664    0.000    0.409
##    .Stst26rdngcmpr    0.225    0.002  120.442    0.000    0.222
##    .Stst31bstrctrs    0.478    0.003  157.472    0.000    0.472
##    .Stst32rthrsnng    0.404    0.003  161.088    0.000    0.399
##    .Stest5math        0.383    0.004  104.517    0.000    0.375
##    .Stst33hghschlm    0.234    0.002  109.517    0.000    0.230
##    .Stst34rthcmptt    0.493    0.004  135.974    0.000    0.486
##    .Stst29vslztn2D    0.610    0.004  162.098    0.000    0.602
##    .Stest35tblrdng    0.377    0.005   69.314    0.000    0.366
##    .Stst36clrclchc    0.438    0.004   97.635    0.000    0.429
##    .Stst37bjctnspc    0.534    0.004  138.832    0.000    0.527
##    .Stst28mchnclrs    0.293    0.002  121.399    0.000    0.288
##    .Stst30vslztn3D    0.394    0.003  126.250    0.000    0.388
##    .english           1.000                               1.000
##    .math              1.000                               1.000
##    .speed             1.000                               1.000
##    .spatial           1.000                               1.000
##    .g                 1.000                               1.000
##  ci.upper   Std.lv  Std.all
##     0.354    0.350    0.376
##     0.483    0.478    0.503
##     0.521    0.515    0.572
##     0.556    0.550    0.596
##     0.310    0.305    0.354
##     0.478    0.472    0.542
##     0.550    0.542    0.633
##     0.420    0.414    0.431
##     0.229    0.225    0.250
##     0.483    0.478    0.513
##     0.409    0.404    0.418
##     0.390    0.383    0.390
##     0.238    0.234    0.244
##     0.500    0.493    0.540
##     0.617    0.610    0.651
##     0.388    0.377    0.475
##     0.447    0.438    0.479
##     0.542    0.534    0.596
##     0.298    0.293    0.405
##     0.400    0.394    0.429
##     1.000    0.176    0.176
##     1.000    0.128    0.128
##     1.000    0.940    0.940
##     1.000    0.524    0.524
##     1.000    0.990    0.990
sem.age2<-sem(hof.age2, data=dgroup, group="sex", meanstructure=TRUE, sampling.weights="BY_WTA", std.lv=T, group.equal=c("loadings", "intercepts", "lv.variances"), group.partial=c("Stest1vocab~1", "Stest28mechanicalreasoning~1", "Stest26readingcomprehension~1", "Stest34arithcomputation~1", "Stest33highschoolmath~1", "Stest19disguisedwords~1", "Stest29visualization2D~1"))
## Warning: lavaan->lav_model_vcov():  
##    The variance-covariance matrix of the estimated parameters (vcov) 
##    does not appear to be positive definite! The smallest eigenvalue 
##    (= 1.648325e-16) is close to zero. This may be a symptom that the 
##    model is not identified.
fitMeasures(sem.age2, c("chisq", "df", "pvalue", "cfi", "rmsea", "srmr", "ecvi", "aic", "bic"))
##       chisq          df      pvalue         cfi       rmsea        srmr 
##  103058.049     433.000       0.000       0.928       0.058       0.056 
##        ecvi         aic         bic 
##       0.726 6497569.242 6498624.764
Mc(sem.age2)
## [1] 0.6970074
summary(sem.age2, standardized=T, ci=T) 
## lavaan 0.6-18 ended normally after 74 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                       151
##   Number of equality constraints                    44
## 
##   Number of observations per group:                   
##     0                                            70776
##     1                                            71381
##   Sampling weights variable                     BY_WTA
## 
## Model Test User Model:
##                                                 Standard      Scaled
##   Test Statistic                              103058.049   87543.461
##   Degrees of freedom                                 433         433
##   P-value (Chi-square)                             0.000       0.000
##   Scaling correction factor                                    1.177
##     Yuan-Bentler correction (Mplus variant)                         
##   Test statistic for each group:
##     0                                         54986.160   46708.421
##     1                                         48071.890   40835.040
## 
## Parameter Estimates:
## 
##   Standard errors                             Sandwich
##   Information bread                           Observed
##   Observed information based on                Hessian
## 
## 
## Group 1 [0]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english =~                                                   
##     Stst1vc (.p1.)    0.320    0.003  116.906    0.000    0.314
##     Stst19d (.p2.)    0.236    0.002  104.190    0.000    0.231
##     Stst20s (.p3.)    0.260    0.002  108.945    0.000    0.255
##     Stst21c (.p4.)    0.256    0.002  111.411    0.000    0.251
##     Stst22p (.p5.)    0.313    0.003  116.214    0.000    0.308
##     Stst23n (.p6.)    0.265    0.002  108.664    0.000    0.260
##     Stst24x (.p7.)    0.235    0.002  105.908    0.000    0.231
##     Stst25w (.p8.)    0.235    0.002  105.847    0.000    0.231
##     Stst26r (.p9.)    0.345    0.003  116.201    0.000    0.339
##     Stst31b (.10.)    0.118    0.001   81.952    0.000    0.115
##     Stst32r (.11.)    0.095    0.002   60.594    0.000    0.092
##   math =~                                                      
##     Stst5mt (.12.)    0.276    0.004   75.242    0.000    0.269
##     Stst25w (.13.)    0.072    0.001   49.947    0.000    0.069
##     Stst32r (.14.)    0.196    0.002   81.166    0.000    0.191
##     Stst33h (.15.)    0.304    0.004   72.923    0.000    0.296
##     Stst34r (.16.)    0.168    0.002   69.070    0.000    0.163
##   speed =~                                                     
##     Stst19d (.17.)    0.280    0.003  108.189    0.000    0.275
##     Sts292D (.18.)    0.209    0.003   73.058    0.000    0.203
##     Stst34r (.19.)    0.341    0.003  125.565    0.000    0.336
##     Stst35t (.20.)    0.626    0.003  188.026    0.000    0.619
##     Stst36c (.21.)    0.669    0.003  200.879    0.000    0.662
##     Stst37b (.22.)    0.547    0.003  174.516    0.000    0.541
##   spatial =~                                                   
##     Stst28m (.23.)    0.475    0.002  240.969    0.000    0.471
##     Sts292D (.24.)    0.357    0.002  151.566    0.000    0.353
##     Sts303D (.25.)    0.524    0.002  221.777    0.000    0.519
##     Stst31b (.26.)    0.333    0.002  153.264    0.000    0.329
##     Stst37b (.27.)    0.097    0.002   45.466    0.000    0.093
##   g =~                                                         
##     english (.28.)    2.143    0.022   97.481    0.000    2.100
##     math    (.29.)    2.589    0.040   65.316    0.000    2.511
##     speed   (.30.)    0.252    0.004   57.550    0.000    0.243
##     spatial (.31.)    0.944    0.006  151.151    0.000    0.932
##  ci.upper   Std.lv  Std.all
##                            
##     0.325    0.765    0.810
##     0.240    0.564    0.580
##     0.265    0.623    0.627
##     0.260    0.612    0.638
##     0.318    0.749    0.778
##     0.269    0.634    0.647
##     0.239    0.563    0.563
##     0.240    0.564    0.571
##     0.350    0.825    0.842
##     0.121    0.282    0.290
##     0.098    0.227    0.233
##                            
##     0.284    0.777    0.836
##     0.075    0.202    0.204
##     0.201    0.551    0.566
##     0.312    0.854    0.865
##     0.172    0.471    0.486
##                            
##     0.285    0.289    0.297
##     0.215    0.216    0.224
##     0.346    0.352    0.363
##     0.632    0.646    0.648
##     0.675    0.690    0.706
##     0.554    0.565    0.557
##                            
##     0.479    0.657    0.765
##     0.362    0.495    0.514
##     0.528    0.725    0.732
##     0.337    0.461    0.474
##     0.101    0.134    0.133
##                            
##     2.186    0.909    0.909
##     2.666    0.935    0.935
##     0.260    0.248    0.248
##     0.956    0.692    0.692
## 
## Regressions:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   g ~                                                          
##     age               0.090    0.004   25.062    0.000    0.083
##     age2             -0.065    0.002  -26.497    0.000   -0.070
##  ci.upper   Std.lv  Std.all
##                            
##     0.097    0.089    0.111
##    -0.060   -0.064   -0.119
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stst1vc           0.244    0.005   53.658    0.000    0.235
##    .Stst19d          -0.054    0.005  -12.035    0.000   -0.063
##    .Stst20s (.64.)   -0.131    0.004  -31.429    0.000   -0.140
##    .Stst21c (.65.)   -0.113    0.004  -27.419    0.000   -0.121
##    .Stst22p (.66.)   -0.143    0.005  -31.148    0.000   -0.152
##    .Stst23n (.67.)   -0.131    0.004  -30.603    0.000   -0.139
##    .Stst24x (.68.)   -0.115    0.004  -27.889    0.000   -0.123
##    .Stst25w (.69.)   -0.036    0.005   -7.688    0.000   -0.045
##    .Stst26r           0.050    0.005   10.165    0.000    0.041
##    .Stst31b (.71.)    0.108    0.004   25.036    0.000    0.099
##    .Stst32r (.72.)    0.175    0.005   36.552    0.000    0.166
##    .Stst5mt (.73.)    0.282    0.005   61.618    0.000    0.273
##    .Stst33h           0.205    0.005   39.047    0.000    0.195
##    .Stst34r          -0.020    0.004   -4.474    0.000   -0.029
##    .Sts292D           0.255    0.004   61.629    0.000    0.247
##    .Stst35t (.77.)   -0.084    0.004  -22.546    0.000   -0.092
##    .Stst36c (.78.)   -0.119    0.004  -31.832    0.000   -0.127
##    .Stst37b (.79.)   -0.040    0.004  -10.702    0.000   -0.047
##    .Stst28m           0.586    0.004  149.766    0.000    0.579
##    .Sts303D (.81.)    0.248    0.004   56.212    0.000    0.240
##  ci.upper   Std.lv  Std.all
##     0.253    0.244    0.258
##    -0.045   -0.054   -0.056
##    -0.123   -0.131   -0.132
##    -0.105   -0.113   -0.118
##    -0.134   -0.143   -0.149
##    -0.122   -0.131   -0.134
##    -0.107   -0.115   -0.115
##    -0.027   -0.036   -0.036
##     0.060    0.050    0.051
##     0.116    0.108    0.110
##     0.185    0.175    0.180
##     0.291    0.282    0.303
##     0.215    0.205    0.208
##    -0.011   -0.020   -0.021
##     0.264    0.255    0.265
##    -0.077   -0.084   -0.085
##    -0.112   -0.119   -0.122
##    -0.032   -0.040   -0.039
##     0.594    0.586    0.682
##     0.257    0.248    0.250
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stest1vocab       0.307    0.002  141.509    0.000    0.303
##    .Stst19dsgsdwrd    0.470    0.003  158.971    0.000    0.464
##    .Stest20spellng    0.599    0.004  168.998    0.000    0.592
##    .Stest21cptlztn    0.547    0.003  171.157    0.000    0.541
##    .Stest22puncttn    0.366    0.003  142.858    0.000    0.361
##    .Stest23english    0.556    0.004  144.075    0.000    0.549
##    .Stest24exprssn    0.683    0.004  158.198    0.000    0.675
##    .Stst25wrdfnctn    0.424    0.003  155.460    0.000    0.419
##    .Stst26rdngcmpr    0.280    0.002  124.214    0.000    0.275
##    .Stst31bstrctrs    0.491    0.003  151.541    0.000    0.485
##    .Stst32rthrsnng    0.381    0.002  154.268    0.000    0.377
##    .Stest5math        0.261    0.003   86.725    0.000    0.255
##    .Stst33hghschlm    0.245    0.002  114.366    0.000    0.241
##    .Stst34rthcmptt    0.516    0.004  142.191    0.000    0.509
##    .Stst29vslztn2D    0.600    0.004  143.320    0.000    0.592
##    .Stest35tblrdng    0.575    0.008   72.482    0.000    0.560
##    .Stst36clrclchc    0.479    0.006   85.784    0.000    0.468
##    .Stst37bjctnspc    0.665    0.005  135.666    0.000    0.655
##    .Stst28mchnclrs    0.306    0.003  114.631    0.000    0.301
##    .Stst30vslztn3D    0.457    0.004  126.546    0.000    0.450
##    .english           1.000                               1.000
##    .math              1.000                               1.000
##    .speed             1.000                               1.000
##    .spatial           1.000                               1.000
##    .g                 1.000                               1.000
##  ci.upper   Std.lv  Std.all
##     0.311    0.307    0.344
##     0.476    0.470    0.498
##     0.606    0.599    0.607
##     0.553    0.547    0.593
##     0.371    0.366    0.394
##     0.564    0.556    0.581
##     0.692    0.683    0.683
##     0.430    0.424    0.435
##     0.284    0.280    0.291
##     0.498    0.491    0.518
##     0.386    0.381    0.402
##     0.267    0.261    0.302
##     0.249    0.245    0.251
##     0.524    0.516    0.550
##     0.608    0.600    0.647
##     0.591    0.575    0.580
##     0.490    0.479    0.501
##     0.674    0.665    0.647
##     0.311    0.306    0.415
##     0.464    0.457    0.465
##     1.000    0.175    0.175
##     1.000    0.127    0.127
##     1.000    0.939    0.939
##     1.000    0.521    0.521
##     1.000    0.971    0.971
## 
## 
## Group 2 [1]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english =~                                                   
##     Stst1vc (.p1.)    0.320    0.003  116.906    0.000    0.314
##     Stst19d (.p2.)    0.236    0.002  104.190    0.000    0.231
##     Stst20s (.p3.)    0.260    0.002  108.945    0.000    0.255
##     Stst21c (.p4.)    0.256    0.002  111.411    0.000    0.251
##     Stst22p (.p5.)    0.313    0.003  116.214    0.000    0.308
##     Stst23n (.p6.)    0.265    0.002  108.664    0.000    0.260
##     Stst24x (.p7.)    0.235    0.002  105.908    0.000    0.231
##     Stst25w (.p8.)    0.235    0.002  105.847    0.000    0.231
##     Stst26r (.p9.)    0.345    0.003  116.201    0.000    0.339
##     Stst31b (.10.)    0.118    0.001   81.952    0.000    0.115
##     Stst32r (.11.)    0.095    0.002   60.594    0.000    0.092
##   math =~                                                      
##     Stst5mt (.12.)    0.276    0.004   75.242    0.000    0.269
##     Stst25w (.13.)    0.072    0.001   49.947    0.000    0.069
##     Stst32r (.14.)    0.196    0.002   81.166    0.000    0.191
##     Stst33h (.15.)    0.304    0.004   72.923    0.000    0.296
##     Stst34r (.16.)    0.168    0.002   69.070    0.000    0.163
##   speed =~                                                     
##     Stst19d (.17.)    0.280    0.003  108.189    0.000    0.275
##     Sts292D (.18.)    0.209    0.003   73.058    0.000    0.203
##     Stst34r (.19.)    0.341    0.003  125.565    0.000    0.336
##     Stst35t (.20.)    0.626    0.003  188.026    0.000    0.619
##     Stst36c (.21.)    0.669    0.003  200.879    0.000    0.662
##     Stst37b (.22.)    0.547    0.003  174.516    0.000    0.541
##   spatial =~                                                   
##     Stst28m (.23.)    0.475    0.002  240.969    0.000    0.471
##     Sts292D (.24.)    0.357    0.002  151.566    0.000    0.353
##     Sts303D (.25.)    0.524    0.002  221.777    0.000    0.519
##     Stst31b (.26.)    0.333    0.002  153.264    0.000    0.329
##     Stst37b (.27.)    0.097    0.002   45.466    0.000    0.093
##   g =~                                                         
##     english (.28.)    2.143    0.022   97.481    0.000    2.100
##     math    (.29.)    2.589    0.040   65.316    0.000    2.511
##     speed   (.30.)    0.252    0.004   57.550    0.000    0.243
##     spatial (.31.)    0.944    0.006  151.151    0.000    0.932
##  ci.upper   Std.lv  Std.all
##                            
##     0.325    0.761    0.789
##     0.240    0.561    0.576
##     0.265    0.619    0.653
##     0.260    0.609    0.635
##     0.318    0.745    0.803
##     0.269    0.630    0.676
##     0.239    0.560    0.605
##     0.240    0.561    0.572
##     0.350    0.820    0.866
##     0.121    0.281    0.291
##     0.098    0.226    0.230
##                            
##     0.284    0.772    0.781
##     0.075    0.201    0.205
##     0.201    0.548    0.558
##     0.312    0.849    0.869
##     0.172    0.468    0.490
##                            
##     0.285    0.289    0.297
##     0.215    0.216    0.223
##     0.346    0.352    0.368
##     0.632    0.646    0.725
##     0.675    0.690    0.722
##     0.554    0.565    0.596
##                            
##     0.479    0.655    0.771
##     0.362    0.493    0.510
##     0.528    0.723    0.755
##     0.337    0.460    0.477
##     0.101    0.134    0.141
##                            
##     2.186    0.907    0.907
##     2.666    0.934    0.934
##     0.260    0.246    0.246
##     0.956    0.689    0.689
## 
## Regressions:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   g ~                                                          
##     age               0.062    0.004   16.106    0.000    0.055
##     age2             -0.049    0.003  -18.556    0.000   -0.055
##  ci.upper   Std.lv  Std.all
##                            
##     0.070    0.062    0.074
##    -0.044   -0.049   -0.082
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stst1vc          -0.533    0.006  -94.177    0.000   -0.544
##    .Stst19d          -0.259    0.005  -50.663    0.000   -0.269
##    .Stst20s (.64.)   -0.131    0.004  -31.429    0.000   -0.140
##    .Stst21c (.65.)   -0.113    0.004  -27.419    0.000   -0.121
##    .Stst22p (.66.)   -0.143    0.005  -31.148    0.000   -0.152
##    .Stst23n (.67.)   -0.131    0.004  -30.603    0.000   -0.139
##    .Stst24x (.68.)   -0.115    0.004  -27.889    0.000   -0.123
##    .Stst25w (.69.)   -0.036    0.005   -7.688    0.000   -0.045
##    .Stst26r          -0.367    0.006  -63.082    0.000   -0.379
##    .Stst31b (.71.)    0.108    0.004   25.036    0.000    0.099
##    .Stst32r (.72.)    0.175    0.005   36.552    0.000    0.166
##    .Stst5mt (.73.)    0.282    0.005   61.618    0.000    0.273
##    .Stst33h           0.421    0.006   67.108    0.000    0.409
##    .Stst34r           0.333    0.005   63.179    0.000    0.322
##    .Sts292D           0.036    0.005    7.120    0.000    0.026
##    .Stst35t (.77.)   -0.084    0.004  -22.546    0.000   -0.092
##    .Stst36c (.78.)   -0.119    0.004  -31.832    0.000   -0.127
##    .Stst37b (.79.)   -0.040    0.004  -10.702    0.000   -0.047
##    .Stst28m          -0.096    0.005  -18.595    0.000   -0.107
##    .Sts303D (.81.)    0.248    0.004   56.212    0.000    0.240
##    .english           1.701    0.011  156.390    0.000    1.680
##    .math             -1.226    0.009 -131.251    0.000   -1.244
##    .speed             0.344    0.007   49.205    0.000    0.331
##    .spatial          -0.553    0.010  -55.770    0.000   -0.573
##    .g                -0.068    0.009   -7.319    0.000   -0.087
##  ci.upper   Std.lv  Std.all
##    -0.522   -0.533   -0.553
##    -0.249   -0.259   -0.266
##    -0.123   -0.131   -0.139
##    -0.105   -0.113   -0.118
##    -0.134   -0.143   -0.154
##    -0.122   -0.131   -0.140
##    -0.107   -0.115   -0.124
##    -0.027   -0.036   -0.036
##    -0.356   -0.367   -0.388
##     0.116    0.108    0.112
##     0.185    0.175    0.179
##     0.291    0.282    0.285
##     0.433    0.421    0.431
##     0.343    0.333    0.348
##     0.046    0.036    0.037
##    -0.077   -0.084   -0.095
##    -0.112   -0.119   -0.125
##    -0.032   -0.040   -0.042
##    -0.086   -0.096   -0.114
##     0.257    0.248    0.259
##     1.723    0.715    0.715
##    -1.207   -0.439   -0.439
##     0.358    0.334    0.334
##    -0.534   -0.401   -0.401
##    -0.050   -0.068   -0.068
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stest1vocab       0.350    0.002  152.765    0.000    0.345
##    .Stst19dsgsdwrd    0.478    0.003  162.884    0.000    0.472
##    .Stest20spellng    0.515    0.003  172.210    0.000    0.509
##    .Stest21cptlztn    0.550    0.003  169.812    0.000    0.543
##    .Stest22puncttn    0.305    0.002  139.926    0.000    0.301
##    .Stest23english    0.472    0.003  145.290    0.000    0.466
##    .Stest24exprssn    0.542    0.004  149.292    0.000    0.535
##    .Stst25wrdfnctn    0.414    0.003  150.650    0.000    0.409
##    .Stst26rdngcmpr    0.225    0.002  120.439    0.000    0.222
##    .Stst31bstrctrs    0.478    0.003  157.483    0.000    0.472
##    .Stst32rthrsnng    0.404    0.003  161.191    0.000    0.399
##    .Stest5math        0.382    0.004  104.462    0.000    0.375
##    .Stst33hghschlm    0.234    0.002  109.593    0.000    0.230
##    .Stst34rthcmptt    0.493    0.004  135.993    0.000    0.486
##    .Stst29vslztn2D    0.610    0.004  162.099    0.000    0.602
##    .Stest35tblrdng    0.377    0.005   69.306    0.000    0.366
##    .Stst36clrclchc    0.438    0.004   97.638    0.000    0.429
##    .Stst37bjctnspc    0.534    0.004  138.838    0.000    0.527
##    .Stst28mchnclrs    0.293    0.002  121.391    0.000    0.288
##    .Stst30vslztn3D    0.394    0.003  126.255    0.000    0.388
##    .english           1.000                               1.000
##    .math              1.000                               1.000
##    .speed             1.000                               1.000
##    .spatial           1.000                               1.000
##    .g                 1.000                               1.000
##  ci.upper   Std.lv  Std.all
##     0.354    0.350    0.377
##     0.483    0.478    0.504
##     0.521    0.515    0.573
##     0.556    0.550    0.597
##     0.310    0.305    0.355
##     0.478    0.472    0.543
##     0.550    0.542    0.634
##     0.420    0.414    0.432
##     0.229    0.225    0.251
##     0.483    0.478    0.514
##     0.409    0.404    0.419
##     0.390    0.382    0.391
##     0.238    0.234    0.245
##     0.500    0.493    0.541
##     0.617    0.610    0.652
##     0.387    0.377    0.475
##     0.447    0.438    0.479
##     0.542    0.534    0.596
##     0.298    0.293    0.405
##     0.400    0.394    0.430
##     1.000    0.176    0.176
##     1.000    0.128    0.128
##     1.000    0.940    0.940
##     1.000    0.525    0.525
##     1.000    0.984    0.984

CHC Bifactor models (g varies depending on which intercept is freed, S26 is freed instead of S5 because S26 has low loading on its factor)

chc.bifactor.model <-'
english =~ Stest19disguisedwords + Stest20spelling + Stest21capitalization + Stest22punctuation + Stest23english + Stest24expression + Stest25wordfunctions + Stest26readingcomprehension + Stest31abstractreasoning 
math =~ Stest5math + Stest25wordfunctions + Stest32arithreasoning + Stest33highschoolmath + Stest34arithcomputation
speed =~ Stest19disguisedwords + Stest29visualization2D + Stest34arithcomputation + Stest35tablereading + Stest36clericalchecking + Stest37objectinspection
spatial =~ Stest28mechanicalreasoning + Stest29visualization2D + Stest30visualization3D + Stest31abstractreasoning + Stest37objectinspection
g=~ Stest1vocab + Stest5math + Stest19disguisedwords + Stest20spelling + Stest21capitalization + Stest22punctuation + Stest23english + Stest24expression + Stest25wordfunctions + Stest26readingcomprehension + Stest28mechanicalreasoning + Stest29visualization2D + Stest30visualization3D + Stest31abstractreasoning + Stest32arithreasoning + Stest33highschoolmath + Stest34arithcomputation + Stest35tablereading + Stest36clericalchecking + Stest37objectinspection
'

baseline<-cfa(chc.bifactor.model, data=dgroup, meanstructure=TRUE, sampling.weights="BY_WTA", std.lv=T, orthogonal=T)
fitMeasures(baseline, c("chisq", "df", "pvalue", "cfi", "rmsea", "srmr", "aic", "bic"))
##       chisq          df      pvalue         cfi       rmsea        srmr 
##   81850.530     145.000       0.000       0.943       0.063       0.048 
##         aic         bic 
## 6592591.839 6593430.338
Mc(baseline)
## [1] 0.7502267
configural<-cfa(chc.bifactor.model, data=dgroup, group="sex", meanstructure=TRUE, sampling.weights="BY_WTA", std.lv=T, orthogonal=T)
fitMeasures(configural, c("chisq", "df", "pvalue", "cfi", "rmsea", "srmr", "aic", "bic"))
##       chisq          df      pvalue         cfi       rmsea        srmr 
##   55981.306     290.000       0.000       0.961       0.052       0.030 
##         aic         bic 
## 6462892.841 6464569.838
Mc(configural)
## [1] 0.8221101
summary(configural, standardized=T, ci=T)
## lavaan 0.6-18 ended normally after 33 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                       170
## 
##   Number of observations per group:                   
##     0                                            70776
##     1                                            71381
##   Sampling weights variable                     BY_WTA
## 
## Model Test User Model:
##                                                Standard      Scaled
##   Test Statistic                              55981.306   48244.345
##   Degrees of freedom                                290         290
##   P-value (Chi-square)                            0.000       0.000
##   Scaling correction factor                                   1.160
##     Yuan-Bentler correction (Mplus variant)                        
##   Test statistic for each group:
##     0                                         30848.992   26585.471
##     1                                         25132.314   21658.873
## 
## Parameter Estimates:
## 
##   Standard errors                             Sandwich
##   Information bread                           Observed
##   Observed information based on                Hessian
## 
## 
## Group 1 [0]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english =~                                                   
##     Stst19dsgsdwrd    0.219    0.008   26.846    0.000    0.203
##     Stest20spellng    0.389    0.008   49.254    0.000    0.374
##     Stest21cptlztn    0.296    0.005   54.121    0.000    0.285
##     Stest22puncttn    0.355    0.006   55.611    0.000    0.343
##     Stest23english    0.269    0.007   40.633    0.000    0.256
##     Stest24exprssn    0.177    0.007   23.661    0.000    0.162
##     Stst25wrdfnctn    0.239    0.005   48.025    0.000    0.229
##     Stst26rdngcmpr    0.082    0.007   12.134    0.000    0.069
##     Stst31bstrctrs    0.077    0.006   13.926    0.000    0.066
##   math =~                                                      
##     Stest5math        0.247    0.004   62.339    0.000    0.239
##     Stst25wrdfnctn    0.172    0.004   44.209    0.000    0.165
##     Stst32rthrsnng    0.191    0.004   43.731    0.000    0.183
##     Stst33hghschlm    0.574    0.006  102.575    0.000    0.563
##     Stst34rthcmptt    0.275    0.005   55.024    0.000    0.265
##   speed =~                                                     
##     Stst19dsgsdwrd    0.268    0.004   74.361    0.000    0.261
##     Stst29vslztn2D    0.230    0.004   57.194    0.000    0.222
##     Stst34rthcmptt    0.378    0.004   97.384    0.000    0.370
##     Stest35tblrdng    0.663    0.005  126.287    0.000    0.653
##     Stst36clrclchc    0.715    0.005  154.246    0.000    0.706
##     Stst37bjctnspc    0.612    0.005  134.086    0.000    0.603
##   spatial =~                                                   
##     Stst28mchnclrs    0.448    0.004  119.638    0.000    0.441
##     Stst29vslztn2D    0.459    0.004  107.646    0.000    0.451
##     Stst30vslztn3D    0.611    0.004  137.507    0.000    0.602
##     Stst31bstrctrs    0.340    0.004   81.934    0.000    0.332
##     Stst37bjctnspc    0.265    0.004   60.403    0.000    0.256
##   g =~                                                         
##     Stest1vocab       0.781    0.003  247.211    0.000    0.775
##     Stest5math        0.729    0.003  229.457    0.000    0.723
##     Stst19dsgsdwrd    0.601    0.004  163.985    0.000    0.594
##     Stest20spellng    0.565    0.004  137.014    0.000    0.557
##     Stest21cptlztn    0.591    0.004  163.087    0.000    0.584
##     Stest22puncttn    0.729    0.003  210.301    0.000    0.722
##     Stest23english    0.661    0.004  155.219    0.000    0.652
##     Stest24exprssn    0.627    0.004  145.305    0.000    0.619
##     Stst25wrdfnctn    0.667    0.003  211.905    0.000    0.660
##     Stst26rdngcmpr    0.875    0.003  269.055    0.000    0.869
##     Stst28mchnclrs    0.513    0.003  149.081    0.000    0.506
##     Stst29vslztn2D    0.341    0.004   84.349    0.000    0.333
##     Stst30vslztn3D    0.496    0.004  122.263    0.000    0.488
##     Stst31bstrctrs    0.593    0.004  145.555    0.000    0.585
##     Stst32rthrsnng    0.746    0.003  238.260    0.000    0.740
##     Stst33hghschlm    0.794    0.003  240.374    0.000    0.787
##     Stst34rthcmptt    0.500    0.004  121.540    0.000    0.492
##     Stest35tblrdng    0.301    0.005   61.440    0.000    0.291
##     Stst36clrclchc    0.118    0.004   27.434    0.000    0.110
##     Stst37bjctnspc    0.126    0.004   28.690    0.000    0.118
##  ci.upper   Std.lv  Std.all
##                            
##     0.235    0.219    0.225
##     0.405    0.389    0.389
##     0.306    0.296    0.302
##     0.368    0.355    0.359
##     0.282    0.269    0.264
##     0.192    0.177    0.169
##     0.248    0.239    0.246
##     0.095    0.082    0.080
##     0.087    0.077    0.078
##                            
##     0.255    0.247    0.263
##     0.180    0.172    0.178
##     0.200    0.191    0.194
##     0.585    0.574    0.552
##     0.284    0.275    0.278
##                            
##     0.275    0.268    0.276
##     0.238    0.230    0.235
##     0.385    0.378    0.382
##     0.673    0.663    0.641
##     0.724    0.715    0.716
##     0.621    0.612    0.593
##                            
##     0.455    0.448    0.505
##     0.467    0.459    0.470
##     0.619    0.611    0.599
##     0.349    0.340    0.346
##     0.273    0.265    0.257
##                            
##     0.787    0.781    0.835
##     0.735    0.729    0.775
##     0.608    0.601    0.617
##     0.574    0.565    0.565
##     0.598    0.591    0.604
##     0.735    0.729    0.736
##     0.669    0.661    0.647
##     0.636    0.627    0.599
##     0.673    0.667    0.688
##     0.882    0.875    0.858
##     0.520    0.513    0.579
##     0.349    0.341    0.349
##     0.504    0.496    0.487
##     0.601    0.593    0.602
##     0.752    0.746    0.755
##     0.800    0.794    0.763
##     0.508    0.500    0.505
##     0.310    0.301    0.291
##     0.127    0.118    0.118
##     0.135    0.126    0.123
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english ~~                                                   
##     math              0.000                               0.000
##     speed             0.000                               0.000
##     spatial           0.000                               0.000
##     g                 0.000                               0.000
##   math ~~                                                      
##     speed             0.000                               0.000
##     spatial           0.000                               0.000
##     g                 0.000                               0.000
##   speed ~~                                                     
##     spatial           0.000                               0.000
##     g                 0.000                               0.000
##   spatial ~~                                                   
##     g                 0.000                               0.000
##  ci.upper   Std.lv  Std.all
##                            
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##                            
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##                            
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##                            
##     0.000    0.000    0.000
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stst19dsgsdwrd   -0.119    0.004  -30.513    0.000   -0.126
##    .Stest20spellng   -0.258    0.004  -64.136    0.000   -0.265
##    .Stest21cptlztn   -0.212    0.004  -54.084    0.000   -0.220
##    .Stest22puncttn   -0.208    0.004  -52.316    0.000   -0.216
##    .Stest23english   -0.144    0.004  -35.041    0.000   -0.152
##    .Stest24exprssn   -0.118    0.004  -28.047    0.000   -0.126
##    .Stst25wrdfnctn   -0.139    0.004  -35.813    0.000   -0.147
##    .Stst26rdngcmpr   -0.032    0.004   -7.896    0.000   -0.041
##    .Stst31bstrctrs    0.055    0.004   13.853    0.000    0.047
##    .Stest5math        0.193    0.004   51.128    0.000    0.186
##    .Stst32rthrsnng    0.121    0.004   30.651    0.000    0.114
##    .Stst33hghschlm    0.117    0.004   28.152    0.000    0.109
##    .Stst34rthcmptt   -0.078    0.004  -19.713    0.000   -0.086
##    .Stst29vslztn2D    0.212    0.004   54.436    0.000    0.204
##    .Stest35tblrdng   -0.068    0.004  -16.347    0.000   -0.076
##    .Stst36clrclchc   -0.147    0.004  -37.322    0.000   -0.155
##    .Stst37bjctnspc   -0.095    0.004  -23.187    0.000   -0.103
##    .Stst28mchnclrs    0.536    0.004  151.033    0.000    0.529
##    .Stst30vslztn3D    0.190    0.004   46.616    0.000    0.182
##    .Stest1vocab       0.167    0.004   44.518    0.000    0.160
##  ci.upper   Std.lv  Std.all
##    -0.111   -0.119   -0.122
##    -0.250   -0.258   -0.257
##    -0.204   -0.212   -0.217
##    -0.200   -0.208   -0.210
##    -0.136   -0.144   -0.141
##    -0.110   -0.118   -0.113
##    -0.132   -0.139   -0.144
##    -0.024   -0.032   -0.032
##     0.063    0.055    0.056
##     0.201    0.193    0.205
##     0.129    0.121    0.123
##     0.125    0.117    0.113
##    -0.070   -0.078   -0.079
##     0.219    0.212    0.217
##    -0.060   -0.068   -0.066
##    -0.140   -0.147   -0.148
##    -0.087   -0.095   -0.092
##     0.543    0.536    0.605
##     0.198    0.190    0.186
##     0.175    0.167    0.179
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stst19dsgsdwrd    0.467    0.003  140.747    0.000    0.460
##    .Stest20spellng    0.530    0.005  105.813    0.000    0.520
##    .Stest21cptlztn    0.520    0.004  147.447    0.000    0.513
##    .Stest22puncttn    0.323    0.004   86.111    0.000    0.316
##    .Stest23english    0.534    0.004  138.828    0.000    0.526
##    .Stest24exprssn    0.672    0.004  154.760    0.000    0.663
##    .Stst25wrdfnctn    0.408    0.003  137.023    0.000    0.402
##    .Stst26rdngcmpr    0.267    0.003  100.892    0.000    0.262
##    .Stst31bstrctrs    0.496    0.003  150.919    0.000    0.490
##    .Stest5math        0.292    0.003   97.784    0.000    0.286
##    .Stst32rthrsnng    0.382    0.002  154.296    0.000    0.377
##    .Stst33hghschlm    0.121    0.006   21.829    0.000    0.111
##    .Stst34rthcmptt    0.510    0.004  131.291    0.000    0.502
##    .Stst29vslztn2D    0.573    0.005  124.530    0.000    0.564
##    .Stest35tblrdng    0.538    0.007   72.188    0.000    0.524
##    .Stst36clrclchc    0.472    0.006   83.606    0.000    0.461
##    .Stst37bjctnspc    0.602    0.005  117.142    0.000    0.592
##    .Stst28mchnclrs    0.322    0.003  114.109    0.000    0.316
##    .Stst30vslztn3D    0.420    0.004   93.720    0.000    0.411
##    .Stest1vocab       0.265    0.002  120.508    0.000    0.260
##     english           1.000                               1.000
##     math              1.000                               1.000
##     speed             1.000                               1.000
##     spatial           1.000                               1.000
##     g                 1.000                               1.000
##  ci.upper   Std.lv  Std.all
##     0.473    0.467    0.492
##     0.540    0.530    0.529
##     0.527    0.520    0.543
##     0.330    0.323    0.330
##     0.542    0.534    0.512
##     0.680    0.672    0.613
##     0.414    0.408    0.434
##     0.272    0.267    0.257
##     0.503    0.496    0.512
##     0.298    0.292    0.330
##     0.387    0.382    0.392
##     0.132    0.121    0.112
##     0.517    0.510    0.521
##     0.582    0.573    0.601
##     0.553    0.538    0.504
##     0.483    0.472    0.473
##     0.612    0.602    0.567
##     0.327    0.322    0.410
##     0.429    0.420    0.404
##     0.269    0.265    0.303
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
## 
## 
## Group 2 [1]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english =~                                                   
##     Stst19dsgsdwrd    0.256    0.008   33.394    0.000    0.241
##     Stest20spellng    0.385    0.008   50.963    0.000    0.370
##     Stest21cptlztn    0.254    0.006   41.236    0.000    0.242
##     Stest22puncttn    0.284    0.006   43.801    0.000    0.272
##     Stest23english    0.245    0.006   44.516    0.000    0.234
##     Stest24exprssn    0.136    0.006   21.898    0.000    0.124
##     Stst25wrdfnctn    0.184    0.006   31.079    0.000    0.172
##     Stst26rdngcmpr    0.043    0.005    8.139    0.000    0.032
##     Stst31bstrctrs    0.074    0.006   12.185    0.000    0.062
##   math =~                                                      
##     Stest5math        0.354    0.005   78.665    0.000    0.345
##     Stst25wrdfnctn    0.152    0.004   35.510    0.000    0.144
##     Stst32rthrsnng    0.161    0.004   39.313    0.000    0.153
##     Stst33hghschlm    0.560    0.005  102.740    0.000    0.549
##     Stst34rthcmptt    0.233    0.005   50.592    0.000    0.224
##   speed =~                                                     
##     Stst19dsgsdwrd    0.291    0.004   80.473    0.000    0.283
##     Stst29vslztn2D    0.210    0.004   51.401    0.000    0.202
##     Stst34rthcmptt    0.334    0.004   87.455    0.000    0.327
##     Stest35tblrdng    0.549    0.005  120.920    0.000    0.540
##     Stst36clrclchc    0.656    0.004  151.021    0.000    0.648
##     Stst37bjctnspc    0.537    0.004  129.535    0.000    0.529
##   spatial =~                                                   
##     Stst28mchnclrs    0.397    0.004  113.163    0.000    0.391
##     Stst29vslztn2D    0.427    0.004   98.979    0.000    0.419
##     Stst30vslztn3D    0.523    0.004  123.291    0.000    0.515
##     Stst31bstrctrs    0.315    0.004   76.269    0.000    0.307
##     Stst37bjctnspc    0.224    0.004   54.833    0.000    0.216
##   g =~                                                         
##     Stest1vocab       0.808    0.003  269.650    0.000    0.802
##     Stest5math        0.675    0.003  197.244    0.000    0.669
##     Stst19dsgsdwrd    0.576    0.004  156.735    0.000    0.569
##     Stest20spellng    0.496    0.004  135.392    0.000    0.488
##     Stest21cptlztn    0.506    0.004  134.750    0.000    0.499
##     Stest22puncttn    0.671    0.003  209.121    0.000    0.665
##     Stest23english    0.554    0.004  152.892    0.000    0.546
##     Stest24exprssn    0.490    0.004  133.079    0.000    0.483
##     Stst25wrdfnctn    0.711    0.003  225.335    0.000    0.704
##     Stst26rdngcmpr    0.785    0.003  274.229    0.000    0.779
##     Stst28mchnclrs    0.446    0.003  145.381    0.000    0.440
##     Stst29vslztn2D    0.324    0.004   83.414    0.000    0.316
##     Stst30vslztn3D    0.452    0.004  125.087    0.000    0.445
##     Stst31bstrctrs    0.573    0.004  148.519    0.000    0.566
##     Stst32rthrsnng    0.709    0.003  234.928    0.000    0.703
##     Stst33hghschlm    0.636    0.003  196.219    0.000    0.630
##     Stst34rthcmptt    0.441    0.004  110.456    0.000    0.433
##     Stest35tblrdng    0.215    0.004   50.915    0.000    0.207
##     Stst36clrclchc    0.121    0.004   30.319    0.000    0.113
##     Stst37bjctnspc    0.147    0.004   37.267    0.000    0.139
##  ci.upper   Std.lv  Std.all
##                            
##     0.271    0.256    0.265
##     0.400    0.385    0.423
##     0.266    0.254    0.275
##     0.297    0.284    0.314
##     0.256    0.245    0.270
##     0.148    0.136    0.152
##     0.196    0.184    0.187
##     0.053    0.043    0.047
##     0.086    0.074    0.078
##                            
##     0.363    0.354    0.358
##     0.161    0.152    0.155
##     0.170    0.161    0.167
##     0.570    0.560    0.607
##     0.242    0.233    0.251
##                            
##     0.298    0.291    0.301
##     0.218    0.210    0.219
##     0.342    0.334    0.359
##     0.558    0.549    0.637
##     0.665    0.656    0.704
##     0.545    0.537    0.578
##                            
##     0.404    0.397    0.483
##     0.435    0.427    0.446
##     0.532    0.523    0.563
##     0.323    0.315    0.330
##     0.232    0.224    0.242
##                            
##     0.814    0.808    0.827
##     0.682    0.675    0.683
##     0.583    0.576    0.597
##     0.503    0.496    0.544
##     0.514    0.506    0.549
##     0.678    0.671    0.743
##     0.561    0.554    0.610
##     0.497    0.490    0.547
##     0.717    0.711    0.721
##     0.790    0.785    0.864
##     0.452    0.446    0.543
##     0.331    0.324    0.338
##     0.459    0.452    0.486
##     0.581    0.573    0.600
##     0.715    0.709    0.735
##     0.642    0.636    0.690
##     0.449    0.441    0.474
##     0.223    0.215    0.250
##     0.129    0.121    0.130
##     0.154    0.147    0.158
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english ~~                                                   
##     math              0.000                               0.000
##     speed             0.000                               0.000
##     spatial           0.000                               0.000
##     g                 0.000                               0.000
##   math ~~                                                      
##     speed             0.000                               0.000
##     spatial           0.000                               0.000
##     g                 0.000                               0.000
##   speed ~~                                                     
##     spatial           0.000                               0.000
##     g                 0.000                               0.000
##   spatial ~~                                                   
##     g                 0.000                               0.000
##  ci.upper   Std.lv  Std.all
##                            
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##                            
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##                            
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##                            
##     0.000    0.000    0.000
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stst19dsgsdwrd    0.150    0.004   38.967    0.000    0.142
##    .Stest20spellng    0.280    0.004   77.302    0.000    0.273
##    .Stest21cptlztn    0.276    0.004   74.784    0.000    0.268
##    .Stest22puncttn    0.278    0.004   76.957    0.000    0.271
##    .Stest23english    0.190    0.004   52.481    0.000    0.183
##    .Stest24exprssn    0.165    0.004   46.240    0.000    0.158
##    .Stst25wrdfnctn    0.196    0.004   50.126    0.000    0.189
##    .Stst26rdngcmpr    0.105    0.004   29.044    0.000    0.098
##    .Stst31bstrctrs    0.026    0.004    6.799    0.000    0.018
##    .Stest5math       -0.155    0.004  -39.596    0.000   -0.163
##    .Stst32rthrsnng   -0.040    0.004  -10.549    0.000   -0.048
##    .Stst33hghschlm   -0.072    0.004  -19.964    0.000   -0.080
##    .Stst34rthcmptt    0.165    0.004   44.491    0.000    0.158
##    .Stst29vslztn2D   -0.150    0.004  -39.724    0.000   -0.157
##    .Stest35tblrdng    0.085    0.003   24.796    0.000    0.078
##    .Stst36clrclchc    0.094    0.004   25.710    0.000    0.087
##    .Stst37bjctnspc    0.084    0.004   22.827    0.000    0.076
##    .Stst28mchnclrs   -0.428    0.003 -131.000    0.000   -0.434
##    .Stst30vslztn3D   -0.115    0.004  -31.342    0.000   -0.122
##    .Stest1vocab      -0.095    0.004  -24.615    0.000   -0.103
##  ci.upper   Std.lv  Std.all
##     0.158    0.150    0.155
##     0.287    0.280    0.308
##     0.283    0.276    0.299
##     0.285    0.278    0.307
##     0.197    0.190    0.209
##     0.172    0.165    0.184
##     0.204    0.196    0.199
##     0.112    0.105    0.116
##     0.033    0.026    0.027
##    -0.147   -0.155   -0.157
##    -0.033   -0.040   -0.042
##    -0.065   -0.072   -0.079
##     0.172    0.165    0.177
##    -0.143   -0.150   -0.157
##     0.091    0.085    0.098
##     0.101    0.094    0.100
##     0.091    0.084    0.090
##    -0.422   -0.428   -0.521
##    -0.108   -0.115   -0.124
##    -0.088   -0.095   -0.097
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stst19dsgsdwrd    0.449    0.004  125.602    0.000    0.442
##    .Stest20spellng    0.436    0.005   86.050    0.000    0.426
##    .Stest21cptlztn    0.531    0.004  150.893    0.000    0.525
##    .Stest22puncttn    0.286    0.003  100.584    0.000    0.280
##    .Stest23english    0.458    0.003  142.008    0.000    0.452
##    .Stest24exprssn    0.544    0.004  151.458    0.000    0.537
##    .Stst25wrdfnctn    0.408    0.003  142.206    0.000    0.402
##    .Stst26rdngcmpr    0.208    0.002   94.212    0.000    0.204
##    .Stst31bstrctrs    0.478    0.003  152.794    0.000    0.471
##    .Stest5math        0.397    0.004  104.882    0.000    0.390
##    .Stst32rthrsnng    0.403    0.003  160.936    0.000    0.398
##    .Stst33hghschlm    0.132    0.006   23.574    0.000    0.121
##    .Stst34rthcmptt    0.504    0.004  131.955    0.000    0.497
##    .Stst29vslztn2D    0.585    0.004  138.970    0.000    0.577
##    .Stest35tblrdng    0.395    0.005   75.209    0.000    0.385
##    .Stst36clrclchc    0.423    0.005   87.801    0.000    0.414
##    .Stst37bjctnspc    0.503    0.004  123.127    0.000    0.495
##    .Stst28mchnclrs    0.319    0.003  124.295    0.000    0.314
##    .Stst30vslztn3D    0.386    0.004  101.273    0.000    0.379
##    .Stest1vocab       0.301    0.002  121.242    0.000    0.296
##     english           1.000                               1.000
##     math              1.000                               1.000
##     speed             1.000                               1.000
##     spatial           1.000                               1.000
##     g                 1.000                               1.000
##  ci.upper   Std.lv  Std.all
##     0.456    0.449    0.482
##     0.446    0.436    0.525
##     0.538    0.531    0.624
##     0.292    0.286    0.350
##     0.464    0.458    0.555
##     0.551    0.544    0.678
##     0.414    0.408    0.421
##     0.212    0.208    0.252
##     0.484    0.478    0.524
##     0.404    0.397    0.406
##     0.408    0.403    0.432
##     0.143    0.132    0.156
##     0.512    0.504    0.583
##     0.593    0.585    0.639
##     0.405    0.395    0.532
##     0.433    0.423    0.487
##     0.511    0.503    0.583
##     0.324    0.319    0.472
##     0.394    0.386    0.447
##     0.306    0.301    0.315
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
modificationIndices(configural, sort=T, maximum.number=30)
##                             lhs op                         rhs block
## 225                        math =~          Stest22punctuation     1
## 71                      english ~~                        math     1
## 252                     spatial =~             Stest20spelling     1
## 634 Stest26readingcomprehension ~~                 Stest1vocab     2
## 389 Stest26readingcomprehension ~~                 Stest1vocab     1
## 459                     english =~     Stest34arithcomputation     2
## 214                     english =~     Stest34arithcomputation     1
## 497                     spatial =~             Stest20spelling     2
## 482                       speed =~             Stest20spelling     2
## 237                       speed =~             Stest20spelling     1
## 177                     english ~~                       speed     2
## 470                        math =~          Stest22punctuation     2
## 473                        math =~ Stest26readingcomprehension     2
## 228                        math =~ Stest26readingcomprehension     1
## 540             Stest20spelling ~~     Stest34arithcomputation     2
## 73                      english ~~                     spatial     1
## 295             Stest20spelling ~~     Stest34arithcomputation     1
## 266       Stest19disguisedwords ~~             Stest20spelling     1
## 262                     spatial =~     Stest34arithcomputation     1
## 181                        math ~~                     spatial     2
## 511       Stest19disguisedwords ~~             Stest20spelling     2
## 76                         math ~~                     spatial     1
## 655                  Stest5math ~~                 Stest1vocab     2
## 323          Stest22punctuation ~~ Stest26readingcomprehension     1
## 229                        math =~    Stest31abstractreasoning     1
## 178                     english ~~                     spatial     2
## 236                        math =~                 Stest1vocab     1
## 284       Stest19disguisedwords ~~                 Stest1vocab     1
## 410                  Stest5math ~~                 Stest1vocab     1
## 280       Stest19disguisedwords ~~     Stest36clericalchecking     1
##     group level       mi    epc sepc.lv sepc.all sepc.nox
## 225     1     1 3552.425  0.189   0.189    0.191    0.191
## 71      1     1 3074.617  0.511   0.511    0.511    0.511
## 252     1     1 2981.106 -0.200  -0.200   -0.200   -0.200
## 634     2     1 2954.047  0.088   0.088    0.351    0.351
## 389     1     1 2750.415  0.083   0.083    0.312    0.312
## 459     2     1 2629.008  0.234   0.234    0.251    0.251
## 214     1     1 2206.003  0.213   0.213    0.216    0.216
## 497     2     1 2073.207 -0.161  -0.161   -0.177   -0.177
## 482     2     1 1837.559  0.137   0.137    0.150    0.150
## 237     1     1 1702.470  0.140   0.140    0.140    0.140
## 177     2     1 1637.416  0.293   0.293    0.293    0.293
## 470     2     1 1537.390  0.113   0.113    0.125    0.125
## 473     2     1 1530.188 -0.114  -0.114   -0.126   -0.126
## 228     1     1 1507.054 -0.127  -0.127   -0.125   -0.125
## 540     2     1 1466.086  0.077   0.077    0.165    0.165
## 73      1     1 1465.756 -0.293  -0.293   -0.293   -0.293
## 295     1     1 1464.646  0.084   0.084    0.162    0.162
## 266     1     1 1434.317  0.090   0.090    0.181    0.181
## 262     1     1 1356.194 -0.131  -0.131   -0.133   -0.133
## 181     2     1 1348.079  0.228   0.228    0.228    0.228
## 511     2     1 1270.429  0.090   0.090    0.202    0.202
## 76      1     1 1211.281  0.212   0.212    0.212    0.212
## 655     2     1 1105.603  0.055   0.055    0.158    0.158
## 323     1     1 1089.215 -0.051  -0.051   -0.172   -0.172
## 229     1     1 1082.012  0.121   0.121    0.123    0.123
## 178     2     1 1075.882 -0.269  -0.269   -0.269   -0.269
## 236     1     1 1057.161 -0.113  -0.113   -0.121   -0.121
## 284     1     1 1030.213  0.053   0.053    0.151    0.151
## 410     1     1 1005.512  0.043   0.043    0.155    0.155
## 280     1     1  993.242  0.078   0.078    0.167    0.167
metric<-cfa(chc.bifactor.model, data=dgroup, group="sex", meanstructure=TRUE, sampling.weights="BY_WTA", std.lv=T, orthogonal=T, group.equal=c("loadings"))
fitMeasures(metric, c("chisq", "df", "pvalue", "cfi", "rmsea", "srmr", "aic", "bic"))
##       chisq          df      pvalue         cfi       rmsea        srmr 
##   61754.707     330.000       0.000       0.957       0.051       0.038 
##         aic         bic 
## 6468586.243 6469868.652
Mc(metric)
## [1] 0.8056976
summary(metric, standardized=T, ci=T)
## lavaan 0.6-18 ended normally after 60 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                       175
##   Number of equality constraints                    45
## 
##   Number of observations per group:                   
##     0                                            70776
##     1                                            71381
##   Sampling weights variable                     BY_WTA
## 
## Model Test User Model:
##                                                Standard      Scaled
##   Test Statistic                              61754.707   52834.766
##   Degrees of freedom                                330         330
##   P-value (Chi-square)                            0.000       0.000
##   Scaling correction factor                                   1.169
##     Yuan-Bentler correction (Mplus variant)                        
##   Test statistic for each group:
##     0                                         33532.795   28689.269
##     1                                         28221.912   24145.497
## 
## Parameter Estimates:
## 
##   Standard errors                             Sandwich
##   Information bread                           Observed
##   Observed information based on                Hessian
## 
## 
## Group 1 [0]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english =~                                                   
##     Stst19d (.p1.)    0.245    0.006   40.928    0.000    0.233
##     Stst20s (.p2.)    0.406    0.006   67.522    0.000    0.394
##     Stst21c (.p3.)    0.291    0.005   61.768    0.000    0.282
##     Stst22p (.p4.)    0.339    0.005   62.192    0.000    0.328
##     Stst23n (.p5.)    0.271    0.005   56.333    0.000    0.261
##     Stst24x (.p6.)    0.165    0.005   30.905    0.000    0.154
##     Stst25w (.p7.)    0.222    0.004   52.257    0.000    0.213
##     Stst26r (.p8.)    0.066    0.005   14.520    0.000    0.057
##     Stst31b (.p9.)    0.081    0.004   18.758    0.000    0.073
##   math =~                                                      
##     Stst5mt (.10.)    0.294    0.003   97.793    0.000    0.288
##     Stst25w (.11.)    0.157    0.003   51.651    0.000    0.151
##     Stst32r (.12.)    0.176    0.003   53.463    0.000    0.170
##     Stst33h (.13.)    0.567    0.005  118.136    0.000    0.557
##     Stst34r (.14.)    0.255    0.004   67.116    0.000    0.248
##   speed =~                                                     
##     Stst19d (.15.)    0.294    0.003  106.486    0.000    0.289
##     Sts292D (.16.)    0.232    0.003   75.363    0.000    0.226
##     Stst34r (.17.)    0.377    0.003  121.458    0.000    0.371
##     Stst35t (.18.)    0.639    0.004  147.540    0.000    0.630
##     Stst36c (.19.)    0.725    0.004  183.376    0.000    0.718
##     Stst37b (.20.)    0.607    0.004  159.930    0.000    0.600
##   spatial =~                                                   
##     Stst28m (.21.)    0.449    0.003  147.351    0.000    0.443
##     Sts292D (.22.)    0.469    0.003  136.247    0.000    0.463
##     Sts303D (.23.)    0.603    0.004  160.415    0.000    0.596
##     Stst31b (.24.)    0.348    0.003  107.176    0.000    0.342
##     Stst37b (.25.)    0.260    0.003   78.725    0.000    0.254
##   g =~                                                         
##     Stst1vc (.26.)    0.819    0.003  300.751    0.000    0.813
##     Stst5mt (.27.)    0.726    0.003  262.668    0.000    0.720
##     Stst19d (.28.)    0.610    0.003  206.070    0.000    0.604
##     Stst20s (.29.)    0.550    0.003  174.811    0.000    0.543
##     Stst21c (.30.)    0.570    0.003  190.405    0.000    0.564
##     Stst22p (.31.)    0.726    0.003  251.070    0.000    0.720
##     Stst23n (.32.)    0.629    0.003  192.076    0.000    0.622
##     Stst24x (.33.)    0.576    0.003  174.470    0.000    0.570
##     Stst25w (.34.)    0.713    0.003  274.806    0.000    0.708
##     Stst26r (.35.)    0.860    0.003  293.850    0.000    0.854
##     Stst28m (.36.)    0.499    0.003  189.805    0.000    0.493
##     Sts292D (.37.)    0.345    0.003  115.785    0.000    0.339
##     Sts303D (.38.)    0.492    0.003  165.615    0.000    0.486
##     Stst31b (.39.)    0.604    0.003  192.556    0.000    0.598
##     Stst32r (.40.)    0.754    0.003  280.700    0.000    0.749
##     Stst33h (.41.)    0.743    0.003  256.511    0.000    0.737
##     Stst34r (.42.)    0.488    0.003  154.794    0.000    0.482
##     Stst35t (.43.)    0.263    0.003   76.941    0.000    0.256
##     Stst36c (.44.)    0.124    0.003   40.587    0.000    0.118
##     Stst37b (.45.)    0.142    0.003   46.445    0.000    0.136
##  ci.upper   Std.lv  Std.all
##                            
##     0.257    0.245    0.248
##     0.418    0.406    0.409
##     0.300    0.291    0.302
##     0.349    0.339    0.344
##     0.280    0.271    0.270
##     0.175    0.165    0.162
##     0.230    0.222    0.222
##     0.075    0.066    0.066
##     0.090    0.081    0.082
##                            
##     0.299    0.294    0.309
##     0.163    0.157    0.158
##     0.183    0.176    0.178
##     0.576    0.567    0.563
##     0.263    0.255    0.261
##                            
##     0.300    0.294    0.298
##     0.239    0.232    0.237
##     0.383    0.377    0.385
##     0.647    0.639    0.628
##     0.733    0.725    0.724
##     0.615    0.607    0.589
##                            
##     0.455    0.449    0.511
##     0.476    0.469    0.479
##     0.611    0.603    0.594
##     0.354    0.348    0.350
##     0.267    0.260    0.252
##                            
##     0.824    0.819    0.848
##     0.731    0.726    0.765
##     0.616    0.610    0.618
##     0.556    0.550    0.553
##     0.576    0.570    0.590
##     0.732    0.726    0.737
##     0.635    0.629    0.627
##     0.583    0.576    0.566
##     0.718    0.713    0.715
##     0.866    0.860    0.856
##     0.504    0.499    0.568
##     0.351    0.345    0.352
##     0.498    0.492    0.485
##     0.611    0.604    0.608
##     0.760    0.754    0.762
##     0.749    0.743    0.739
##     0.495    0.488    0.499
##     0.270    0.263    0.258
##     0.130    0.124    0.124
##     0.148    0.142    0.138
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english ~~                                                   
##     math              0.000                               0.000
##     speed             0.000                               0.000
##     spatial           0.000                               0.000
##     g                 0.000                               0.000
##   math ~~                                                      
##     speed             0.000                               0.000
##     spatial           0.000                               0.000
##     g                 0.000                               0.000
##   speed ~~                                                     
##     spatial           0.000                               0.000
##     g                 0.000                               0.000
##   spatial ~~                                                   
##     g                 0.000                               0.000
##  ci.upper   Std.lv  Std.all
##                            
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##                            
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##                            
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##                            
##     0.000    0.000    0.000
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stst19dsgsdwrd   -0.119    0.004  -30.513    0.000   -0.126
##    .Stest20spellng   -0.258    0.004  -64.136    0.000   -0.265
##    .Stest21cptlztn   -0.212    0.004  -54.084    0.000   -0.220
##    .Stest22puncttn   -0.208    0.004  -52.316    0.000   -0.216
##    .Stest23english   -0.144    0.004  -35.041    0.000   -0.152
##    .Stest24exprssn   -0.118    0.004  -28.047    0.000   -0.126
##    .Stst25wrdfnctn   -0.139    0.004  -35.813    0.000   -0.147
##    .Stst26rdngcmpr   -0.032    0.004   -7.896    0.000   -0.041
##    .Stst31bstrctrs    0.055    0.004   13.853    0.000    0.047
##    .Stest5math        0.193    0.004   51.128    0.000    0.186
##    .Stst32rthrsnng    0.121    0.004   30.651    0.000    0.114
##    .Stst33hghschlm    0.117    0.004   28.152    0.000    0.109
##    .Stst34rthcmptt   -0.078    0.004  -19.713    0.000   -0.086
##    .Stst29vslztn2D    0.212    0.004   54.436    0.000    0.204
##    .Stest35tblrdng   -0.068    0.004  -16.347    0.000   -0.076
##    .Stst36clrclchc   -0.147    0.004  -37.322    0.000   -0.155
##    .Stst37bjctnspc   -0.095    0.004  -23.187    0.000   -0.103
##    .Stst28mchnclrs    0.536    0.004  151.033    0.000    0.529
##    .Stst30vslztn3D    0.190    0.004   46.616    0.000    0.182
##    .Stest1vocab       0.167    0.004   44.518    0.000    0.160
##  ci.upper   Std.lv  Std.all
##    -0.111   -0.119   -0.120
##    -0.250   -0.258   -0.259
##    -0.204   -0.212   -0.220
##    -0.200   -0.208   -0.211
##    -0.136   -0.144   -0.144
##    -0.110   -0.118   -0.116
##    -0.132   -0.139   -0.140
##    -0.024   -0.032   -0.032
##     0.063    0.055    0.055
##     0.201    0.193    0.204
##     0.129    0.121    0.123
##     0.125    0.117    0.116
##    -0.070   -0.078   -0.080
##     0.219    0.212    0.216
##    -0.060   -0.068   -0.067
##    -0.140   -0.147   -0.147
##    -0.087   -0.095   -0.092
##     0.543    0.536    0.610
##     0.198    0.190    0.187
##     0.175    0.167    0.173
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stst19dsgsdwrd    0.457    0.003  142.918    0.000    0.450
##    .Stest20spellng    0.520    0.005  114.541    0.000    0.511
##    .Stest21cptlztn    0.522    0.003  154.702    0.000    0.516
##    .Stest22puncttn    0.329    0.003  104.599    0.000    0.323
##    .Stest23english    0.536    0.004  139.986    0.000    0.528
##    .Stest24exprssn    0.679    0.004  154.949    0.000    0.670
##    .Stst25wrdfnctn    0.412    0.003  144.978    0.000    0.407
##    .Stst26rdngcmpr    0.266    0.002  109.580    0.000    0.261
##    .Stst31bstrctrs    0.495    0.003  152.542    0.000    0.488
##    .Stest5math        0.287    0.003   94.818    0.000    0.281
##    .Stst32rthrsnng    0.380    0.002  156.682    0.000    0.376
##    .Stst33hghschlm    0.139    0.004   31.282    0.000    0.130
##    .Stst34rthcmptt    0.512    0.004  138.451    0.000    0.505
##    .Stst29vslztn2D    0.569    0.004  129.130    0.000    0.560
##    .Stest35tblrdng    0.557    0.007   74.397    0.000    0.542
##    .Stst36clrclchc    0.461    0.005   86.924    0.000    0.451
##    .Stst37bjctnspc    0.608    0.005  125.026    0.000    0.598
##    .Stst28mchnclrs    0.322    0.003  123.059    0.000    0.317
##    .Stst30vslztn3D    0.426    0.004  106.416    0.000    0.418
##    .Stest1vocab       0.261    0.002  120.523    0.000    0.257
##     english           1.000                               1.000
##     math              1.000                               1.000
##     speed             1.000                               1.000
##     spatial           1.000                               1.000
##     g                 1.000                               1.000
##  ci.upper   Std.lv  Std.all
##     0.463    0.457    0.468
##     0.529    0.520    0.527
##     0.529    0.522    0.561
##     0.335    0.329    0.339
##     0.543    0.536    0.533
##     0.687    0.679    0.654
##     0.418    0.412    0.415
##     0.271    0.266    0.263
##     0.501    0.495    0.501
##     0.293    0.287    0.319
##     0.385    0.380    0.388
##     0.148    0.139    0.137
##     0.519    0.512    0.534
##     0.577    0.569    0.591
##     0.572    0.557    0.539
##     0.471    0.461    0.460
##     0.617    0.608    0.571
##     0.327    0.322    0.417
##     0.434    0.426    0.413
##     0.265    0.261    0.280
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
## 
## 
## Group 2 [1]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english =~                                                   
##     Stst19d (.p1.)    0.245    0.006   40.928    0.000    0.233
##     Stst20s (.p2.)    0.406    0.006   67.522    0.000    0.394
##     Stst21c (.p3.)    0.291    0.005   61.768    0.000    0.282
##     Stst22p (.p4.)    0.339    0.005   62.192    0.000    0.328
##     Stst23n (.p5.)    0.271    0.005   56.333    0.000    0.261
##     Stst24x (.p6.)    0.165    0.005   30.905    0.000    0.154
##     Stst25w (.p7.)    0.222    0.004   52.257    0.000    0.213
##     Stst26r (.p8.)    0.066    0.005   14.520    0.000    0.057
##     Stst31b (.p9.)    0.081    0.004   18.758    0.000    0.073
##   math =~                                                      
##     Stst5mt (.10.)    0.294    0.003   97.793    0.000    0.288
##     Stst25w (.11.)    0.157    0.003   51.651    0.000    0.151
##     Stst32r (.12.)    0.176    0.003   53.463    0.000    0.170
##     Stst33h (.13.)    0.567    0.005  118.136    0.000    0.557
##     Stst34r (.14.)    0.255    0.004   67.116    0.000    0.248
##   speed =~                                                     
##     Stst19d (.15.)    0.294    0.003  106.486    0.000    0.289
##     Sts292D (.16.)    0.232    0.003   75.363    0.000    0.226
##     Stst34r (.17.)    0.377    0.003  121.458    0.000    0.371
##     Stst35t (.18.)    0.639    0.004  147.540    0.000    0.630
##     Stst36c (.19.)    0.725    0.004  183.376    0.000    0.718
##     Stst37b (.20.)    0.607    0.004  159.930    0.000    0.600
##   spatial =~                                                   
##     Stst28m (.21.)    0.449    0.003  147.351    0.000    0.443
##     Sts292D (.22.)    0.469    0.003  136.247    0.000    0.463
##     Sts303D (.23.)    0.603    0.004  160.415    0.000    0.596
##     Stst31b (.24.)    0.348    0.003  107.176    0.000    0.342
##     Stst37b (.25.)    0.260    0.003   78.725    0.000    0.254
##   g =~                                                         
##     Stst1vc (.26.)    0.819    0.003  300.751    0.000    0.813
##     Stst5mt (.27.)    0.726    0.003  262.668    0.000    0.720
##     Stst19d (.28.)    0.610    0.003  206.070    0.000    0.604
##     Stst20s (.29.)    0.550    0.003  174.811    0.000    0.543
##     Stst21c (.30.)    0.570    0.003  190.405    0.000    0.564
##     Stst22p (.31.)    0.726    0.003  251.070    0.000    0.720
##     Stst23n (.32.)    0.629    0.003  192.076    0.000    0.622
##     Stst24x (.33.)    0.576    0.003  174.470    0.000    0.570
##     Stst25w (.34.)    0.713    0.003  274.806    0.000    0.708
##     Stst26r (.35.)    0.860    0.003  293.850    0.000    0.854
##     Stst28m (.36.)    0.499    0.003  189.805    0.000    0.493
##     Sts292D (.37.)    0.345    0.003  115.785    0.000    0.339
##     Sts303D (.38.)    0.492    0.003  165.615    0.000    0.486
##     Stst31b (.39.)    0.604    0.003  192.556    0.000    0.598
##     Stst32r (.40.)    0.754    0.003  280.700    0.000    0.749
##     Stst33h (.41.)    0.743    0.003  256.511    0.000    0.737
##     Stst34r (.42.)    0.488    0.003  154.794    0.000    0.482
##     Stst35t (.43.)    0.263    0.003   76.941    0.000    0.256
##     Stst36c (.44.)    0.124    0.003   40.587    0.000    0.118
##     Stst37b (.45.)    0.142    0.003   46.445    0.000    0.136
##  ci.upper   Std.lv  Std.all
##                            
##     0.257    0.221    0.233
##     0.418    0.367    0.400
##     0.300    0.263    0.281
##     0.349    0.306    0.337
##     0.280    0.245    0.264
##     0.175    0.149    0.162
##     0.230    0.200    0.210
##     0.075    0.060    0.065
##     0.090    0.073    0.078
##                            
##     0.299    0.293    0.301
##     0.163    0.157    0.164
##     0.183    0.176    0.183
##     0.576    0.566    0.591
##     0.263    0.255    0.271
##                            
##     0.300    0.262    0.276
##     0.239    0.207    0.217
##     0.383    0.336    0.357
##     0.647    0.569    0.649
##     0.733    0.646    0.694
##     0.615    0.540    0.582
##                            
##     0.455    0.396    0.477
##     0.476    0.414    0.435
##     0.611    0.532    0.570
##     0.354    0.307    0.325
##     0.267    0.230    0.247
##                            
##     0.824    0.759    0.806
##     0.731    0.672    0.691
##     0.616    0.565    0.595
##     0.556    0.509    0.555
##     0.576    0.528    0.564
##     0.732    0.673    0.740
##     0.635    0.583    0.629
##     0.583    0.534    0.579
##     0.718    0.660    0.691
##     0.866    0.797    0.865
##     0.504    0.462    0.557
##     0.351    0.320    0.336
##     0.498    0.456    0.489
##     0.611    0.560    0.593
##     0.760    0.699    0.727
##     0.749    0.689    0.720
##     0.495    0.453    0.481
##     0.270    0.244    0.278
##     0.130    0.115    0.124
##     0.148    0.132    0.142
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english ~~                                                   
##     math              0.000                               0.000
##     speed             0.000                               0.000
##     spatial           0.000                               0.000
##     g                 0.000                               0.000
##   math ~~                                                      
##     speed             0.000                               0.000
##     spatial           0.000                               0.000
##     g                 0.000                               0.000
##   speed ~~                                                     
##     spatial           0.000                               0.000
##     g                 0.000                               0.000
##   spatial ~~                                                   
##     g                 0.000                               0.000
##  ci.upper   Std.lv  Std.all
##                            
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##                            
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##                            
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##                            
##     0.000    0.000    0.000
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stst19dsgsdwrd    0.150    0.004   38.967    0.000    0.142
##    .Stest20spellng    0.280    0.004   77.302    0.000    0.273
##    .Stest21cptlztn    0.276    0.004   74.784    0.000    0.268
##    .Stest22puncttn    0.278    0.004   76.957    0.000    0.271
##    .Stest23english    0.190    0.004   52.481    0.000    0.183
##    .Stest24exprssn    0.165    0.004   46.240    0.000    0.158
##    .Stst25wrdfnctn    0.196    0.004   50.126    0.000    0.189
##    .Stst26rdngcmpr    0.105    0.004   29.044    0.000    0.098
##    .Stst31bstrctrs    0.026    0.004    6.799    0.000    0.018
##    .Stest5math       -0.155    0.004  -39.596    0.000   -0.163
##    .Stst32rthrsnng   -0.040    0.004  -10.549    0.000   -0.048
##    .Stst33hghschlm   -0.072    0.004  -19.964    0.000   -0.080
##    .Stst34rthcmptt    0.165    0.004   44.491    0.000    0.158
##    .Stst29vslztn2D   -0.150    0.004  -39.724    0.000   -0.157
##    .Stest35tblrdng    0.085    0.003   24.796    0.000    0.078
##    .Stst36clrclchc    0.094    0.004   25.710    0.000    0.087
##    .Stst37bjctnspc    0.084    0.004   22.827    0.000    0.076
##    .Stst28mchnclrs   -0.428    0.003 -131.000    0.000   -0.434
##    .Stst30vslztn3D   -0.115    0.004  -31.342    0.000   -0.122
##    .Stest1vocab      -0.095    0.004  -24.615    0.000   -0.103
##  ci.upper   Std.lv  Std.all
##     0.158    0.150    0.158
##     0.287    0.280    0.306
##     0.283    0.276    0.294
##     0.285    0.278    0.306
##     0.197    0.190    0.205
##     0.172    0.165    0.179
##     0.204    0.196    0.205
##     0.112    0.105    0.114
##     0.033    0.026    0.027
##    -0.147   -0.155   -0.159
##    -0.033   -0.040   -0.042
##    -0.065   -0.072   -0.076
##     0.172    0.165    0.175
##    -0.143   -0.150   -0.158
##     0.091    0.085    0.097
##     0.101    0.094    0.101
##     0.091    0.084    0.090
##    -0.422   -0.428   -0.516
##    -0.108   -0.115   -0.124
##    -0.088   -0.095   -0.101
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stst19dsgsdwrd    0.465    0.003  148.106    0.000    0.458
##    .Stest20spellng    0.448    0.004  111.851    0.000    0.440
##    .Stest21cptlztn    0.528    0.003  159.434    0.000    0.522
##    .Stest22puncttn    0.279    0.003  107.447    0.000    0.274
##    .Stest23english    0.458    0.003  143.620    0.000    0.452
##    .Stest24exprssn    0.543    0.004  151.151    0.000    0.536
##    .Stst25wrdfnctn    0.413    0.003  146.263    0.000    0.408
##    .Stst26rdngcmpr    0.210    0.002  103.611    0.000    0.206
##    .Stst31bstrctrs    0.480    0.003  156.821    0.000    0.474
##    .Stest5math        0.410    0.004  111.475    0.000    0.403
##    .Stst32rthrsnng    0.406    0.002  164.079    0.000    0.401
##    .Stst33hghschlm    0.121    0.004   27.074    0.000    0.112
##    .Stst34rthcmptt    0.502    0.004  133.799    0.000    0.495
##    .Stst29vslztn2D    0.590    0.004  150.475    0.000    0.583
##    .Stest35tblrdng    0.384    0.005   74.155    0.000    0.374
##    .Stst36clrclchc    0.434    0.005   96.263    0.000    0.425
##    .Stst37bjctnspc    0.499    0.004  129.907    0.000    0.492
##    .Stst28mchnclrs    0.319    0.002  135.252    0.000    0.314
##    .Stst30vslztn3D    0.380    0.003  112.675    0.000    0.373
##    .Stest1vocab       0.310    0.002  136.984    0.000    0.306
##     english           0.817    0.017   47.924    0.000    0.783
##     math              0.996    0.016   60.940    0.000    0.964
##     speed             0.792    0.010   78.896    0.000    0.772
##     spatial           0.778    0.010   79.001    0.000    0.759
##     g                 0.859    0.007  126.604    0.000    0.845
##  ci.upper   Std.lv  Std.all
##     0.471    0.465    0.515
##     0.455    0.448    0.532
##     0.535    0.528    0.603
##     0.284    0.279    0.338
##     0.464    0.458    0.534
##     0.550    0.543    0.638
##     0.419    0.413    0.452
##     0.214    0.210    0.247
##     0.486    0.480    0.537
##     0.418    0.410    0.433
##     0.411    0.406    0.438
##     0.130    0.121    0.132
##     0.509    0.502    0.568
##     0.598    0.590    0.651
##     0.394    0.384    0.501
##     0.443    0.434    0.502
##     0.507    0.499    0.580
##     0.323    0.319    0.463
##     0.387    0.380    0.436
##     0.315    0.310    0.350
##     0.850    1.000    1.000
##     1.028    1.000    1.000
##     0.812    1.000    1.000
##     0.797    1.000    1.000
##     0.872    1.000    1.000
lavTestScore(metric, release = 1:45)
## Warning: lavaan->lavTestScore():  
##    se is not `standard'; not implemented yet; falling back to 
##    ordinary score test
## $test
## 
## total score test:
## 
##    test      X2 df p.value
## 1 score 5800.25 45       0
## 
## $uni
## 
## univariate score tests:
## 
##      lhs op    rhs       X2 df p.value
## 1   .p1. == .p106.  162.858  1   0.000
## 2   .p2. == .p107.    4.751  1   0.029
## 3   .p3. == .p108.    1.891  1   0.169
## 4   .p4. == .p109.   31.086  1   0.000
## 5   .p5. == .p110.    3.107  1   0.078
## 6   .p6. == .p111.   40.770  1   0.000
## 7   .p7. == .p112.    5.512  1   0.019
## 8   .p8. == .p113.  107.429  1   0.000
## 9   .p9. == .p114.    8.500  1   0.004
## 10 .p10. == .p115.  855.629  1   0.000
## 11 .p11. == .p116.   11.197  1   0.001
## 12 .p12. == .p117.  119.009  1   0.000
## 13 .p13. == .p118.  139.456  1   0.000
## 14 .p14. == .p119.  177.651  1   0.000
## 15 .p15. == .p120.  185.219  1   0.000
## 16 .p16. == .p121.    0.638  1   0.425
## 17 .p17. == .p122.    0.163  1   0.686
## 18 .p18. == .p123.  103.954  1   0.000
## 19 .p19. == .p124.    5.486  1   0.019
## 20 .p20. == .p125.    0.431  1   0.512
## 21 .p21. == .p126.    0.889  1   0.346
## 22 .p22. == .p127.   18.785  1   0.000
## 23 .p23. == .p128.   19.736  1   0.000
## 24 .p24. == .p129.    8.332  1   0.004
## 25 .p25. == .p130.    2.096  1   0.148
## 26 .p26. == .p131. 1161.881  1   0.000
## 27 .p27. == .p132.  165.853  1   0.000
## 28 .p28. == .p133.   74.628  1   0.000
## 29 .p29. == .p134.   32.448  1   0.000
## 30 .p30. == .p135.  107.404  1   0.000
## 31 .p31. == .p136.    0.325  1   0.569
## 32 .p32. == .p137.  225.163  1   0.000
## 33 .p33. == .p138.  504.121  1   0.000
## 34 .p34. == .p139. 1028.719  1   0.000
## 35 .p35. == .p140.  194.864  1   0.000
## 36 .p36. == .p141.   99.405  1   0.000
## 37 .p37. == .p142.   10.362  1   0.001
## 38 .p38. == .p143.    4.352  1   0.037
## 39 .p39. == .p144.   64.919  1   0.000
## 40 .p40. == .p145.  103.869  1   0.000
## 41 .p41. == .p146. 1298.089  1   0.000
## 42 .p42. == .p147.    0.104  1   0.747
## 43 .p43. == .p148.  354.849  1   0.000
## 44 .p44. == .p149.   23.722  1   0.000
## 45 .p45. == .p150.   76.426  1   0.000
scalar<-cfa(chc.bifactor.model, data=dgroup, group="sex", meanstructure=TRUE, sampling.weights="BY_WTA", std.lv=T, orthogonal=T, group.equal=c("loadings", "intercepts"))
fitMeasures(scalar, c("chisq", "df", "pvalue", "cfi", "rmsea", "srmr", "aic", "bic"))
##       chisq          df      pvalue         cfi       rmsea        srmr 
##   89153.670     345.000       0.000       0.938       0.060       0.045 
##         aic         bic 
## 6495955.205 6497089.645
Mc(scalar)
## [1] 0.7317156
summary(scalar, standardized=T, ci=T)
## lavaan 0.6-18 ended normally after 76 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                       180
##   Number of equality constraints                    65
## 
##   Number of observations per group:                   
##     0                                            70776
##     1                                            71381
##   Sampling weights variable                     BY_WTA
## 
## Model Test User Model:
##                                                Standard      Scaled
##   Test Statistic                              89153.670   76136.675
##   Degrees of freedom                                345         345
##   P-value (Chi-square)                            0.000       0.000
##   Scaling correction factor                                   1.171
##     Yuan-Bentler correction (Mplus variant)                        
##   Test statistic for each group:
##     0                                         47762.728   40789.071
##     1                                         41390.941   35347.605
## 
## Parameter Estimates:
## 
##   Standard errors                             Sandwich
##   Information bread                           Observed
##   Observed information based on                Hessian
## 
## 
## Group 1 [0]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english =~                                                   
##     Stst19d (.p1.)    0.172    0.002   70.021    0.000    0.167
##     Stst20s (.p2.)    0.351    0.003  104.419    0.000    0.344
##     Stst21c (.p3.)    0.320    0.003  108.034    0.000    0.314
##     Stst22p (.p4.)    0.347    0.003  111.679    0.000    0.341
##     Stst23n (.p5.)    0.262    0.003   91.923    0.000    0.256
##     Stst24x (.p6.)    0.219    0.003   82.928    0.000    0.213
##     Stst25w (.p7.)    0.260    0.002  106.201    0.000    0.255
##     Stst26r (.p8.)    0.168    0.002   89.797    0.000    0.164
##     Stst31b (.p9.)    0.201    0.003   71.205    0.000    0.195
##   math =~                                                      
##     Stst5mt (.10.)    0.280    0.003   98.165    0.000    0.274
##     Stst25w (.11.)    0.163    0.003   52.023    0.000    0.157
##     Stst32r (.12.)    0.178    0.003   53.324    0.000    0.171
##     Stst33h (.13.)    0.570    0.005  117.816    0.000    0.561
##     Stst34r (.14.)    0.264    0.004   62.651    0.000    0.256
##   speed =~                                                     
##     Stst19d (.15.)    0.286    0.003  103.482    0.000    0.280
##     Sts292D (.16.)    0.260    0.003   86.127    0.000    0.254
##     Stst34r (.17.)    0.408    0.003  137.688    0.000    0.403
##     Stst35t (.18.)    0.621    0.004  149.725    0.000    0.613
##     Stst36c (.19.)    0.697    0.004  176.190    0.000    0.689
##     Stst37b (.20.)    0.635    0.004  171.753    0.000    0.628
##   spatial =~                                                   
##     Stst28m (.21.)    0.609    0.003  195.661    0.000    0.603
##     Sts292D (.22.)    0.377    0.004   94.467    0.000    0.369
##     Sts303D (.23.)    0.355    0.004   88.759    0.000    0.347
##     Stst31b (.24.)    0.277    0.005   57.508    0.000    0.268
##     Stst37b (.25.)    0.175    0.003   54.214    0.000    0.168
##   g =~                                                         
##     Stst1vc (.26.)    0.823    0.003  306.064    0.000    0.818
##     Stst5mt (.27.)    0.742    0.003  278.924    0.000    0.737
##     Stst19d (.28.)    0.619    0.003  225.659    0.000    0.613
##     Stst20s (.29.)    0.550    0.003  182.990    0.000    0.544
##     Stst21c (.30.)    0.558    0.003  189.312    0.000    0.553
##     Stst22p (.31.)    0.718    0.003  249.384    0.000    0.712
##     Stst23n (.32.)    0.625    0.003  197.136    0.000    0.619
##     Stst24x (.33.)    0.562    0.003  179.039    0.000    0.556
##     Stst25w (.34.)    0.701    0.003  275.234    0.000    0.696
##     Stst26r (.35.)    0.837    0.003  303.416    0.000    0.832
##     Stst28m (.36.)    0.509    0.003  197.090    0.000    0.504
##     Sts292D (.37.)    0.346    0.003  114.213    0.000    0.340
##     Sts303D (.38.)    0.478    0.003  149.595    0.000    0.471
##     Stst31b (.39.)    0.584    0.003  187.612    0.000    0.578
##     Stst32r (.40.)    0.747    0.003  273.569    0.000    0.742
##     Stst33h (.41.)    0.745    0.003  258.008    0.000    0.739
##     Stst34r (.42.)    0.471    0.003  146.959    0.000    0.465
##     Stst35t (.43.)    0.270    0.003   79.682    0.000    0.264
##     Stst36c (.44.)    0.135    0.003   44.144    0.000    0.129
##     Stst37b (.45.)    0.139    0.003   45.066    0.000    0.133
##  ci.upper   Std.lv  Std.all
##                            
##     0.177    0.172    0.175
##     0.357    0.351    0.355
##     0.326    0.320    0.332
##     0.353    0.347    0.353
##     0.267    0.262    0.262
##     0.224    0.219    0.215
##     0.264    0.260    0.261
##     0.171    0.168    0.167
##     0.206    0.201    0.202
##                            
##     0.285    0.280    0.292
##     0.169    0.163    0.164
##     0.184    0.178    0.180
##     0.580    0.570    0.566
##     0.273    0.264    0.268
##                            
##     0.291    0.286    0.290
##     0.266    0.260    0.268
##     0.414    0.408    0.414
##     0.629    0.621    0.614
##     0.705    0.697    0.701
##     0.643    0.635    0.614
##                            
##     0.615    0.609    0.676
##     0.385    0.377    0.388
##     0.362    0.355    0.361
##     0.287    0.277    0.279
##     0.181    0.175    0.169
##                            
##     0.829    0.823    0.854
##     0.747    0.742    0.775
##     0.624    0.619    0.629
##     0.555    0.550    0.555
##     0.564    0.558    0.579
##     0.723    0.718    0.730
##     0.631    0.625    0.625
##     0.568    0.562    0.551
##     0.706    0.701    0.704
##     0.843    0.837    0.834
##     0.514    0.509    0.565
##     0.352    0.346    0.356
##     0.484    0.478    0.486
##     0.590    0.584    0.587
##     0.753    0.747    0.758
##     0.750    0.745    0.740
##     0.478    0.471    0.478
##     0.277    0.270    0.267
##     0.141    0.135    0.136
##     0.145    0.139    0.134
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english ~~                                                   
##     math              0.000                               0.000
##     speed             0.000                               0.000
##     spatial           0.000                               0.000
##     g                 0.000                               0.000
##   math ~~                                                      
##     speed             0.000                               0.000
##     spatial           0.000                               0.000
##     g                 0.000                               0.000
##   speed ~~                                                     
##     spatial           0.000                               0.000
##     g                 0.000                               0.000
##   spatial ~~                                                   
##     g                 0.000                               0.000
##  ci.upper   Std.lv  Std.all
##                            
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##                            
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##                            
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##                            
##     0.000    0.000    0.000
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stst19d (.81.)   -0.142    0.004  -37.317    0.000   -0.150
##    .Stst20s (.82.)   -0.269    0.004  -68.662    0.000   -0.276
##    .Stst21c (.83.)   -0.214    0.004  -55.968    0.000   -0.222
##    .Stst22p (.84.)   -0.215    0.004  -54.536    0.000   -0.223
##    .Stst23n (.85.)   -0.154    0.004  -37.763    0.000   -0.161
##    .Stst24x (.86.)   -0.117    0.004  -28.254    0.000   -0.125
##    .Stst25w (.87.)   -0.139    0.004  -36.221    0.000   -0.146
##    .Stst26r (.88.)   -0.007    0.004   -1.711    0.087   -0.015
##    .Stst31b (.89.)    0.088    0.004   22.584    0.000    0.080
##    .Stst5mt (.90.)    0.136    0.004   36.409    0.000    0.129
##    .Stst32r (.91.)    0.148    0.004   40.328    0.000    0.141
##    .Stst33h (.92.)    0.117    0.004   28.188    0.000    0.109
##    .Stst34r (.93.)    0.001    0.004    0.286    0.775   -0.006
##    .Sts292D (.94.)    0.240    0.003   68.901    0.000    0.234
##    .Stst35t (.95.)   -0.120    0.004  -32.027    0.000   -0.127
##    .Stst36c (.96.)   -0.189    0.004  -53.274    0.000   -0.196
##    .Stst37b (.97.)   -0.041    0.004  -10.402    0.000   -0.048
##    .Stst28m (.98.)    0.497    0.004  114.006    0.000    0.488
##    .Sts303D (.99.)    0.331    0.004   90.402    0.000    0.324
##    .Stst1vc (.100)    0.162    0.004   42.311    0.000    0.155
##  ci.upper   Std.lv  Std.all
##    -0.135   -0.142   -0.144
##    -0.261   -0.269   -0.271
##    -0.207   -0.214   -0.222
##    -0.207   -0.215   -0.219
##    -0.146   -0.154   -0.153
##    -0.109   -0.117   -0.115
##    -0.131   -0.139   -0.139
##     0.001   -0.007   -0.007
##     0.095    0.088    0.088
##     0.143    0.136    0.142
##     0.155    0.148    0.150
##     0.126    0.117    0.117
##     0.008    0.001    0.001
##     0.247    0.240    0.247
##    -0.112   -0.120   -0.118
##    -0.182   -0.189   -0.190
##    -0.033   -0.041   -0.039
##     0.505    0.497    0.551
##     0.339    0.331    0.337
##     0.170    0.162    0.168
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stst19dsgsdwrd    0.473    0.003  161.013    0.000    0.468
##    .Stest20spellng    0.554    0.003  158.994    0.000    0.548
##    .Stest21cptlztn    0.517    0.003  161.688    0.000    0.511
##    .Stest22puncttn    0.331    0.002  134.894    0.000    0.327
##    .Stest23english    0.541    0.004  143.950    0.000    0.534
##    .Stest24exprssn    0.674    0.004  156.175    0.000    0.666
##    .Stst25wrdfnctn    0.406    0.003  151.641    0.000    0.401
##    .Stst26rdngcmpr    0.280    0.002  124.029    0.000    0.275
##    .Stst31bstrctrs    0.530    0.004  142.188    0.000    0.523
##    .Stest5math        0.289    0.003   97.324    0.000    0.283
##    .Stst32rthrsnng    0.383    0.002  156.153    0.000    0.378
##    .Stst33hghschlm    0.134    0.005   29.609    0.000    0.125
##    .Stst34rthcmptt    0.514    0.004  132.850    0.000    0.506
##    .Stst29vslztn2D    0.617    0.005  126.236    0.000    0.607
##    .Stest35tblrdng    0.564    0.007   78.522    0.000    0.550
##    .Stst36clrclchc    0.485    0.006   88.093    0.000    0.474
##    .Stst37bjctnspc    0.617    0.005  123.001    0.000    0.607
##    .Stst28mchnclrs    0.182    0.005   37.706    0.000    0.172
##    .Stst30vslztn3D    0.610    0.004  148.735    0.000    0.602
##    .Stest1vocab       0.251    0.002  117.233    0.000    0.247
##     english           1.000                               1.000
##     math              1.000                               1.000
##     speed             1.000                               1.000
##     spatial           1.000                               1.000
##     g                 1.000                               1.000
##  ci.upper   Std.lv  Std.all
##     0.479    0.473    0.489
##     0.561    0.554    0.566
##     0.523    0.517    0.555
##     0.336    0.331    0.343
##     0.548    0.541    0.541
##     0.683    0.674    0.650
##     0.411    0.406    0.409
##     0.284    0.280    0.277
##     0.538    0.530    0.537
##     0.295    0.289    0.315
##     0.387    0.383    0.393
##     0.143    0.134    0.132
##     0.522    0.514    0.528
##     0.626    0.617    0.651
##     0.578    0.564    0.552
##     0.496    0.485    0.490
##     0.627    0.617    0.576
##     0.191    0.182    0.224
##     0.618    0.610    0.633
##     0.255    0.251    0.270
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
## 
## 
## Group 2 [1]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english =~                                                   
##     Stst19d (.p1.)    0.172    0.002   70.021    0.000    0.167
##     Stst20s (.p2.)    0.351    0.003  104.419    0.000    0.344
##     Stst21c (.p3.)    0.320    0.003  108.034    0.000    0.314
##     Stst22p (.p4.)    0.347    0.003  111.679    0.000    0.341
##     Stst23n (.p5.)    0.262    0.003   91.923    0.000    0.256
##     Stst24x (.p6.)    0.219    0.003   82.928    0.000    0.213
##     Stst25w (.p7.)    0.260    0.002  106.201    0.000    0.255
##     Stst26r (.p8.)    0.168    0.002   89.797    0.000    0.164
##     Stst31b (.p9.)    0.201    0.003   71.205    0.000    0.195
##   math =~                                                      
##     Stst5mt (.10.)    0.280    0.003   98.165    0.000    0.274
##     Stst25w (.11.)    0.163    0.003   52.023    0.000    0.157
##     Stst32r (.12.)    0.178    0.003   53.324    0.000    0.171
##     Stst33h (.13.)    0.570    0.005  117.816    0.000    0.561
##     Stst34r (.14.)    0.264    0.004   62.651    0.000    0.256
##   speed =~                                                     
##     Stst19d (.15.)    0.286    0.003  103.482    0.000    0.280
##     Sts292D (.16.)    0.260    0.003   86.127    0.000    0.254
##     Stst34r (.17.)    0.408    0.003  137.688    0.000    0.403
##     Stst35t (.18.)    0.621    0.004  149.725    0.000    0.613
##     Stst36c (.19.)    0.697    0.004  176.190    0.000    0.689
##     Stst37b (.20.)    0.635    0.004  171.753    0.000    0.628
##   spatial =~                                                   
##     Stst28m (.21.)    0.609    0.003  195.661    0.000    0.603
##     Sts292D (.22.)    0.377    0.004   94.467    0.000    0.369
##     Sts303D (.23.)    0.355    0.004   88.759    0.000    0.347
##     Stst31b (.24.)    0.277    0.005   57.508    0.000    0.268
##     Stst37b (.25.)    0.175    0.003   54.214    0.000    0.168
##   g =~                                                         
##     Stst1vc (.26.)    0.823    0.003  306.064    0.000    0.818
##     Stst5mt (.27.)    0.742    0.003  278.924    0.000    0.737
##     Stst19d (.28.)    0.619    0.003  225.659    0.000    0.613
##     Stst20s (.29.)    0.550    0.003  182.990    0.000    0.544
##     Stst21c (.30.)    0.558    0.003  189.312    0.000    0.553
##     Stst22p (.31.)    0.718    0.003  249.384    0.000    0.712
##     Stst23n (.32.)    0.625    0.003  197.136    0.000    0.619
##     Stst24x (.33.)    0.562    0.003  179.039    0.000    0.556
##     Stst25w (.34.)    0.701    0.003  275.234    0.000    0.696
##     Stst26r (.35.)    0.837    0.003  303.416    0.000    0.832
##     Stst28m (.36.)    0.509    0.003  197.090    0.000    0.504
##     Sts292D (.37.)    0.346    0.003  114.213    0.000    0.340
##     Sts303D (.38.)    0.478    0.003  149.595    0.000    0.471
##     Stst31b (.39.)    0.584    0.003  187.612    0.000    0.578
##     Stst32r (.40.)    0.747    0.003  273.569    0.000    0.742
##     Stst33h (.41.)    0.745    0.003  258.008    0.000    0.739
##     Stst34r (.42.)    0.471    0.003  146.959    0.000    0.465
##     Stst35t (.43.)    0.270    0.003   79.682    0.000    0.264
##     Stst36c (.44.)    0.135    0.003   44.144    0.000    0.129
##     Stst37b (.45.)    0.139    0.003   45.066    0.000    0.133
##  ci.upper   Std.lv  Std.all
##                            
##     0.177    0.151    0.159
##     0.357    0.308    0.337
##     0.326    0.281    0.301
##     0.353    0.305    0.336
##     0.267    0.230    0.249
##     0.224    0.192    0.208
##     0.264    0.228    0.239
##     0.171    0.147    0.159
##     0.206    0.176    0.186
##                            
##     0.285    0.273    0.277
##     0.169    0.159    0.167
##     0.184    0.173    0.181
##     0.580    0.556    0.582
##     0.273    0.258    0.273
##                            
##     0.291    0.255    0.268
##     0.266    0.232    0.245
##     0.414    0.364    0.385
##     0.629    0.554    0.635
##     0.705    0.622    0.673
##     0.643    0.567    0.608
##                            
##     0.615    0.548    0.643
##     0.385    0.339    0.358
##     0.362    0.319    0.352
##     0.287    0.250    0.264
##     0.181    0.157    0.169
##                            
##     0.829    0.767    0.812
##     0.747    0.691    0.703
##     0.624    0.576    0.606
##     0.555    0.512    0.559
##     0.564    0.520    0.556
##     0.723    0.669    0.737
##     0.631    0.582    0.630
##     0.568    0.523    0.567
##     0.706    0.653    0.684
##     0.843    0.780    0.844
##     0.514    0.474    0.556
##     0.352    0.323    0.340
##     0.484    0.445    0.490
##     0.590    0.544    0.575
##     0.753    0.696    0.725
##     0.750    0.694    0.726
##     0.478    0.439    0.464
##     0.277    0.252    0.289
##     0.141    0.126    0.136
##     0.145    0.129    0.139
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english ~~                                                   
##     math              0.000                               0.000
##     speed             0.000                               0.000
##     spatial           0.000                               0.000
##     g                 0.000                               0.000
##   math ~~                                                      
##     speed             0.000                               0.000
##     spatial           0.000                               0.000
##     g                 0.000                               0.000
##   speed ~~                                                     
##     spatial           0.000                               0.000
##     g                 0.000                               0.000
##   spatial ~~                                                   
##     g                 0.000                               0.000
##  ci.upper   Std.lv  Std.all
##                            
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##                            
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##                            
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##                            
##     0.000    0.000    0.000
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stst19d (.81.)   -0.142    0.004  -37.317    0.000   -0.150
##    .Stst20s (.82.)   -0.269    0.004  -68.662    0.000   -0.276
##    .Stst21c (.83.)   -0.214    0.004  -55.968    0.000   -0.222
##    .Stst22p (.84.)   -0.215    0.004  -54.536    0.000   -0.223
##    .Stst23n (.85.)   -0.154    0.004  -37.763    0.000   -0.161
##    .Stst24x (.86.)   -0.117    0.004  -28.254    0.000   -0.125
##    .Stst25w (.87.)   -0.139    0.004  -36.221    0.000   -0.146
##    .Stst26r (.88.)   -0.007    0.004   -1.711    0.087   -0.015
##    .Stst31b (.89.)    0.088    0.004   22.584    0.000    0.080
##    .Stst5mt (.90.)    0.136    0.004   36.409    0.000    0.129
##    .Stst32r (.91.)    0.148    0.004   40.328    0.000    0.141
##    .Stst33h (.92.)    0.117    0.004   28.188    0.000    0.109
##    .Stst34r (.93.)    0.001    0.004    0.286    0.775   -0.006
##    .Sts292D (.94.)    0.240    0.003   68.901    0.000    0.234
##    .Stst35t (.95.)   -0.120    0.004  -32.027    0.000   -0.127
##    .Stst36c (.96.)   -0.189    0.004  -53.274    0.000   -0.196
##    .Stst37b (.97.)   -0.041    0.004  -10.402    0.000   -0.048
##    .Stst28m (.98.)    0.497    0.004  114.006    0.000    0.488
##    .Sts303D (.99.)    0.331    0.004   90.402    0.000    0.324
##    .Stst1vc (.100)    0.162    0.004   42.311    0.000    0.155
##     english           2.069    0.021   99.853    0.000    2.028
##     math              0.064    0.009    6.861    0.000    0.046
##     speed             0.520    0.008   65.126    0.000    0.504
##     spatial          -1.192    0.010 -114.260    0.000   -1.212
##     g                -0.305    0.007  -43.061    0.000   -0.319
##  ci.upper   Std.lv  Std.all
##    -0.135   -0.142   -0.150
##    -0.261   -0.269   -0.294
##    -0.207   -0.214   -0.229
##    -0.207   -0.215   -0.237
##    -0.146   -0.154   -0.166
##    -0.109   -0.117   -0.127
##    -0.131   -0.139   -0.145
##     0.001   -0.007   -0.008
##     0.095    0.088    0.093
##     0.143    0.136    0.138
##     0.155    0.148    0.154
##     0.126    0.117    0.123
##     0.008    0.001    0.001
##     0.247    0.240    0.253
##    -0.112   -0.120   -0.137
##    -0.182   -0.189   -0.204
##    -0.033   -0.041   -0.044
##     0.505    0.497    0.583
##     0.339    0.331    0.365
##     0.170    0.162    0.172
##     2.110    2.355    2.355
##     0.082    0.066    0.066
##     0.536    0.583    0.583
##    -1.171   -1.325   -1.325
##    -0.291   -0.327   -0.327
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stst19dsgsdwrd    0.483    0.003  164.605    0.000    0.477
##    .Stest20spellng    0.480    0.003  159.244    0.000    0.474
##    .Stest21cptlztn    0.525    0.003  163.303    0.000    0.519
##    .Stest22puncttn    0.282    0.002  130.213    0.000    0.278
##    .Stest23english    0.464    0.003  145.422    0.000    0.457
##    .Stest24exprssn    0.540    0.004  149.125    0.000    0.532
##    .Stst25wrdfnctn    0.409    0.003  145.017    0.000    0.404
##    .Stst26rdngcmpr    0.224    0.002  122.885    0.000    0.221
##    .Stst31bstrctrs    0.506    0.003  147.118    0.000    0.500
##    .Stest5math        0.415    0.004  107.795    0.000    0.408
##    .Stst32rthrsnng    0.408    0.002  164.227    0.000    0.403
##    .Stst33hghschlm    0.122    0.005   25.963    0.000    0.113
##    .Stst34rthcmptt    0.504    0.004  129.659    0.000    0.496
##    .Stst29vslztn2D    0.628    0.004  154.681    0.000    0.620
##    .Stest35tblrdng    0.390    0.005   74.896    0.000    0.380
##    .Stst36clrclchc    0.452    0.004  105.681    0.000    0.443
##    .Stst37bjctnspc    0.505    0.004  128.064    0.000    0.498
##    .Stst28mchnclrs    0.202    0.004   48.895    0.000    0.193
##    .Stst30vslztn3D    0.523    0.003  159.189    0.000    0.517
##    .Stest1vocab       0.303    0.002  134.103    0.000    0.299
##     english           0.772    0.017   46.276    0.000    0.739
##     math              0.952    0.016   59.049    0.000    0.920
##     speed             0.796    0.010   79.113    0.000    0.776
##     spatial           0.809    0.010   79.351    0.000    0.789
##     g                 0.868    0.007  126.668    0.000    0.854
##  ci.upper   Std.lv  Std.all
##     0.489    0.483    0.535
##     0.486    0.480    0.574
##     0.531    0.525    0.600
##     0.286    0.282    0.343
##     0.470    0.464    0.542
##     0.547    0.540    0.635
##     0.415    0.409    0.448
##     0.228    0.224    0.262
##     0.513    0.506    0.565
##     0.423    0.415    0.429
##     0.413    0.408    0.442
##     0.132    0.122    0.134
##     0.512    0.504    0.562
##     0.636    0.628    0.697
##     0.400    0.390    0.513
##     0.460    0.452    0.529
##     0.513    0.505    0.582
##     0.210    0.202    0.278
##     0.530    0.523    0.636
##     0.308    0.303    0.340
##     0.804    1.000    1.000
##     0.983    1.000    1.000
##     0.816    1.000    1.000
##     0.829    1.000    1.000
##     0.881    1.000    1.000
lavTestScore(scalar, release = 46:65) 
## Warning: lavaan->lavTestScore():  
##    se is not `standard'; not implemented yet; falling back to 
##    ordinary score test
## $test
## 
## total score test:
## 
##    test       X2 df p.value
## 1 score 28316.67 20       0
## 
## $uni
## 
## univariate score tests:
## 
##       lhs op    rhs        X2 df p.value
## 1   .p81. == .p186.   825.303  1   0.000
## 2   .p82. == .p187.   184.470  1   0.000
## 3   .p83. == .p188.     8.062  1   0.005
## 4   .p84. == .p189.   146.395  1   0.000
## 5   .p85. == .p190.   103.456  1   0.000
## 6   .p86. == .p191.     1.403  1   0.236
## 7   .p87. == .p192.     1.161  1   0.281
## 8   .p88. == .p193.  1722.897  1   0.000
## 9   .p89. == .p194.  1536.686  1   0.000
## 10  .p90. == .p195.  2417.385  1   0.000
## 11  .p91. == .p196.   338.923  1   0.000
## 12  .p92. == .p197.     2.004  1   0.157
## 13  .p93. == .p198.  2371.607  1   0.000
## 14  .p94. == .p199.   444.312  1   0.000
## 15  .p95. == .p200.   978.462  1   0.000
## 16  .p96. == .p201.   947.242  1   0.000
## 17  .p97. == .p202.  1413.995  1   0.000
## 18  .p98. == .p203. 18513.178  1   0.000
## 19  .p99. == .p204.  9565.303  1   0.000
## 20 .p100. == .p205.    51.116  1   0.000
scalar2<-cfa(chc.bifactor.model, data=dgroup, group="sex", meanstructure=TRUE, sampling.weights="BY_WTA", std.lv=T, orthogonal=T, group.equal=c("loadings", "intercepts"), group.partial=c("Stest28mechanicalreasoning~1", "Stest34arithcomputation~1", "Stest29visualization2D~1", "Stest26readingcomprehension~1"))
fitMeasures(scalar2, c("chisq", "df", "pvalue", "cfi", "rmsea", "srmr", "aic", "bic"))
##       chisq          df      pvalue         cfi       rmsea        srmr 
##   64908.038     341.000       0.000       0.955       0.052       0.039 
##         aic         bic 
## 6471717.573 6472891.471
Mc(scalar2)
## [1] 0.7968417
summary(scalar2, standardized=T, ci=T) # -.367 but -.292 if math is released instead of reading comprehension
## lavaan 0.6-18 ended normally after 69 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                       180
##   Number of equality constraints                    61
## 
##   Number of observations per group:                   
##     0                                            70776
##     1                                            71381
##   Sampling weights variable                     BY_WTA
## 
## Model Test User Model:
##                                                Standard      Scaled
##   Test Statistic                              64908.038   55248.453
##   Degrees of freedom                                341         341
##   P-value (Chi-square)                            0.000       0.000
##   Scaling correction factor                                   1.175
##     Yuan-Bentler correction (Mplus variant)                        
##   Test statistic for each group:
##     0                                         34674.798   29514.511
##     1                                         30233.239   25733.943
## 
## Parameter Estimates:
## 
##   Standard errors                             Sandwich
##   Information bread                           Observed
##   Observed information based on                Hessian
## 
## 
## Group 1 [0]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english =~                                                   
##     Stst19d (.p1.)    0.185    0.002   78.569    0.000    0.181
##     Stst20s (.p2.)    0.354    0.003  110.677    0.000    0.348
##     Stst21c (.p3.)    0.321    0.003  112.287    0.000    0.315
##     Stst22p (.p4.)    0.353    0.003  118.424    0.000    0.348
##     Stst23n (.p5.)    0.264    0.003   95.696    0.000    0.259
##     Stst24x (.p6.)    0.213    0.003   81.026    0.000    0.208
##     Stst25w (.p7.)    0.261    0.002  108.880    0.000    0.256
##     Stst26r (.p8.)    0.066    0.004   18.539    0.000    0.059
##     Stst31b (.p9.)    0.114    0.002   56.129    0.000    0.110
##   math =~                                                      
##     Stst5mt (.10.)    0.288    0.003   97.960    0.000    0.282
##     Stst25w (.11.)    0.162    0.003   53.986    0.000    0.156
##     Stst32r (.12.)    0.185    0.003   59.538    0.000    0.179
##     Stst33h (.13.)    0.576    0.005  120.383    0.000    0.567
##     Stst34r (.14.)    0.256    0.004   67.877    0.000    0.249
##   speed =~                                                     
##     Stst19d (.15.)    0.295    0.003  107.562    0.000    0.290
##     Sts292D (.16.)    0.233    0.003   75.522    0.000    0.227
##     Stst34r (.17.)    0.378    0.003  121.770    0.000    0.372
##     Stst35t (.18.)    0.636    0.004  151.492    0.000    0.628
##     Stst36c (.19.)    0.725    0.004  186.868    0.000    0.717
##     Stst37b (.20.)    0.613    0.004  165.179    0.000    0.606
##   spatial =~                                                   
##     Stst28m (.21.)    0.451    0.003  149.561    0.000    0.445
##     Sts292D (.22.)    0.470    0.003  137.079    0.000    0.463
##     Sts303D (.23.)    0.607    0.004  163.823    0.000    0.600
##     Stst31b (.24.)    0.355    0.003  114.253    0.000    0.349
##     Stst37b (.25.)    0.258    0.003   78.423    0.000    0.252
##   g =~                                                         
##     Stst1vc (.26.)    0.820    0.003  305.119    0.000    0.815
##     Stst5mt (.27.)    0.737    0.003  278.424    0.000    0.732
##     Stst19d (.28.)    0.621    0.003  228.514    0.000    0.615
##     Stst20s (.29.)    0.557    0.003  187.704    0.000    0.552
##     Stst21c (.30.)    0.565    0.003  192.537    0.000    0.559
##     Stst22p (.31.)    0.723    0.003  254.061    0.000    0.718
##     Stst23n (.32.)    0.630    0.003  199.140    0.000    0.624
##     Stst24x (.33.)    0.567    0.003  180.417    0.000    0.561
##     Stst25w (.34.)    0.705    0.003  280.464    0.000    0.700
##     Stst26r (.35.)    0.860    0.003  303.700    0.000    0.855
##     Stst28m (.36.)    0.497    0.003  190.476    0.000    0.492
##     Sts292D (.37.)    0.344    0.003  115.871    0.000    0.338
##     Sts303D (.38.)    0.491    0.003  167.346    0.000    0.485
##     Stst31b (.39.)    0.597    0.003  199.081    0.000    0.591
##     Stst32r (.40.)    0.743    0.003  277.958    0.000    0.738
##     Stst33h (.41.)    0.739    0.003  259.685    0.000    0.734
##     Stst34r (.42.)    0.488    0.003  155.149    0.000    0.482
##     Stst35t (.43.)    0.263    0.003   77.974    0.000    0.257
##     Stst36c (.44.)    0.126    0.003   41.594    0.000    0.120
##     Stst37b (.45.)    0.138    0.003   45.545    0.000    0.132
##  ci.upper   Std.lv  Std.all
##                            
##     0.190    0.185    0.188
##     0.361    0.354    0.357
##     0.326    0.321    0.332
##     0.359    0.353    0.359
##     0.270    0.264    0.264
##     0.219    0.213    0.209
##     0.265    0.261    0.261
##     0.073    0.066    0.066
##     0.118    0.114    0.115
##                            
##     0.294    0.288    0.301
##     0.168    0.162    0.162
##     0.191    0.185    0.188
##     0.586    0.576    0.573
##     0.264    0.256    0.262
##                            
##     0.300    0.295    0.299
##     0.239    0.233    0.238
##     0.384    0.378    0.386
##     0.644    0.636    0.626
##     0.732    0.725    0.724
##     0.621    0.613    0.593
##                            
##     0.457    0.451    0.513
##     0.476    0.470    0.479
##     0.614    0.607    0.597
##     0.361    0.355    0.357
##     0.265    0.258    0.250
##                            
##     0.825    0.820    0.851
##     0.742    0.737    0.770
##     0.626    0.621    0.629
##     0.563    0.557    0.562
##     0.570    0.565    0.584
##     0.729    0.723    0.735
##     0.636    0.630    0.628
##     0.573    0.567    0.555
##     0.710    0.705    0.706
##     0.866    0.860    0.856
##     0.502    0.497    0.566
##     0.349    0.344    0.350
##     0.496    0.491    0.482
##     0.603    0.597    0.600
##     0.748    0.743    0.754
##     0.745    0.739    0.735
##     0.494    0.488    0.498
##     0.270    0.263    0.259
##     0.132    0.126    0.126
##     0.144    0.138    0.134
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english ~~                                                   
##     math              0.000                               0.000
##     speed             0.000                               0.000
##     spatial           0.000                               0.000
##     g                 0.000                               0.000
##   math ~~                                                      
##     speed             0.000                               0.000
##     spatial           0.000                               0.000
##     g                 0.000                               0.000
##   speed ~~                                                     
##     spatial           0.000                               0.000
##     g                 0.000                               0.000
##   spatial ~~                                                   
##     g                 0.000                               0.000
##  ci.upper   Std.lv  Std.all
##                            
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##                            
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##                            
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##                            
##     0.000    0.000    0.000
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stst19d (.81.)   -0.131    0.004  -34.288    0.000   -0.138
##    .Stst20s (.82.)   -0.265    0.004  -67.421    0.000   -0.272
##    .Stst21c (.83.)   -0.207    0.004  -54.046    0.000   -0.215
##    .Stst22p (.84.)   -0.212    0.004  -53.488    0.000   -0.219
##    .Stst23n (.85.)   -0.147    0.004  -36.127    0.000   -0.155
##    .Stst24x (.86.)   -0.102    0.004  -24.535    0.000   -0.110
##    .Stst25w (.87.)   -0.131    0.004  -34.258    0.000   -0.139
##    .Stst26r          -0.032    0.004   -7.898    0.000   -0.041
##    .Stst31b (.89.)    0.059    0.004   15.327    0.000    0.052
##    .Stst5mt (.90.)    0.143    0.004   38.807    0.000    0.136
##    .Stst32r (.91.)    0.158    0.004   43.431    0.000    0.151
##    .Stst33h (.92.)    0.124    0.004   29.550    0.000    0.115
##    .Stst34r          -0.078    0.004  -19.714    0.000   -0.086
##    .Sts292D           0.212    0.004   54.435    0.000    0.204
##    .Stst35t (.95.)   -0.074    0.004  -20.578    0.000   -0.082
##    .Stst36c (.96.)   -0.150    0.004  -40.929    0.000   -0.157
##    .Stst37b (.97.)   -0.076    0.004  -20.581    0.000   -0.083
##    .Stst28m           0.536    0.004  151.032    0.000    0.529
##    .Sts303D (.99.)    0.182    0.004   45.187    0.000    0.175
##    .Stst1vc (.100)    0.175    0.004   47.190    0.000    0.167
##  ci.upper   Std.lv  Std.all
##    -0.123   -0.131   -0.133
##    -0.257   -0.265   -0.267
##    -0.200   -0.207   -0.214
##    -0.204   -0.212   -0.215
##    -0.139   -0.147   -0.146
##    -0.093   -0.102   -0.099
##    -0.124   -0.131   -0.131
##    -0.024   -0.032   -0.032
##     0.067    0.059    0.059
##     0.150    0.143    0.149
##     0.165    0.158    0.160
##     0.132    0.124    0.123
##    -0.070   -0.078   -0.080
##     0.219    0.212    0.216
##    -0.067   -0.074   -0.073
##    -0.143   -0.150   -0.150
##    -0.069   -0.076   -0.074
##     0.543    0.536    0.610
##     0.190    0.182    0.179
##     0.182    0.175    0.181
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stst19dsgsdwrd    0.466    0.003  158.802    0.000    0.461
##    .Stest20spellng    0.547    0.003  158.024    0.000    0.540
##    .Stest21cptlztn    0.514    0.003  160.767    0.000    0.508
##    .Stest22puncttn    0.322    0.002  131.826    0.000    0.317
##    .Stest23english    0.538    0.004  143.389    0.000    0.530
##    .Stest24exprssn    0.676    0.004  155.478    0.000    0.667
##    .Stst25wrdfnctn    0.405    0.003  150.201    0.000    0.399
##    .Stst26rdngcmpr    0.265    0.002  114.518    0.000    0.261
##    .Stst31bstrctrs    0.493    0.003  152.043    0.000    0.487
##    .Stest5math        0.290    0.003   97.237    0.000    0.285
##    .Stst32rthrsnng    0.384    0.002  157.326    0.000    0.380
##    .Stst33hghschlm    0.133    0.005   29.090    0.000    0.124
##    .Stst34rthcmptt    0.512    0.004  138.405    0.000    0.505
##    .Stst29vslztn2D    0.569    0.004  129.450    0.000    0.561
##    .Stest35tblrdng    0.560    0.007   76.183    0.000    0.545
##    .Stst36clrclchc    0.461    0.005   85.161    0.000    0.450
##    .Stst37bjctnspc    0.606    0.005  124.320    0.000    0.597
##    .Stst28mchnclrs    0.321    0.003  122.897    0.000    0.316
##    .Stst30vslztn3D    0.425    0.004  106.360    0.000    0.418
##    .Stest1vocab       0.255    0.002  123.012    0.000    0.251
##     english           1.000                               1.000
##     math              1.000                               1.000
##     speed             1.000                               1.000
##     spatial           1.000                               1.000
##     g                 1.000                               1.000
##  ci.upper   Std.lv  Std.all
##     0.472    0.466    0.479
##     0.554    0.547    0.556
##     0.520    0.514    0.549
##     0.326    0.322    0.332
##     0.545    0.538    0.535
##     0.684    0.676    0.648
##     0.410    0.405    0.407
##     0.270    0.265    0.263
##     0.500    0.493    0.499
##     0.296    0.290    0.317
##     0.389    0.384    0.396
##     0.142    0.133    0.132
##     0.519    0.512    0.534
##     0.578    0.569    0.592
##     0.574    0.560    0.542
##     0.471    0.461    0.460
##     0.616    0.606    0.568
##     0.326    0.321    0.416
##     0.433    0.425    0.411
##     0.260    0.255    0.275
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
## 
## 
## Group 2 [1]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english =~                                                   
##     Stst19d (.p1.)    0.185    0.002   78.569    0.000    0.181
##     Stst20s (.p2.)    0.354    0.003  110.677    0.000    0.348
##     Stst21c (.p3.)    0.321    0.003  112.287    0.000    0.315
##     Stst22p (.p4.)    0.353    0.003  118.424    0.000    0.348
##     Stst23n (.p5.)    0.264    0.003   95.696    0.000    0.259
##     Stst24x (.p6.)    0.213    0.003   81.026    0.000    0.208
##     Stst25w (.p7.)    0.261    0.002  108.880    0.000    0.256
##     Stst26r (.p8.)    0.066    0.004   18.539    0.000    0.059
##     Stst31b (.p9.)    0.114    0.002   56.129    0.000    0.110
##   math =~                                                      
##     Stst5mt (.10.)    0.288    0.003   97.960    0.000    0.282
##     Stst25w (.11.)    0.162    0.003   53.986    0.000    0.156
##     Stst32r (.12.)    0.185    0.003   59.538    0.000    0.179
##     Stst33h (.13.)    0.576    0.005  120.383    0.000    0.567
##     Stst34r (.14.)    0.256    0.004   67.877    0.000    0.249
##   speed =~                                                     
##     Stst19d (.15.)    0.295    0.003  107.562    0.000    0.290
##     Sts292D (.16.)    0.233    0.003   75.522    0.000    0.227
##     Stst34r (.17.)    0.378    0.003  121.770    0.000    0.372
##     Stst35t (.18.)    0.636    0.004  151.492    0.000    0.628
##     Stst36c (.19.)    0.725    0.004  186.868    0.000    0.717
##     Stst37b (.20.)    0.613    0.004  165.179    0.000    0.606
##   spatial =~                                                   
##     Stst28m (.21.)    0.451    0.003  149.561    0.000    0.445
##     Sts292D (.22.)    0.470    0.003  137.079    0.000    0.463
##     Sts303D (.23.)    0.607    0.004  163.823    0.000    0.600
##     Stst31b (.24.)    0.355    0.003  114.253    0.000    0.349
##     Stst37b (.25.)    0.258    0.003   78.423    0.000    0.252
##   g =~                                                         
##     Stst1vc (.26.)    0.820    0.003  305.119    0.000    0.815
##     Stst5mt (.27.)    0.737    0.003  278.424    0.000    0.732
##     Stst19d (.28.)    0.621    0.003  228.514    0.000    0.615
##     Stst20s (.29.)    0.557    0.003  187.704    0.000    0.552
##     Stst21c (.30.)    0.565    0.003  192.537    0.000    0.559
##     Stst22p (.31.)    0.723    0.003  254.061    0.000    0.718
##     Stst23n (.32.)    0.630    0.003  199.140    0.000    0.624
##     Stst24x (.33.)    0.567    0.003  180.417    0.000    0.561
##     Stst25w (.34.)    0.705    0.003  280.464    0.000    0.700
##     Stst26r (.35.)    0.860    0.003  303.700    0.000    0.855
##     Stst28m (.36.)    0.497    0.003  190.476    0.000    0.492
##     Sts292D (.37.)    0.344    0.003  115.871    0.000    0.338
##     Sts303D (.38.)    0.491    0.003  167.346    0.000    0.485
##     Stst31b (.39.)    0.597    0.003  199.081    0.000    0.591
##     Stst32r (.40.)    0.743    0.003  277.958    0.000    0.738
##     Stst33h (.41.)    0.739    0.003  259.685    0.000    0.734
##     Stst34r (.42.)    0.488    0.003  155.149    0.000    0.482
##     Stst35t (.43.)    0.263    0.003   77.974    0.000    0.257
##     Stst36c (.44.)    0.126    0.003   41.594    0.000    0.120
##     Stst37b (.45.)    0.138    0.003   45.545    0.000    0.132
##  ci.upper   Std.lv  Std.all
##                            
##     0.190    0.164    0.173
##     0.361    0.314    0.343
##     0.326    0.284    0.304
##     0.359    0.313    0.345
##     0.270    0.235    0.253
##     0.219    0.189    0.205
##     0.265    0.231    0.242
##     0.073    0.059    0.064
##     0.118    0.101    0.107
##                            
##     0.294    0.285    0.290
##     0.168    0.160    0.167
##     0.191    0.183    0.191
##     0.586    0.570    0.597
##     0.264    0.253    0.270
##                            
##     0.300    0.262    0.276
##     0.239    0.207    0.218
##     0.384    0.336    0.357
##     0.644    0.566    0.647
##     0.732    0.645    0.694
##     0.621    0.546    0.587
##                            
##     0.457    0.398    0.479
##     0.476    0.414    0.435
##     0.614    0.535    0.573
##     0.361    0.313    0.331
##     0.265    0.228    0.245
##                            
##     0.825    0.761    0.809
##     0.742    0.684    0.696
##     0.626    0.576    0.606
##     0.563    0.517    0.565
##     0.570    0.524    0.559
##     0.729    0.671    0.740
##     0.636    0.584    0.631
##     0.573    0.526    0.570
##     0.710    0.654    0.683
##     0.866    0.798    0.866
##     0.502    0.461    0.556
##     0.349    0.319    0.335
##     0.496    0.455    0.487
##     0.603    0.554    0.586
##     0.748    0.689    0.719
##     0.745    0.686    0.718
##     0.494    0.452    0.481
##     0.270    0.244    0.279
##     0.132    0.117    0.126
##     0.144    0.128    0.138
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english ~~                                                   
##     math              0.000                               0.000
##     speed             0.000                               0.000
##     spatial           0.000                               0.000
##     g                 0.000                               0.000
##   math ~~                                                      
##     speed             0.000                               0.000
##     spatial           0.000                               0.000
##     g                 0.000                               0.000
##   speed ~~                                                     
##     spatial           0.000                               0.000
##     g                 0.000                               0.000
##   spatial ~~                                                   
##     g                 0.000                               0.000
##  ci.upper   Std.lv  Std.all
##                            
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##                            
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##                            
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##                            
##     0.000    0.000    0.000
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stst19d (.81.)   -0.131    0.004  -34.288    0.000   -0.138
##    .Stst20s (.82.)   -0.265    0.004  -67.421    0.000   -0.272
##    .Stst21c (.83.)   -0.207    0.004  -54.046    0.000   -0.215
##    .Stst22p (.84.)   -0.212    0.004  -53.488    0.000   -0.219
##    .Stst23n (.85.)   -0.147    0.004  -36.127    0.000   -0.155
##    .Stst24x (.86.)   -0.102    0.004  -24.535    0.000   -0.110
##    .Stst25w (.87.)   -0.131    0.004  -34.258    0.000   -0.139
##    .Stst26r           0.260    0.008   31.183    0.000    0.243
##    .Stst31b (.89.)    0.059    0.004   15.327    0.000    0.052
##    .Stst5mt (.90.)    0.143    0.004   38.807    0.000    0.136
##    .Stst32r (.91.)    0.158    0.004   43.431    0.000    0.151
##    .Stst33h (.92.)    0.124    0.004   29.550    0.000    0.115
##    .Stst34r           0.158    0.004   35.452    0.000    0.150
##    .Sts292D          -0.030    0.005   -6.141    0.000   -0.040
##    .Stst35t (.95.)   -0.074    0.004  -20.578    0.000   -0.082
##    .Stst36c (.96.)   -0.150    0.004  -40.929    0.000   -0.157
##    .Stst37b (.97.)   -0.076    0.004  -20.581    0.000   -0.083
##    .Stst28m          -0.167    0.004  -37.700    0.000   -0.176
##    .Sts303D (.99.)    0.182    0.004   45.187    0.000    0.175
##    .Stst1vc (.100)    0.175    0.004   47.190    0.000    0.167
##     english           2.090    0.019  108.868    0.000    2.053
##     math              0.086    0.009   10.017    0.000    0.069
##     speed             0.398    0.007   55.129    0.000    0.384
##     spatial          -0.204    0.008  -24.801    0.000   -0.220
##     g                -0.340    0.007  -50.872    0.000   -0.353
##  ci.upper   Std.lv  Std.all
##    -0.123   -0.131   -0.138
##    -0.257   -0.265   -0.289
##    -0.200   -0.207   -0.221
##    -0.204   -0.212   -0.233
##    -0.139   -0.147   -0.159
##    -0.093   -0.102   -0.110
##    -0.124   -0.131   -0.137
##     0.276    0.260    0.282
##     0.067    0.059    0.062
##     0.150    0.143    0.146
##     0.165    0.158    0.164
##     0.132    0.124    0.129
##     0.167    0.158    0.168
##    -0.021   -0.030   -0.032
##    -0.067   -0.074   -0.085
##    -0.143   -0.150   -0.161
##    -0.069   -0.076   -0.082
##    -0.158   -0.167   -0.201
##     0.190    0.182    0.195
##     0.182    0.175    0.186
##     2.128    2.357    2.357
##     0.102    0.087    0.087
##     0.412    0.447    0.447
##    -0.188   -0.232   -0.232
##    -0.327   -0.367   -0.367
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stst19dsgsdwrd    0.475    0.003  162.699    0.000    0.470
##    .Stest20spellng    0.472    0.003  157.964    0.000    0.466
##    .Stest21cptlztn    0.522    0.003  162.584    0.000    0.516
##    .Stest22puncttn    0.274    0.002  126.968    0.000    0.270
##    .Stest23english    0.460    0.003  145.147    0.000    0.454
##    .Stest24exprssn    0.540    0.004  149.343    0.000    0.533
##    .Stst25wrdfnctn    0.409    0.003  144.478    0.000    0.403
##    .Stst26rdngcmpr    0.209    0.002  109.759    0.000    0.205
##    .Stst31bstrctrs    0.479    0.003  155.619    0.000    0.473
##    .Stest5math        0.416    0.004  108.540    0.000    0.409
##    .Stst32rthrsnng    0.411    0.002  165.829    0.000    0.406
##    .Stst33hghschlm    0.117    0.005   25.324    0.000    0.108
##    .Stst34rthcmptt    0.502    0.004  133.775    0.000    0.495
##    .Stst29vslztn2D    0.591    0.004  150.776    0.000    0.583
##    .Stest35tblrdng    0.386    0.005   73.999    0.000    0.375
##    .Stst36clrclchc    0.434    0.004   99.411    0.000    0.426
##    .Stst37bjctnspc    0.498    0.004  129.481    0.000    0.490
##    .Stst28mchnclrs    0.318    0.002  135.096    0.000    0.314
##    .Stst30vslztn3D    0.379    0.003  112.736    0.000    0.373
##    .Stest1vocab       0.307    0.002  139.730    0.000    0.302
##     english           0.787    0.016   47.872    0.000    0.754
##     math              0.978    0.016   61.921    0.000    0.947
##     speed             0.792    0.010   78.993    0.000    0.772
##     spatial           0.778    0.010   79.652    0.000    0.759
##     g                 0.861    0.007  127.108    0.000    0.847
##  ci.upper   Std.lv  Std.all
##     0.481    0.475    0.527
##     0.478    0.472    0.563
##     0.528    0.522    0.595
##     0.279    0.274    0.333
##     0.466    0.460    0.537
##     0.547    0.540    0.633
##     0.414    0.409    0.447
##     0.213    0.209    0.246
##     0.485    0.479    0.536
##     0.424    0.416    0.431
##     0.416    0.411    0.447
##     0.126    0.117    0.128
##     0.510    0.502    0.568
##     0.599    0.591    0.651
##     0.396    0.386    0.504
##     0.443    0.434    0.503
##     0.505    0.498    0.576
##     0.323    0.318    0.462
##     0.386    0.379    0.434
##     0.311    0.307    0.346
##     0.819    1.000    1.000
##     1.009    1.000    1.000
##     0.812    1.000    1.000
##     0.797    1.000    1.000
##     0.874    1.000    1.000
lavTestScore(scalar2, release = 46:61) 
## Warning: lavaan->lavTestScore():  
##    se is not `standard'; not implemented yet; falling back to 
##    ordinary score test
## $test
## 
## total score test:
## 
##    test       X2 df p.value
## 1 score 2976.258 16       0
## 
## $uni
## 
## univariate score tests:
## 
##       lhs op    rhs       X2 df p.value
## 1   .p81. == .p186.  225.418  1   0.000
## 2   .p82. == .p187.   74.580  1   0.000
## 3   .p83. == .p188.   34.737  1   0.000
## 4   .p84. == .p189.   41.833  1   0.000
## 5   .p85. == .p190.    7.302  1   0.007
## 6   .p86. == .p191.  244.387  1   0.000
## 7   .p87. == .p192.  135.652  1   0.000
## 8   .p89. == .p194.   25.461  1   0.000
## 9   .p90. == .p195. 1863.722  1   0.000
## 10  .p91. == .p196.  647.880  1   0.000
## 11  .p92. == .p197.  544.237  1   0.000
## 12  .p95. == .p200.   15.464  1   0.000
## 13  .p96. == .p201.    3.144  1   0.076
## 14  .p97. == .p202.  122.599  1   0.000
## 15  .p99. == .p204.  146.213  1   0.000
## 16 .p100. == .p205.  114.745  1   0.000
strict<-cfa(chc.bifactor.model, data=dgroup, group="sex", meanstructure=TRUE, sampling.weights="BY_WTA", std.lv=T, orthogonal=T, group.equal=c("loadings", "intercepts", "residuals"), group.partial=c("Stest28mechanicalreasoning~1", "Stest34arithcomputation~1", "Stest29visualization2D~1", "Stest26readingcomprehension~1"))
fitMeasures(strict, c("chisq", "df", "pvalue", "cfi", "rmsea", "srmr", "aic", "bic"))
##       chisq          df      pvalue         cfi       rmsea        srmr 
##   71764.852     361.000       0.000       0.950       0.053       0.042 
##         aic         bic 
## 6478534.388 6479510.992
Mc(strict)
## [1] 0.7779087
chc.bifactor<-cfa(chc.bifactor.model, data=dgroup, group="sex", meanstructure=TRUE, sampling.weights="BY_WTA", std.lv=T, orthogonal=T, group.equal=c("loadings", "intercepts", "lv.variances"), group.partial=c("Stest28mechanicalreasoning~1", "Stest34arithcomputation~1", "Stest29visualization2D~1", "Stest26readingcomprehension~1"))
fitMeasures(chc.bifactor, c("chisq", "df", "pvalue", "cfi", "rmsea", "srmr", "aic", "bic"))
##       chisq          df      pvalue         cfi       rmsea        srmr 
##   66364.961     346.000       0.000       0.954       0.052       0.052 
##         aic         bic 
## 6473164.497 6474289.071
Mc(chc.bifactor)
## [1] 0.7927828
summary(chc.bifactor, standardized=T, ci=T) # -.352 but -.281 if math is released instead
## lavaan 0.6-18 ended normally after 54 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                       175
##   Number of equality constraints                    61
## 
##   Number of observations per group:                   
##     0                                            70776
##     1                                            71381
##   Sampling weights variable                     BY_WTA
## 
## Model Test User Model:
##                                                Standard      Scaled
##   Test Statistic                              66364.961   56481.427
##   Degrees of freedom                                346         346
##   P-value (Chi-square)                            0.000       0.000
##   Scaling correction factor                                   1.175
##     Yuan-Bentler correction (Mplus variant)                        
##   Test statistic for each group:
##     0                                         35482.055   30197.819
##     1                                         30882.906   26283.608
## 
## Parameter Estimates:
## 
##   Standard errors                             Sandwich
##   Information bread                           Observed
##   Observed information based on                Hessian
## 
## 
## Group 1 [0]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english =~                                                   
##     Stst19d (.p1.)    0.175    0.002   82.839    0.000    0.171
##     Stst20s (.p2.)    0.334    0.003  131.896    0.000    0.329
##     Stst21c (.p3.)    0.303    0.002  135.463    0.000    0.299
##     Stst22p (.p4.)    0.333    0.002  150.938    0.000    0.329
##     Stst23n (.p5.)    0.249    0.002  111.469    0.000    0.245
##     Stst24x (.p6.)    0.201    0.002   92.639    0.000    0.197
##     Stst25w (.p7.)    0.246    0.002  126.821    0.000    0.242
##     Stst26r (.p8.)    0.062    0.003   18.984    0.000    0.056
##     Stst31b (.p9.)    0.108    0.002   58.157    0.000    0.104
##   math =~                                                      
##     Stst5mt (.10.)    0.287    0.003   98.509    0.000    0.281
##     Stst25w (.11.)    0.161    0.003   56.263    0.000    0.155
##     Stst32r (.12.)    0.184    0.003   64.377    0.000    0.178
##     Stst33h (.13.)    0.573    0.004  141.812    0.000    0.565
##     Stst34r (.14.)    0.255    0.003   74.228    0.000    0.248
##   speed =~                                                     
##     Stst19d (.15.)    0.280    0.003  110.730    0.000    0.276
##     Sts292D (.16.)    0.221    0.003   76.999    0.000    0.215
##     Stst34r (.17.)    0.357    0.003  131.064    0.000    0.352
##     Stst35t (.18.)    0.597    0.003  177.324    0.000    0.591
##     Stst36c (.19.)    0.686    0.003  219.686    0.000    0.679
##     Stst37b (.20.)    0.578    0.003  192.524    0.000    0.572
##   spatial =~                                                   
##     Stst28m (.21.)    0.425    0.003  167.364    0.000    0.420
##     Sts292D (.22.)    0.444    0.003  147.141    0.000    0.438
##     Sts303D (.23.)    0.570    0.003  188.368    0.000    0.564
##     Stst31b (.24.)    0.335    0.003  120.130    0.000    0.329
##     Stst37b (.25.)    0.242    0.003   80.990    0.000    0.236
##   g =~                                                         
##     Stst1vc (.26.)    0.792    0.002  368.465    0.000    0.788
##     Stst5mt (.27.)    0.712    0.002  317.539    0.000    0.707
##     Stst19d (.28.)    0.599    0.002  252.509    0.000    0.594
##     Stst20s (.29.)    0.538    0.003  206.381    0.000    0.533
##     Stst21c (.30.)    0.545    0.003  211.779    0.000    0.540
##     Stst22p (.31.)    0.698    0.002  300.515    0.000    0.693
##     Stst23n (.32.)    0.607    0.003  224.093    0.000    0.602
##     Stst24x (.33.)    0.547    0.003  199.656    0.000    0.541
##     Stst25w (.34.)    0.681    0.002  318.810    0.000    0.676
##     Stst26r (.35.)    0.829    0.002  398.807    0.000    0.825
##     Stst28m (.36.)    0.479    0.002  208.222    0.000    0.475
##     Sts292D (.37.)    0.331    0.003  118.487    0.000    0.326
##     Sts303D (.38.)    0.473    0.003  176.480    0.000    0.468
##     Stst31b (.39.)    0.576    0.003  215.099    0.000    0.571
##     Stst32r (.40.)    0.717    0.002  334.414    0.000    0.713
##     Stst33h (.41.)    0.713    0.002  309.959    0.000    0.709
##     Stst34r (.42.)    0.470    0.003  164.348    0.000    0.465
##     Stst35t (.43.)    0.253    0.003   78.963    0.000    0.247
##     Stst36c (.44.)    0.122    0.003   41.660    0.000    0.116
##     Stst37b (.45.)    0.134    0.003   45.618    0.000    0.128
##  ci.upper   Std.lv  Std.all
##                            
##     0.179    0.175    0.181
##     0.339    0.334    0.343
##     0.307    0.303    0.318
##     0.338    0.333    0.347
##     0.254    0.249    0.253
##     0.205    0.201    0.199
##     0.250    0.246    0.252
##     0.068    0.062    0.063
##     0.111    0.108    0.111
##                            
##     0.292    0.287    0.306
##     0.166    0.161    0.165
##     0.189    0.184    0.190
##     0.581    0.573    0.581
##     0.262    0.255    0.265
##                            
##     0.285    0.280    0.290
##     0.226    0.221    0.229
##     0.363    0.357    0.371
##     0.604    0.597    0.601
##     0.692    0.686    0.703
##     0.584    0.578    0.572
##                            
##     0.430    0.425    0.496
##     0.450    0.444    0.461
##     0.576    0.570    0.574
##     0.340    0.335    0.344
##     0.248    0.242    0.239
##                            
##     0.796    0.792    0.842
##     0.716    0.712    0.759
##     0.604    0.599    0.619
##     0.543    0.538    0.551
##     0.550    0.545    0.573
##     0.702    0.698    0.727
##     0.613    0.607    0.617
##     0.552    0.547    0.543
##     0.685    0.681    0.696
##     0.833    0.829    0.847
##     0.484    0.479    0.559
##     0.337    0.331    0.344
##     0.479    0.473    0.477
##     0.581    0.576    0.591
##     0.721    0.717    0.743
##     0.718    0.713    0.724
##     0.476    0.470    0.489
##     0.260    0.253    0.255
##     0.128    0.122    0.125
##     0.139    0.134    0.132
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english ~~                                                   
##     math              0.000                               0.000
##     speed             0.000                               0.000
##     spatial           0.000                               0.000
##     g                 0.000                               0.000
##   math ~~                                                      
##     speed             0.000                               0.000
##     spatial           0.000                               0.000
##     g                 0.000                               0.000
##   speed ~~                                                     
##     spatial           0.000                               0.000
##     g                 0.000                               0.000
##   spatial ~~                                                   
##     g                 0.000                               0.000
##  ci.upper   Std.lv  Std.all
##                            
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##                            
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##                            
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##                            
##     0.000    0.000    0.000
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stst19d (.81.)   -0.132    0.004  -34.495    0.000   -0.139
##    .Stst20s (.82.)   -0.265    0.004  -67.441    0.000   -0.272
##    .Stst21c (.83.)   -0.208    0.004  -54.075    0.000   -0.215
##    .Stst22p (.84.)   -0.211    0.004  -53.421    0.000   -0.219
##    .Stst23n (.85.)   -0.147    0.004  -36.160    0.000   -0.155
##    .Stst24x (.86.)   -0.101    0.004  -24.496    0.000   -0.109
##    .Stst25w (.87.)   -0.131    0.004  -34.269    0.000   -0.139
##    .Stst26r          -0.032    0.004   -7.896    0.000   -0.041
##    .Stst31b (.89.)    0.059    0.004   15.290    0.000    0.051
##    .Stst5mt (.90.)    0.143    0.004   38.792    0.000    0.136
##    .Stst32r (.91.)    0.158    0.004   43.423    0.000    0.150
##    .Stst33h (.92.)    0.124    0.004   29.582    0.000    0.116
##    .Stst34r          -0.078    0.004  -19.713    0.000   -0.086
##    .Sts292D           0.212    0.004   54.436    0.000    0.204
##    .Stst35t (.95.)   -0.074    0.004  -20.457    0.000   -0.081
##    .Stst36c (.96.)   -0.150    0.004  -40.962    0.000   -0.157
##    .Stst37b (.97.)   -0.076    0.004  -20.491    0.000   -0.083
##    .Stst28m           0.536    0.004  151.033    0.000    0.529
##    .Sts303D (.99.)    0.182    0.004   45.146    0.000    0.174
##    .Stst1vc (.100)    0.175    0.004   47.238    0.000    0.168
##  ci.upper   Std.lv  Std.all
##    -0.124   -0.132   -0.136
##    -0.257   -0.265   -0.271
##    -0.200   -0.208   -0.218
##    -0.204   -0.211   -0.220
##    -0.139   -0.147   -0.149
##    -0.093   -0.101   -0.100
##    -0.124   -0.131   -0.134
##    -0.024   -0.032   -0.033
##     0.066    0.059    0.060
##     0.150    0.143    0.153
##     0.165    0.158    0.163
##     0.132    0.124    0.126
##    -0.070   -0.078   -0.081
##     0.219    0.212    0.220
##    -0.067   -0.074   -0.074
##    -0.143   -0.150   -0.154
##    -0.068   -0.076   -0.075
##     0.543    0.536    0.625
##     0.190    0.182    0.184
##     0.182    0.175    0.186
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stst19dsgsdwrd    0.467    0.003  159.143    0.000    0.461
##    .Stest20spellng    0.550    0.003  159.797    0.000    0.544
##    .Stest21cptlztn    0.516    0.003  162.030    0.000    0.510
##    .Stest22puncttn    0.324    0.002  133.382    0.000    0.320
##    .Stest23english    0.539    0.004  143.245    0.000    0.532
##    .Stest24exprssn    0.676    0.004  155.476    0.000    0.668
##    .Stst25wrdfnctn    0.405    0.003  150.963    0.000    0.400
##    .Stst26rdngcmpr    0.267    0.002  116.184    0.000    0.263
##    .Stst31bstrctrs    0.494    0.003  152.141    0.000    0.488
##    .Stest5math        0.291    0.003   97.792    0.000    0.285
##    .Stst32rthrsnng    0.384    0.002  157.737    0.000    0.380
##    .Stst33hghschlm    0.135    0.004   30.861    0.000    0.126
##    .Stst34rthcmptt    0.513    0.004  138.530    0.000    0.506
##    .Stst29vslztn2D    0.571    0.004  130.187    0.000    0.563
##    .Stest35tblrdng    0.566    0.007   76.300    0.000    0.552
##    .Stst36clrclchc    0.467    0.005   86.150    0.000    0.457
##    .Stst37bjctnspc    0.611    0.005  125.733    0.000    0.602
##    .Stst28mchnclrs    0.324    0.003  124.968    0.000    0.319
##    .Stst30vslztn3D    0.435    0.004  111.482    0.000    0.427
##    .Stest1vocab       0.258    0.002  125.991    0.000    0.254
##     english           1.000                               1.000
##     math              1.000                               1.000
##     speed             1.000                               1.000
##     spatial           1.000                               1.000
##     g                 1.000                               1.000
##  ci.upper   Std.lv  Std.all
##     0.473    0.467    0.499
##     0.557    0.550    0.579
##     0.522    0.516    0.570
##     0.329    0.324    0.352
##     0.546    0.539    0.556
##     0.685    0.676    0.666
##     0.411    0.405    0.424
##     0.272    0.267    0.279
##     0.500    0.494    0.520
##     0.296    0.291    0.331
##     0.389    0.384    0.412
##     0.143    0.135    0.138
##     0.520    0.513    0.553
##     0.580    0.571    0.616
##     0.581    0.566    0.574
##     0.478    0.467    0.491
##     0.621    0.611    0.598
##     0.330    0.324    0.441
##     0.442    0.435    0.442
##     0.262    0.258    0.292
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
## 
## 
## Group 2 [1]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english =~                                                   
##     Stst19d (.p1.)    0.175    0.002   82.839    0.000    0.171
##     Stst20s (.p2.)    0.334    0.003  131.896    0.000    0.329
##     Stst21c (.p3.)    0.303    0.002  135.463    0.000    0.299
##     Stst22p (.p4.)    0.333    0.002  150.938    0.000    0.329
##     Stst23n (.p5.)    0.249    0.002  111.469    0.000    0.245
##     Stst24x (.p6.)    0.201    0.002   92.639    0.000    0.197
##     Stst25w (.p7.)    0.246    0.002  126.821    0.000    0.242
##     Stst26r (.p8.)    0.062    0.003   18.984    0.000    0.056
##     Stst31b (.p9.)    0.108    0.002   58.157    0.000    0.104
##   math =~                                                      
##     Stst5mt (.10.)    0.287    0.003   98.509    0.000    0.281
##     Stst25w (.11.)    0.161    0.003   56.263    0.000    0.155
##     Stst32r (.12.)    0.184    0.003   64.377    0.000    0.178
##     Stst33h (.13.)    0.573    0.004  141.812    0.000    0.565
##     Stst34r (.14.)    0.255    0.003   74.228    0.000    0.248
##   speed =~                                                     
##     Stst19d (.15.)    0.280    0.003  110.730    0.000    0.276
##     Sts292D (.16.)    0.221    0.003   76.999    0.000    0.215
##     Stst34r (.17.)    0.357    0.003  131.064    0.000    0.352
##     Stst35t (.18.)    0.597    0.003  177.324    0.000    0.591
##     Stst36c (.19.)    0.686    0.003  219.686    0.000    0.679
##     Stst37b (.20.)    0.578    0.003  192.524    0.000    0.572
##   spatial =~                                                   
##     Stst28m (.21.)    0.425    0.003  167.364    0.000    0.420
##     Sts292D (.22.)    0.444    0.003  147.141    0.000    0.438
##     Sts303D (.23.)    0.570    0.003  188.368    0.000    0.564
##     Stst31b (.24.)    0.335    0.003  120.130    0.000    0.329
##     Stst37b (.25.)    0.242    0.003   80.990    0.000    0.236
##   g =~                                                         
##     Stst1vc (.26.)    0.792    0.002  368.465    0.000    0.788
##     Stst5mt (.27.)    0.712    0.002  317.539    0.000    0.707
##     Stst19d (.28.)    0.599    0.002  252.509    0.000    0.594
##     Stst20s (.29.)    0.538    0.003  206.381    0.000    0.533
##     Stst21c (.30.)    0.545    0.003  211.779    0.000    0.540
##     Stst22p (.31.)    0.698    0.002  300.515    0.000    0.693
##     Stst23n (.32.)    0.607    0.003  224.093    0.000    0.602
##     Stst24x (.33.)    0.547    0.003  199.656    0.000    0.541
##     Stst25w (.34.)    0.681    0.002  318.810    0.000    0.676
##     Stst26r (.35.)    0.829    0.002  398.807    0.000    0.825
##     Stst28m (.36.)    0.479    0.002  208.222    0.000    0.475
##     Sts292D (.37.)    0.331    0.003  118.487    0.000    0.326
##     Sts303D (.38.)    0.473    0.003  176.480    0.000    0.468
##     Stst31b (.39.)    0.576    0.003  215.099    0.000    0.571
##     Stst32r (.40.)    0.717    0.002  334.414    0.000    0.713
##     Stst33h (.41.)    0.713    0.002  309.959    0.000    0.709
##     Stst34r (.42.)    0.470    0.003  164.348    0.000    0.465
##     Stst35t (.43.)    0.253    0.003   78.963    0.000    0.247
##     Stst36c (.44.)    0.122    0.003   41.660    0.000    0.116
##     Stst37b (.45.)    0.134    0.003   45.618    0.000    0.128
##  ci.upper   Std.lv  Std.all
##                            
##     0.179    0.175    0.180
##     0.339    0.334    0.358
##     0.307    0.303    0.318
##     0.338    0.333    0.357
##     0.254    0.249    0.264
##     0.205    0.201    0.214
##     0.250    0.246    0.252
##     0.068    0.062    0.065
##     0.111    0.108    0.112
##                            
##     0.292    0.287    0.286
##     0.166    0.161    0.164
##     0.189    0.184    0.188
##     0.581    0.573    0.587
##     0.262    0.255    0.266
##                            
##     0.285    0.280    0.289
##     0.226    0.221    0.227
##     0.363    0.357    0.373
##     0.604    0.597    0.666
##     0.692    0.686    0.718
##     0.584    0.578    0.607
##                            
##     0.430    0.425    0.499
##     0.450    0.444    0.457
##     0.576    0.570    0.593
##     0.340    0.335    0.347
##     0.248    0.242    0.254
##                            
##     0.796    0.792    0.821
##     0.716    0.712    0.710
##     0.604    0.599    0.617
##     0.543    0.538    0.576
##     0.550    0.545    0.571
##     0.702    0.698    0.748
##     0.613    0.607    0.644
##     0.552    0.547    0.583
##     0.685    0.681    0.696
##     0.833    0.829    0.875
##     0.484    0.479    0.563
##     0.337    0.331    0.341
##     0.479    0.473    0.493
##     0.581    0.576    0.596
##     0.721    0.717    0.732
##     0.718    0.713    0.731
##     0.476    0.470    0.492
##     0.260    0.253    0.282
##     0.128    0.122    0.128
##     0.139    0.134    0.140
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english ~~                                                   
##     math              0.000                               0.000
##     speed             0.000                               0.000
##     spatial           0.000                               0.000
##     g                 0.000                               0.000
##   math ~~                                                      
##     speed             0.000                               0.000
##     spatial           0.000                               0.000
##     g                 0.000                               0.000
##   speed ~~                                                     
##     spatial           0.000                               0.000
##     g                 0.000                               0.000
##   spatial ~~                                                   
##     g                 0.000                               0.000
##  ci.upper   Std.lv  Std.all
##                            
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##                            
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##                            
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##                            
##     0.000    0.000    0.000
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stst19d (.81.)   -0.132    0.004  -34.495    0.000   -0.139
##    .Stst20s (.82.)   -0.265    0.004  -67.441    0.000   -0.272
##    .Stst21c (.83.)   -0.208    0.004  -54.075    0.000   -0.215
##    .Stst22p (.84.)   -0.211    0.004  -53.421    0.000   -0.219
##    .Stst23n (.85.)   -0.147    0.004  -36.160    0.000   -0.155
##    .Stst24x (.86.)   -0.101    0.004  -24.496    0.000   -0.109
##    .Stst25w (.87.)   -0.131    0.004  -34.269    0.000   -0.139
##    .Stst26r           0.260    0.008   31.370    0.000    0.244
##    .Stst31b (.89.)    0.059    0.004   15.290    0.000    0.051
##    .Stst5mt (.90.)    0.143    0.004   38.792    0.000    0.136
##    .Stst32r (.91.)    0.158    0.004   43.423    0.000    0.150
##    .Stst33h (.92.)    0.124    0.004   29.582    0.000    0.116
##    .Stst34r           0.158    0.004   35.425    0.000    0.149
##    .Sts292D          -0.030    0.005   -6.026    0.000   -0.039
##    .Stst35t (.95.)   -0.074    0.004  -20.457    0.000   -0.081
##    .Stst36c (.96.)   -0.150    0.004  -40.962    0.000   -0.157
##    .Stst37b (.97.)   -0.076    0.004  -20.491    0.000   -0.083
##    .Stst28m          -0.167    0.004  -37.580    0.000   -0.175
##    .Sts303D (.99.)    0.182    0.004   45.146    0.000    0.174
##    .Stst1vc (.100)    0.175    0.004   47.238    0.000    0.168
##     english           2.214    0.017  128.054    0.000    2.180
##     math              0.086    0.009    9.933    0.000    0.069
##     speed             0.422    0.007   58.977    0.000    0.408
##     spatial          -0.218    0.009  -24.936    0.000   -0.235
##     g                -0.352    0.007  -52.257    0.000   -0.365
##  ci.upper   Std.lv  Std.all
##    -0.124   -0.132   -0.136
##    -0.257   -0.265   -0.284
##    -0.200   -0.208   -0.218
##    -0.204   -0.211   -0.227
##    -0.139   -0.147   -0.155
##    -0.093   -0.101   -0.108
##    -0.124   -0.131   -0.134
##     0.276    0.260    0.274
##     0.066    0.059    0.061
##     0.150    0.143    0.143
##     0.165    0.158    0.161
##     0.132    0.124    0.127
##     0.167    0.158    0.165
##    -0.020   -0.030   -0.030
##    -0.067   -0.074   -0.082
##    -0.143   -0.150   -0.157
##    -0.068   -0.076   -0.080
##    -0.158   -0.167   -0.196
##     0.190    0.182    0.190
##     0.182    0.175    0.181
##     2.248    2.214    2.214
##     0.103    0.086    0.086
##     0.436    0.422    0.422
##    -0.201   -0.218   -0.218
##    -0.339   -0.352   -0.352
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stst19dsgsdwrd    0.473    0.003  162.159    0.000    0.467
##    .Stest20spellng    0.469    0.003  157.669    0.000    0.463
##    .Stest21cptlztn    0.520    0.003  162.111    0.000    0.514
##    .Stest22puncttn    0.272    0.002  126.160    0.000    0.268
##    .Stest23english    0.459    0.003  144.992    0.000    0.453
##    .Stest24exprssn    0.540    0.004  149.341    0.000    0.533
##    .Stst25wrdfnctn    0.408    0.003  144.028    0.000    0.402
##    .Stst26rdngcmpr    0.207    0.002  109.040    0.000    0.203
##    .Stst31bstrctrs    0.477    0.003  155.347    0.000    0.471
##    .Stest5math        0.416    0.004  108.467    0.000    0.408
##    .Stst32rthrsnng    0.411    0.002  165.617    0.000    0.406
##    .Stst33hghschlm    0.116    0.005   25.553    0.000    0.107
##    .Stst34rthcmptt    0.502    0.004  133.597    0.000    0.494
##    .Stst29vslztn2D    0.587    0.004  149.761    0.000    0.580
##    .Stest35tblrdng    0.385    0.005   74.178    0.000    0.374
##    .Stst36clrclchc    0.427    0.004   98.633    0.000    0.419
##    .Stst37bjctnspc    0.496    0.004  128.776    0.000    0.488
##    .Stst28mchnclrs    0.315    0.002  133.351    0.000    0.310
##    .Stst30vslztn3D    0.374    0.003  110.592    0.000    0.367
##    .Stest1vocab       0.303    0.002  138.919    0.000    0.298
##     english           1.000                               1.000
##     math              1.000                               1.000
##     speed             1.000                               1.000
##     spatial           1.000                               1.000
##     g                 1.000                               1.000
##  ci.upper   Std.lv  Std.all
##     0.479    0.473    0.503
##     0.475    0.469    0.539
##     0.527    0.520    0.572
##     0.276    0.272    0.313
##     0.466    0.459    0.516
##     0.547    0.540    0.614
##     0.413    0.408    0.426
##     0.211    0.207    0.231
##     0.483    0.477    0.512
##     0.423    0.416    0.414
##     0.416    0.411    0.428
##     0.125    0.116    0.121
##     0.509    0.502    0.548
##     0.595    0.587    0.623
##     0.395    0.385    0.477
##     0.436    0.427    0.468
##     0.503    0.496    0.547
##     0.320    0.315    0.434
##     0.380    0.374    0.405
##     0.307    0.303    0.325
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
standardizedSolution(chc.bifactor) # get the correct SEs for standardized solution
##                            lhs op                         rhs group
## 1                      english =~       Stest19disguisedwords     1
## 2                      english =~             Stest20spelling     1
## 3                      english =~       Stest21capitalization     1
## 4                      english =~          Stest22punctuation     1
## 5                      english =~              Stest23english     1
## 6                      english =~           Stest24expression     1
## 7                      english =~        Stest25wordfunctions     1
## 8                      english =~ Stest26readingcomprehension     1
## 9                      english =~    Stest31abstractreasoning     1
## 10                        math =~                  Stest5math     1
## 11                        math =~        Stest25wordfunctions     1
## 12                        math =~       Stest32arithreasoning     1
## 13                        math =~       Stest33highschoolmath     1
## 14                        math =~     Stest34arithcomputation     1
## 15                       speed =~       Stest19disguisedwords     1
## 16                       speed =~      Stest29visualization2D     1
## 17                       speed =~     Stest34arithcomputation     1
## 18                       speed =~         Stest35tablereading     1
## 19                       speed =~     Stest36clericalchecking     1
## 20                       speed =~     Stest37objectinspection     1
## 21                     spatial =~  Stest28mechanicalreasoning     1
## 22                     spatial =~      Stest29visualization2D     1
## 23                     spatial =~      Stest30visualization3D     1
## 24                     spatial =~    Stest31abstractreasoning     1
## 25                     spatial =~     Stest37objectinspection     1
## 26                           g =~                 Stest1vocab     1
## 27                           g =~                  Stest5math     1
## 28                           g =~       Stest19disguisedwords     1
## 29                           g =~             Stest20spelling     1
## 30                           g =~       Stest21capitalization     1
## 31                           g =~          Stest22punctuation     1
## 32                           g =~              Stest23english     1
## 33                           g =~           Stest24expression     1
## 34                           g =~        Stest25wordfunctions     1
## 35                           g =~ Stest26readingcomprehension     1
## 36                           g =~  Stest28mechanicalreasoning     1
## 37                           g =~      Stest29visualization2D     1
## 38                           g =~      Stest30visualization3D     1
## 39                           g =~    Stest31abstractreasoning     1
## 40                           g =~       Stest32arithreasoning     1
## 41                           g =~       Stest33highschoolmath     1
## 42                           g =~     Stest34arithcomputation     1
## 43                           g =~         Stest35tablereading     1
## 44                           g =~     Stest36clericalchecking     1
## 45                           g =~     Stest37objectinspection     1
## 46       Stest19disguisedwords ~~       Stest19disguisedwords     1
## 47             Stest20spelling ~~             Stest20spelling     1
## 48       Stest21capitalization ~~       Stest21capitalization     1
## 49          Stest22punctuation ~~          Stest22punctuation     1
## 50              Stest23english ~~              Stest23english     1
## 51           Stest24expression ~~           Stest24expression     1
## 52        Stest25wordfunctions ~~        Stest25wordfunctions     1
## 53 Stest26readingcomprehension ~~ Stest26readingcomprehension     1
## 54    Stest31abstractreasoning ~~    Stest31abstractreasoning     1
## 55                  Stest5math ~~                  Stest5math     1
## 56       Stest32arithreasoning ~~       Stest32arithreasoning     1
## 57       Stest33highschoolmath ~~       Stest33highschoolmath     1
## 58     Stest34arithcomputation ~~     Stest34arithcomputation     1
## 59      Stest29visualization2D ~~      Stest29visualization2D     1
## 60         Stest35tablereading ~~         Stest35tablereading     1
## 61     Stest36clericalchecking ~~     Stest36clericalchecking     1
## 62     Stest37objectinspection ~~     Stest37objectinspection     1
## 63  Stest28mechanicalreasoning ~~  Stest28mechanicalreasoning     1
## 64      Stest30visualization3D ~~      Stest30visualization3D     1
## 65                 Stest1vocab ~~                 Stest1vocab     1
## 66                     english ~~                     english     1
## 67                        math ~~                        math     1
## 68                       speed ~~                       speed     1
## 69                     spatial ~~                     spatial     1
## 70                           g ~~                           g     1
## 71                     english ~~                        math     1
## 72                     english ~~                       speed     1
## 73                     english ~~                     spatial     1
## 74                     english ~~                           g     1
## 75                        math ~~                       speed     1
## 76                        math ~~                     spatial     1
## 77                        math ~~                           g     1
## 78                       speed ~~                     spatial     1
## 79                       speed ~~                           g     1
## 80                     spatial ~~                           g     1
## 81       Stest19disguisedwords ~1                                 1
## 82             Stest20spelling ~1                                 1
## 83       Stest21capitalization ~1                                 1
## 84          Stest22punctuation ~1                                 1
## 85              Stest23english ~1                                 1
## 86           Stest24expression ~1                                 1
## 87        Stest25wordfunctions ~1                                 1
## 88 Stest26readingcomprehension ~1                                 1
## 89    Stest31abstractreasoning ~1                                 1
## 90                  Stest5math ~1                                 1
##    label est.std    se       z pvalue ci.lower ci.upper
## 1   .p1.   0.181 0.002  81.595      0    0.177    0.185
## 2   .p2.   0.343 0.003 130.957      0    0.338    0.348
## 3   .p3.   0.318 0.002 133.549      0    0.314    0.323
## 4   .p4.   0.347 0.002 150.971      0    0.342    0.351
## 5   .p5.   0.253 0.002 114.950      0    0.249    0.258
## 6   .p6.   0.199 0.002  96.291      0    0.195    0.204
## 7   .p7.   0.252 0.002 126.341      0    0.248    0.256
## 8   .p8.   0.063 0.003  19.000      0    0.057    0.070
## 9   .p9.   0.111 0.002  59.227      0    0.107    0.114
## 10 .p10.   0.306 0.003 100.011      0    0.300    0.312
## 11 .p11.   0.165 0.003  55.992      0    0.159    0.170
## 12 .p12.   0.190 0.003  64.388      0    0.185    0.196
## 13 .p13.   0.581 0.004 143.969      0    0.573    0.589
## 14 .p14.   0.265 0.004  74.295      0    0.258    0.272
## 15 .p15.   0.290 0.003 111.569      0    0.285    0.295
## 16 .p16.   0.229 0.003  76.025      0    0.223    0.235
## 17 .p17.   0.371 0.003 135.997      0    0.366    0.376
## 18 .p18.   0.601 0.003 178.394      0    0.595    0.608
## 19 .p19.   0.703 0.003 231.041      0    0.697    0.709
## 20 .p20.   0.572 0.003 203.823      0    0.566    0.577
## 21 .p21.   0.496 0.003 172.578      0    0.490    0.502
## 22 .p22.   0.461 0.003 149.435      0    0.455    0.467
## 23 .p23.   0.574 0.003 190.988      0    0.569    0.580
## 24 .p24.   0.344 0.003 122.682      0    0.338    0.349
## 25 .p25.   0.239 0.003  81.821      0    0.234    0.245
## 26 .p26.   0.842 0.001 675.415      0    0.839    0.844
## 27 .p27.   0.759 0.002 424.751      0    0.755    0.762
## 28 .p28.   0.619 0.002 308.944      0    0.615    0.623
## 29 .p29.   0.551 0.002 239.091      0    0.547    0.556
## 30 .p30.   0.573 0.002 249.159      0    0.568    0.577
## 31 .p31.   0.727 0.002 423.836      0    0.723    0.730
## 32 .p32.   0.617 0.002 288.456      0    0.612    0.621
## 33 .p33.   0.543 0.002 229.958      0    0.538    0.547
## 34 .p34.   0.696 0.002 415.312      0    0.693    0.700
## 35 .p35.   0.847 0.001 617.074      0    0.844    0.850
## 36 .p36.   0.559 0.002 243.253      0    0.555    0.564
## 37 .p37.   0.344 0.003 125.327      0    0.339    0.350
## 38 .p38.   0.477 0.002 193.493      0    0.473    0.482
## 39 .p39.   0.591 0.002 275.623      0    0.587    0.595
## 40 .p40.   0.743 0.002 453.154      0    0.739    0.746
## 41 .p41.   0.724 0.002 428.088      0    0.720    0.727
## 42 .p42.   0.489 0.003 189.991      0    0.484    0.494
## 43 .p43.   0.255 0.003  81.462      0    0.249    0.261
## 44 .p44.   0.125 0.003  41.424      0    0.119    0.131
## 45 .p45.   0.132 0.003  45.875      0    0.127    0.138
## 46         0.499 0.002 201.664      0    0.495    0.504
## 47         0.579 0.003 223.013      0    0.573    0.584
## 48         0.570 0.003 212.506      0    0.565    0.576
## 49         0.352 0.002 155.627      0    0.347    0.356
## 50         0.556 0.003 210.706      0    0.550    0.561
## 51         0.666 0.003 259.650      0    0.661    0.671
## 52         0.424 0.002 196.817      0    0.420    0.429
## 53         0.279 0.002 127.568      0    0.274    0.283
## 54         0.520 0.003 196.603      0    0.515    0.526
## 55         0.331 0.002 143.116      0    0.326    0.335
## 56         0.412 0.002 183.218      0    0.408    0.417
## 57         0.138 0.004  30.828      0    0.130    0.147
## 58         0.553 0.003 187.000      0    0.548    0.559
## 59         0.616 0.003 190.643      0    0.610    0.623
## 60         0.574 0.004 134.445      0    0.565    0.582
## 61         0.491 0.004 114.707      0    0.482    0.499
## 62         0.598 0.003 174.925      0    0.591    0.605
## 63         0.441 0.003 144.922      0    0.435    0.447
## 64         0.442 0.003 129.873      0    0.436    0.449
## 65         0.292 0.002 139.162      0    0.288    0.296
## 66         1.000 0.000      NA     NA    1.000    1.000
## 67         1.000 0.000      NA     NA    1.000    1.000
## 68         1.000 0.000      NA     NA    1.000    1.000
## 69         1.000 0.000      NA     NA    1.000    1.000
## 70         1.000 0.000      NA     NA    1.000    1.000
## 71         0.000 0.000      NA     NA    0.000    0.000
## 72         0.000 0.000      NA     NA    0.000    0.000
## 73         0.000 0.000      NA     NA    0.000    0.000
## 74         0.000 0.000      NA     NA    0.000    0.000
## 75         0.000 0.000      NA     NA    0.000    0.000
## 76         0.000 0.000      NA     NA    0.000    0.000
## 77         0.000 0.000      NA     NA    0.000    0.000
## 78         0.000 0.000      NA     NA    0.000    0.000
## 79         0.000 0.000      NA     NA    0.000    0.000
## 80         0.000 0.000      NA     NA    0.000    0.000
## 81 .p81.  -0.136 0.004 -34.144      0   -0.144   -0.128
## 82 .p82.  -0.271 0.004 -67.257      0   -0.279   -0.263
## 83 .p83.  -0.218 0.004 -53.788      0   -0.226   -0.210
## 84 .p84.  -0.220 0.004 -54.170      0   -0.228   -0.212
## 85 .p85.  -0.149 0.004 -37.098      0   -0.157   -0.141
## 86 .p86.  -0.100 0.004 -25.186      0   -0.108   -0.093
## 87 .p87.  -0.134 0.004 -34.404      0   -0.142   -0.127
## 88        -0.033 0.004  -7.941      0   -0.041   -0.025
## 89 .p89.   0.060 0.004  15.089      0    0.053    0.068
## 90 .p90.   0.153 0.004  36.801      0    0.144    0.161
##  [ reached 'max' / getOption("max.print") -- omitted 120 rows ]
tests<-lavTestLRT(configural, metric, scalar2, chc.bifactor)
Td=tests[2:4,"Chisq diff"]
Td
## [1] 4693.293 2326.845 1229.364
dfd=tests[2:4,"Df diff"]
dfd
## [1] 40 11  5
lambda<-Td-dfd
ld<-lambda/dfd
G<-2 # number of groups
N<-71381 + 70776 # sample size
RMSEAD<-sqrt((ld)*G/(N-G))
RMSEAD
## [1] 0.04045611 0.05442424 0.05869543
RMSEA.CI(T=Td[1],df=dfd[1],N=N,G=2)
## [1] 0.03948273 0.04143782
RMSEA.CI(T=Td[2],df=dfd[2],N=N,G=2)
## [1] 0.05257352 0.05629796
RMSEA.CI(T=Td[3],df=dfd[3],N=N,G=2)
## [1] 0.0559577 0.0614805
round(pvals(T=Td[1],df=dfd[1],N=N,G=2),3)
##   RMSEA>0 RMSEA>.01 RMSEA>.05 RMSEA>.06 RMSEA>.08 RMSEA>.10 
##         1         1         0         0         0         0
round(pvals(T=Td[2],df=dfd[2],N=N,G=2),3)
##   RMSEA>0 RMSEA>.01 RMSEA>.05 RMSEA>.06 RMSEA>.08 RMSEA>.10 
##         1         1         1         0         0         0
round(pvals(T=Td[3],df=dfd[3],N=N,G=2),3)
##   RMSEA>0 RMSEA>.01 RMSEA>.05 RMSEA>.06 RMSEA>.08 RMSEA>.10 
##     1.000     1.000     1.000     0.223     0.000     0.000
tests<-lavTestLRT(configural, metric, scalar)
Td=tests[2:3,"Chisq diff"]
Td
## [1]  4693.293 22493.463
dfd=tests[2:3,"Df diff"]
dfd
## [1] 40 15
lambda<-Td-dfd
ld<-lambda/dfd
G<-2 # number of groups
N<-71381 + 70776 # sample size
RMSEAD<-sqrt((ld)*G/(N-G))
RMSEAD
## [1] 0.04045611 0.14520167
RMSEA.CI(T=Td[1],df=dfd[1],N=N,G=2)
## [1] 0.03948273 0.04143782
RMSEA.CI(T=Td[2],df=dfd[2],N=N,G=2)
## [1] 0.1436111 0.1467976
round(pvals(T=Td[1],df=dfd[1],N=N,G=2),3)
##   RMSEA>0 RMSEA>.01 RMSEA>.05 RMSEA>.06 RMSEA>.08 RMSEA>.10 
##         1         1         0         0         0         0
round(pvals(T=Td[2],df=dfd[2],N=N,G=2),3)
##   RMSEA>0 RMSEA>.01 RMSEA>.05 RMSEA>.06 RMSEA>.08 RMSEA>.10 
##         1         1         1         1         1         1
tests<-lavTestLRT(configural, metric, scalar2, strict)
Td=tests[2:4,"Chisq diff"]
Td
## [1] 4693.293 2326.845 4724.868
dfd=tests[2:4,"Df diff"]
dfd
## [1] 40 11 20
lambda<-Td-dfd
ld<-lambda/dfd
G<-2 # number of groups
N<-71381 + 70776 # sample size
RMSEAD<-sqrt((ld)*G/(N-G))
RMSEAD
## [1] 0.04045611 0.05442424 0.05752977
RMSEA.CI(T=Td[1],df=dfd[1],N=N,G=2)
## [1] 0.03948273 0.04143782
RMSEA.CI(T=Td[2],df=dfd[2],N=N,G=2)
## [1] 0.05257352 0.05629796
RMSEA.CI(T=Td[3],df=dfd[3],N=N,G=2)
## [1] 0.05615469 0.05891662
round(pvals(T=Td[1],df=dfd[1],N=N,G=2),3)
##   RMSEA>0 RMSEA>.01 RMSEA>.05 RMSEA>.06 RMSEA>.08 RMSEA>.10 
##         1         1         0         0         0         0
round(pvals(T=Td[2],df=dfd[2],N=N,G=2),3)
##   RMSEA>0 RMSEA>.01 RMSEA>.05 RMSEA>.06 RMSEA>.08 RMSEA>.10 
##         1         1         1         0         0         0
round(pvals(T=Td[3],df=dfd[3],N=N,G=2),3)
##   RMSEA>0 RMSEA>.01 RMSEA>.05 RMSEA>.06 RMSEA>.08 RMSEA>.10 
##     1.000     1.000     1.000     0.002     0.000     0.000
bf.age <-'
english =~ Stest19disguisedwords + Stest20spelling + Stest21capitalization + Stest22punctuation + Stest23english + Stest24expression + Stest25wordfunctions + Stest26readingcomprehension + Stest31abstractreasoning 
math =~ Stest5math + Stest25wordfunctions + Stest32arithreasoning + Stest33highschoolmath + Stest34arithcomputation
speed =~ Stest19disguisedwords + Stest29visualization2D + Stest34arithcomputation + Stest35tablereading + Stest36clericalchecking + Stest37objectinspection
spatial =~ Stest28mechanicalreasoning + Stest29visualization2D + Stest30visualization3D + Stest31abstractreasoning + Stest37objectinspection
g=~ Stest1vocab + Stest5math + Stest19disguisedwords + Stest20spelling + Stest21capitalization + Stest22punctuation + Stest23english + Stest24expression + Stest25wordfunctions + Stest26readingcomprehension + Stest28mechanicalreasoning + Stest29visualization2D + Stest30visualization3D + Stest31abstractreasoning + Stest32arithreasoning + Stest33highschoolmath + Stest34arithcomputation + Stest35tablereading + Stest36clericalchecking + Stest37objectinspection
g ~ age
'

bf.age2 <-'
english =~ Stest19disguisedwords + Stest20spelling + Stest21capitalization + Stest22punctuation + Stest23english + Stest24expression + Stest25wordfunctions + Stest26readingcomprehension + Stest31abstractreasoning 
math =~ Stest5math + Stest25wordfunctions + Stest32arithreasoning + Stest33highschoolmath + Stest34arithcomputation
speed =~ Stest19disguisedwords + Stest29visualization2D + Stest34arithcomputation + Stest35tablereading + Stest36clericalchecking + Stest37objectinspection
spatial =~ Stest28mechanicalreasoning + Stest29visualization2D + Stest30visualization3D + Stest31abstractreasoning + Stest37objectinspection
g=~ Stest1vocab + Stest5math + Stest19disguisedwords + Stest20spelling + Stest21capitalization + Stest22punctuation + Stest23english + Stest24expression + Stest25wordfunctions + Stest26readingcomprehension + Stest28mechanicalreasoning + Stest29visualization2D + Stest30visualization3D + Stest31abstractreasoning + Stest32arithreasoning + Stest33highschoolmath + Stest34arithcomputation + Stest35tablereading + Stest36clericalchecking + Stest37objectinspection
g ~ age + age2 
'

sem.age<-sem(bf.age, data=dgroup, group="sex", meanstructure=TRUE, sampling.weights="BY_WTA", std.lv=T, orthogonal=T, group.equal=c("loadings", "intercepts", "lv.variances"), group.partial=c("Stest28mechanicalreasoning~1", "Stest34arithcomputation~1", "Stest29visualization2D~1", "Stest26readingcomprehension~1"))
fitMeasures(sem.age, c("chisq", "df", "pvalue", "cfi", "rmsea", "srmr", "ecvi", "aic", "bic"))
##       chisq          df      pvalue         cfi       rmsea        srmr 
##   74693.344     384.000       0.000       0.948       0.052       0.052 
##        ecvi         aic         bic 
##       0.527 6471091.259 6472235.563
Mc(sem.age)
## [1] 0.7699994
summary(sem.age, standardized=T, ci=T) 
## lavaan 0.6-18 ended normally after 54 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                       177
##   Number of equality constraints                    61
## 
##   Number of observations per group:                   
##     0                                            70776
##     1                                            71381
##   Sampling weights variable                     BY_WTA
## 
## Model Test User Model:
##                                                Standard      Scaled
##   Test Statistic                              74693.344   63653.071
##   Degrees of freedom                                384         384
##   P-value (Chi-square)                            0.000       0.000
##   Scaling correction factor                                   1.173
##     Yuan-Bentler correction (Mplus variant)                        
##   Test statistic for each group:
##     0                                         38625.946   32916.722
##     1                                         36067.398   30736.348
## 
## Parameter Estimates:
## 
##   Standard errors                             Sandwich
##   Information bread                           Observed
##   Observed information based on                Hessian
## 
## 
## Group 1 [0]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english =~                                                   
##     Stst19d (.p1.)    0.175    0.002   82.740    0.000    0.171
##     Stst20s (.p2.)    0.333    0.003  131.603    0.000    0.328
##     Stst21c (.p3.)    0.302    0.002  134.895    0.000    0.298
##     Stst22p (.p4.)    0.333    0.002  150.118    0.000    0.328
##     Stst23n (.p5.)    0.249    0.002  111.258    0.000    0.244
##     Stst24x (.p6.)    0.200    0.002   92.522    0.000    0.196
##     Stst25w (.p7.)    0.246    0.002  126.334    0.000    0.242
##     Stst26r (.p8.)    0.060    0.003   18.217    0.000    0.053
##     Stst31b (.p9.)    0.108    0.002   58.213    0.000    0.104
##   math =~                                                      
##     Stst5mt (.10.)    0.288    0.003   99.031    0.000    0.283
##     Stst25w (.11.)    0.161    0.003   56.677    0.000    0.156
##     Stst32r (.12.)    0.185    0.003   65.111    0.000    0.180
##     Stst33h (.13.)    0.575    0.004  142.964    0.000    0.567
##     Stst34r (.14.)    0.255    0.003   74.634    0.000    0.248
##   speed =~                                                     
##     Stst19d (.15.)    0.280    0.003  110.489    0.000    0.275
##     Sts292D (.16.)    0.221    0.003   77.031    0.000    0.215
##     Stst34r (.17.)    0.357    0.003  130.893    0.000    0.352
##     Stst35t (.18.)    0.597    0.003  177.204    0.000    0.590
##     Stst36c (.19.)    0.685    0.003  219.539    0.000    0.679
##     Stst37b (.20.)    0.578    0.003  192.469    0.000    0.572
##   spatial =~                                                   
##     Stst28m (.21.)    0.426    0.003  167.554    0.000    0.421
##     Sts292D (.22.)    0.444    0.003  147.413    0.000    0.439
##     Sts303D (.23.)    0.570    0.003  188.476    0.000    0.564
##     Stst31b (.24.)    0.336    0.003  120.399    0.000    0.330
##     Stst37b (.25.)    0.241    0.003   80.851    0.000    0.235
##   g =~                                                         
##     Stst1vc (.26.)    0.786    0.002  367.629    0.000    0.782
##     Stst5mt (.27.)    0.705    0.002  313.791    0.000    0.701
##     Stst19d (.28.)    0.594    0.002  251.537    0.000    0.590
##     Stst20s (.29.)    0.534    0.003  207.498    0.000    0.529
##     Stst21c (.30.)    0.541    0.003  211.574    0.000    0.536
##     Stst22p (.31.)    0.692    0.002  298.921    0.000    0.688
##     Stst23n (.32.)    0.603    0.003  224.398    0.000    0.598
##     Stst24x (.33.)    0.543    0.003  200.603    0.000    0.538
##     Stst25w (.34.)    0.675    0.002  317.342    0.000    0.671
##     Stst26r (.35.)    0.823    0.002  397.988    0.000    0.819
##     Stst28m (.36.)    0.475    0.002  207.356    0.000    0.471
##     Sts292D (.37.)    0.328    0.003  118.109    0.000    0.323
##     Sts303D (.38.)    0.470    0.003  176.515    0.000    0.464
##     Stst31b (.39.)    0.571    0.003  213.492    0.000    0.566
##     Stst32r (.40.)    0.711    0.002  332.590    0.000    0.707
##     Stst33h (.41.)    0.706    0.002  305.953    0.000    0.702
##     Stst34r (.42.)    0.467    0.003  164.927    0.000    0.462
##     Stst35t (.43.)    0.252    0.003   79.489    0.000    0.246
##     Stst36c (.44.)    0.122    0.003   41.994    0.000    0.116
##     Stst37b (.45.)    0.134    0.003   45.976    0.000    0.128
##  ci.upper   Std.lv  Std.all
##                            
##     0.179    0.175    0.181
##     0.338    0.333    0.342
##     0.307    0.302    0.318
##     0.337    0.333    0.346
##     0.253    0.249    0.252
##     0.204    0.200    0.198
##     0.249    0.246    0.252
##     0.066    0.060    0.061
##     0.112    0.108    0.111
##                            
##     0.294    0.288    0.308
##     0.167    0.161    0.165
##     0.191    0.185    0.192
##     0.583    0.575    0.584
##     0.261    0.255    0.265
##                            
##     0.285    0.280    0.290
##     0.226    0.221    0.229
##     0.362    0.357    0.371
##     0.604    0.597    0.601
##     0.691    0.685    0.702
##     0.584    0.578    0.572
##                            
##     0.431    0.426    0.497
##     0.450    0.444    0.462
##     0.575    0.570    0.574
##     0.341    0.336    0.344
##     0.247    0.241    0.239
##                            
##     0.790    0.792    0.841
##     0.709    0.710    0.758
##     0.599    0.599    0.619
##     0.539    0.538    0.552
##     0.546    0.545    0.573
##     0.697    0.698    0.726
##     0.608    0.607    0.617
##     0.549    0.547    0.543
##     0.679    0.680    0.696
##     0.827    0.829    0.847
##     0.480    0.479    0.559
##     0.334    0.331    0.344
##     0.475    0.473    0.477
##     0.576    0.575    0.590
##     0.715    0.716    0.742
##     0.711    0.712    0.722
##     0.473    0.471    0.489
##     0.259    0.254    0.256
##     0.128    0.123    0.126
##     0.139    0.135    0.133
## 
## Regressions:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   g ~                                                          
##     age               0.097    0.004   26.719    0.000    0.090
##  ci.upper   Std.lv  Std.all
##                            
##     0.104    0.097    0.120
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english ~~                                                   
##     math              0.000                               0.000
##     speed             0.000                               0.000
##     spatial           0.000                               0.000
##   math ~~                                                      
##     speed             0.000                               0.000
##     spatial           0.000                               0.000
##   speed ~~                                                     
##     spatial           0.000                               0.000
##  ci.upper   Std.lv  Std.all
##                            
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##                            
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##                            
##     0.000    0.000    0.000
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stst19d (.79.)   -0.125    0.004  -32.620    0.000   -0.133
##    .Stst20s (.80.)   -0.258    0.004  -65.684    0.000   -0.266
##    .Stst21c (.81.)   -0.202    0.004  -52.396    0.000   -0.209
##    .Stst22p (.82.)   -0.204    0.004  -51.258    0.000   -0.212
##    .Stst23n (.83.)   -0.140    0.004  -34.358    0.000   -0.148
##    .Stst24x (.84.)   -0.094    0.004  -22.870    0.000   -0.102
##    .Stst25w (.85.)   -0.124    0.004  -32.161    0.000   -0.131
##    .Stst26r          -0.023    0.004   -5.669    0.000   -0.031
##    .Stst31b (.87.)    0.065    0.004   16.768    0.000    0.057
##    .Stst5mt (.88.)    0.151    0.004   40.635    0.000    0.144
##    .Stst32r (.89.)    0.165    0.004   45.356    0.000    0.158
##    .Stst33h (.90.)    0.132    0.004   31.186    0.000    0.123
##    .Stst34r          -0.073    0.004  -18.406    0.000   -0.081
##    .Sts292D           0.215    0.004   55.375    0.000    0.208
##    .Stst35t (.93.)   -0.071    0.004  -19.767    0.000   -0.078
##    .Stst36c (.94.)   -0.149    0.004  -40.695    0.000   -0.156
##    .Stst37b (.95.)   -0.074    0.004  -20.120    0.000   -0.081
##    .Stst28m           0.541    0.004  152.651    0.000    0.534
##    .Sts303D (.97.)    0.188    0.004   46.511    0.000    0.180
##    .Stst1vc (.98.)    0.184    0.004   49.426    0.000    0.176
##  ci.upper   Std.lv  Std.all
##    -0.118   -0.125   -0.130
##    -0.250   -0.258   -0.265
##    -0.194   -0.202   -0.212
##    -0.196   -0.204   -0.213
##    -0.132   -0.140   -0.142
##    -0.086   -0.094   -0.094
##    -0.116   -0.124   -0.127
##    -0.015   -0.023   -0.024
##     0.072    0.065    0.067
##     0.158    0.151    0.161
##     0.173    0.165    0.171
##     0.140    0.132    0.134
##    -0.065   -0.073   -0.076
##     0.223    0.215    0.224
##    -0.064   -0.071   -0.071
##    -0.142   -0.149   -0.152
##    -0.067   -0.074   -0.073
##     0.548    0.541    0.631
##     0.196    0.188    0.189
##     0.191    0.184    0.195
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stst19dsgsdwrd    0.467    0.003  159.211    0.000    0.462
##    .Stest20spellng    0.550    0.003  159.847    0.000    0.544
##    .Stest21cptlztn    0.516    0.003  162.041    0.000    0.510
##    .Stest22puncttn    0.325    0.002  133.413    0.000    0.320
##    .Stest23english    0.539    0.004  143.180    0.000    0.531
##    .Stest24exprssn    0.676    0.004  155.406    0.000    0.667
##    .Stst25wrdfnctn    0.405    0.003  150.993    0.000    0.400
##    .Stst26rdngcmpr    0.267    0.002  115.978    0.000    0.262
##    .Stst31bstrctrs    0.494    0.003  152.103    0.000    0.488
##    .Stest5math        0.291    0.003   97.704    0.000    0.285
##    .Stst32rthrsnng    0.384    0.002  157.762    0.000    0.380
##    .Stst33hghschlm    0.134    0.004   30.781    0.000    0.125
##    .Stst34rthcmptt    0.513    0.004  138.721    0.000    0.506
##    .Stst29vslztn2D    0.571    0.004  130.122    0.000    0.563
##    .Stest35tblrdng    0.566    0.007   76.293    0.000    0.551
##    .Stst36clrclchc    0.467    0.005   86.125    0.000    0.457
##    .Stst37bjctnspc    0.612    0.005  125.753    0.000    0.602
##    .Stst28mchnclrs    0.324    0.003  124.914    0.000    0.319
##    .Stst30vslztn3D    0.435    0.004  111.593    0.000    0.427
##    .Stest1vocab       0.258    0.002  126.073    0.000    0.254
##     english           1.000                               1.000
##     math              1.000                               1.000
##     speed             1.000                               1.000
##     spatial           1.000                               1.000
##    .g                 1.000                               1.000
##  ci.upper   Std.lv  Std.all
##     0.473    0.467    0.500
##     0.557    0.550    0.579
##     0.522    0.516    0.571
##     0.330    0.325    0.352
##     0.546    0.539    0.556
##     0.684    0.676    0.666
##     0.411    0.405    0.425
##     0.271    0.267    0.278
##     0.501    0.494    0.521
##     0.297    0.291    0.331
##     0.389    0.384    0.413
##     0.142    0.134    0.138
##     0.520    0.513    0.554
##     0.580    0.571    0.616
##     0.581    0.566    0.573
##     0.478    0.467    0.491
##     0.621    0.612    0.598
##     0.329    0.324    0.441
##     0.443    0.435    0.442
##     0.262    0.258    0.292
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    0.985    0.985
## 
## 
## Group 2 [1]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english =~                                                   
##     Stst19d (.p1.)    0.175    0.002   82.740    0.000    0.171
##     Stst20s (.p2.)    0.333    0.003  131.603    0.000    0.328
##     Stst21c (.p3.)    0.302    0.002  134.895    0.000    0.298
##     Stst22p (.p4.)    0.333    0.002  150.118    0.000    0.328
##     Stst23n (.p5.)    0.249    0.002  111.258    0.000    0.244
##     Stst24x (.p6.)    0.200    0.002   92.522    0.000    0.196
##     Stst25w (.p7.)    0.246    0.002  126.334    0.000    0.242
##     Stst26r (.p8.)    0.060    0.003   18.217    0.000    0.053
##     Stst31b (.p9.)    0.108    0.002   58.213    0.000    0.104
##   math =~                                                      
##     Stst5mt (.10.)    0.288    0.003   99.031    0.000    0.283
##     Stst25w (.11.)    0.161    0.003   56.677    0.000    0.156
##     Stst32r (.12.)    0.185    0.003   65.111    0.000    0.180
##     Stst33h (.13.)    0.575    0.004  142.964    0.000    0.567
##     Stst34r (.14.)    0.255    0.003   74.634    0.000    0.248
##   speed =~                                                     
##     Stst19d (.15.)    0.280    0.003  110.489    0.000    0.275
##     Sts292D (.16.)    0.221    0.003   77.031    0.000    0.215
##     Stst34r (.17.)    0.357    0.003  130.893    0.000    0.352
##     Stst35t (.18.)    0.597    0.003  177.204    0.000    0.590
##     Stst36c (.19.)    0.685    0.003  219.539    0.000    0.679
##     Stst37b (.20.)    0.578    0.003  192.469    0.000    0.572
##   spatial =~                                                   
##     Stst28m (.21.)    0.426    0.003  167.554    0.000    0.421
##     Sts292D (.22.)    0.444    0.003  147.413    0.000    0.439
##     Sts303D (.23.)    0.570    0.003  188.476    0.000    0.564
##     Stst31b (.24.)    0.336    0.003  120.399    0.000    0.330
##     Stst37b (.25.)    0.241    0.003   80.851    0.000    0.235
##   g =~                                                         
##     Stst1vc (.26.)    0.786    0.002  367.629    0.000    0.782
##     Stst5mt (.27.)    0.705    0.002  313.791    0.000    0.701
##     Stst19d (.28.)    0.594    0.002  251.537    0.000    0.590
##     Stst20s (.29.)    0.534    0.003  207.498    0.000    0.529
##     Stst21c (.30.)    0.541    0.003  211.574    0.000    0.536
##     Stst22p (.31.)    0.692    0.002  298.921    0.000    0.688
##     Stst23n (.32.)    0.603    0.003  224.398    0.000    0.598
##     Stst24x (.33.)    0.543    0.003  200.603    0.000    0.538
##     Stst25w (.34.)    0.675    0.002  317.342    0.000    0.671
##     Stst26r (.35.)    0.823    0.002  397.988    0.000    0.819
##     Stst28m (.36.)    0.475    0.002  207.356    0.000    0.471
##     Sts292D (.37.)    0.328    0.003  118.109    0.000    0.323
##     Sts303D (.38.)    0.470    0.003  176.515    0.000    0.464
##     Stst31b (.39.)    0.571    0.003  213.492    0.000    0.566
##     Stst32r (.40.)    0.711    0.002  332.590    0.000    0.707
##     Stst33h (.41.)    0.706    0.002  305.953    0.000    0.702
##     Stst34r (.42.)    0.467    0.003  164.927    0.000    0.462
##     Stst35t (.43.)    0.252    0.003   79.489    0.000    0.246
##     Stst36c (.44.)    0.122    0.003   41.994    0.000    0.116
##     Stst37b (.45.)    0.134    0.003   45.976    0.000    0.128
##  ci.upper   Std.lv  Std.all
##                            
##     0.179    0.175    0.180
##     0.338    0.333    0.357
##     0.307    0.302    0.317
##     0.337    0.333    0.356
##     0.253    0.249    0.263
##     0.204    0.200    0.213
##     0.249    0.246    0.251
##     0.066    0.060    0.063
##     0.112    0.108    0.112
##                            
##     0.294    0.288    0.288
##     0.167    0.161    0.165
##     0.191    0.185    0.189
##     0.583    0.575    0.589
##     0.261    0.255    0.266
##                            
##     0.285    0.280    0.288
##     0.226    0.221    0.227
##     0.362    0.357    0.373
##     0.604    0.597    0.665
##     0.691    0.685    0.718
##     0.584    0.578    0.607
##                            
##     0.431    0.426    0.499
##     0.450    0.444    0.458
##     0.575    0.570    0.593
##     0.341    0.336    0.347
##     0.247    0.241    0.253
##                            
##     0.790    0.793    0.822
##     0.709    0.711    0.709
##     0.599    0.599    0.618
##     0.539    0.539    0.578
##     0.546    0.546    0.572
##     0.697    0.699    0.749
##     0.608    0.608    0.644
##     0.549    0.548    0.584
##     0.679    0.681    0.696
##     0.827    0.830    0.876
##     0.480    0.479    0.563
##     0.334    0.331    0.341
##     0.475    0.474    0.493
##     0.576    0.576    0.596
##     0.715    0.717    0.732
##     0.711    0.713    0.730
##     0.473    0.471    0.492
##     0.259    0.255    0.284
##     0.128    0.123    0.129
##     0.139    0.135    0.142
## 
## Regressions:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   g ~                                                          
##     age               0.111    0.003   31.847    0.000    0.105
##  ci.upper   Std.lv  Std.all
##                            
##     0.118    0.110    0.132
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english ~~                                                   
##     math              0.000                               0.000
##     speed             0.000                               0.000
##     spatial           0.000                               0.000
##   math ~~                                                      
##     speed             0.000                               0.000
##     spatial           0.000                               0.000
##   speed ~~                                                     
##     spatial           0.000                               0.000
##  ci.upper   Std.lv  Std.all
##                            
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##                            
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##                            
##     0.000    0.000    0.000
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stst19d (.79.)   -0.125    0.004  -32.620    0.000   -0.133
##    .Stst20s (.80.)   -0.258    0.004  -65.684    0.000   -0.266
##    .Stst21c (.81.)   -0.202    0.004  -52.396    0.000   -0.209
##    .Stst22p (.82.)   -0.204    0.004  -51.258    0.000   -0.212
##    .Stst23n (.83.)   -0.140    0.004  -34.358    0.000   -0.148
##    .Stst24x (.84.)   -0.094    0.004  -22.870    0.000   -0.102
##    .Stst25w (.85.)   -0.124    0.004  -32.161    0.000   -0.131
##    .Stst26r           0.274    0.008   32.945    0.000    0.258
##    .Stst31b (.87.)    0.065    0.004   16.768    0.000    0.057
##    .Stst5mt (.88.)    0.151    0.004   40.635    0.000    0.144
##    .Stst32r (.89.)    0.165    0.004   45.356    0.000    0.158
##    .Stst33h (.90.)    0.132    0.004   31.186    0.000    0.123
##    .Stst34r           0.164    0.004   36.656    0.000    0.155
##    .Sts292D          -0.026    0.005   -5.266    0.000   -0.035
##    .Stst35t (.93.)   -0.071    0.004  -19.767    0.000   -0.078
##    .Stst36c (.94.)   -0.149    0.004  -40.695    0.000   -0.156
##    .Stst37b (.95.)   -0.074    0.004  -20.120    0.000   -0.081
##    .Stst28m          -0.161    0.004  -36.294    0.000   -0.170
##    .Sts303D (.97.)    0.188    0.004   46.511    0.000    0.180
##    .Stst1vc (.98.)    0.184    0.004   49.426    0.000    0.176
##     english           2.220    0.017  127.578    0.000    2.186
##     math              0.084    0.009    9.818    0.000    0.067
##     speed             0.422    0.007   59.034    0.000    0.408
##     spatial          -0.219    0.009  -25.021    0.000   -0.236
##    .g                -0.342    0.007  -50.026    0.000   -0.356
##  ci.upper   Std.lv  Std.all
##    -0.118   -0.125   -0.129
##    -0.250   -0.258   -0.277
##    -0.194   -0.202   -0.212
##    -0.196   -0.204   -0.219
##    -0.132   -0.140   -0.148
##    -0.086   -0.094   -0.100
##    -0.116   -0.124   -0.127
##     0.290    0.274    0.289
##     0.072    0.065    0.067
##     0.158    0.151    0.150
##     0.173    0.165    0.169
##     0.140    0.132    0.135
##     0.172    0.164    0.171
##    -0.016   -0.026   -0.027
##    -0.064   -0.071   -0.079
##    -0.142   -0.149   -0.156
##    -0.067   -0.074   -0.078
##    -0.152   -0.161   -0.189
##     0.196    0.188    0.195
##     0.191    0.184    0.190
##     2.254    2.220    2.220
##     0.101    0.084    0.084
##     0.436    0.422    0.422
##    -0.202   -0.219   -0.219
##    -0.329   -0.340   -0.340
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stst19dsgsdwrd    0.473    0.003  162.230    0.000    0.468
##    .Stest20spellng    0.469    0.003  157.781    0.000    0.463
##    .Stest21cptlztn    0.520    0.003  162.118    0.000    0.514
##    .Stest22puncttn    0.272    0.002  126.174    0.000    0.268
##    .Stest23english    0.459    0.003  144.973    0.000    0.453
##    .Stest24exprssn    0.540    0.004  149.395    0.000    0.533
##    .Stst25wrdfnctn    0.408    0.003  144.039    0.000    0.402
##    .Stst26rdngcmpr    0.206    0.002  108.687    0.000    0.202
##    .Stst31bstrctrs    0.478    0.003  155.279    0.000    0.472
##    .Stest5math        0.416    0.004  108.467    0.000    0.409
##    .Stst32rthrsnng    0.411    0.002  165.706    0.000    0.406
##    .Stst33hghschlm    0.115    0.005   25.469    0.000    0.106
##    .Stst34rthcmptt    0.502    0.004  133.743    0.000    0.494
##    .Stst29vslztn2D    0.587    0.004  149.676    0.000    0.580
##    .Stest35tblrdng    0.385    0.005   74.180    0.000    0.374
##    .Stst36clrclchc    0.427    0.004   98.622    0.000    0.419
##    .Stst37bjctnspc    0.496    0.004  128.803    0.000    0.488
##    .Stst28mchnclrs    0.315    0.002  133.328    0.000    0.311
##    .Stst30vslztn3D    0.374    0.003  110.676    0.000    0.367
##    .Stest1vocab       0.302    0.002  138.907    0.000    0.298
##     english           1.000                               1.000
##     math              1.000                               1.000
##     speed             1.000                               1.000
##     spatial           1.000                               1.000
##    .g                 1.000                               1.000
##  ci.upper   Std.lv  Std.all
##     0.479    0.473    0.503
##     0.475    0.469    0.539
##     0.527    0.520    0.572
##     0.277    0.272    0.313
##     0.465    0.459    0.515
##     0.547    0.540    0.613
##     0.413    0.408    0.426
##     0.210    0.206    0.229
##     0.484    0.478    0.512
##     0.424    0.416    0.414
##     0.416    0.411    0.428
##     0.124    0.115    0.121
##     0.509    0.502    0.548
##     0.595    0.587    0.623
##     0.395    0.385    0.477
##     0.436    0.427    0.468
##     0.503    0.496    0.547
##     0.320    0.315    0.434
##     0.380    0.374    0.405
##     0.306    0.302    0.325
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    0.983    0.983
sem.age2<-sem(bf.age2, data=dgroup, group="sex", meanstructure=TRUE, sampling.weights="BY_WTA", std.lv=T, orthogonal=T, group.equal=c("loadings", "intercepts", "lv.variances"), group.partial=c("Stest28mechanicalreasoning~1", "Stest34arithcomputation~1", "Stest29visualization2D~1", "Stest26readingcomprehension~1"))
fitMeasures(sem.age2, c("chisq", "df", "pvalue", "cfi", "rmsea", "srmr", "ecvi", "aic", "bic"))
##       chisq          df      pvalue         cfi       rmsea        srmr 
##   75367.055     422.000       0.000       0.948       0.050       0.050 
##        ecvi         aic         bic 
##       0.532 6469900.248 6471064.281
Mc(sem.age2)
## [1] 0.7682797
summary(sem.age2, standardized=T, ci=T) 
## lavaan 0.6-18 ended normally after 56 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                       179
##   Number of equality constraints                    61
## 
##   Number of observations per group:                   
##     0                                            70776
##     1                                            71381
##   Sampling weights variable                     BY_WTA
## 
## Model Test User Model:
##                                                Standard      Scaled
##   Test Statistic                              75367.055   64231.063
##   Degrees of freedom                                422         422
##   P-value (Chi-square)                            0.000       0.000
##   Scaling correction factor                                   1.173
##     Yuan-Bentler correction (Mplus variant)                        
##   Test statistic for each group:
##     0                                         38942.325   33188.333
##     1                                         36424.730   31042.730
## 
## Parameter Estimates:
## 
##   Standard errors                             Sandwich
##   Information bread                           Observed
##   Observed information based on                Hessian
## 
## 
## Group 1 [0]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english =~                                                   
##     Stst19d (.p1.)    0.175    0.002   82.826    0.000    0.171
##     Stst20s (.p2.)    0.333    0.003  131.757    0.000    0.328
##     Stst21c (.p3.)    0.302    0.002  135.047    0.000    0.298
##     Stst22p (.p4.)    0.333    0.002  150.253    0.000    0.328
##     Stst23n (.p5.)    0.249    0.002  111.347    0.000    0.244
##     Stst24x (.p6.)    0.200    0.002   92.606    0.000    0.196
##     Stst25w (.p7.)    0.246    0.002  126.446    0.000    0.242
##     Stst26r (.p8.)    0.060    0.003   18.362    0.000    0.054
##     Stst31b (.p9.)    0.108    0.002   58.235    0.000    0.104
##   math =~                                                      
##     Stst5mt (.10.)    0.288    0.003   98.879    0.000    0.282
##     Stst25w (.11.)    0.161    0.003   56.582    0.000    0.156
##     Stst32r (.12.)    0.185    0.003   65.062    0.000    0.180
##     Stst33h (.13.)    0.575    0.004  142.729    0.000    0.567
##     Stst34r (.14.)    0.255    0.003   74.534    0.000    0.248
##   speed =~                                                     
##     Stst19d (.15.)    0.280    0.003  110.410    0.000    0.275
##     Sts292D (.16.)    0.221    0.003   77.013    0.000    0.215
##     Stst34r (.17.)    0.357    0.003  130.846    0.000    0.351
##     Stst35t (.18.)    0.597    0.003  177.176    0.000    0.590
##     Stst36c (.19.)    0.685    0.003  219.483    0.000    0.679
##     Stst37b (.20.)    0.578    0.003  192.436    0.000    0.572
##   spatial =~                                                   
##     Stst28m (.21.)    0.425    0.003  167.530    0.000    0.420
##     Sts292D (.22.)    0.444    0.003  147.372    0.000    0.438
##     Sts303D (.23.)    0.570    0.003  188.447    0.000    0.564
##     Stst31b (.24.)    0.336    0.003  120.401    0.000    0.330
##     Stst37b (.25.)    0.241    0.003   80.794    0.000    0.235
##   g =~                                                         
##     Stst1vc (.26.)    0.782    0.002  367.215    0.000    0.778
##     Stst5mt (.27.)    0.702    0.002  314.497    0.000    0.698
##     Stst19d (.28.)    0.592    0.002  251.798    0.000    0.587
##     Stst20s (.29.)    0.532    0.003  207.485    0.000    0.527
##     Stst21c (.30.)    0.538    0.003  211.737    0.000    0.533
##     Stst22p (.31.)    0.689    0.002  298.864    0.000    0.685
##     Stst23n (.32.)    0.600    0.003  224.467    0.000    0.595
##     Stst24x (.33.)    0.541    0.003  200.730    0.000    0.536
##     Stst25w (.34.)    0.672    0.002  317.397    0.000    0.668
##     Stst26r (.35.)    0.819    0.002  397.430    0.000    0.815
##     Stst28m (.36.)    0.473    0.002  207.502    0.000    0.469
##     Sts292D (.37.)    0.327    0.003  118.266    0.000    0.322
##     Sts303D (.38.)    0.467    0.003  176.440    0.000    0.462
##     Stst31b (.39.)    0.568    0.003  213.616    0.000    0.563
##     Stst32r (.40.)    0.708    0.002  332.203    0.000    0.704
##     Stst33h (.41.)    0.703    0.002  306.178    0.000    0.699
##     Stst34r (.42.)    0.465    0.003  165.068    0.000    0.460
##     Stst35t (.43.)    0.252    0.003   79.641    0.000    0.245
##     Stst36c (.44.)    0.122    0.003   42.129    0.000    0.116
##     Stst37b (.45.)    0.133    0.003   46.130    0.000    0.128
##  ci.upper   Std.lv  Std.all
##                            
##     0.179    0.175    0.181
##     0.338    0.333    0.341
##     0.307    0.302    0.318
##     0.337    0.333    0.346
##     0.253    0.249    0.252
##     0.204    0.200    0.198
##     0.249    0.246    0.251
##     0.066    0.060    0.061
##     0.112    0.108    0.111
##                            
##     0.293    0.288    0.307
##     0.167    0.161    0.165
##     0.191    0.185    0.192
##     0.583    0.575    0.583
##     0.261    0.255    0.264
##                            
##     0.285    0.280    0.289
##     0.226    0.221    0.229
##     0.362    0.357    0.370
##     0.603    0.597    0.601
##     0.691    0.685    0.702
##     0.584    0.578    0.572
##                            
##     0.430    0.425    0.496
##     0.450    0.444    0.462
##     0.575    0.570    0.574
##     0.341    0.336    0.344
##     0.247    0.241    0.239
##                            
##     0.786    0.793    0.842
##     0.706    0.712    0.759
##     0.596    0.600    0.620
##     0.537    0.539    0.553
##     0.543    0.546    0.574
##     0.694    0.699    0.727
##     0.605    0.608    0.617
##     0.546    0.548    0.544
##     0.676    0.681    0.697
##     0.823    0.831    0.848
##     0.478    0.480    0.559
##     0.332    0.331    0.344
##     0.473    0.474    0.478
##     0.573    0.576    0.591
##     0.712    0.717    0.743
##     0.708    0.713    0.723
##     0.471    0.472    0.490
##     0.258    0.255    0.257
##     0.127    0.123    0.126
##     0.139    0.135    0.134
## 
## Regressions:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   g ~                                                          
##     age               0.089    0.004   25.116    0.000    0.082
##     age2             -0.061    0.002  -24.957    0.000   -0.066
##  ci.upper   Std.lv  Std.all
##                            
##     0.096    0.088    0.110
##    -0.056   -0.060   -0.112
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english ~~                                                   
##     math              0.000                               0.000
##     speed             0.000                               0.000
##     spatial           0.000                               0.000
##   math ~~                                                      
##     speed             0.000                               0.000
##     spatial           0.000                               0.000
##   speed ~~                                                     
##     spatial           0.000                               0.000
##  ci.upper   Std.lv  Std.all
##                            
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##                            
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##                            
##     0.000    0.000    0.000
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stst19d (.82.)   -0.069    0.004  -15.410    0.000   -0.078
##    .Stst20s (.83.)   -0.208    0.004  -46.777    0.000   -0.216
##    .Stst21c (.84.)   -0.151    0.004  -34.595    0.000   -0.159
##    .Stst22p (.85.)   -0.139    0.005  -29.197    0.000   -0.148
##    .Stst23n (.86.)   -0.083    0.005  -17.885    0.000   -0.092
##    .Stst24x (.87.)   -0.043    0.005   -9.374    0.000   -0.052
##    .Stst25w (.88.)   -0.060    0.005  -12.855    0.000   -0.069
##    .Stst26r           0.055    0.005   10.647    0.000    0.044
##    .Stst31b (.90.)    0.119    0.004   27.142    0.000    0.110
##    .Stst5mt (.91.)    0.218    0.005   47.612    0.000    0.209
##    .Stst32r (.92.)    0.233    0.005   51.378    0.000    0.224
##    .Stst33h (.93.)    0.198    0.005   39.122    0.000    0.188
##    .Stst34r          -0.029    0.004   -6.606    0.000   -0.037
##    .Sts292D           0.246    0.004   60.733    0.000    0.239
##    .Stst35t (.96.)   -0.047    0.004  -12.836    0.000   -0.054
##    .Stst36c (.97.)   -0.137    0.004  -37.385    0.000   -0.144
##    .Stst37b (.98.)   -0.062    0.004  -16.540    0.000   -0.069
##    .Stst28m           0.586    0.004  148.337    0.000    0.578
##    .Sts303D (.100)    0.232    0.004   52.494    0.000    0.223
##    .Stst1vc (.101)    0.258    0.005   54.682    0.000    0.249
##  ci.upper   Std.lv  Std.all
##    -0.060   -0.069   -0.071
##    -0.199   -0.208   -0.213
##    -0.142   -0.151   -0.158
##    -0.129   -0.139   -0.144
##    -0.074   -0.083   -0.084
##    -0.034   -0.043   -0.043
##    -0.051   -0.060   -0.061
##     0.065    0.055    0.056
##     0.127    0.119    0.122
##     0.227    0.218    0.232
##     0.242    0.233    0.241
##     0.208    0.198    0.201
##    -0.020   -0.029   -0.030
##     0.254    0.246    0.256
##    -0.040   -0.047   -0.047
##    -0.130   -0.137   -0.141
##    -0.054   -0.062   -0.061
##     0.594    0.586    0.684
##     0.241    0.232    0.234
##     0.267    0.258    0.274
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stst19dsgsdwrd    0.468    0.003  159.231    0.000    0.462
##    .Stest20spellng    0.550    0.003  159.840    0.000    0.544
##    .Stest21cptlztn    0.516    0.003  162.046    0.000    0.510
##    .Stest22puncttn    0.325    0.002  133.420    0.000    0.320
##    .Stest23english    0.539    0.004  143.178    0.000    0.532
##    .Stest24exprssn    0.676    0.004  155.396    0.000    0.667
##    .Stst25wrdfnctn    0.405    0.003  151.004    0.000    0.400
##    .Stst26rdngcmpr    0.267    0.002  116.129    0.000    0.262
##    .Stst31bstrctrs    0.494    0.003  152.103    0.000    0.488
##    .Stest5math        0.291    0.003   97.669    0.000    0.285
##    .Stst32rthrsnng    0.385    0.002  157.780    0.000    0.380
##    .Stst33hghschlm    0.134    0.004   30.694    0.000    0.125
##    .Stst34rthcmptt    0.513    0.004  138.710    0.000    0.506
##    .Stst29vslztn2D    0.571    0.004  130.127    0.000    0.563
##    .Stest35tblrdng    0.566    0.007   76.289    0.000    0.551
##    .Stst36clrclchc    0.467    0.005   86.122    0.000    0.457
##    .Stst37bjctnspc    0.612    0.005  125.755    0.000    0.602
##    .Stst28mchnclrs    0.324    0.003  124.903    0.000    0.319
##    .Stst30vslztn3D    0.435    0.004  111.576    0.000    0.427
##    .Stest1vocab       0.258    0.002  126.094    0.000    0.254
##     english           1.000                               1.000
##     math              1.000                               1.000
##     speed             1.000                               1.000
##     spatial           1.000                               1.000
##    .g                 1.000                               1.000
##  ci.upper   Std.lv  Std.all
##     0.473    0.468    0.500
##     0.557    0.550    0.578
##     0.522    0.516    0.570
##     0.330    0.325    0.352
##     0.546    0.539    0.555
##     0.684    0.676    0.665
##     0.411    0.405    0.424
##     0.271    0.267    0.278
##     0.501    0.494    0.520
##     0.296    0.291    0.330
##     0.389    0.385    0.412
##     0.142    0.134    0.138
##     0.520    0.513    0.553
##     0.580    0.571    0.616
##     0.580    0.566    0.573
##     0.478    0.467    0.491
##     0.621    0.612    0.598
##     0.329    0.324    0.441
##     0.443    0.435    0.442
##     0.262    0.258    0.291
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    0.973    0.973
## 
## 
## Group 2 [1]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english =~                                                   
##     Stst19d (.p1.)    0.175    0.002   82.826    0.000    0.171
##     Stst20s (.p2.)    0.333    0.003  131.757    0.000    0.328
##     Stst21c (.p3.)    0.302    0.002  135.047    0.000    0.298
##     Stst22p (.p4.)    0.333    0.002  150.253    0.000    0.328
##     Stst23n (.p5.)    0.249    0.002  111.347    0.000    0.244
##     Stst24x (.p6.)    0.200    0.002   92.606    0.000    0.196
##     Stst25w (.p7.)    0.246    0.002  126.446    0.000    0.242
##     Stst26r (.p8.)    0.060    0.003   18.362    0.000    0.054
##     Stst31b (.p9.)    0.108    0.002   58.235    0.000    0.104
##   math =~                                                      
##     Stst5mt (.10.)    0.288    0.003   98.879    0.000    0.282
##     Stst25w (.11.)    0.161    0.003   56.582    0.000    0.156
##     Stst32r (.12.)    0.185    0.003   65.062    0.000    0.180
##     Stst33h (.13.)    0.575    0.004  142.729    0.000    0.567
##     Stst34r (.14.)    0.255    0.003   74.534    0.000    0.248
##   speed =~                                                     
##     Stst19d (.15.)    0.280    0.003  110.410    0.000    0.275
##     Sts292D (.16.)    0.221    0.003   77.013    0.000    0.215
##     Stst34r (.17.)    0.357    0.003  130.846    0.000    0.351
##     Stst35t (.18.)    0.597    0.003  177.176    0.000    0.590
##     Stst36c (.19.)    0.685    0.003  219.483    0.000    0.679
##     Stst37b (.20.)    0.578    0.003  192.436    0.000    0.572
##   spatial =~                                                   
##     Stst28m (.21.)    0.425    0.003  167.530    0.000    0.420
##     Sts292D (.22.)    0.444    0.003  147.372    0.000    0.438
##     Sts303D (.23.)    0.570    0.003  188.447    0.000    0.564
##     Stst31b (.24.)    0.336    0.003  120.401    0.000    0.330
##     Stst37b (.25.)    0.241    0.003   80.794    0.000    0.235
##   g =~                                                         
##     Stst1vc (.26.)    0.782    0.002  367.215    0.000    0.778
##     Stst5mt (.27.)    0.702    0.002  314.497    0.000    0.698
##     Stst19d (.28.)    0.592    0.002  251.798    0.000    0.587
##     Stst20s (.29.)    0.532    0.003  207.485    0.000    0.527
##     Stst21c (.30.)    0.538    0.003  211.737    0.000    0.533
##     Stst22p (.31.)    0.689    0.002  298.864    0.000    0.685
##     Stst23n (.32.)    0.600    0.003  224.467    0.000    0.595
##     Stst24x (.33.)    0.541    0.003  200.730    0.000    0.536
##     Stst25w (.34.)    0.672    0.002  317.397    0.000    0.668
##     Stst26r (.35.)    0.819    0.002  397.430    0.000    0.815
##     Stst28m (.36.)    0.473    0.002  207.502    0.000    0.469
##     Sts292D (.37.)    0.327    0.003  118.266    0.000    0.322
##     Sts303D (.38.)    0.467    0.003  176.440    0.000    0.462
##     Stst31b (.39.)    0.568    0.003  213.616    0.000    0.563
##     Stst32r (.40.)    0.708    0.002  332.203    0.000    0.704
##     Stst33h (.41.)    0.703    0.002  306.178    0.000    0.699
##     Stst34r (.42.)    0.465    0.003  165.068    0.000    0.460
##     Stst35t (.43.)    0.252    0.003   79.641    0.000    0.245
##     Stst36c (.44.)    0.122    0.003   42.129    0.000    0.116
##     Stst37b (.45.)    0.133    0.003   46.130    0.000    0.128
##  ci.upper   Std.lv  Std.all
##                            
##     0.179    0.175    0.180
##     0.338    0.333    0.357
##     0.307    0.302    0.317
##     0.337    0.333    0.357
##     0.253    0.249    0.264
##     0.204    0.200    0.213
##     0.249    0.246    0.251
##     0.066    0.060    0.063
##     0.112    0.108    0.112
##                            
##     0.293    0.288    0.287
##     0.167    0.161    0.165
##     0.191    0.185    0.189
##     0.583    0.575    0.589
##     0.261    0.255    0.266
##                            
##     0.285    0.280    0.288
##     0.226    0.221    0.227
##     0.362    0.357    0.373
##     0.603    0.597    0.665
##     0.691    0.685    0.718
##     0.584    0.578    0.607
##                            
##     0.430    0.425    0.500
##     0.450    0.444    0.458
##     0.575    0.570    0.593
##     0.341    0.336    0.348
##     0.247    0.241    0.253
##                            
##     0.786    0.791    0.821
##     0.706    0.710    0.709
##     0.596    0.598    0.617
##     0.537    0.538    0.577
##     0.543    0.545    0.571
##     0.694    0.697    0.748
##     0.605    0.607    0.644
##     0.546    0.547    0.584
##     0.676    0.680    0.695
##     0.823    0.829    0.875
##     0.478    0.479    0.562
##     0.332    0.331    0.341
##     0.473    0.473    0.493
##     0.573    0.575    0.595
##     0.712    0.716    0.732
##     0.708    0.712    0.729
##     0.471    0.471    0.492
##     0.258    0.254    0.284
##     0.127    0.123    0.129
##     0.139    0.135    0.142
## 
## Regressions:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   g ~                                                          
##     age               0.091    0.004   24.273    0.000    0.083
##     age2             -0.048    0.003  -17.550    0.000   -0.053
##  ci.upper   Std.lv  Std.all
##                            
##     0.098    0.090    0.107
##    -0.042   -0.047   -0.079
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english ~~                                                   
##     math              0.000                               0.000
##     speed             0.000                               0.000
##     spatial           0.000                               0.000
##   math ~~                                                      
##     speed             0.000                               0.000
##     spatial           0.000                               0.000
##   speed ~~                                                     
##     spatial           0.000                               0.000
##  ci.upper   Std.lv  Std.all
##                            
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##                            
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##                            
##     0.000    0.000    0.000
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stst19d (.82.)   -0.069    0.004  -15.410    0.000   -0.078
##    .Stst20s (.83.)   -0.208    0.004  -46.777    0.000   -0.216
##    .Stst21c (.84.)   -0.151    0.004  -34.595    0.000   -0.159
##    .Stst22p (.85.)   -0.139    0.005  -29.197    0.000   -0.148
##    .Stst23n (.86.)   -0.083    0.005  -17.885    0.000   -0.092
##    .Stst24x (.87.)   -0.043    0.005   -9.374    0.000   -0.052
##    .Stst25w (.88.)   -0.060    0.005  -12.855    0.000   -0.069
##    .Stst26r           0.351    0.009   39.549    0.000    0.334
##    .Stst31b (.90.)    0.119    0.004   27.142    0.000    0.110
##    .Stst5mt (.91.)    0.218    0.005   47.612    0.000    0.209
##    .Stst32r (.92.)    0.233    0.005   51.378    0.000    0.224
##    .Stst33h (.93.)    0.198    0.005   39.122    0.000    0.188
##    .Stst34r           0.208    0.005   42.842    0.000    0.198
##    .Sts292D           0.005    0.005    1.026    0.305   -0.005
##    .Stst35t (.96.)   -0.047    0.004  -12.836    0.000   -0.054
##    .Stst36c (.97.)   -0.137    0.004  -37.385    0.000   -0.144
##    .Stst37b (.98.)   -0.062    0.004  -16.540    0.000   -0.069
##    .Stst28m          -0.116    0.005  -24.081    0.000   -0.126
##    .Sts303D (.100)    0.232    0.004   52.494    0.000    0.223
##    .Stst1vc (.101)    0.258    0.005   54.682    0.000    0.249
##     english           2.220    0.017  127.720    0.000    2.186
##     math              0.085    0.009    9.868    0.000    0.068
##     speed             0.422    0.007   59.058    0.000    0.408
##     spatial          -0.219    0.009  -25.011    0.000   -0.236
##    .g                -0.374    0.009  -43.246    0.000   -0.390
##  ci.upper   Std.lv  Std.all
##    -0.060   -0.069   -0.071
##    -0.199   -0.208   -0.223
##    -0.142   -0.151   -0.158
##    -0.129   -0.139   -0.149
##    -0.074   -0.083   -0.088
##    -0.034   -0.043   -0.046
##    -0.051   -0.060   -0.061
##     0.368    0.351    0.371
##     0.127    0.119    0.123
##     0.227    0.218    0.217
##     0.242    0.233    0.238
##     0.208    0.198    0.203
##     0.217    0.208    0.217
##     0.015    0.005    0.005
##    -0.040   -0.047   -0.052
##    -0.130   -0.137   -0.144
##    -0.054   -0.062   -0.065
##    -0.107   -0.116   -0.136
##     0.241    0.232    0.242
##     0.267    0.258    0.268
##     2.254    2.220    2.220
##     0.102    0.085    0.085
##     0.436    0.422    0.422
##    -0.202   -0.219   -0.219
##    -0.357   -0.369   -0.369
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stst19dsgsdwrd    0.473    0.003  162.261    0.000    0.468
##    .Stest20spellng    0.469    0.003  157.784    0.000    0.463
##    .Stest21cptlztn    0.520    0.003  162.120    0.000    0.514
##    .Stest22puncttn    0.272    0.002  126.179    0.000    0.268
##    .Stest23english    0.459    0.003  144.988    0.000    0.453
##    .Stest24exprssn    0.540    0.004  149.390    0.000    0.533
##    .Stst25wrdfnctn    0.408    0.003  144.044    0.000    0.402
##    .Stst26rdngcmpr    0.206    0.002  108.819    0.000    0.203
##    .Stst31bstrctrs    0.478    0.003  155.284    0.000    0.472
##    .Stest5math        0.416    0.004  108.461    0.000    0.409
##    .Stst32rthrsnng    0.411    0.002  165.782    0.000    0.406
##    .Stst33hghschlm    0.115    0.005   25.394    0.000    0.106
##    .Stst34rthcmptt    0.502    0.004  133.732    0.000    0.494
##    .Stst29vslztn2D    0.587    0.004  149.680    0.000    0.580
##    .Stest35tblrdng    0.385    0.005   74.179    0.000    0.374
##    .Stst36clrclchc    0.427    0.004   98.620    0.000    0.419
##    .Stst37bjctnspc    0.496    0.004  128.811    0.000    0.488
##    .Stst28mchnclrs    0.315    0.002  133.336    0.000    0.311
##    .Stst30vslztn3D    0.374    0.003  110.654    0.000    0.367
##    .Stest1vocab       0.302    0.002  138.922    0.000    0.298
##     english           1.000                               1.000
##     math              1.000                               1.000
##     speed             1.000                               1.000
##     spatial           1.000                               1.000
##    .g                 1.000                               1.000
##  ci.upper   Std.lv  Std.all
##     0.479    0.473    0.503
##     0.475    0.469    0.539
##     0.527    0.520    0.573
##     0.277    0.272    0.313
##     0.465    0.459    0.516
##     0.547    0.540    0.614
##     0.413    0.408    0.426
##     0.210    0.206    0.230
##     0.484    0.478    0.512
##     0.424    0.416    0.415
##     0.416    0.411    0.429
##     0.124    0.115    0.121
##     0.509    0.502    0.548
##     0.595    0.587    0.623
##     0.395    0.385    0.477
##     0.436    0.427    0.468
##     0.503    0.496    0.547
##     0.320    0.315    0.435
##     0.380    0.374    0.405
##     0.306    0.302    0.325
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    0.977    0.977

MGCFA FOR BLACKS

dmale<- subset(db, sex==0)
dfemale<- subset(db, sex==1)

datamale<- select(dmale, starts_with("Stest"), -Stest2literature, -Stest3music, -Stest4socialstudies, -Stest6physicalscience, -Stest7biologicalscience, -Stest8aeronautics, -Stest9electronics, -Stest10mechanics, -Stest11art, -Stest12law, -Stest13health, -Stest14bible, -Stest15theater, -Stest16miscellaneous, -Stest17memsentences, -Stest18memwords, -Stest27creativity)
datafemale<- select(dfemale, starts_with("Stest"), -Stest2literature, -Stest3music, -Stest4socialstudies, -Stest6physicalscience, -Stest7biologicalscience, -Stest8aeronautics, -Stest9electronics, -Stest10mechanics, -Stest11art, -Stest12law, -Stest13health, -Stest14bible, -Stest15theater, -Stest16miscellaneous, -Stest17memsentences, -Stest18memwords, -Stest27creativity)
datagroup<- select(db, starts_with("Stest"), -Stest2literature, -Stest3music, -Stest4socialstudies, -Stest6physicalscience, -Stest7biologicalscience, -Stest8aeronautics, -Stest9electronics, -Stest10mechanics, -Stest11art, -Stest12law, -Stest13health, -Stest14bible, -Stest15theater, -Stest16miscellaneous, -Stest17memsentences, -Stest18memwords, -Stest27creativity)
dgroup<- select(db, starts_with("Stest"), wb, age, age2, sex, BY_WTA, -Stest2literature, -Stest3music, -Stest4socialstudies, -Stest6physicalscience, -Stest7biologicalscience, -Stest8aeronautics, -Stest9electronics, -Stest10mechanics, -Stest11art, -Stest12law, -Stest13health, -Stest14bible, -Stest15theater, -Stest16miscellaneous, -Stest17memsentences, -Stest18memwords, -Stest27creativity)

describeBy(datamale)
## Warning in describeBy(datamale): no grouping variable requested
##                             vars    n  mean   sd median trimmed  mad
## Stest1vocab                    1 2443 -1.11 1.06  -1.31   -1.15 1.13
## Stest5math                     2 2443 -0.79 1.05  -0.70   -0.76 1.13
## Stest19disguisedwords          3 2443 -0.97 0.88  -1.18   -1.07 0.87
## Stest20spelling                4 2443 -0.83 1.00  -0.93   -0.85 1.00
## Stest21capitalization          5 2443 -1.14 0.95  -1.41   -1.24 0.92
## Stest22punctuation             6 2443 -1.21 1.00  -1.28   -1.23 1.01
## Stest23english                 7 2443 -1.04 1.18  -1.03   -1.01 0.95
## Stest24expression              8 2443 -0.95 1.17  -0.90   -0.92 1.36
## Stest25wordfunctions           9 2443 -0.86 0.78  -0.93   -0.91 0.77
## Stest26readingcomprehension   10 2443 -1.26 1.08  -1.46   -1.34 1.19
## Stest28mechanicalreasoning    11 2443 -0.69 0.90  -0.76   -0.75 1.05
## Stest29visualization2D        12 2443 -0.49 1.10  -0.45   -0.53 1.36
## Stest30visualization3D        13 2443 -0.69 0.95  -0.65   -0.73 0.93
## Stest31abstractreasoning      14 2443 -1.02 1.14  -0.90   -1.04 1.60
## Stest32arithreasoning         15 2443 -1.03 0.85  -1.18   -1.11 0.85
## Stest33highschoolmath         16 2443 -0.85 0.80  -0.93   -0.94 0.60
## Stest34arithcomputation       17 2443 -1.14 1.14  -1.18   -1.19 1.21
## Stest35tablereading           18 2443 -0.68 1.65  -0.49   -0.60 1.29
## Stest36clericalchecking       19 2443  0.00 1.30  -0.41   -0.09 1.18
## Stest37objectinspection       20 2443 -0.28 1.24  -0.51   -0.35 1.08
##                               min  max range  skew kurtosis   se
## Stest1vocab                 -3.08 1.73  4.81  0.35    -0.60 0.02
## Stest5math                  -3.10 1.58  4.68 -0.29    -0.19 0.02
## Stest19disguisedwords       -2.20 2.04  4.24  1.06     0.73 0.02
## Stest20spelling             -2.95 2.09  5.04  0.23    -0.31 0.02
## Stest21capitalization       -2.21 1.79  4.01  0.81    -0.23 0.02
## Stest22punctuation          -4.01 1.91  5.92  0.18    -0.22 0.02
## Stest23english              -5.18 2.49  7.66 -0.25     0.22 0.02
## Stest24expression           -3.65 1.40  5.06 -0.18    -0.67 0.02
## Stest25wordfunctions        -2.61 1.67  4.28  0.48     0.45 0.02
## Stest26readingcomprehension -3.16 1.55  4.71  0.59    -0.58 0.02
## Stest28mechanicalreasoning  -2.41 2.08  4.50  0.54    -0.18 0.02
## Stest29visualization2D      -2.28 1.92  4.21  0.22    -0.96 0.02
## Stest30visualization3D      -2.54 2.18  4.72  0.35    -0.47 0.02
## Stest31abstractreasoning    -3.05 1.97  5.03  0.15    -0.85 0.02
## Stest32arithreasoning       -2.33 1.97  4.30  0.90     0.54 0.02
## Stest33highschoolmath       -2.15 2.52  4.67  1.11     1.41 0.02
## Stest34arithcomputation     -3.94 3.20  7.14  0.53     0.72 0.02
## Stest35tablereading         -4.82 3.61  8.43 -0.44     0.55 0.03
## Stest36clericalchecking     -2.66 2.63  5.29  0.56    -0.89 0.03
## Stest37objectinspection     -3.28 2.40  5.69  0.42    -0.54 0.03
describeBy(datafemale)
## Warning in describeBy(datafemale): no grouping variable requested
##                             vars    n  mean   sd median trimmed  mad
## Stest1vocab                    1 3642 -1.31 0.92  -1.31   -1.36 0.75
## Stest5math                     2 3642 -0.94 0.99  -0.70   -0.91 1.04
## Stest19disguisedwords          3 3642 -0.84 0.95  -1.03   -0.94 0.87
## Stest20spelling                4 3642 -0.42 0.97  -0.26   -0.42 1.00
## Stest21capitalization          5 3642 -0.86 1.02  -1.14   -0.94 1.18
## Stest22punctuation             6 3642 -0.90 0.98  -1.05   -0.92 1.01
## Stest23english                 7 3642 -0.70 1.09  -0.71   -0.68 0.95
## Stest24expression              8 3642 -0.67 1.08  -0.44   -0.64 1.36
## Stest25wordfunctions           9 3642 -0.78 0.80  -0.93   -0.83 0.77
## Stest26readingcomprehension   10 3642 -1.19 0.98  -1.36   -1.25 1.04
## Stest28mechanicalreasoning    11 3642 -1.30 0.62  -1.47   -1.35 0.70
## Stest29visualization2D        12 3642 -0.90 0.99  -1.00   -0.98 1.08
## Stest30visualization3D        13 3642 -0.96 0.77  -0.97   -0.99 0.93
## Stest31abstractreasoning      14 3642 -1.20 1.10  -1.26   -1.24 1.06
## Stest32arithreasoning         15 3642 -1.17 0.74  -1.18   -1.24 0.85
## Stest33highschoolmath         16 3642 -0.92 0.70  -1.13   -0.98 0.60
## Stest34arithcomputation       17 3642 -1.01 1.13  -1.08   -1.04 1.06
## Stest35tablereading           18 3642 -0.50 1.59  -0.28   -0.41 1.18
## Stest36clericalchecking       19 3642  0.30 1.28   0.02    0.25 1.40
## Stest37objectinspection       20 3642 -0.20 1.13  -0.37   -0.25 1.08
##                               min  max range  skew kurtosis   se
## Stest1vocab                 -3.08 1.73  4.81  0.54    -0.03 0.02
## Stest5math                  -3.10 1.58  4.68 -0.35    -0.13 0.02
## Stest19disguisedwords       -2.20 2.04  4.24  0.84    -0.01 0.02
## Stest20spelling             -2.95 2.09  5.04  0.00    -0.39 0.02
## Stest21capitalization       -2.21 1.79  4.01  0.56    -0.57 0.02
## Stest22punctuation          -3.78 1.91  5.69  0.12    -0.30 0.02
## Stest23english              -5.18 2.49  7.66 -0.24     0.09 0.02
## Stest24expression           -3.65 1.40  5.06 -0.28    -0.44 0.02
## Stest25wordfunctions        -2.61 1.79  4.40  0.55     0.41 0.01
## Stest26readingcomprehension -3.16 1.55  4.71  0.54    -0.41 0.02
## Stest28mechanicalreasoning  -2.41 1.37  3.79  0.74     0.69 0.01
## Stest29visualization2D      -2.28 1.92  4.21  0.62    -0.43 0.02
## Stest30visualization3D      -2.54 2.18  4.72  0.47     0.13 0.01
## Stest31abstractreasoning    -3.05 1.97  5.03  0.26    -0.79 0.02
## Stest32arithreasoning       -2.33 1.97  4.30  0.97     1.13 0.01
## Stest33highschoolmath       -2.15 2.32  4.47  0.95     1.27 0.01
## Stest34arithcomputation     -3.94 3.30  7.24  0.41     0.57 0.02
## Stest35tablereading         -4.82 3.61  8.43 -0.57     0.88 0.03
## Stest36clericalchecking     -2.66 2.63  5.29  0.35    -1.07 0.02
## Stest37objectinspection     -3.28 2.40  5.69  0.32    -0.39 0.02
scree(datamale)

VSS.scree(datafemale)

scree(datamale)

VSS.scree(datafemale)

malecor<- cor(datamale) # fa.parallel requires cor matrix if n.obs is to be used
femalecor<- cor(datafemale) # fa.parallel requires cor matrix if n.obs is to be used

eigen(malecor) # all eigenvalues different from zero
## eigen() decomposition
## $values
##  [1] 8.6583961 1.8139087 1.2964261 0.8394189 0.6715033 0.6574052
##  [7] 0.6062938 0.5585229 0.5293081 0.5094921 0.4730171 0.4523746
## [13] 0.4433373 0.4322079 0.4114139 0.4033314 0.3684169 0.3479582
## [19] 0.3240996 0.2031679
## 
## $vectors
##              [,1]        [,2]         [,3]         [,4]          [,5]
##  [1,] -0.27587266 -0.10282264  0.079699440 -0.004943307 -0.0003010366
##  [2,] -0.23490802 -0.05383064  0.092226077 -0.407624215 -0.0437092848
##  [3,] -0.24232997  0.04985263  0.166654652  0.155197989  0.3783830403
##  [4,] -0.22087608 -0.09070136  0.362479102  0.180310911  0.1745655120
##  [5,] -0.24952078 -0.08881315  0.081954710  0.209096489  0.0386618377
##  [6,] -0.26571917 -0.09480855  0.088371026  0.134199229  0.0352794871
##  [7,] -0.24757144 -0.07554141  0.096769961  0.340361709 -0.0361968976
##  [8,] -0.20949649 -0.13920656  0.074492746  0.387528332 -0.4384058605
##  [9,] -0.21081560 -0.08518498  0.030539915 -0.281954859  0.4709854580
## [10,] -0.28982442 -0.13578165  0.069881120 -0.001069219  0.0274009778
## [11,] -0.23279410  0.01572243 -0.376293285  0.008968547  0.0592197173
## [12,] -0.18013889  0.19478006 -0.385145593  0.247830712  0.1710201580
## [13,] -0.18725398  0.03049985 -0.528691130 -0.041076618  0.0794297081
## [14,] -0.23841109 -0.01621751 -0.308041425  0.015146618 -0.1126800400
## [15,] -0.24802767 -0.10710501 -0.050362916 -0.335679838 -0.1828278293
## [16,] -0.25725064 -0.08856373  0.005645796 -0.383065650 -0.1291394100
## [17,] -0.22471366  0.21505445  0.200145850 -0.130334250 -0.2538587959
## [18,] -0.15070074  0.45391647  0.094238940 -0.083569209 -0.4085552245
## [19,] -0.06946434  0.55426969  0.253221203 -0.083609985  0.2690004226
## [20,] -0.10216877  0.53848398 -0.103709225  0.127145391  0.0053410545
##              [,6]         [,7]          [,8]        [,9]       [,10]
##  [1,]  0.31378510  0.013977152 -0.0941892189 -0.02166546  0.17055764
##  [2,]  0.30771782 -0.001122891 -0.2763833547 -0.34477574  0.11709507
##  [3,]  0.26702281 -0.078573839 -0.0251530701  0.18542115  0.10279451
##  [4,] -0.07544474  0.381377575 -0.0734527012 -0.07762637 -0.12763302
##  [5,] -0.11886970  0.291158383  0.2871681261  0.04843912  0.06240718
##  [6,] -0.16412736  0.109259720  0.2256829994  0.06368338 -0.06848582
##  [7,]  0.10621666 -0.105315973  0.0125221386  0.03198304  0.04700293
##  [8,] -0.06451370 -0.568614024 -0.1574225989 -0.12981041 -0.30805773
##  [9,] -0.50766488 -0.504308582  0.1902546628  0.02946663  0.09784008
## [10,]  0.16209258 -0.064863109 -0.0121329123  0.07962908  0.09542644
## [11,]  0.28849273 -0.035330513  0.0340642736  0.16307908  0.09297491
## [12,] -0.34231253  0.090428198 -0.6535837466 -0.11849236  0.26698379
## [13,]  0.09280695  0.096347219  0.0712191850  0.17314336 -0.56950253
## [14,] -0.11858436  0.189404941  0.2433602308 -0.06593199  0.03412464
## [15,]  0.01667687 -0.096910074 -0.0002351783  0.09577629 -0.05231279
## [16,] -0.07052804  0.086160967 -0.0226086600 -0.13722586 -0.04788017
## [17,] -0.33980079  0.246179472 -0.0835687709 -0.16603595 -0.20534510
## [18,] -0.09276441 -0.034642578  0.0394627547  0.56966555  0.34533237
## [19,]  0.13403408 -0.085552370 -0.1691092064  0.13117256 -0.45798668
## [20,]  0.13775909 -0.134166345  0.4286641372 -0.58009556  0.15602867
##             [,11]        [,12]       [,13]        [,14]        [,15]
##  [1,]  0.03291043 -0.136070786  0.03849895 -0.007479012 -0.022406326
##  [2,]  0.46600850 -0.081406443 -0.19201269  0.161494095  0.085967647
##  [3,] -0.28719454  0.436029359 -0.20992183 -0.112208906  0.416003022
##  [4,]  0.12015069  0.401881054  0.02178972  0.001796907 -0.575446774
##  [5,] -0.10593163 -0.416407407 -0.35315772  0.429670254  0.216355018
##  [6,]  0.05067500 -0.272153666  0.16821129  0.083807203 -0.162483007
##  [7,]  0.29551248 -0.056284664  0.57812389 -0.105263311  0.231020932
##  [8,] -0.02531616  0.029147399 -0.28304714  0.010024816 -0.089158320
##  [9,]  0.20117584  0.017501563  0.02938124 -0.005469309 -0.023055635
## [10,] -0.10737056 -0.007263245 -0.06423536 -0.003620065 -0.001034437
## [11,] -0.08935490 -0.249453384  0.22764521 -0.250382490 -0.236208579
## [12,] -0.11610559 -0.052760965 -0.01415583  0.124860654 -0.039123234
## [13,]  0.25067602  0.285249292  0.03423453  0.339835385  0.128308814
## [14,]  0.13633306  0.021320082 -0.40682675 -0.648427001 -0.028434695
## [15,] -0.56570794  0.046879270  0.16396546  0.148168510 -0.197416639
## [16,] -0.15845216  0.075289487  0.01586886 -0.015141133 -0.013044307
## [17,] -0.09873062  0.033325531  0.26522812 -0.209078276  0.447979776
## [18,]  0.24637095  0.180120790 -0.07852809  0.144191651 -0.102028578
## [19,] -0.03328796 -0.398835961 -0.12296765 -0.162328132 -0.124659455
## [20,] -0.10724243  0.155130938  0.08536003  0.176464784 -0.111675015
##             [,16]        [,17]        [,18]        [,19]         [,20]
##  [1,] -0.23985689  0.441446035 -0.085985393 -0.428094313  0.5524085732
##  [2,]  0.03689746 -0.065300222 -0.015610347  0.395543119 -0.0723313439
##  [3,] -0.03154124 -0.205114409 -0.141946279  0.199235762  0.1243878181
##  [4,] -0.06476584  0.001703979  0.236262917  0.045283911 -0.0113480707
##  [5,]  0.03223332 -0.075190816  0.377279849  0.006721102  0.0216394271
##  [6,] -0.06071606 -0.127504982 -0.758251084  0.243114370  0.0493833998
##  [7,]  0.49585511 -0.070471838  0.199504697 -0.030013820 -0.0018296105
##  [8,] -0.13927396 -0.105348460  0.035888918  0.026906019  0.0512466525
##  [9,] -0.10421261  0.085558941  0.152677787 -0.031898160  0.0513987576
## [10,] -0.02432767  0.297614594 -0.137938645 -0.302300756 -0.7940741421
## [11,] -0.46483057 -0.311572938  0.288889765  0.186819487 -0.0864660765
## [12,]  0.10698234  0.011487168 -0.083799143 -0.023894461 -0.0014687845
## [13,] -0.03059368  0.112509218 -0.032383531 -0.083238700  0.0177381723
## [14,]  0.28541851  0.160367847 -0.018669441  0.054469564  0.0640062005
## [15,]  0.35420828  0.276546018  0.105800826  0.345856794  0.1183256226
## [16,]  0.15130516 -0.620412539 -0.065055847 -0.530435178  0.0606000591
## [17,] -0.39541859  0.157510817  0.084296033  0.103540531 -0.0662013613
## [18,] -0.01596519 -0.043759540 -0.007123298 -0.017983431  0.0166500427
## [19,]  0.19895764  0.010411563  0.022362003 -0.079147270  0.0003565032
## [20,]  0.00258874  0.033282479 -0.026867769 -0.041264880 -0.0325029568
eigen(femalecor) # all eigenvalues different from zero
## eigen() decomposition
## $values
##  [1] 8.0218295 1.8291878 1.2389828 0.9232200 0.7076098 0.6672964
##  [7] 0.6511390 0.6050737 0.6002025 0.5421577 0.5330719 0.5186053
## [13] 0.5010382 0.4565058 0.4454519 0.4363057 0.3958557 0.3569285
## [19] 0.3260553 0.2434826
## 
## $vectors
##              [,1]        [,2]        [,3]        [,4]         [,5]
##  [1,] -0.27549182 -0.09058894 -0.13391032  0.06465275 -0.154194043
##  [2,] -0.20639785 -0.06937211 -0.02669664  0.52731342  0.276347821
##  [3,] -0.26266049  0.10024704 -0.12719730 -0.09664043 -0.251497964
##  [4,] -0.23320969 -0.01513397 -0.37305282 -0.11263146 -0.000675705
##  [5,] -0.25892242 -0.06201150 -0.12485676 -0.18316663 -0.052568702
##  [6,] -0.28480324 -0.08716956 -0.09286358 -0.10744280  0.102292421
##  [7,] -0.25303471 -0.07007348 -0.12610928 -0.27821701  0.003314375
##  [8,] -0.20242030 -0.10820614 -0.06806613 -0.46283102  0.140305356
##  [9,] -0.23045259 -0.11901955  0.01382859  0.28698571 -0.022251697
## [10,] -0.29600735 -0.11092670 -0.08929235 -0.03397010 -0.117254025
## [11,] -0.19637241 -0.04866721  0.33767490  0.08876923 -0.674028575
## [12,] -0.16759997  0.10851243  0.47060980 -0.16971728  0.410769412
## [13,] -0.17163698 -0.01041844  0.54050174 -0.09606301  0.021440526
## [14,] -0.24049023 -0.06801830  0.26751966 -0.13810953  0.087936941
## [15,] -0.23363969 -0.14368283  0.09288839  0.24381527 -0.075770942
## [16,] -0.25331102 -0.09441883  0.01770885  0.35822632  0.190296038
## [17,] -0.22222910  0.25307608 -0.17891975  0.09805546  0.268682274
## [18,] -0.15790472  0.45677869 -0.06730470 -0.01509676  0.063241777
## [19,] -0.06219771  0.57454126 -0.07786850  0.11182326 -0.199061261
## [20,] -0.11556391  0.52051836  0.14946442 -0.02009681 -0.020723072
##               [,6]         [,7]         [,8]         [,9]        [,10]
##  [1,] -0.230649710 -0.018983709 -0.100148351  0.039987415  0.208674413
##  [2,] -0.411474818  0.220436495 -0.380278395  0.230364552  0.009135734
##  [3,] -0.295283218 -0.153414514  0.065790265 -0.160760415  0.118841940
##  [4,] -0.110428517 -0.303083567 -0.002955792 -0.053116029 -0.200952826
##  [5,]  0.135940801 -0.207894938 -0.049979785  0.044274645  0.096170042
##  [6,]  0.058003885 -0.113459284  0.021842600 -0.041694971 -0.105397994
##  [7,] -0.050177669  0.020131442 -0.113949979  0.031190892 -0.295702022
##  [8,]  0.005020240  0.736936408 -0.020073852  0.020003507 -0.075165237
##  [9,]  0.169881360  0.192408141  0.156084924 -0.533971475  0.016846754
## [10,] -0.098086731 -0.010550767 -0.041903802  0.003881148  0.187106811
## [11,]  0.003625086  0.063255720  0.168493696  0.451349589 -0.178206445
## [12,] -0.440266424 -0.140566967  0.522798050  0.024355863  0.032851759
## [13,]  0.108915269 -0.228440143 -0.592108193 -0.309332521 -0.063394166
## [14,]  0.159440091 -0.046465421 -0.065741759  0.088945236  0.295739927
## [15,]  0.298441159  0.143904436  0.316755572 -0.268714220  0.057372142
## [16,]  0.127582078 -0.005739864  0.088418845  0.188961171 -0.192941396
## [17,]  0.348415989 -0.224579651  0.122970674  0.177528692 -0.229766107
## [18,]  0.262047646  0.087918809 -0.055024580  0.233778489  0.610768350
## [19,] -0.272874795  0.114099743  0.022865178 -0.349342665 -0.033511124
## [20,]  0.119312755  0.170045364 -0.122858360  0.049247696 -0.401668167
##              [,11]        [,12]       [,13]       [,14]        [,15]
##  [1,] -0.048626535  0.244483529 -0.21687018 -0.20924159 -0.145767357
##  [2,] -0.037686198 -0.044924827  0.04254792  0.16637066  0.155795730
##  [3,] -0.030454283  0.092212750  0.01995326 -0.27720179 -0.250275148
##  [4,]  0.193958036 -0.079474352 -0.02163109 -0.20817117  0.483456910
##  [5,] -0.349331228  0.015954148  0.09741888  0.40005858  0.426148262
##  [6,] -0.074997427 -0.079650673  0.08466285  0.20326646  0.055329285
##  [7,]  0.015287947 -0.196112459 -0.21445099  0.48895510 -0.555197939
##  [8,]  0.220129764  0.002457415  0.12837033 -0.19785823  0.160858032
##  [9,] -0.325599717 -0.555403908 -0.07572860 -0.18754522 -0.008062176
## [10,] -0.028289025  0.178329130 -0.13816773 -0.13653237 -0.086177806
## [11,]  0.118934353 -0.263215854  0.06119673 -0.00408548  0.123359120
## [12,]  0.005639457 -0.077134726 -0.15925500  0.03368073  0.088663695
## [13,]  0.337505457 -0.044990617 -0.09613582 -0.08359312  0.069906129
## [14,] -0.290567592  0.140785827  0.60596051 -0.07504621 -0.172123968
## [15,]  0.272722506  0.521469576 -0.17451166  0.30857365  0.100020666
## [16,]  0.085260281  0.048490068  0.12088125 -0.08867167 -0.156669383
## [17,]  0.238685811 -0.039543879  0.16008183 -0.23858643 -0.173329291
## [18,]  0.161720236 -0.272664476 -0.30219836  0.08571279  0.033119842
## [19,]  0.206047754  0.008330159  0.44893117  0.27172755 -0.008654189
## [20,] -0.504738820  0.301185214 -0.27793193 -0.14142872  0.092083938
##               [,16]        [,17]        [,18]        [,19]
##  [1,] -0.1208113564  0.048334049  0.547387682  0.135395194
##  [2,]  0.0150558106 -0.301409929 -0.150660915 -0.102208894
##  [3,] -0.1592731502 -0.047820679 -0.665955206 -0.200059778
##  [4,]  0.5557937073  0.039678754  0.055200412 -0.105750715
##  [5,] -0.4481154658  0.154103481  0.043765798 -0.317971839
##  [6,] -0.0636631385 -0.101392542 -0.231350829  0.841068635
##  [7,]  0.2252470783 -0.018792413  0.079761629 -0.209683904
##  [8,] -0.1456698241  0.043181556 -0.028433873 -0.048971630
##  [9,]  0.0103391007 -0.053211375  0.104143867 -0.069100009
## [10,] -0.0754360634  0.014364351  0.165001067  0.137269714
## [11,] -0.0002695756 -0.105721779  0.023197772  0.027905977
## [12,] -0.0336668275  0.003597163  0.096214026 -0.040986896
## [13,] -0.1143557531  0.059286644 -0.006857047 -0.015318112
## [14,]  0.4237702955 -0.116666117  0.069328372 -0.073897406
## [15,]  0.1495270111 -0.189539067 -0.104100780 -0.097962309
## [16,] -0.0131670524  0.771292294 -0.114977767 -0.006373877
## [17,] -0.3359503549 -0.417615455  0.165540253 -0.123182237
## [18,]  0.1484549821  0.104492641 -0.116596513  0.042233187
## [19,] -0.0386448798  0.138616415  0.220710962  0.072257374
## [20,]  0.1247829053 -0.001436042 -0.045022365  0.039477273
##               [,20]
##  [1,]  0.5021757761
##  [2,] -0.0189771729
##  [3,]  0.1291669483
##  [4,]  0.0090738688
##  [5,]  0.0282944471
##  [6,]  0.1110277170
##  [7,] -0.0003557049
##  [8,]  0.0545581491
##  [9,]  0.0023576905
## [10,] -0.8372348592
## [11,]  0.0084134772
## [12,] -0.0109352507
## [13,]  0.0182381115
## [14,]  0.0416188666
## [15,]  0.0681363164
## [16,]  0.0062511859
## [17,] -0.0227793453
## [18,]  0.0440730910
## [19,] -0.0636986976
## [20,] -0.0128485450
mpa<- fa.parallel(malecor, n.obs=2443, n.iter=1000)

## Parallel analysis suggests that the number of factors =  5  and the number of components =  3
fpa<- fa.parallel(femalecor, n.obs=3642, n.iter=1000)

## Parallel analysis suggests that the number of factors =  5  and the number of components =  3
mqqnorm(datafemale, main = "Multi-normal Q-Q Plot") # very minor

## 4858 3006 
## 2415  563
mqqnorm(datamale, main = "Multi-normal Q-Q Plot") # very minor

## [1] 2159 2241
mqqnorm(datagroup, main = "Multi-normal Q-Q Plot") # very minor

## [1] 2159 3006
mvn(data = datamale, mvnTest = "mardia")
## $multivariateNormality
##              Test        Statistic p value Result
## 1 Mardia Skewness 5198.45570681991       0     NO
## 2 Mardia Kurtosis 8.94471073737084       0     NO
## 3             MVN             <NA>    <NA>     NO
## 
## $univariateNormality
##                Test                    Variable Statistic   p value
## 1  Anderson-Darling         Stest1vocab           17.2962  <0.001  
## 2  Anderson-Darling         Stest5math            19.8829  <0.001  
## 3  Anderson-Darling    Stest19disguisedwords      60.6622  <0.001  
## 4  Anderson-Darling       Stest20spelling         13.5916  <0.001  
## 5  Anderson-Darling    Stest21capitalization      79.2095  <0.001  
## 6  Anderson-Darling     Stest22punctuation         7.0268  <0.001  
## 7  Anderson-Darling       Stest23english           9.7213  <0.001  
## 8  Anderson-Darling      Stest24expression        21.4125  <0.001  
## 9  Anderson-Darling    Stest25wordfunctions       23.0605  <0.001  
## 10 Anderson-Darling Stest26readingcomprehension   39.6555  <0.001  
## 11 Anderson-Darling Stest28mechanicalreasoning    22.9034  <0.001  
## 12 Anderson-Darling   Stest29visualization2D      22.3567  <0.001  
## 13 Anderson-Darling   Stest30visualization3D      19.6763  <0.001  
## 14 Anderson-Darling  Stest31abstractreasoning     21.9210  <0.001  
## 15 Anderson-Darling    Stest32arithreasoning      48.8610  <0.001  
## 16 Anderson-Darling    Stest33highschoolmath      49.4632  <0.001  
## 17 Anderson-Darling   Stest34arithcomputation      5.6482  <0.001  
## 18 Anderson-Darling     Stest35tablereading       26.8353  <0.001  
## 19 Anderson-Darling   Stest36clericalchecking     70.2704  <0.001  
## 20 Anderson-Darling   Stest37objectinspection     26.1694  <0.001  
##    Normality
## 1     NO    
## 2     NO    
## 3     NO    
## 4     NO    
## 5     NO    
## 6     NO    
## 7     NO    
## 8     NO    
## 9     NO    
## 10    NO    
## 11    NO    
## 12    NO    
## 13    NO    
## 14    NO    
## 15    NO    
## 16    NO    
## 17    NO    
## 18    NO    
## 19    NO    
## 20    NO    
## 
## $Descriptives
##                                n          Mean   Std.Dev     Median
## Stest1vocab                 2443 -1.1095892563 1.0621130 -1.3076552
## Stest5math                  2443 -0.7896922969 1.0531123 -0.7002896
## Stest19disguisedwords       2443 -0.9650082562 0.8800368 -1.1766655
## Stest20spelling             2443 -0.8272665823 1.0004359 -0.9333158
## Stest21capitalization       2443 -1.1436734095 0.9454176 -1.4082177
## Stest22punctuation          2443 -1.2064543525 0.9968915 -1.2766891
## Stest23english              2443 -1.0353461760 1.1804729 -1.0251536
## Stest24expression           2443 -0.9498035005 1.1681145 -0.8965657
## Stest25wordfunctions        2443 -0.8645041762 0.7783038 -0.9300168
## Stest26readingcomprehension 2443 -1.2550031376 1.0826988 -1.4556234
## Stest28mechanicalreasoning  2443 -0.6930350339 0.8982447 -0.7570797
## Stest29visualization2D      2443 -0.4859242630 1.0960685 -0.4541734
## Stest30visualization3D      2443 -0.6885105790 0.9516764 -0.6518204
## Stest31abstractreasoning    2443 -1.0209400576 1.1409325 -0.8992617
## Stest32arithreasoning       2443 -1.0263748677 0.8487616 -1.1815940
## Stest33highschoolmath       2443 -0.8535754828 0.8021980 -0.9288142
## Stest34arithcomputation     2443 -1.1433319274 1.1393281 -1.1848340
## Stest35tablereading         2443 -0.6809154199 1.6458126 -0.4864526
## Stest36clericalchecking     2443  0.0003385028 1.2952453 -0.4144503
## Stest37objectinspection     2443 -0.2813571657 1.2386776 -0.5141888
##                                   Min      Max       25th        75th
## Stest1vocab                 -3.081020 1.732398 -1.9409997 -0.29430412
## Stest5math                  -3.103322 1.578247 -1.4629972 -0.19790688
## Stest19disguisedwords       -2.200294 2.040453 -1.6153635 -0.44550220
## Stest20spelling             -2.949489 2.090944 -1.6053734 -0.26125817
## Stest21capitalization       -2.212520 1.792646 -1.9895058 -0.34408038
## Stest22punctuation          -4.007462 1.909213 -1.9593824 -0.59399588
## Stest23english              -5.175212 2.486434 -1.6636241 -0.38668319
## Stest24expression           -3.654018 1.401311 -1.8157166  0.02258511
## Stest25wordfunctions        -2.609127 1.665905 -1.4507123 -0.49105015
## Stest26readingcomprehension -3.158804 1.549990 -2.1569331 -0.55393946
## Stest28mechanicalreasoning  -2.414006 2.083365 -1.4671908 -0.04696863
## Stest29visualization2D      -2.283595 1.924074 -1.5518262  0.27759518
## Stest30visualization3D      -2.538855 2.178732 -1.2808320 -0.02280880
## Stest31abstractreasoning    -3.053322 1.972819 -1.9762918 -0.18124158
## Stest32arithreasoning       -2.327215 1.968863 -1.7544044 -0.60878369
## Stest33highschoolmath       -2.147432 2.523936 -1.3350200 -0.52260833
## Stest34arithcomputation     -3.938878 3.201236 -2.0008470 -0.47082264
## Stest35tablereading         -4.815108 3.610163 -1.6444251  0.38398259
## Stest36clericalchecking     -2.661621 2.630104 -0.9943653  0.99909258
## Stest37objectinspection     -3.283883 2.401279 -1.2430558  0.50622493
##                                   Skew   Kurtosis
## Stest1vocab                  0.3451069 -0.5997669
## Stest5math                  -0.2883481 -0.1940244
## Stest19disguisedwords        1.0608678  0.7255663
## Stest20spelling              0.2312739 -0.3140564
## Stest21capitalization        0.8070777 -0.2315324
## Stest22punctuation           0.1822344 -0.2204551
## Stest23english              -0.2516029  0.2185956
## Stest24expression           -0.1804949 -0.6694891
## Stest25wordfunctions         0.4788478  0.4527625
## Stest26readingcomprehension  0.5876726 -0.5775554
## Stest28mechanicalreasoning   0.5402410 -0.1778992
## Stest29visualization2D       0.2211926 -0.9614718
## Stest30visualization3D       0.3515051 -0.4692480
## Stest31abstractreasoning     0.1504664 -0.8482587
## Stest32arithreasoning        0.8961258  0.5414459
## Stest33highschoolmath        1.1096846  1.4057803
## Stest34arithcomputation      0.5314790  0.7230444
## Stest35tablereading         -0.4445734  0.5465100
## Stest36clericalchecking      0.5649866 -0.8859927
## Stest37objectinspection      0.4228243 -0.5425451
mvn(data = datafemale, mvnTest = "mardia")
## $multivariateNormality
##              Test        Statistic p value Result
## 1 Mardia Skewness 6918.67023670638       0     NO
## 2 Mardia Kurtosis 12.4918121321916       0     NO
## 3             MVN             <NA>    <NA>     NO
## 
## $univariateNormality
##                Test                    Variable Statistic   p value
## 1  Anderson-Darling         Stest1vocab           29.6155  <0.001  
## 2  Anderson-Darling         Stest5math            40.5679  <0.001  
## 3  Anderson-Darling    Stest19disguisedwords      77.7550  <0.001  
## 4  Anderson-Darling       Stest20spelling         18.8864  <0.001  
## 5  Anderson-Darling    Stest21capitalization      76.8646  <0.001  
## 6  Anderson-Darling     Stest22punctuation        10.1089  <0.001  
## 7  Anderson-Darling       Stest23english          14.3929  <0.001  
## 8  Anderson-Darling      Stest24expression        34.0889  <0.001  
## 9  Anderson-Darling    Stest25wordfunctions       41.3657  <0.001  
## 10 Anderson-Darling Stest26readingcomprehension   36.4058  <0.001  
## 11 Anderson-Darling Stest28mechanicalreasoning    44.7846  <0.001  
## 12 Anderson-Darling   Stest29visualization2D      55.7612  <0.001  
## 13 Anderson-Darling   Stest30visualization3D      34.3835  <0.001  
## 14 Anderson-Darling  Stest31abstractreasoning     35.9934  <0.001  
## 15 Anderson-Darling    Stest32arithreasoning      66.7532  <0.001  
## 16 Anderson-Darling    Stest33highschoolmath      51.9887  <0.001  
## 17 Anderson-Darling   Stest34arithcomputation      5.6984  <0.001  
## 18 Anderson-Darling     Stest35tablereading       49.6425  <0.001  
## 19 Anderson-Darling   Stest36clericalchecking     76.8501  <0.001  
## 20 Anderson-Darling   Stest37objectinspection     24.2471  <0.001  
##    Normality
## 1     NO    
## 2     NO    
## 3     NO    
## 4     NO    
## 5     NO    
## 6     NO    
## 7     NO    
## 8     NO    
## 9     NO    
## 10    NO    
## 11    NO    
## 12    NO    
## 13    NO    
## 14    NO    
## 15    NO    
## 16    NO    
## 17    NO    
## 18    NO    
## 19    NO    
## 20    NO    
## 
## $Descriptives
##                                n       Mean   Std.Dev      Median
## Stest1vocab                 3642 -1.3059162 0.9248888 -1.30765522
## Stest5math                  3642 -0.9443045 0.9910145 -0.70028957
## Stest19disguisedwords       3642 -0.8405552 0.9511804 -1.03043286
## Stest20spelling             3642 -0.4191234 0.9671101 -0.26125817
## Stest21capitalization       3642 -0.8593189 1.0230130 -1.13661640
## Stest22punctuation          3642 -0.9019139 0.9821093 -1.04912472
## Stest23english              3642 -0.7026752 1.0872635 -0.70591842
## Stest24expression           3642 -0.6723303 1.0808223 -0.43699031
## Stest25wordfunctions        3642 -0.7847425 0.7999295 -0.93001676
## Stest26readingcomprehension 3642 -1.1869173 0.9780501 -1.35543630
## Stest28mechanicalreasoning  3642 -1.3049688 0.6162571 -1.46719079
## Stest29visualization2D      3642 -0.8971626 0.9881316 -1.00299976
## Stest30visualization3D      3642 -0.9572589 0.7740721 -0.96632617
## Stest31abstractreasoning    3642 -1.2023797 1.0962782 -1.25827171
## Stest32arithreasoning       3642 -1.1661807 0.7435679 -1.18159405
## Stest33highschoolmath       3642 -0.9221779 0.7029660 -1.13191711
## Stest34arithcomputation     3642 -1.0090058 1.1311203 -1.08283240
## Stest35tablereading         3642 -0.5028674 1.5899830 -0.27888648
## Stest36clericalchecking     3642  0.3031985 1.2764551  0.02048598
## Stest37objectinspection     3642 -0.2015085 1.1318854 -0.36841545
##                                   Min      Max       25th        75th
## Stest1vocab                 -3.081020 1.732398 -2.0676685 -0.80097967
## Stest5math                  -3.103322 1.578247 -1.4629972 -0.19790688
## Stest19disguisedwords       -2.200294 2.040453 -1.6153635 -0.29926954
## Stest20spelling             -2.949489 2.090944 -0.9333158  0.07477064
## Stest21capitalization       -2.212520 1.792646 -1.7779803 -0.34408038
## Stest22punctuation          -3.779898 1.909213 -1.5042536 -0.13886704
## Stest23english              -5.175212 2.486434 -1.3443889 -0.06744796
## Stest24expression           -3.654018 1.401311 -1.3561412  0.02258511
## Stest25wordfunctions        -2.609127 1.788020 -1.1772477 -0.29229762
## Stest26readingcomprehension -3.158804 1.549990 -1.9565589 -0.55393946
## Stest28mechanicalreasoning  -2.414006 1.373254 -1.7038945 -0.99378340
## Stest29visualization2D      -2.283595 1.924074 -1.7347683 -0.27123122
## Stest30visualization3D      -2.538855 2.178732 -1.5953378 -0.33731459
## Stest31abstractreasoning    -3.053322 1.972819 -1.9762918 -0.27099409
## Stest32arithreasoning       -2.327215 1.968863 -1.7544044 -0.89518887
## Stest33highschoolmath       -2.147432 2.320833 -1.3350200 -0.52260833
## Stest34arithcomputation     -3.938878 3.303237 -1.7968438 -0.36882102
## Stest35tablereading         -4.815108 3.610163 -1.2852414  0.38398259
## Stest36clericalchecking     -2.661621 2.630104 -0.7768972  1.45215119
## Stest37objectinspection     -3.283883 2.401279 -0.9515090  0.50622493
##                                     Skew     Kurtosis
## Stest1vocab                  0.535868058 -0.032645035
## Stest5math                  -0.352819327 -0.127331788
## Stest19disguisedwords        0.836665160 -0.007085817
## Stest20spelling              0.002357536 -0.387807405
## Stest21capitalization        0.563701708 -0.574558620
## Stest22punctuation           0.123386844 -0.302025868
## Stest23english              -0.236414541  0.093257874
## Stest24expression           -0.278535675 -0.439309073
## Stest25wordfunctions         0.548651694  0.412662989
## Stest26readingcomprehension  0.537123619 -0.413658623
## Stest28mechanicalreasoning   0.737112611  0.694206093
## Stest29visualization2D       0.616914647 -0.425638201
## Stest30visualization3D       0.467354756  0.133077169
## Stest31abstractreasoning     0.261892929 -0.790686145
## Stest32arithreasoning        0.967723776  1.133224623
## Stest33highschoolmath        0.952540727  1.271246103
## Stest34arithcomputation      0.406086185  0.574457758
## Stest35tablereading         -0.573971387  0.882021013
## Stest36clericalchecking      0.351036496 -1.067695471
## Stest37objectinspection      0.324476372 -0.392041976
mvn(data = datagroup, mvnTest = "mardia")
## $multivariateNormality
##              Test        Statistic p value Result
## 1 Mardia Skewness 10921.6134842946       0     NO
## 2 Mardia Kurtosis 16.6888411387986       0     NO
## 3             MVN             <NA>    <NA>     NO
## 
## $univariateNormality
##                Test                    Variable Statistic   p value
## 1  Anderson-Darling         Stest1vocab           48.2718  <0.001  
## 2  Anderson-Darling         Stest5math            58.4651  <0.001  
## 3  Anderson-Darling    Stest19disguisedwords     139.9232  <0.001  
## 4  Anderson-Darling       Stest20spelling         30.1780  <0.001  
## 5  Anderson-Darling    Stest21capitalization     152.5606  <0.001  
## 6  Anderson-Darling     Stest22punctuation        16.1634  <0.001  
## 7  Anderson-Darling       Stest23english          23.6787  <0.001  
## 8  Anderson-Darling      Stest24expression        55.2359  <0.001  
## 9  Anderson-Darling    Stest25wordfunctions       64.1826  <0.001  
## 10 Anderson-Darling Stest26readingcomprehension   72.4436  <0.001  
## 11 Anderson-Darling Stest28mechanicalreasoning    97.9184  <0.001  
## 12 Anderson-Darling   Stest29visualization2D      78.4859  <0.001  
## 13 Anderson-Darling   Stest30visualization3D      57.8360  <0.001  
## 14 Anderson-Darling  Stest31abstractreasoning     57.5540  <0.001  
## 15 Anderson-Darling    Stest32arithreasoning     119.2201  <0.001  
## 16 Anderson-Darling    Stest33highschoolmath     102.6981  <0.001  
## 17 Anderson-Darling   Stest34arithcomputation     10.6258  <0.001  
## 18 Anderson-Darling     Stest35tablereading       76.0593  <0.001  
## 19 Anderson-Darling   Stest36clericalchecking    141.1956  <0.001  
## 20 Anderson-Darling   Stest37objectinspection     47.7660  <0.001  
##    Normality
## 1     NO    
## 2     NO    
## 3     NO    
## 4     NO    
## 5     NO    
## 6     NO    
## 7     NO    
## 8     NO    
## 9     NO    
## 10    NO    
## 11    NO    
## 12    NO    
## 13    NO    
## 14    NO    
## 15    NO    
## 16    NO    
## 17    NO    
## 18    NO    
## 19    NO    
## 20    NO    
## 
## $Descriptives
##                                n       Mean   Std.Dev     Median
## Stest1vocab                 6085 -1.2270951 0.9869065 -1.3076552
## Stest5math                  6085 -0.8822309 1.0191384 -0.7002896
## Stest19disguisedwords       6085 -0.8905205 0.9252168 -1.1766655
## Stest20spelling             6085 -0.5829844 1.0007505 -0.5972870
## Stest21capitalization       6085 -0.9734813 1.0022519 -1.1366164
## Stest22punctuation          6085 -1.0241805 0.9992056 -1.0491247
## Stest23english              6085 -0.8362356 1.1372716 -0.7059184
## Stest24expression           6085 -0.7837300 1.1248490 -0.8965657
## Stest25wordfunctions        6085 -0.8167652 0.7922195 -0.9300168
## Stest26readingcomprehension 6085 -1.2142523 1.0218114 -1.3554363
## Stest28mechanicalreasoning  6085 -1.0592902 0.8007023 -1.2304871
## Stest29visualization2D      6085 -0.7320590 1.0522279 -0.8200576
## Stest30visualization3D      6085 -0.8493621 0.8599248 -0.9663262
## Stest31abstractreasoning    6085 -1.1295355 1.1178724 -1.2582717
## Stest32arithreasoning       6085 -1.1100516 0.7904001 -1.1815940
## Stest33highschoolmath       6085 -0.8946355 0.7450916 -0.9288142
## Stest34arithcomputation     6085 -1.0629350 1.1362390 -1.0828324
## Stest35tablereading         6085 -0.5743500 1.6148560 -0.2788865
## Stest36clericalchecking     6085  0.1816066 1.2924821 -0.1244928
## Stest37objectinspection     6085 -0.2335661 1.1764773 -0.3684154
##                                   Min      Max       25th        75th
## Stest1vocab                 -3.081020 1.732398 -2.0676685 -0.54764189
## Stest5math                  -3.103322 1.578247 -1.4629972 -0.19790688
## Stest19disguisedwords       -2.200294 2.040453 -1.6153635 -0.29926954
## Stest20spelling             -2.949489 2.090944 -1.2693446  0.07477064
## Stest21capitalization       -2.212520 1.792646 -1.8990475 -0.34408038
## Stest22punctuation          -4.007462 1.909213 -1.7318180 -0.36643146
## Stest23english              -5.175212 2.486434 -1.6636241 -0.06744796
## Stest24expression           -3.654018 1.401311 -1.3561412  0.02258511
## Stest25wordfunctions        -2.609127 1.788020 -1.4507123 -0.49105015
## Stest26readingcomprehension -3.158804 1.549990 -2.0567460 -0.55393946
## Stest28mechanicalreasoning  -2.414006 2.083365 -1.7038945 -0.52037602
## Stest29visualization2D      -2.283595 1.924074 -1.5518262  0.09465304
## Stest30visualization3D      -2.538855 2.178732 -1.5953378 -0.33731459
## Stest31abstractreasoning    -3.053322 1.972819 -1.9762918 -0.18124158
## Stest32arithreasoning       -2.327215 1.968863 -1.7544044 -0.60878369
## Stest33highschoolmath       -2.147432 2.523936 -1.3350200 -0.52260833
## Stest34arithcomputation     -3.938878 3.303237 -1.8988454 -0.36882102
## Stest35tablereading         -4.815108 3.610163 -1.2852414  0.38398259
## Stest36clericalchecking     -2.661621 2.630104 -0.8493866  1.25280540
## Stest37objectinspection     -3.283883 2.401279 -1.0972824  0.50622493
##                                    Skew    Kurtosis
## Stest1vocab                  0.47717287 -0.27969289
## Stest5math                  -0.30838742 -0.14354630
## Stest19disguisedwords        0.92528173  0.25002207
## Stest20spelling              0.07162174 -0.41402487
## Stest21capitalization        0.66079326 -0.45474924
## Stest22punctuation           0.13503261 -0.27371782
## Stest23english              -0.27221625  0.19291627
## Stest24expression           -0.25731040 -0.52677341
## Stest25wordfunctions         0.52426120  0.43972905
## Stest26readingcomprehension  0.55267240 -0.48267484
## Stest28mechanicalreasoning   0.89527624  0.74079782
## Stest29visualization2D       0.46617489 -0.71363353
## Stest30visualization3D       0.49007612 -0.05428675
## Stest31abstractreasoning     0.22160144 -0.81473251
## Stest32arithreasoning        0.96214821  0.92707276
## Stest33highschoolmath        1.05266420  1.46681124
## Stest34arithcomputation      0.45360729  0.61692702
## Stest35tablereading         -0.52240978  0.72934119
## Stest36clericalchecking      0.42520016 -1.01692278
## Stest37objectinspection      0.36212399 -0.45668332
mvn(data = datamale, mvnTest = "hz", multivariatePlot = "qq", multivariateOutlierMethod = "quan") # no serious departure

## $multivariateNormality
##            Test       HZ p value MVN
## 1 Henze-Zirkler 1.009486       0  NO
## 
## $univariateNormality
##                Test                    Variable Statistic   p value
## 1  Anderson-Darling         Stest1vocab           17.2962  <0.001  
## 2  Anderson-Darling         Stest5math            19.8829  <0.001  
## 3  Anderson-Darling    Stest19disguisedwords      60.6622  <0.001  
## 4  Anderson-Darling       Stest20spelling         13.5916  <0.001  
## 5  Anderson-Darling    Stest21capitalization      79.2095  <0.001  
## 6  Anderson-Darling     Stest22punctuation         7.0268  <0.001  
## 7  Anderson-Darling       Stest23english           9.7213  <0.001  
## 8  Anderson-Darling      Stest24expression        21.4125  <0.001  
## 9  Anderson-Darling    Stest25wordfunctions       23.0605  <0.001  
## 10 Anderson-Darling Stest26readingcomprehension   39.6555  <0.001  
## 11 Anderson-Darling Stest28mechanicalreasoning    22.9034  <0.001  
## 12 Anderson-Darling   Stest29visualization2D      22.3567  <0.001  
## 13 Anderson-Darling   Stest30visualization3D      19.6763  <0.001  
## 14 Anderson-Darling  Stest31abstractreasoning     21.9210  <0.001  
## 15 Anderson-Darling    Stest32arithreasoning      48.8610  <0.001  
## 16 Anderson-Darling    Stest33highschoolmath      49.4632  <0.001  
## 17 Anderson-Darling   Stest34arithcomputation      5.6482  <0.001  
## 18 Anderson-Darling     Stest35tablereading       26.8353  <0.001  
## 19 Anderson-Darling   Stest36clericalchecking     70.2704  <0.001  
## 20 Anderson-Darling   Stest37objectinspection     26.1694  <0.001  
##    Normality
## 1     NO    
## 2     NO    
## 3     NO    
## 4     NO    
## 5     NO    
## 6     NO    
## 7     NO    
## 8     NO    
## 9     NO    
## 10    NO    
## 11    NO    
## 12    NO    
## 13    NO    
## 14    NO    
## 15    NO    
## 16    NO    
## 17    NO    
## 18    NO    
## 19    NO    
## 20    NO    
## 
## $Descriptives
##                                n          Mean   Std.Dev     Median
## Stest1vocab                 2443 -1.1095892563 1.0621130 -1.3076552
## Stest5math                  2443 -0.7896922969 1.0531123 -0.7002896
## Stest19disguisedwords       2443 -0.9650082562 0.8800368 -1.1766655
## Stest20spelling             2443 -0.8272665823 1.0004359 -0.9333158
## Stest21capitalization       2443 -1.1436734095 0.9454176 -1.4082177
## Stest22punctuation          2443 -1.2064543525 0.9968915 -1.2766891
## Stest23english              2443 -1.0353461760 1.1804729 -1.0251536
## Stest24expression           2443 -0.9498035005 1.1681145 -0.8965657
## Stest25wordfunctions        2443 -0.8645041762 0.7783038 -0.9300168
## Stest26readingcomprehension 2443 -1.2550031376 1.0826988 -1.4556234
## Stest28mechanicalreasoning  2443 -0.6930350339 0.8982447 -0.7570797
## Stest29visualization2D      2443 -0.4859242630 1.0960685 -0.4541734
## Stest30visualization3D      2443 -0.6885105790 0.9516764 -0.6518204
## Stest31abstractreasoning    2443 -1.0209400576 1.1409325 -0.8992617
## Stest32arithreasoning       2443 -1.0263748677 0.8487616 -1.1815940
## Stest33highschoolmath       2443 -0.8535754828 0.8021980 -0.9288142
## Stest34arithcomputation     2443 -1.1433319274 1.1393281 -1.1848340
## Stest35tablereading         2443 -0.6809154199 1.6458126 -0.4864526
## Stest36clericalchecking     2443  0.0003385028 1.2952453 -0.4144503
## Stest37objectinspection     2443 -0.2813571657 1.2386776 -0.5141888
##                                   Min      Max       25th        75th
## Stest1vocab                 -3.081020 1.732398 -1.9409997 -0.29430412
## Stest5math                  -3.103322 1.578247 -1.4629972 -0.19790688
## Stest19disguisedwords       -2.200294 2.040453 -1.6153635 -0.44550220
## Stest20spelling             -2.949489 2.090944 -1.6053734 -0.26125817
## Stest21capitalization       -2.212520 1.792646 -1.9895058 -0.34408038
## Stest22punctuation          -4.007462 1.909213 -1.9593824 -0.59399588
## Stest23english              -5.175212 2.486434 -1.6636241 -0.38668319
## Stest24expression           -3.654018 1.401311 -1.8157166  0.02258511
## Stest25wordfunctions        -2.609127 1.665905 -1.4507123 -0.49105015
## Stest26readingcomprehension -3.158804 1.549990 -2.1569331 -0.55393946
## Stest28mechanicalreasoning  -2.414006 2.083365 -1.4671908 -0.04696863
## Stest29visualization2D      -2.283595 1.924074 -1.5518262  0.27759518
## Stest30visualization3D      -2.538855 2.178732 -1.2808320 -0.02280880
## Stest31abstractreasoning    -3.053322 1.972819 -1.9762918 -0.18124158
## Stest32arithreasoning       -2.327215 1.968863 -1.7544044 -0.60878369
## Stest33highschoolmath       -2.147432 2.523936 -1.3350200 -0.52260833
## Stest34arithcomputation     -3.938878 3.201236 -2.0008470 -0.47082264
## Stest35tablereading         -4.815108 3.610163 -1.6444251  0.38398259
## Stest36clericalchecking     -2.661621 2.630104 -0.9943653  0.99909258
## Stest37objectinspection     -3.283883 2.401279 -1.2430558  0.50622493
##                                   Skew   Kurtosis
## Stest1vocab                  0.3451069 -0.5997669
## Stest5math                  -0.2883481 -0.1940244
## Stest19disguisedwords        1.0608678  0.7255663
## Stest20spelling              0.2312739 -0.3140564
## Stest21capitalization        0.8070777 -0.2315324
## Stest22punctuation           0.1822344 -0.2204551
## Stest23english              -0.2516029  0.2185956
## Stest24expression           -0.1804949 -0.6694891
## Stest25wordfunctions         0.4788478  0.4527625
## Stest26readingcomprehension  0.5876726 -0.5775554
## Stest28mechanicalreasoning   0.5402410 -0.1778992
## Stest29visualization2D       0.2211926 -0.9614718
## Stest30visualization3D       0.3515051 -0.4692480
## Stest31abstractreasoning     0.1504664 -0.8482587
## Stest32arithreasoning        0.8961258  0.5414459
## Stest33highschoolmath        1.1096846  1.4057803
## Stest34arithcomputation      0.5314790  0.7230444
## Stest35tablereading         -0.4445734  0.5465100
## Stest36clericalchecking      0.5649866 -0.8859927
## Stest37objectinspection      0.4228243 -0.5425451
mvn(data = datafemale, mvnTest = "hz", multivariatePlot = "qq", multivariateOutlierMethod = "quan") # no serious departure

## $multivariateNormality
##            Test       HZ p value MVN
## 1 Henze-Zirkler 1.010121       0  NO
## 
## $univariateNormality
##                Test                    Variable Statistic   p value
## 1  Anderson-Darling         Stest1vocab           29.6155  <0.001  
## 2  Anderson-Darling         Stest5math            40.5679  <0.001  
## 3  Anderson-Darling    Stest19disguisedwords      77.7550  <0.001  
## 4  Anderson-Darling       Stest20spelling         18.8864  <0.001  
## 5  Anderson-Darling    Stest21capitalization      76.8646  <0.001  
## 6  Anderson-Darling     Stest22punctuation        10.1089  <0.001  
## 7  Anderson-Darling       Stest23english          14.3929  <0.001  
## 8  Anderson-Darling      Stest24expression        34.0889  <0.001  
## 9  Anderson-Darling    Stest25wordfunctions       41.3657  <0.001  
## 10 Anderson-Darling Stest26readingcomprehension   36.4058  <0.001  
## 11 Anderson-Darling Stest28mechanicalreasoning    44.7846  <0.001  
## 12 Anderson-Darling   Stest29visualization2D      55.7612  <0.001  
## 13 Anderson-Darling   Stest30visualization3D      34.3835  <0.001  
## 14 Anderson-Darling  Stest31abstractreasoning     35.9934  <0.001  
## 15 Anderson-Darling    Stest32arithreasoning      66.7532  <0.001  
## 16 Anderson-Darling    Stest33highschoolmath      51.9887  <0.001  
## 17 Anderson-Darling   Stest34arithcomputation      5.6984  <0.001  
## 18 Anderson-Darling     Stest35tablereading       49.6425  <0.001  
## 19 Anderson-Darling   Stest36clericalchecking     76.8501  <0.001  
## 20 Anderson-Darling   Stest37objectinspection     24.2471  <0.001  
##    Normality
## 1     NO    
## 2     NO    
## 3     NO    
## 4     NO    
## 5     NO    
## 6     NO    
## 7     NO    
## 8     NO    
## 9     NO    
## 10    NO    
## 11    NO    
## 12    NO    
## 13    NO    
## 14    NO    
## 15    NO    
## 16    NO    
## 17    NO    
## 18    NO    
## 19    NO    
## 20    NO    
## 
## $Descriptives
##                                n       Mean   Std.Dev      Median
## Stest1vocab                 3642 -1.3059162 0.9248888 -1.30765522
## Stest5math                  3642 -0.9443045 0.9910145 -0.70028957
## Stest19disguisedwords       3642 -0.8405552 0.9511804 -1.03043286
## Stest20spelling             3642 -0.4191234 0.9671101 -0.26125817
## Stest21capitalization       3642 -0.8593189 1.0230130 -1.13661640
## Stest22punctuation          3642 -0.9019139 0.9821093 -1.04912472
## Stest23english              3642 -0.7026752 1.0872635 -0.70591842
## Stest24expression           3642 -0.6723303 1.0808223 -0.43699031
## Stest25wordfunctions        3642 -0.7847425 0.7999295 -0.93001676
## Stest26readingcomprehension 3642 -1.1869173 0.9780501 -1.35543630
## Stest28mechanicalreasoning  3642 -1.3049688 0.6162571 -1.46719079
## Stest29visualization2D      3642 -0.8971626 0.9881316 -1.00299976
## Stest30visualization3D      3642 -0.9572589 0.7740721 -0.96632617
## Stest31abstractreasoning    3642 -1.2023797 1.0962782 -1.25827171
## Stest32arithreasoning       3642 -1.1661807 0.7435679 -1.18159405
## Stest33highschoolmath       3642 -0.9221779 0.7029660 -1.13191711
## Stest34arithcomputation     3642 -1.0090058 1.1311203 -1.08283240
## Stest35tablereading         3642 -0.5028674 1.5899830 -0.27888648
## Stest36clericalchecking     3642  0.3031985 1.2764551  0.02048598
## Stest37objectinspection     3642 -0.2015085 1.1318854 -0.36841545
##                                   Min      Max       25th        75th
## Stest1vocab                 -3.081020 1.732398 -2.0676685 -0.80097967
## Stest5math                  -3.103322 1.578247 -1.4629972 -0.19790688
## Stest19disguisedwords       -2.200294 2.040453 -1.6153635 -0.29926954
## Stest20spelling             -2.949489 2.090944 -0.9333158  0.07477064
## Stest21capitalization       -2.212520 1.792646 -1.7779803 -0.34408038
## Stest22punctuation          -3.779898 1.909213 -1.5042536 -0.13886704
## Stest23english              -5.175212 2.486434 -1.3443889 -0.06744796
## Stest24expression           -3.654018 1.401311 -1.3561412  0.02258511
## Stest25wordfunctions        -2.609127 1.788020 -1.1772477 -0.29229762
## Stest26readingcomprehension -3.158804 1.549990 -1.9565589 -0.55393946
## Stest28mechanicalreasoning  -2.414006 1.373254 -1.7038945 -0.99378340
## Stest29visualization2D      -2.283595 1.924074 -1.7347683 -0.27123122
## Stest30visualization3D      -2.538855 2.178732 -1.5953378 -0.33731459
## Stest31abstractreasoning    -3.053322 1.972819 -1.9762918 -0.27099409
## Stest32arithreasoning       -2.327215 1.968863 -1.7544044 -0.89518887
## Stest33highschoolmath       -2.147432 2.320833 -1.3350200 -0.52260833
## Stest34arithcomputation     -3.938878 3.303237 -1.7968438 -0.36882102
## Stest35tablereading         -4.815108 3.610163 -1.2852414  0.38398259
## Stest36clericalchecking     -2.661621 2.630104 -0.7768972  1.45215119
## Stest37objectinspection     -3.283883 2.401279 -0.9515090  0.50622493
##                                     Skew     Kurtosis
## Stest1vocab                  0.535868058 -0.032645035
## Stest5math                  -0.352819327 -0.127331788
## Stest19disguisedwords        0.836665160 -0.007085817
## Stest20spelling              0.002357536 -0.387807405
## Stest21capitalization        0.563701708 -0.574558620
## Stest22punctuation           0.123386844 -0.302025868
## Stest23english              -0.236414541  0.093257874
## Stest24expression           -0.278535675 -0.439309073
## Stest25wordfunctions         0.548651694  0.412662989
## Stest26readingcomprehension  0.537123619 -0.413658623
## Stest28mechanicalreasoning   0.737112611  0.694206093
## Stest29visualization2D       0.616914647 -0.425638201
## Stest30visualization3D       0.467354756  0.133077169
## Stest31abstractreasoning     0.261892929 -0.790686145
## Stest32arithreasoning        0.967723776  1.133224623
## Stest33highschoolmath        0.952540727  1.271246103
## Stest34arithcomputation      0.406086185  0.574457758
## Stest35tablereading         -0.573971387  0.882021013
## Stest36clericalchecking      0.351036496 -1.067695471
## Stest37objectinspection      0.324476372 -0.392041976
mvn(data = datagroup, mvnTest = "hz", multivariatePlot = "qq", multivariateOutlierMethod = "quan") # no serious departure

## $multivariateNormality
##            Test       HZ p value MVN
## 1 Henze-Zirkler 1.015938       0  NO
## 
## $univariateNormality
##                Test                    Variable Statistic   p value
## 1  Anderson-Darling         Stest1vocab           48.2718  <0.001  
## 2  Anderson-Darling         Stest5math            58.4651  <0.001  
## 3  Anderson-Darling    Stest19disguisedwords     139.9232  <0.001  
## 4  Anderson-Darling       Stest20spelling         30.1780  <0.001  
## 5  Anderson-Darling    Stest21capitalization     152.5606  <0.001  
## 6  Anderson-Darling     Stest22punctuation        16.1634  <0.001  
## 7  Anderson-Darling       Stest23english          23.6787  <0.001  
## 8  Anderson-Darling      Stest24expression        55.2359  <0.001  
## 9  Anderson-Darling    Stest25wordfunctions       64.1826  <0.001  
## 10 Anderson-Darling Stest26readingcomprehension   72.4436  <0.001  
## 11 Anderson-Darling Stest28mechanicalreasoning    97.9184  <0.001  
## 12 Anderson-Darling   Stest29visualization2D      78.4859  <0.001  
## 13 Anderson-Darling   Stest30visualization3D      57.8360  <0.001  
## 14 Anderson-Darling  Stest31abstractreasoning     57.5540  <0.001  
## 15 Anderson-Darling    Stest32arithreasoning     119.2201  <0.001  
## 16 Anderson-Darling    Stest33highschoolmath     102.6981  <0.001  
## 17 Anderson-Darling   Stest34arithcomputation     10.6258  <0.001  
## 18 Anderson-Darling     Stest35tablereading       76.0593  <0.001  
## 19 Anderson-Darling   Stest36clericalchecking    141.1956  <0.001  
## 20 Anderson-Darling   Stest37objectinspection     47.7660  <0.001  
##    Normality
## 1     NO    
## 2     NO    
## 3     NO    
## 4     NO    
## 5     NO    
## 6     NO    
## 7     NO    
## 8     NO    
## 9     NO    
## 10    NO    
## 11    NO    
## 12    NO    
## 13    NO    
## 14    NO    
## 15    NO    
## 16    NO    
## 17    NO    
## 18    NO    
## 19    NO    
## 20    NO    
## 
## $Descriptives
##                                n       Mean   Std.Dev     Median
## Stest1vocab                 6085 -1.2270951 0.9869065 -1.3076552
## Stest5math                  6085 -0.8822309 1.0191384 -0.7002896
## Stest19disguisedwords       6085 -0.8905205 0.9252168 -1.1766655
## Stest20spelling             6085 -0.5829844 1.0007505 -0.5972870
## Stest21capitalization       6085 -0.9734813 1.0022519 -1.1366164
## Stest22punctuation          6085 -1.0241805 0.9992056 -1.0491247
## Stest23english              6085 -0.8362356 1.1372716 -0.7059184
## Stest24expression           6085 -0.7837300 1.1248490 -0.8965657
## Stest25wordfunctions        6085 -0.8167652 0.7922195 -0.9300168
## Stest26readingcomprehension 6085 -1.2142523 1.0218114 -1.3554363
## Stest28mechanicalreasoning  6085 -1.0592902 0.8007023 -1.2304871
## Stest29visualization2D      6085 -0.7320590 1.0522279 -0.8200576
## Stest30visualization3D      6085 -0.8493621 0.8599248 -0.9663262
## Stest31abstractreasoning    6085 -1.1295355 1.1178724 -1.2582717
## Stest32arithreasoning       6085 -1.1100516 0.7904001 -1.1815940
## Stest33highschoolmath       6085 -0.8946355 0.7450916 -0.9288142
## Stest34arithcomputation     6085 -1.0629350 1.1362390 -1.0828324
## Stest35tablereading         6085 -0.5743500 1.6148560 -0.2788865
## Stest36clericalchecking     6085  0.1816066 1.2924821 -0.1244928
## Stest37objectinspection     6085 -0.2335661 1.1764773 -0.3684154
##                                   Min      Max       25th        75th
## Stest1vocab                 -3.081020 1.732398 -2.0676685 -0.54764189
## Stest5math                  -3.103322 1.578247 -1.4629972 -0.19790688
## Stest19disguisedwords       -2.200294 2.040453 -1.6153635 -0.29926954
## Stest20spelling             -2.949489 2.090944 -1.2693446  0.07477064
## Stest21capitalization       -2.212520 1.792646 -1.8990475 -0.34408038
## Stest22punctuation          -4.007462 1.909213 -1.7318180 -0.36643146
## Stest23english              -5.175212 2.486434 -1.6636241 -0.06744796
## Stest24expression           -3.654018 1.401311 -1.3561412  0.02258511
## Stest25wordfunctions        -2.609127 1.788020 -1.4507123 -0.49105015
## Stest26readingcomprehension -3.158804 1.549990 -2.0567460 -0.55393946
## Stest28mechanicalreasoning  -2.414006 2.083365 -1.7038945 -0.52037602
## Stest29visualization2D      -2.283595 1.924074 -1.5518262  0.09465304
## Stest30visualization3D      -2.538855 2.178732 -1.5953378 -0.33731459
## Stest31abstractreasoning    -3.053322 1.972819 -1.9762918 -0.18124158
## Stest32arithreasoning       -2.327215 1.968863 -1.7544044 -0.60878369
## Stest33highschoolmath       -2.147432 2.523936 -1.3350200 -0.52260833
## Stest34arithcomputation     -3.938878 3.303237 -1.8988454 -0.36882102
## Stest35tablereading         -4.815108 3.610163 -1.2852414  0.38398259
## Stest36clericalchecking     -2.661621 2.630104 -0.8493866  1.25280540
## Stest37objectinspection     -3.283883 2.401279 -1.0972824  0.50622493
##                                    Skew    Kurtosis
## Stest1vocab                  0.47717287 -0.27969289
## Stest5math                  -0.30838742 -0.14354630
## Stest19disguisedwords        0.92528173  0.25002207
## Stest20spelling              0.07162174 -0.41402487
## Stest21capitalization        0.66079326 -0.45474924
## Stest22punctuation           0.13503261 -0.27371782
## Stest23english              -0.27221625  0.19291627
## Stest24expression           -0.25731040 -0.52677341
## Stest25wordfunctions         0.52426120  0.43972905
## Stest26readingcomprehension  0.55267240 -0.48267484
## Stest28mechanicalreasoning   0.89527624  0.74079782
## Stest29visualization2D       0.46617489 -0.71363353
## Stest30visualization3D       0.49007612 -0.05428675
## Stest31abstractreasoning     0.22160144 -0.81473251
## Stest32arithreasoning        0.96214821  0.92707276
## Stest33highschoolmath        1.05266420  1.46681124
## Stest34arithcomputation      0.45360729  0.61692702
## Stest35tablereading         -0.52240978  0.72934119
## Stest36clericalchecking      0.42520016 -1.01692278
## Stest37objectinspection      0.36212399 -0.45668332
# standardized loadings for Jensen's MCV

FAmale<-fa(r=datamale, nfactors=4, max.iter=100, warnings=TRUE, rotate="none", fm="pa", weight=dmale$BY_WTA)
print(FAmale, digits=2, cutoff=.10)
## Factor Analysis using method =  pa
## Call: fa(r = datamale, nfactors = 4, rotate = "none", max.iter = 100, 
##     warnings = TRUE, fm = "pa", weight = dmale$BY_WTA)
## Standardized loadings (pattern matrix) based upon correlation matrix
##                              PA1   PA2   PA3   PA4   h2   u2 com
## Stest1vocab                 0.80 -0.12 -0.08 -0.01 0.67 0.33 1.1
## Stest5math                  0.66 -0.06 -0.08 -0.23 0.50 0.50 1.3
## Stest19disguisedwords       0.70  0.07 -0.14  0.10 0.52 0.48 1.1
## Stest20spelling             0.63 -0.10 -0.34  0.11 0.53 0.47 1.7
## Stest21capitalization       0.72 -0.10 -0.08  0.15 0.56 0.44 1.1
## Stest22punctuation          0.77 -0.11 -0.09  0.11 0.63 0.37 1.1
## Stest23english              0.72 -0.07 -0.11  0.22 0.58 0.42 1.3
## Stest24expression           0.58 -0.14 -0.06  0.12 0.38 0.62 1.2
## Stest25wordfunctions        0.58 -0.10 -0.02 -0.11 0.36 0.64 1.1
## Stest26readingcomprehension 0.85 -0.17 -0.08  0.01 0.76 0.24 1.1
## Stest28mechanicalreasoning  0.67  0.01  0.36  0.03 0.58 0.42 1.6
## Stest29visualization2D      0.51  0.20  0.30  0.12 0.40 0.60 2.1
## Stest30visualization3D      0.54  0.03  0.47  0.02 0.51 0.49 2.0
## Stest31abstractreasoning    0.69 -0.02  0.29  0.04 0.56 0.44 1.4
## Stest32arithreasoning       0.71 -0.12  0.06 -0.22 0.58 0.42 1.3
## Stest33highschoolmath       0.75 -0.11  0.00 -0.31 0.67 0.33 1.4
## Stest34arithcomputation     0.64  0.28 -0.17 -0.09 0.52 0.48 1.6
## Stest35tablereading         0.43  0.51 -0.05 -0.05 0.44 0.56 2.0
## Stest36clericalchecking     0.21  0.64 -0.21 -0.05 0.50 0.50 1.5
## Stest37objectinspection     0.30  0.61  0.09  0.06 0.48 0.52 1.5
## 
##                        PA1  PA2  PA3  PA4
## SS loadings           8.26 1.30 0.80 0.37
## Proportion Var        0.41 0.07 0.04 0.02
## Cumulative Var        0.41 0.48 0.52 0.54
## Proportion Explained  0.77 0.12 0.07 0.03
## Cumulative Proportion 0.77 0.89 0.97 1.00
## 
## Mean item complexity =  1.4
## Test of the hypothesis that 4 factors are sufficient.
## 
## df null model =  190  with the objective function =  10.2 0.1 with Chi Square =  24835.72
## df of  the model are 116  and the objective function was  0.28 
##  0.1
## The root mean square of the residuals (RMSR) is  0.02 
## The df corrected root mean square of the residuals is  0.02 
##  0.1
## The harmonic n.obs is  2443 with the empirical chi square  255.23  with prob <  1.8e-12 
##  0.1The total n.obs was  2443  with Likelihood Chi Square =  689.36  with prob <  2.6e-82 
##  0.1
## Tucker Lewis Index of factoring reliability =  0.962
## RMSEA index =  0.045  and the 90 % confidence intervals are  0.042 0.048 0.1
## BIC =  -215.55
## Fit based upon off diagonal values = 1
## Measures of factor score adequacy             
##                                                    PA1  PA2  PA3   PA4
## Correlation of (regression) scores with factors   0.98 0.85 0.79  0.68
## Multiple R square of scores with factors          0.95 0.72 0.63  0.47
## Minimum correlation of possible factor scores     0.91 0.44 0.26 -0.07
FAfemale<-fa(r=datafemale, nfactors=4, max.iter=100, warnings=TRUE, rotate="none", fm="pa", weight=dfemale$BY_WTA)
print(FAfemale, digits=2, cutoff=.10)
## Factor Analysis using method =  pa
## Call: fa(r = datafemale, nfactors = 4, rotate = "none", max.iter = 100, 
##     warnings = TRUE, fm = "pa", weight = dfemale$BY_WTA)
## Standardized loadings (pattern matrix) based upon correlation matrix
##                              PA1   PA2   PA3   PA4   h2   u2 com
## Stest1vocab                 0.76 -0.10 -0.13  0.05 0.61 0.39 1.1
## Stest5math                  0.55 -0.06  0.00  0.28 0.39 0.61 1.5
## Stest19disguisedwords       0.73  0.13 -0.13 -0.07 0.56 0.44 1.1
## Stest20spelling             0.63  0.00 -0.35 -0.06 0.52 0.48 1.6
## Stest21capitalization       0.72 -0.07 -0.10 -0.14 0.55 0.45 1.1
## Stest22punctuation          0.79 -0.11 -0.08 -0.09 0.66 0.34 1.1
## Stest23english              0.70 -0.08 -0.11 -0.19 0.54 0.46 1.2
## Stest24expression           0.54 -0.11 -0.06 -0.19 0.34 0.66 1.4
## Stest25wordfunctions        0.63 -0.14  0.04  0.18 0.44 0.56 1.3
## Stest26readingcomprehension 0.84 -0.14 -0.10 -0.03 0.73 0.27 1.1
## Stest28mechanicalreasoning  0.53 -0.06  0.24  0.02 0.35 0.65 1.4
## Stest29visualization2D      0.45  0.09  0.34 -0.09 0.33 0.67 2.1
## Stest30visualization3D      0.47 -0.04  0.44 -0.09 0.42 0.58 2.1
## Stest31abstractreasoning    0.66 -0.10  0.26 -0.12 0.53 0.47 1.4
## Stest32arithreasoning       0.63 -0.16  0.09  0.17 0.47 0.53 1.3
## Stest33highschoolmath       0.70 -0.11  0.06  0.30 0.60 0.40 1.4
## Stest34arithcomputation     0.60  0.31 -0.13  0.08 0.48 0.52 1.6
## Stest35tablereading         0.44  0.52 -0.02  0.01 0.46 0.54 2.0
## Stest36clericalchecking     0.18  0.66 -0.05  0.07 0.47 0.53 1.2
## Stest37objectinspection     0.34  0.59  0.16 -0.04 0.49 0.51 1.8
## 
##                        PA1  PA2  PA3  PA4
## SS loadings           7.56 1.31 0.69 0.38
## Proportion Var        0.38 0.07 0.03 0.02
## Cumulative Var        0.38 0.44 0.48 0.50
## Proportion Explained  0.76 0.13 0.07 0.04
## Cumulative Proportion 0.76 0.89 0.96 1.00
## 
## Mean item complexity =  1.4
## Test of the hypothesis that 4 factors are sufficient.
## 
## df null model =  190  with the objective function =  8.88 0.1 with Chi Square =  32272.14
## df of  the model are 116  and the objective function was  0.24 
##  0.1
## The root mean square of the residuals (RMSR) is  0.02 
## The df corrected root mean square of the residuals is  0.02 
##  0.1
## The harmonic n.obs is  3642 with the empirical chi square  368.51  with prob <  4.6e-28 
##  0.1The total n.obs was  3642  with Likelihood Chi Square =  857.85  with prob <  1.7e-113 
##  0.1
## Tucker Lewis Index of factoring reliability =  0.962
## RMSEA index =  0.042  and the 90 % confidence intervals are  0.039 0.045 0.1
## BIC =  -93.38
## Fit based upon off diagonal values = 1
## Measures of factor score adequacy             
##                                                    PA1  PA2  PA3   PA4
## Correlation of (regression) scores with factors   0.97 0.85 0.75  0.66
## Multiple R square of scores with factors          0.94 0.72 0.56  0.44
## Minimum correlation of possible factor scores     0.89 0.44 0.12 -0.13
FA<-fa(r=datagroup, nfactors=4, max.iter=100, warnings=TRUE, rotate="none", fm="pa", weight=dgroup$BY_WTA)
print(FA, digits=2, cutoff=.10)
## Factor Analysis using method =  pa
## Call: fa(r = datagroup, nfactors = 4, rotate = "none", max.iter = 100, 
##     warnings = TRUE, fm = "pa", weight = dgroup$BY_WTA)
## Standardized loadings (pattern matrix) based upon correlation matrix
##                              PA1   PA2   PA3   PA4   h2   u2 com
## Stest1vocab                 0.77 -0.12 -0.04 -0.09 0.62 0.38 1.1
## Stest5math                  0.60 -0.07  0.03 -0.29 0.45 0.55 1.5
## Stest19disguisedwords       0.71  0.13 -0.12  0.04 0.54 0.46 1.1
## Stest20spelling             0.62  0.03 -0.40  0.03 0.54 0.46 1.7
## Stest21capitalization       0.71 -0.04 -0.18  0.16 0.56 0.44 1.2
## Stest22punctuation          0.78 -0.07 -0.19  0.12 0.66 0.34 1.2
## Stest23english              0.70 -0.03 -0.18  0.19 0.56 0.44 1.3
## Stest24expression           0.55 -0.09 -0.14  0.16 0.36 0.64 1.4
## Stest25wordfunctions        0.60 -0.11 -0.04 -0.12 0.39 0.61 1.1
## Stest26readingcomprehension 0.84 -0.14 -0.11 -0.01 0.74 0.26 1.1
## Stest28mechanicalreasoning  0.55 -0.14  0.43 -0.01 0.50 0.50 2.0
## Stest29visualization2D      0.47  0.06  0.38  0.13 0.38 0.62 2.1
## Stest30visualization3D      0.49 -0.10  0.45  0.13 0.47 0.53 2.2
## Stest31abstractreasoning    0.67 -0.11  0.25  0.14 0.54 0.46 1.4
## Stest32arithreasoning       0.67 -0.17  0.10 -0.17 0.51 0.49 1.3
## Stest33highschoolmath       0.72 -0.12  0.06 -0.26 0.61 0.39 1.3
## Stest34arithcomputation     0.62  0.32 -0.09 -0.09 0.50 0.50 1.6
## Stest35tablereading         0.43  0.51  0.05 -0.02 0.46 0.54 2.0
## Stest36clericalchecking     0.19  0.67 -0.02 -0.09 0.49 0.51 1.2
## Stest37objectinspection     0.32  0.58  0.20  0.07 0.48 0.52 1.9
## 
##                        PA1  PA2  PA3  PA4
## SS loadings           7.71 1.31 0.97 0.38
## Proportion Var        0.39 0.07 0.05 0.02
## Cumulative Var        0.39 0.45 0.50 0.52
## Proportion Explained  0.74 0.13 0.09 0.04
## Cumulative Proportion 0.74 0.87 0.96 1.00
## 
## Mean item complexity =  1.5
## Test of the hypothesis that 4 factors are sufficient.
## 
## df null model =  190  with the objective function =  9.39 0.1 with Chi Square =  57071.23
## df of  the model are 116  and the objective function was  0.25 
##  0.1
## The root mean square of the residuals (RMSR) is  0.02 
## The df corrected root mean square of the residuals is  0.02 
##  0.1
## The harmonic n.obs is  6085 with the empirical chi square  610.95  with prob <  2.9e-68 
##  0.1The total n.obs was  6085  with Likelihood Chi Square =  1530.03  with prob <  3.6e-245 
##  0.1
## Tucker Lewis Index of factoring reliability =  0.959
## RMSEA index =  0.045  and the 90 % confidence intervals are  0.043 0.047 0.1
## BIC =  519.26
## Fit based upon off diagonal values = 1
## Measures of factor score adequacy             
##                                                    PA1  PA2  PA3   PA4
## Correlation of (regression) scores with factors   0.97 0.85 0.81  0.67
## Multiple R square of scores with factors          0.95 0.72 0.66  0.45
## Minimum correlation of possible factor scores     0.89 0.44 0.32 -0.10
# EFA: The rotate options "promax" and "Promax" differ slightly. Because unlike "Promax", the "promax" performs a Kaiser normalization before rotation, which is recommended according to Kaizer.

male3<-fa(datamale, nfactors=3, rotate="promax", fm="minres", weight=dmale$BY_WTA)
print(male3, digits=2, cutoff=.10)
## Factor Analysis using method =  minres
## Call: fa(r = datamale, nfactors = 3, rotate = "promax", fm = "minres", 
##     weight = dmale$BY_WTA)
## Standardized loadings (pattern matrix) based upon correlation matrix
##                               MR1   MR3   MR2   h2   u2 com
## Stest1vocab                  0.78  0.07 -0.04 0.67 0.33 1.0
## Stest5math                   0.62  0.06  0.02 0.44 0.56 1.0
## Stest19disguisedwords        0.65 -0.02  0.17 0.51 0.49 1.1
## Stest20spelling              0.87 -0.30  0.03 0.52 0.48 1.2
## Stest21capitalization        0.70  0.06 -0.02 0.54 0.46 1.0
## Stest22punctuation           0.76  0.06 -0.02 0.62 0.38 1.0
## Stest23english               0.69  0.03  0.02 0.52 0.48 1.0
## Stest24expression            0.59  0.05 -0.08 0.36 0.64 1.0
## Stest25wordfunctions         0.54  0.10 -0.04 0.35 0.65 1.1
## Stest26readingcomprehension  0.85  0.08 -0.09 0.77 0.23 1.0
## Stest28mechanicalreasoning   0.16  0.65 -0.02 0.58 0.42 1.1
## Stest29visualization2D       0.00  0.53  0.18 0.38 0.62 1.2
## Stest30visualization3D      -0.06  0.77 -0.04 0.52 0.48 1.0
## Stest31abstractreasoning     0.26  0.56 -0.03 0.56 0.44 1.4
## Stest32arithreasoning        0.57  0.23 -0.07 0.52 0.48 1.4
## Stest33highschoolmath        0.64  0.17 -0.04 0.56 0.44 1.2
## Stest34arithcomputation      0.50 -0.05  0.39 0.51 0.49 1.9
## Stest35tablereading          0.09  0.07  0.59 0.44 0.56 1.1
## Stest36clericalchecking      0.00 -0.20  0.76 0.50 0.50 1.1
## Stest37objectinspection     -0.20  0.24  0.65 0.47 0.53 1.5
## 
##                        MR1  MR3  MR2
## SS loadings           6.51 2.23 1.59
## Proportion Var        0.33 0.11 0.08
## Cumulative Var        0.33 0.44 0.52
## Proportion Explained  0.63 0.22 0.15
## Cumulative Proportion 0.63 0.85 1.00
## 
##  With factor correlations of 
##      MR1  MR3  MR2
## MR1 1.00 0.67 0.38
## MR3 0.67 1.00 0.37
## MR2 0.38 0.37 1.00
## 
## Mean item complexity =  1.2
## Test of the hypothesis that 3 factors are sufficient.
## 
## df null model =  190  with the objective function =  10.2 0.1 with Chi Square =  24835.72
## df of  the model are 133  and the objective function was  0.46 
##  0.1
## The root mean square of the residuals (RMSR) is  0.02 
## The df corrected root mean square of the residuals is  0.03 
##  0.1
## The harmonic n.obs is  2443 with the empirical chi square  529.29  with prob <  1.1e-48 
##  0.1The total n.obs was  2443  with Likelihood Chi Square =  1114.79  with prob <  1.1e-154 
##  0.1
## Tucker Lewis Index of factoring reliability =  0.943
## RMSEA index =  0.055  and the 90 % confidence intervals are  0.052 0.058 0.1
## BIC =  77.26
## Fit based upon off diagonal values = 1
## Measures of factor score adequacy             
##                                                    MR1  MR3  MR2
## Correlation of (regression) scores with factors   0.97 0.91 0.87
## Multiple R square of scores with factors          0.94 0.83 0.76
## Minimum correlation of possible factor scores     0.88 0.66 0.53
male4<-fa(datamale, nfactors=4, rotate="promax", fm="minres", weight=dmale$BY_WTA)
print(male4, digits=2, cutoff=.10)
## Factor Analysis using method =  minres
## Call: fa(r = datamale, nfactors = 4, rotate = "promax", fm = "minres", 
##     weight = dmale$BY_WTA)
## Standardized loadings (pattern matrix) based upon correlation matrix
##                               MR1   MR3   MR4   MR2   h2   u2 com
## Stest1vocab                  0.59  0.07  0.23 -0.03 0.67 0.33 1.3
## Stest5math                   0.20 -0.02  0.54  0.05 0.50 0.50 1.3
## Stest19disguisedwords        0.64  0.01  0.00  0.16 0.52 0.48 1.1
## Stest20spelling              0.86 -0.27  0.00  0.02 0.53 0.47 1.2
## Stest21capitalization        0.72  0.10 -0.04 -0.04 0.56 0.44 1.1
## Stest22punctuation           0.72  0.09  0.03 -0.04 0.63 0.37 1.0
## Stest23english               0.82  0.09 -0.17 -0.01 0.58 0.42 1.1
## Stest24expression            0.60  0.09 -0.02 -0.09 0.38 0.62 1.1
## Stest25wordfunctions         0.27  0.06  0.33 -0.03 0.36 0.64 2.0
## Stest26readingcomprehension  0.66  0.08  0.23 -0.08 0.76 0.24 1.3
## Stest28mechanicalreasoning   0.08  0.64  0.11 -0.03 0.58 0.42 1.1
## Stest29visualization2D       0.07  0.57 -0.11  0.17 0.40 0.60 1.3
## Stest30visualization3D      -0.11  0.75  0.08 -0.04 0.51 0.49 1.1
## Stest31abstractreasoning     0.18  0.56  0.10 -0.04 0.56 0.44 1.3
## Stest32arithreasoning        0.14  0.16  0.55 -0.05 0.58 0.42 1.3
## Stest33highschoolmath        0.10  0.07  0.70  0.00 0.67 0.33 1.1
## Stest34arithcomputation      0.30 -0.07  0.24  0.41 0.52 0.48 2.6
## Stest35tablereading          0.01  0.06  0.09  0.59 0.44 0.56 1.1
## Stest36clericalchecking     -0.02 -0.20  0.01  0.76 0.50 0.50 1.1
## Stest37objectinspection     -0.10  0.26 -0.14  0.65 0.48 0.52 1.5
## 
##                        MR1  MR3  MR4  MR2
## SS loadings           4.91 2.18 2.04 1.60
## Proportion Var        0.25 0.11 0.10 0.08
## Cumulative Var        0.25 0.35 0.46 0.54
## Proportion Explained  0.46 0.20 0.19 0.15
## Cumulative Proportion 0.46 0.66 0.85 1.00
## 
##  With factor correlations of 
##      MR1  MR3  MR4  MR2
## MR1 1.00 0.65 0.77 0.39
## MR3 0.65 1.00 0.61 0.37
## MR4 0.77 0.61 1.00 0.31
## MR2 0.39 0.37 0.31 1.00
## 
## Mean item complexity =  1.3
## Test of the hypothesis that 4 factors are sufficient.
## 
## df null model =  190  with the objective function =  10.2 0.1 with Chi Square =  24835.72
## df of  the model are 116  and the objective function was  0.28 
##  0.1
## The root mean square of the residuals (RMSR) is  0.02 
## The df corrected root mean square of the residuals is  0.02 
##  0.1
## The harmonic n.obs is  2443 with the empirical chi square  255.23  with prob <  1.8e-12 
##  0.1The total n.obs was  2443  with Likelihood Chi Square =  689.45  with prob <  2.5e-82 
##  0.1
## Tucker Lewis Index of factoring reliability =  0.962
## RMSEA index =  0.045  and the 90 % confidence intervals are  0.042 0.048 0.1
## BIC =  -215.47
## Fit based upon off diagonal values = 1
## Measures of factor score adequacy             
##                                                    MR1  MR3  MR4  MR2
## Correlation of (regression) scores with factors   0.96 0.91 0.92 0.88
## Multiple R square of scores with factors          0.93 0.83 0.84 0.77
## Minimum correlation of possible factor scores     0.85 0.66 0.68 0.53
male5<-fa(datamale, nfactors=5, rotate="promax", fm="minres", weight=dmale$BY_WTA)
print(male5, digits=2, cutoff=.10)
## Factor Analysis using method =  minres
## Call: fa(r = datamale, nfactors = 5, rotate = "promax", fm = "minres", 
##     weight = dmale$BY_WTA)
## Standardized loadings (pattern matrix) based upon correlation matrix
##                               MR1   MR3   MR4   MR2   MR5   h2   u2 com
## Stest1vocab                  0.60  0.07  0.20  0.02  0.30 0.73 0.27 1.8
## Stest5math                   0.18 -0.02  0.55  0.07  0.15 0.52 0.48 1.4
## Stest19disguisedwords        0.65  0.01 -0.02  0.19  0.17 0.54 0.46 1.3
## Stest20spelling              0.86 -0.27  0.01  0.00 -0.02 0.53 0.47 1.2
## Stest21capitalization        0.73  0.10 -0.03 -0.06 -0.05 0.57 0.43 1.1
## Stest22punctuation           0.73  0.09  0.04 -0.07 -0.09 0.66 0.34 1.1
## Stest23english               0.82  0.09 -0.16  0.01  0.08 0.57 0.43 1.1
## Stest24expression            0.60  0.09 -0.02 -0.10  0.01 0.38 0.62 1.1
## Stest25wordfunctions         0.27  0.07  0.34 -0.04  0.00 0.36 0.64 2.0
## Stest26readingcomprehension  0.67  0.08  0.20 -0.04  0.24 0.80 0.20 1.5
## Stest28mechanicalreasoning   0.07  0.66  0.09  0.01  0.17 0.61 0.39 1.2
## Stest29visualization2D       0.07  0.57 -0.10  0.15 -0.05 0.41 0.59 1.3
## Stest30visualization3D      -0.11  0.75  0.08 -0.04  0.04 0.51 0.49 1.1
## Stest31abstractreasoning     0.17  0.57  0.11 -0.06 -0.06 0.57 0.43 1.3
## Stest32arithreasoning        0.13  0.17  0.55 -0.06  0.03 0.57 0.43 1.3
## Stest33highschoolmath        0.05  0.07  0.76 -0.04 -0.07 0.70 0.30 1.1
## Stest34arithcomputation      0.29 -0.09  0.29  0.36 -0.20 0.57 0.43 3.6
## Stest35tablereading          0.01  0.07  0.10  0.57 -0.08 0.44 0.56 1.1
## Stest36clericalchecking     -0.02 -0.20  0.00  0.78  0.03 0.52 0.48 1.1
## Stest37objectinspection     -0.10  0.26 -0.14  0.64 -0.01 0.47 0.53 1.5
## 
##                        MR1  MR3  MR4  MR2  MR5
## SS loadings           4.86 2.20 2.12 1.59 0.27
## Proportion Var        0.24 0.11 0.11 0.08 0.01
## Cumulative Var        0.24 0.35 0.46 0.54 0.55
## Proportion Explained  0.44 0.20 0.19 0.14 0.02
## Cumulative Proportion 0.44 0.64 0.83 0.98 1.00
## 
##  With factor correlations of 
##       MR1   MR3   MR4   MR2   MR5
## MR1  1.00  0.65  0.78  0.40 -0.09
## MR3  0.65  1.00  0.61  0.38 -0.07
## MR4  0.78  0.61  1.00  0.33 -0.01
## MR2  0.40  0.38  0.33  1.00 -0.15
## MR5 -0.09 -0.07 -0.01 -0.15  1.00
## 
## Mean item complexity =  1.4
## Test of the hypothesis that 5 factors are sufficient.
## 
## df null model =  190  with the objective function =  10.2 0.1 with Chi Square =  24835.72
## df of  the model are 100  and the objective function was  0.13 
##  0.1
## The root mean square of the residuals (RMSR) is  0.01 
## The df corrected root mean square of the residuals is  0.02 
##  0.1
## The harmonic n.obs is  2443 with the empirical chi square  121.92  with prob <  0.067 
##  0.1The total n.obs was  2443  with Likelihood Chi Square =  323.37  with prob <  2.4e-25 
##  0.1
## Tucker Lewis Index of factoring reliability =  0.983
## RMSEA index =  0.03  and the 90 % confidence intervals are  0.027 0.034 0.1
## BIC =  -456.72
## Fit based upon off diagonal values = 1
## Measures of factor score adequacy             
##                                                    MR1  MR3  MR4  MR2
## Correlation of (regression) scores with factors   0.96 0.91 0.92 0.88
## Multiple R square of scores with factors          0.92 0.83 0.86 0.77
## Minimum correlation of possible factor scores     0.85 0.66 0.71 0.54
##                                                     MR5
## Correlation of (regression) scores with factors    0.67
## Multiple R square of scores with factors           0.44
## Minimum correlation of possible factor scores     -0.11
female3<-fa(datafemale, nfactors=3, rotate="promax", fm="minres", weight=dfemale$BY_WTA)
print(female3, digits=2, cutoff=.10)
## Factor Analysis using method =  minres
## Call: fa(r = datafemale, nfactors = 3, rotate = "promax", fm = "minres", 
##     weight = dfemale$BY_WTA)
## Standardized loadings (pattern matrix) based upon correlation matrix
##                               MR1   MR3   MR2   h2   u2 com
## Stest1vocab                  0.79  0.00 -0.03 0.61 0.39 1.0
## Stest5math                   0.46  0.12  0.00 0.30 0.70 1.1
## Stest19disguisedwords        0.66 -0.02  0.21 0.56 0.44 1.2
## Stest20spelling              0.88 -0.32  0.06 0.52 0.48 1.3
## Stest21capitalization        0.70  0.03  0.00 0.53 0.47 1.0
## Stest22punctuation           0.76  0.09 -0.04 0.65 0.35 1.0
## Stest23english               0.69  0.03 -0.01 0.50 0.50 1.0
## Stest24expression            0.52  0.06 -0.05 0.30 0.70 1.0
## Stest25wordfunctions         0.52  0.19 -0.07 0.41 0.59 1.3
## Stest26readingcomprehension  0.84  0.06 -0.06 0.74 0.26 1.0
## Stest28mechanicalreasoning   0.19  0.45 -0.01 0.35 0.65 1.3
## Stest29visualization2D      -0.04  0.54  0.15 0.33 0.67 1.2
## Stest30visualization3D      -0.08  0.69  0.01 0.41 0.59 1.0
## Stest31abstractreasoning     0.29  0.50 -0.03 0.51 0.49 1.6
## Stest32arithreasoning        0.48  0.27 -0.10 0.43 0.57 1.7
## Stest33highschoolmath        0.54  0.23 -0.04 0.49 0.51 1.3
## Stest34arithcomputation      0.48 -0.07  0.40 0.48 0.52 2.0
## Stest35tablereading          0.15  0.02  0.60 0.46 0.54 1.1
## Stest36clericalchecking     -0.08 -0.08  0.72 0.47 0.53 1.1
## Stest37objectinspection     -0.15  0.23  0.67 0.48 0.52 1.4
## 
##                        MR1  MR3  MR2
## SS loadings           6.04 1.86 1.62
## Proportion Var        0.30 0.09 0.08
## Cumulative Var        0.30 0.40 0.48
## Proportion Explained  0.63 0.20 0.17
## Cumulative Proportion 0.63 0.83 1.00
## 
##  With factor correlations of 
##      MR1  MR3  MR2
## MR1 1.00 0.67 0.36
## MR3 0.67 1.00 0.27
## MR2 0.36 0.27 1.00
## 
## Mean item complexity =  1.2
## Test of the hypothesis that 3 factors are sufficient.
## 
## df null model =  190  with the objective function =  8.88 0.1 with Chi Square =  32272.14
## df of  the model are 133  and the objective function was  0.39 
##  0.1
## The root mean square of the residuals (RMSR) is  0.02 
## The df corrected root mean square of the residuals is  0.03 
##  0.1
## The harmonic n.obs is  3642 with the empirical chi square  823.65  with prob <  4.6e-100 
##  0.1The total n.obs was  3642  with Likelihood Chi Square =  1408.27  with prob <  8.6e-212 
##  0.1
## Tucker Lewis Index of factoring reliability =  0.943
## RMSEA index =  0.051  and the 90 % confidence intervals are  0.049 0.054 0.1
## BIC =  317.63
## Fit based upon off diagonal values = 1
## Measures of factor score adequacy             
##                                                    MR1  MR3  MR2
## Correlation of (regression) scores with factors   0.97 0.88 0.87
## Multiple R square of scores with factors          0.93 0.78 0.76
## Minimum correlation of possible factor scores     0.87 0.56 0.52
female4<-fa(datafemale, nfactors=4, rotate="promax", fm="minres", weight=dfemale$BY_WTA)
print(female4, digits=2, cutoff=.10)
## Factor Analysis using method =  minres
## Call: fa(r = datafemale, nfactors = 4, rotate = "promax", fm = "minres", 
##     weight = dfemale$BY_WTA)
## Standardized loadings (pattern matrix) based upon correlation matrix
##                               MR1   MR4   MR3   MR2   h2   u2 com
## Stest1vocab                  0.54  0.31 -0.04 -0.02 0.61 0.39 1.6
## Stest5math                  -0.01  0.63 -0.03  0.03 0.39 0.61 1.0
## Stest19disguisedwords        0.59  0.06  0.01  0.20 0.56 0.44 1.3
## Stest20spelling              0.80  0.06 -0.28  0.05 0.52 0.48 1.3
## Stest21capitalization        0.71 -0.02  0.08 -0.02 0.55 0.45 1.0
## Stest22punctuation           0.68  0.10  0.10 -0.05 0.66 0.34 1.1
## Stest23english               0.76 -0.10  0.09 -0.03 0.54 0.46 1.1
## Stest24expression            0.63 -0.13  0.12 -0.08 0.34 0.66 1.2
## Stest25wordfunctions         0.14  0.51  0.08 -0.05 0.44 0.56 1.2
## Stest26readingcomprehension  0.66  0.22  0.05 -0.06 0.73 0.27 1.2
## Stest28mechanicalreasoning   0.05  0.22  0.39 -0.01 0.35 0.65 1.6
## Stest29visualization2D      -0.01 -0.01  0.54  0.14 0.33 0.67 1.1
## Stest30visualization3D      -0.07  0.03  0.67  0.00 0.42 0.58 1.0
## Stest31abstractreasoning     0.28  0.04  0.51 -0.05 0.53 0.47 1.6
## Stest32arithreasoning        0.10  0.51  0.16 -0.08 0.47 0.53 1.3
## Stest33highschoolmath        0.01  0.73  0.07 -0.01 0.60 0.40 1.0
## Stest34arithcomputation      0.30  0.22 -0.10  0.41 0.48 0.52 2.6
## Stest35tablereading          0.13  0.00  0.03  0.61 0.46 0.54 1.1
## Stest36clericalchecking     -0.11  0.00 -0.09  0.74 0.47 0.53 1.1
## Stest37objectinspection     -0.08 -0.11  0.25  0.67 0.49 0.51 1.4
## 
##                        MR1  MR4  MR3  MR2
## SS loadings           4.42 2.26 1.64 1.63
## Proportion Var        0.22 0.11 0.08 0.08
## Cumulative Var        0.22 0.33 0.42 0.50
## Proportion Explained  0.44 0.23 0.16 0.16
## Cumulative Proportion 0.44 0.67 0.84 1.00
## 
##  With factor correlations of 
##      MR1  MR4  MR3  MR2
## MR1 1.00 0.79 0.62 0.39
## MR4 0.79 1.00 0.63 0.33
## MR3 0.62 0.63 1.00 0.29
## MR2 0.39 0.33 0.29 1.00
## 
## Mean item complexity =  1.3
## Test of the hypothesis that 4 factors are sufficient.
## 
## df null model =  190  with the objective function =  8.88 0.1 with Chi Square =  32272.14
## df of  the model are 116  and the objective function was  0.24 
##  0.1
## The root mean square of the residuals (RMSR) is  0.02 
## The df corrected root mean square of the residuals is  0.02 
##  0.1
## The harmonic n.obs is  3642 with the empirical chi square  368.5  with prob <  4.6e-28 
##  0.1The total n.obs was  3642  with Likelihood Chi Square =  857.85  with prob <  1.7e-113 
##  0.1
## Tucker Lewis Index of factoring reliability =  0.962
## RMSEA index =  0.042  and the 90 % confidence intervals are  0.039 0.045 0.1
## BIC =  -93.38
## Fit based upon off diagonal values = 1
## Measures of factor score adequacy             
##                                                    MR1  MR4  MR3  MR2
## Correlation of (regression) scores with factors   0.96 0.92 0.87 0.88
## Multiple R square of scores with factors          0.92 0.85 0.77 0.77
## Minimum correlation of possible factor scores     0.84 0.69 0.53 0.53
female5<-fa(datafemale, nfactors=5, rotate="promax", fm="minres", weight=dfemale$BY_WTA)
print(female5, digits=2, cutoff=.10)
## Factor Analysis using method =  minres
## Call: fa(r = datafemale, nfactors = 5, rotate = "promax", fm = "minres", 
##     weight = dfemale$BY_WTA)
## Standardized loadings (pattern matrix) based upon correlation matrix
##                               MR1   MR4   MR2   MR3   MR5   h2   u2 com
## Stest1vocab                  0.51  0.25  0.02 -0.05  0.33 0.68 0.32 2.3
## Stest5math                  -0.01  0.61  0.03 -0.02  0.07 0.38 0.62 1.0
## Stest19disguisedwords        0.58 -0.01  0.24  0.01  0.25 0.60 0.40 1.7
## Stest20spelling              0.78  0.08  0.05 -0.28  0.04 0.52 0.48 1.3
## Stest21capitalization        0.70 -0.01 -0.02  0.08  0.04 0.55 0.45 1.0
## Stest22punctuation           0.69  0.12 -0.07  0.11 -0.06 0.68 0.32 1.1
## Stest23english               0.75 -0.08 -0.04  0.09  0.01 0.54 0.46 1.1
## Stest24expression            0.62 -0.12 -0.09  0.13  0.01 0.34 0.66 1.2
## Stest25wordfunctions         0.14  0.49 -0.06  0.09  0.04 0.44 0.56 1.3
## Stest26readingcomprehension  0.64  0.16 -0.04  0.05  0.27 0.77 0.23 1.5
## Stest28mechanicalreasoning   0.03  0.19  0.01  0.40  0.12 0.36 0.64 1.6
## Stest29visualization2D      -0.01 -0.01  0.14  0.54 -0.02 0.33 0.67 1.1
## Stest30visualization3D      -0.06  0.03  0.01  0.67 -0.01 0.42 0.58 1.0
## Stest31abstractreasoning     0.28  0.05 -0.06  0.50 -0.02 0.53 0.47 1.6
## Stest32arithreasoning        0.10  0.50 -0.09  0.17  0.03 0.46 0.54 1.4
## Stest33highschoolmath       -0.03  0.82 -0.04  0.06 -0.11 0.64 0.36 1.1
## Stest34arithcomputation      0.30  0.30  0.39 -0.12 -0.18 0.55 0.45 3.5
## Stest35tablereading          0.13  0.02  0.60  0.03 -0.04 0.46 0.54 1.1
## Stest36clericalchecking     -0.12 -0.03  0.76 -0.08  0.08 0.50 0.50 1.1
## Stest37objectinspection     -0.08 -0.10  0.66  0.24 -0.04 0.48 0.52 1.4
## 
##                        MR1  MR4  MR2  MR3  MR5
## SS loadings           4.29 2.25 1.65 1.64 0.40
## Proportion Var        0.21 0.11 0.08 0.08 0.02
## Cumulative Var        0.21 0.33 0.41 0.49 0.51
## Proportion Explained  0.42 0.22 0.16 0.16 0.04
## Cumulative Proportion 0.42 0.64 0.80 0.96 1.00
## 
##  With factor correlations of 
##      MR1  MR4   MR2  MR3   MR5
## MR1 1.00 0.79  0.40 0.61  0.12
## MR4 0.79 1.00  0.34 0.62  0.22
## MR2 0.40 0.34  1.00 0.29 -0.03
## MR3 0.61 0.62  0.29 1.00  0.17
## MR5 0.12 0.22 -0.03 0.17  1.00
## 
## Mean item complexity =  1.4
## Test of the hypothesis that 5 factors are sufficient.
## 
## df null model =  190  with the objective function =  8.88 0.1 with Chi Square =  32272.14
## df of  the model are 100  and the objective function was  0.11 
##  0.1
## The root mean square of the residuals (RMSR) is  0.01 
## The df corrected root mean square of the residuals is  0.02 
##  0.1
## The harmonic n.obs is  3642 with the empirical chi square  186.88  with prob <  3.2e-07 
##  0.1The total n.obs was  3642  with Likelihood Chi Square =  402.51  with prob <  6.5e-38 
##  0.1
## Tucker Lewis Index of factoring reliability =  0.982
## RMSEA index =  0.029  and the 90 % confidence intervals are  0.026 0.032 0.1
## BIC =  -417.52
## Fit based upon off diagonal values = 1
## Measures of factor score adequacy             
##                                                    MR1  MR4  MR2  MR3
## Correlation of (regression) scores with factors   0.95 0.93 0.88 0.87
## Multiple R square of scores with factors          0.91 0.86 0.77 0.77
## Minimum correlation of possible factor scores     0.82 0.71 0.55 0.53
##                                                     MR5
## Correlation of (regression) scores with factors    0.67
## Multiple R square of scores with factors           0.45
## Minimum correlation of possible factor scores     -0.10

CHC common factor model

chc.factor.model <-'
english =~ Stest1vocab + Stest19disguisedwords + Stest20spelling + Stest21capitalization + Stest22punctuation + Stest23english + Stest24expression + Stest26readingcomprehension + Stest31abstractreasoning + Stest34arithcomputation
math =~ Stest1vocab + Stest5math + Stest25wordfunctions + Stest26readingcomprehension + Stest32arithreasoning + Stest33highschoolmath + Stest34arithcomputation
speed =~ Stest34arithcomputation + Stest35tablereading + Stest36clericalchecking + Stest37objectinspection
spatial =~ Stest28mechanicalreasoning + Stest29visualization2D + Stest30visualization3D + Stest31abstractreasoning + Stest37objectinspection
'

baseline<-cfa(chc.factor.model, data=dgroup, meanstructure=TRUE, sampling.weights="BY_WTA")
fitMeasures(baseline, c("chisq", "df", "pvalue", "cfi", "rmsea", "srmr", "aic", "bic"))
##      chisq         df     pvalue        cfi      rmsea       srmr 
##   3330.952    158.000      0.000      0.944      0.057      0.043 
##        aic        bic 
## 294444.955 294928.333
Mc(baseline)
## [1] 0.7704643
configural<-cfa(chc.factor.model, data=dgroup, group="sex", meanstructure=TRUE, sampling.weights="BY_WTA", std.lv=T)
fitMeasures(configural, c("chisq", "df", "pvalue", "cfi", "rmsea", "srmr", "aic", "bic"))
##      chisq         df     pvalue        cfi      rmsea       srmr 
##   3357.819    316.000      0.000      0.947      0.056      0.042 
##        aic        bic 
## 291291.549 292258.305
Mc(configural)
## [1] 0.7788124
summary(configural, standardized=T, ci=T)
## lavaan 0.6-18 ended normally after 60 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                       144
## 
##   Number of observations per group:                   
##     0                                             2443
##     1                                             3642
##   Sampling weights variable                     BY_WTA
## 
## Model Test User Model:
##                                               Standard      Scaled
##   Test Statistic                              3357.819    2996.637
##   Degrees of freedom                               316         316
##   P-value (Chi-square)                           0.000       0.000
##   Scaling correction factor                                  1.121
##     Yuan-Bentler correction (Mplus variant)                       
##   Test statistic for each group:
##     0                                         1435.077    1280.714
##     1                                         1922.742    1715.923
## 
## Parameter Estimates:
## 
##   Standard errors                             Sandwich
##   Information bread                           Observed
##   Observed information based on                Hessian
## 
## 
## Group 1 [0]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english =~                                                   
##     Stest1vocab       0.543    0.070    7.712    0.000    0.405
##     Stst19dsgsdwrd    0.619    0.018   34.938    0.000    0.585
##     Stest20spellng    0.672    0.019   34.682    0.000    0.634
##     Stest21cptlztn    0.708    0.016   44.489    0.000    0.677
##     Stest22puncttn    0.792    0.018   44.049    0.000    0.757
##     Stest23english    0.884    0.021   41.314    0.000    0.842
##     Stest24exprssn    0.712    0.021   33.719    0.000    0.671
##     Stst26rdngcmpr    0.600    0.067    8.915    0.000    0.468
##     Stst31bstrctrs    0.244    0.035    6.907    0.000    0.175
##     Stst34rthcmptt    0.258    0.064    4.041    0.000    0.133
##   math =~                                                      
##     Stest1vocab       0.366    0.072    5.123    0.000    0.226
##     Stest5math        0.740    0.019   39.662    0.000    0.703
##     Stst25wrdfnctn    0.476    0.018   26.400    0.000    0.440
##     Stst26rdngcmpr    0.372    0.069    5.431    0.000    0.238
##     Stst32rthrsnng    0.638    0.018   35.571    0.000    0.603
##     Stst33hghschlm    0.624    0.019   33.149    0.000    0.587
##     Stst34rthcmptt    0.285    0.065    4.380    0.000    0.157
##   speed =~                                                     
##     Stst34rthcmptt    0.469    0.031   15.369    0.000    0.409
##     Stest35tblrdng    1.188    0.045   26.167    0.000    1.099
##     Stst36clrclchc    0.801    0.032   25.052    0.000    0.739
##     Stst37bjctnspc    0.735    0.035   21.021    0.000    0.666
##   spatial =~                                                   
##     Stst28mchnclrs    0.706    0.018   39.612    0.000    0.671
##     Stst29vslztn2D    0.658    0.022   30.214    0.000    0.616
##     Stst30vslztn3D    0.646    0.019   34.333    0.000    0.609
##     Stst31bstrctrs    0.657    0.036   18.142    0.000    0.586
##     Stst37bjctnspc    0.115    0.030    3.872    0.000    0.057
##  ci.upper   Std.lv  Std.all
##                            
##     0.681    0.543    0.509
##     0.654    0.619    0.709
##     0.710    0.672    0.674
##     0.739    0.708    0.750
##     0.827    0.792    0.793
##     0.926    0.884    0.744
##     0.753    0.712    0.612
##     0.732    0.600    0.558
##     0.314    0.244    0.214
##     0.383    0.258    0.225
##                            
##     0.507    0.366    0.344
##     0.776    0.740    0.706
##     0.511    0.476    0.611
##     0.507    0.372    0.346
##     0.674    0.638    0.760
##     0.661    0.624    0.794
##     0.413    0.285    0.249
##                            
##     0.529    0.469    0.409
##     1.277    1.188    0.712
##     0.864    0.801    0.619
##     0.803    0.735    0.593
##                            
##     0.741    0.706    0.785
##     0.701    0.658    0.604
##     0.683    0.646    0.681
##     0.728    0.657    0.576
##     0.174    0.115    0.093
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english ~~                                                   
##     math              0.861    0.011   81.260    0.000    0.840
##     speed             0.353    0.026   13.624    0.000    0.302
##     spatial           0.703    0.018   39.244    0.000    0.668
##   math ~~                                                      
##     speed             0.317    0.027   11.833    0.000    0.264
##     spatial           0.749    0.017   43.938    0.000    0.716
##   speed ~~                                                     
##     spatial           0.365    0.030   12.228    0.000    0.307
##  ci.upper   Std.lv  Std.all
##                            
##     0.882    0.861    0.861
##     0.404    0.353    0.353
##     0.738    0.703    0.703
##                            
##     0.369    0.317    0.317
##     0.782    0.749    0.749
##                            
##     0.424    0.365    0.365
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stest1vocab      -1.155    0.023  -50.360    0.000   -1.200
##    .Stst19dsgsdwrd   -0.992    0.018  -53.776    0.000   -1.028
##    .Stest20spellng   -0.848    0.021  -39.900    0.000   -0.890
##    .Stest21cptlztn   -1.167    0.020  -58.007    0.000   -1.206
##    .Stest22puncttn   -1.226    0.021  -57.496    0.000   -1.268
##    .Stest23english   -1.062    0.026  -41.362    0.000   -1.113
##    .Stest24exprssn   -0.965    0.025  -38.928    0.000   -1.014
##    .Stst26rdngcmpr   -1.292    0.023  -56.802    0.000   -1.337
##    .Stst31bstrctrs   -1.070    0.024  -43.766    0.000   -1.118
##    .Stst34rthcmptt   -1.153    0.025  -46.702    0.000   -1.201
##    .Stest5math       -0.814    0.022  -36.442    0.000   -0.857
##    .Stst25wrdfnctn   -0.871    0.017  -52.726    0.000   -0.903
##    .Stst32rthrsnng   -1.052    0.018  -59.194    0.000   -1.087
##    .Stst33hghschlm   -0.875    0.016  -53.483    0.000   -0.907
##    .Stest35tblrdng   -0.712    0.037  -19.463    0.000   -0.784
##    .Stst36clrclchc   -0.032    0.028   -1.139    0.255   -0.086
##    .Stst37bjctnspc   -0.318    0.027  -11.957    0.000   -0.370
##    .Stst28mchnclrs   -0.715    0.019  -36.895    0.000   -0.753
##    .Stst29vslztn2D   -0.512    0.023  -22.047    0.000   -0.557
##    .Stst30vslztn3D   -0.723    0.020  -35.874    0.000   -0.762
##  ci.upper   Std.lv  Std.all
##    -1.110   -1.155   -1.083
##    -0.956   -0.992   -1.136
##    -0.806   -0.848   -0.851
##    -1.128   -1.167   -1.236
##    -1.184   -1.226   -1.229
##    -1.012   -1.062   -0.893
##    -0.916   -0.965   -0.829
##    -1.248   -1.292   -1.202
##    -1.022   -1.070   -0.937
##    -1.104   -1.153   -1.006
##    -0.770   -0.814   -0.777
##    -0.838   -0.871   -1.119
##    -1.017   -1.052   -1.253
##    -0.843   -0.875   -1.115
##    -0.640   -0.712   -0.427
##     0.023   -0.032   -0.025
##    -0.266   -0.318   -0.257
##    -0.677   -0.715   -0.795
##    -0.466   -0.512   -0.469
##    -0.683   -0.723   -0.763
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stest1vocab       0.366    0.013   27.382    0.000    0.340
##    .Stst19dsgsdwrd    0.379    0.014   27.124    0.000    0.351
##    .Stest20spellng    0.542    0.018   30.368    0.000    0.507
##    .Stest21cptlztn    0.390    0.016   25.109    0.000    0.360
##    .Stest22puncttn    0.369    0.013   27.877    0.000    0.343
##    .Stest23english    0.632    0.023   27.034    0.000    0.586
##    .Stest24exprssn    0.848    0.026   32.988    0.000    0.798
##    .Stst26rdngcmpr    0.273    0.011   24.254    0.000    0.251
##    .Stst31bstrctrs    0.586    0.023   25.638    0.000    0.541
##    .Stst34rthcmptt    0.648    0.030   21.843    0.000    0.590
##    .Stest5math        0.550    0.021   26.331    0.000    0.509
##    .Stst25wrdfnctn    0.379    0.012   31.698    0.000    0.356
##    .Stst32rthrsnng    0.297    0.011   27.283    0.000    0.276
##    .Stst33hghschlm    0.228    0.010   23.175    0.000    0.208
##    .Stest35tblrdng    1.371    0.088   15.621    0.000    1.199
##    .Stst36clrclchc    1.036    0.048   21.733    0.000    0.943
##    .Stst37bjctnspc    0.920    0.040   23.088    0.000    0.842
##    .Stst28mchnclrs    0.310    0.015   20.015    0.000    0.280
##    .Stst29vslztn2D    0.756    0.027   28.152    0.000    0.703
##    .Stst30vslztn3D    0.481    0.017   27.531    0.000    0.447
##     english           1.000                               1.000
##     math              1.000                               1.000
##     speed             1.000                               1.000
##     spatial           1.000                               1.000
##  ci.upper   Std.lv  Std.all
##     0.392    0.366    0.321
##     0.406    0.379    0.497
##     0.577    0.542    0.546
##     0.420    0.390    0.438
##     0.395    0.369    0.370
##     0.678    0.632    0.447
##     0.899    0.848    0.626
##     0.295    0.273    0.236
##     0.630    0.586    0.450
##     0.706    0.648    0.494
##     0.591    0.550    0.501
##     0.403    0.379    0.626
##     0.319    0.297    0.422
##     0.247    0.228    0.369
##     1.543    1.371    0.493
##     1.129    1.036    0.617
##     0.998    0.920    0.599
##     0.341    0.310    0.383
##     0.808    0.756    0.636
##     0.515    0.481    0.536
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
## 
## 
## Group 2 [1]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english =~                                                   
##     Stest1vocab       0.517    0.043   12.062    0.000    0.433
##     Stst19dsgsdwrd    0.690    0.014   48.821    0.000    0.663
##     Stest20spellng    0.642    0.015   43.261    0.000    0.613
##     Stest21cptlztn    0.749    0.014   54.541    0.000    0.723
##     Stest22puncttn    0.797    0.014   56.336    0.000    0.769
##     Stest23english    0.784    0.017   47.284    0.000    0.751
##     Stest24exprssn    0.602    0.017   35.254    0.000    0.568
##     Stst26rdngcmpr    0.633    0.039   16.125    0.000    0.556
##     Stst31bstrctrs    0.282    0.030    9.324    0.000    0.223
##     Stst34rthcmptt    0.291    0.048    6.117    0.000    0.198
##   math =~                                                      
##     Stest1vocab       0.226    0.046    4.948    0.000    0.137
##     Stest5math        0.595    0.016   37.277    0.000    0.563
##     Stst25wrdfnctn    0.539    0.015   36.593    0.000    0.510
##     Stst26rdngcmpr    0.223    0.041    5.389    0.000    0.142
##     Stst32rthrsnng    0.512    0.015   33.488    0.000    0.482
##     Stst33hghschlm    0.526    0.014   37.512    0.000    0.498
##     Stst34rthcmptt    0.203    0.046    4.447    0.000    0.114
##   speed =~                                                     
##     Stst34rthcmptt    0.490    0.027   18.414    0.000    0.438
##     Stest35tblrdng    1.184    0.038   31.392    0.000    1.110
##     Stst36clrclchc    0.766    0.026   29.587    0.000    0.715
##     Stst37bjctnspc    0.706    0.027   26.207    0.000    0.654
##   spatial =~                                                   
##     Stst28mchnclrs    0.379    0.013   29.236    0.000    0.354
##     Stst29vslztn2D    0.548    0.019   29.282    0.000    0.511
##     Stst30vslztn3D    0.471    0.015   31.370    0.000    0.442
##     Stst31bstrctrs    0.559    0.032   17.693    0.000    0.497
##     Stst37bjctnspc    0.109    0.024    4.576    0.000    0.063
##  ci.upper   Std.lv  Std.all
##                            
##     0.601    0.517    0.562
##     0.718    0.690    0.735
##     0.671    0.642    0.667
##     0.776    0.749    0.741
##     0.825    0.797    0.808
##     0.816    0.784    0.718
##     0.635    0.602    0.557
##     0.710    0.633    0.653
##     0.341    0.282    0.258
##     0.385    0.291    0.252
##                            
##     0.316    0.226    0.246
##     0.626    0.595    0.603
##     0.568    0.539    0.676
##     0.303    0.223    0.229
##     0.542    0.512    0.694
##     0.553    0.526    0.756
##     0.293    0.203    0.176
##                            
##     0.542    0.490    0.424
##     1.258    1.184    0.729
##     0.817    0.766    0.598
##     0.759    0.706    0.615
##                            
##     0.405    0.379    0.619
##     0.585    0.548    0.554
##     0.501    0.471    0.610
##     0.621    0.559    0.511
##     0.156    0.109    0.095
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english ~~                                                   
##     math              0.840    0.010   87.880    0.000    0.821
##     speed             0.389    0.022   17.678    0.000    0.346
##     spatial           0.695    0.017   41.519    0.000    0.662
##   math ~~                                                      
##     speed             0.291    0.022   13.104    0.000    0.248
##     spatial           0.749    0.018   42.221    0.000    0.714
##   speed ~~                                                     
##     spatial           0.330    0.027   12.298    0.000    0.277
##  ci.upper   Std.lv  Std.all
##                            
##     0.859    0.840    0.840
##     0.432    0.389    0.389
##     0.727    0.695    0.695
##                            
##     0.335    0.291    0.291
##     0.784    0.749    0.749
##                            
##     0.382    0.330    0.330
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stest1vocab      -1.339    0.016  -83.554    0.000   -1.370
##    .Stst19dsgsdwrd   -0.878    0.016  -54.059    0.000   -0.910
##    .Stest20spellng   -0.450    0.017  -26.686    0.000   -0.483
##    .Stest21cptlztn   -0.899    0.017  -51.477    0.000   -0.934
##    .Stest22puncttn   -0.929    0.017  -53.286    0.000   -0.963
##    .Stest23english   -0.744    0.019  -38.449    0.000   -0.781
##    .Stest24exprssn   -0.704    0.019  -37.099    0.000   -0.742
##    .Stst26rdngcmpr   -1.226    0.017  -72.842    0.000   -1.259
##    .Stst31bstrctrs   -1.260    0.019  -65.843    0.000   -1.297
##    .Stst34rthcmptt   -1.004    0.021  -47.990    0.000   -1.045
##    .Stest5math       -0.965    0.017  -55.615    0.000   -0.999
##    .Stst25wrdfnctn   -0.788    0.014  -57.181    0.000   -0.816
##    .Stst32rthrsnng   -1.184    0.013  -92.849    0.000   -1.209
##    .Stst33hghschlm   -0.942    0.012  -78.389    0.000   -0.966
##    .Stest35tblrdng   -0.524    0.029  -17.830    0.000   -0.582
##    .Stst36clrclchc    0.300    0.023   13.284    0.000    0.256
##    .Stst37bjctnspc   -0.217    0.021  -10.567    0.000   -0.257
##    .Stst28mchnclrs   -1.323    0.011 -124.285    0.000   -1.344
##    .Stst29vslztn2D   -0.916    0.017  -52.801    0.000   -0.950
##    .Stst30vslztn3D   -0.982    0.014  -72.639    0.000   -1.008
##  ci.upper   Std.lv  Std.all
##    -1.307   -1.339   -1.455
##    -0.846   -0.878   -0.935
##    -0.417   -0.450   -0.467
##    -0.865   -0.899   -0.889
##    -0.895   -0.929   -0.942
##    -0.706   -0.744   -0.682
##    -0.667   -0.704   -0.652
##    -1.193   -1.226   -1.265
##    -1.222   -1.260   -1.152
##    -0.963   -1.004   -0.868
##    -0.931   -0.965   -0.978
##    -0.761   -0.788   -0.989
##    -1.159   -1.184   -1.604
##    -0.919   -0.942   -1.356
##    -0.466   -0.524   -0.323
##     0.344    0.300    0.234
##    -0.176   -0.217   -0.189
##    -1.303   -1.323   -2.162
##    -0.882   -0.916   -0.926
##    -0.955   -0.982   -1.270
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stest1vocab       0.331    0.010   34.380    0.000    0.312
##    .Stst19dsgsdwrd    0.406    0.012   34.677    0.000    0.383
##    .Stest20spellng    0.516    0.014   37.393    0.000    0.489
##    .Stest21cptlztn    0.461    0.014   32.923    0.000    0.434
##    .Stest22puncttn    0.337    0.011   30.531    0.000    0.315
##    .Stest23english    0.576    0.017   34.094    0.000    0.543
##    .Stest24exprssn    0.805    0.021   37.943    0.000    0.763
##    .Stst26rdngcmpr    0.254    0.008   29.918    0.000    0.237
##    .Stst31bstrctrs    0.585    0.019   31.567    0.000    0.548
##    .Stst34rthcmptt    0.703    0.027   26.377    0.000    0.651
##    .Stest5math        0.620    0.017   35.640    0.000    0.586
##    .Stst25wrdfnctn    0.346    0.010   33.725    0.000    0.326
##    .Stst32rthrsnng    0.282    0.008   34.343    0.000    0.266
##    .Stst33hghschlm    0.207    0.007   28.975    0.000    0.193
##    .Stest35tblrdng    1.235    0.073   16.839    0.000    1.091
##    .Stst36clrclchc    1.055    0.036   29.157    0.000    0.984
##    .Stst37bjctnspc    0.756    0.031   24.423    0.000    0.696
##    .Stst28mchnclrs    0.231    0.007   33.590    0.000    0.218
##    .Stst29vslztn2D    0.677    0.020   33.905    0.000    0.638
##    .Stst30vslztn3D    0.375    0.011   33.037    0.000    0.353
##     english           1.000                               1.000
##     math              1.000                               1.000
##     speed             1.000                               1.000
##     spatial           1.000                               1.000
##  ci.upper   Std.lv  Std.all
##     0.350    0.331    0.391
##     0.429    0.406    0.460
##     0.543    0.516    0.556
##     0.489    0.461    0.451
##     0.358    0.337    0.346
##     0.609    0.576    0.484
##     0.846    0.805    0.690
##     0.270    0.254    0.270
##     0.621    0.585    0.489
##     0.755    0.703    0.525
##     0.654    0.620    0.637
##     0.366    0.346    0.543
##     0.299    0.282    0.518
##     0.221    0.207    0.428
##     1.379    1.235    0.468
##     1.126    1.055    0.643
##     0.817    0.756    0.574
##     0.245    0.231    0.616
##     0.716    0.677    0.693
##     0.398    0.375    0.628
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
modificationIndices(configural, sort=T, maximum.number=30)
##                         lhs op                         rhs block group
## 409                 english =~         Stest35tablereading     2     2
## 422                    math =~         Stest35tablereading     2     2
## 465             Stest1vocab ~~ Stest26readingcomprehension     2     2
## 429                   speed =~       Stest19disguisedwords     2     2
## 457                 spatial =~         Stest35tablereading     2     2
## 491   Stest19disguisedwords ~~     Stest36clericalchecking     2     2
## 178                    math =~         Stest35tablereading     1     1
## 446                 spatial =~             Stest20spelling     2     2
## 213                 spatial =~         Stest35tablereading     1     1
## 221             Stest1vocab ~~ Stest26readingcomprehension     1     1
## 165                 english =~         Stest35tablereading     1     1
## 410                 english =~     Stest36clericalchecking     2     2
## 423                    math =~     Stest36clericalchecking     2     2
## 458                 spatial =~     Stest36clericalchecking     2     2
## 202                 spatial =~             Stest20spelling     1     1
## 639 Stest36clericalchecking ~~     Stest37objectinspection     2     2
## 425                    math =~  Stest28mechanicalreasoning     2     2
## 214                 spatial =~     Stest36clericalchecking     1     1
## 180                    math =~     Stest37objectinspection     1     1
## 597 Stest34arithcomputation ~~       Stest33highschoolmath     2     2
## 185                   speed =~       Stest19disguisedwords     1     1
## 198                   speed =~      Stest29visualization2D     1     1
## 462             Stest1vocab ~~          Stest22punctuation     2     2
## 424                    math =~     Stest37objectinspection     2     2
## 247   Stest19disguisedwords ~~     Stest36clericalchecking     1     1
## 418                    math =~          Stest22punctuation     2     2
## 635     Stest35tablereading ~~     Stest37objectinspection     2     2
## 167                 english =~     Stest37objectinspection     1     1
## 395 Stest36clericalchecking ~~     Stest37objectinspection     1     1
## 412                 english =~  Stest28mechanicalreasoning     2     2
##     level      mi    epc sepc.lv sepc.all sepc.nox
## 409     1 246.736  0.562   0.562    0.346    0.346
## 422     1 238.265  0.551   0.551    0.339    0.339
## 465     1 200.392  0.083   0.083    0.286    0.286
## 429     1 189.846  0.205   0.205    0.218    0.218
## 457     1 184.916  0.546   0.546    0.336    0.336
## 491     1 173.523  0.162   0.162    0.248    0.248
## 178     1 169.046  0.561   0.561    0.336    0.336
## 446     1 159.565 -0.315  -0.315   -0.326   -0.326
## 213     1 148.124  0.580   0.580    0.347    0.347
## 221     1 146.514  0.096   0.096    0.305    0.305
## 165     1 137.695  0.499   0.499    0.299    0.299
## 410     1 124.214 -0.276  -0.276   -0.215   -0.215
## 423     1 122.977 -0.270  -0.270   -0.211   -0.211
## 458     1 121.094 -0.296  -0.296   -0.231   -0.231
## 202     1 120.462 -0.316  -0.316   -0.317   -0.317
## 639     1 115.014  0.257   0.257    0.287    0.287
## 425     1 102.412  0.244   0.244    0.399    0.399
## 214     1 101.302 -0.332  -0.332   -0.256   -0.256
## 180     1  93.404 -0.423  -0.423   -0.341   -0.341
## 597     1  87.319  0.076   0.076    0.199    0.199
## 185     1  84.673  0.158   0.158    0.181    0.181
## 198     1  82.881  0.230   0.230    0.211    0.211
## 462     1  76.495 -0.059  -0.059   -0.177   -0.177
## 424     1  71.564 -0.309  -0.309   -0.269   -0.269
## 247     1  70.411  0.122   0.122    0.194    0.194
## 418     1  66.010  0.266   0.266    0.270    0.270
## 635     1  64.523 -0.303  -0.303   -0.313   -0.313
## 167     1  64.317 -0.314  -0.314   -0.254   -0.254
## 395     1  63.268  0.262   0.262    0.268    0.268
## 412     1  62.656  0.163   0.163    0.266    0.266
metric<-cfa(chc.factor.model, data=dgroup, group="sex", meanstructure=TRUE, sampling.weights="BY_WTA", std.lv=T, group.equal=c("loadings"))
fitMeasures(metric, c("chisq", "df", "pvalue", "cfi", "rmsea", "srmr", "aic", "bic"))
##      chisq         df     pvalue        cfi      rmsea       srmr 
##   3678.537    338.000      0.000      0.941      0.057      0.052 
##        aic        bic 
## 291568.267 292387.324
Mc(metric)
## [1] 0.7599257
summary(metric, standardized=T, ci=T)
## lavaan 0.6-18 ended normally after 78 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                       148
##   Number of equality constraints                    26
## 
##   Number of observations per group:                   
##     0                                             2443
##     1                                             3642
##   Sampling weights variable                     BY_WTA
## 
## Model Test User Model:
##                                               Standard      Scaled
##   Test Statistic                              3678.537    3267.595
##   Degrees of freedom                               338         338
##   P-value (Chi-square)                           0.000       0.000
##   Scaling correction factor                                  1.126
##     Yuan-Bentler correction (Mplus variant)                       
##   Test statistic for each group:
##     0                                         1599.587    1420.892
##     1                                         2078.949    1846.703
## 
## Parameter Estimates:
## 
##   Standard errors                             Sandwich
##   Information bread                           Observed
##   Observed information based on                Hessian
## 
## 
## Group 1 [0]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english =~                                                   
##     Stst1vc (.p1.)    0.490    0.042   11.781    0.000    0.408
##     Stst19d (.p2.)    0.669    0.014   48.664    0.000    0.642
##     Stst20s (.p3.)    0.665    0.014   46.410    0.000    0.637
##     Stst21c (.p4.)    0.742    0.013   56.244    0.000    0.716
##     Stst22p (.p5.)    0.808    0.014   55.773    0.000    0.780
##     Stst23n (.p6.)    0.835    0.017   49.265    0.000    0.802
##     Stst24x (.p7.)    0.655    0.016   40.443    0.000    0.624
##     Stst26r (.p8.)    0.597    0.039   15.399    0.000    0.521
##     Stst31b (.p9.)    0.309    0.022   14.145    0.000    0.266
##     Stst34r (.10.)    0.289    0.038    7.650    0.000    0.215
##   math =~                                                      
##     Stst1vc (.11.)    0.363    0.046    7.858    0.000    0.272
##     Stst5mt (.12.)    0.724    0.017   41.584    0.000    0.690
##     Stst25w (.13.)    0.559    0.014   39.318    0.000    0.531
##     Stst26r (.14.)    0.349    0.042    8.287    0.000    0.267
##     Stst32r (.15.)    0.622    0.016   39.121    0.000    0.591
##     Stst33h (.16.)    0.623    0.016   39.334    0.000    0.592
##     Stst34r (.17.)    0.252    0.041    6.213    0.000    0.173
##   speed =~                                                     
##     Stst34r (.18.)    0.484    0.021   22.561    0.000    0.442
##     Stst35t (.19.)    1.193    0.035   33.611    0.000    1.123
##     Stst36c (.20.)    0.784    0.025   31.453    0.000    0.735
##     Stst37b (.21.)    0.722    0.026   28.068    0.000    0.672
##   spatial =~                                                   
##     Stst28m (.22.)    0.625    0.018   34.353    0.000    0.589
##     Sts292D (.23.)    0.713    0.018   39.987    0.000    0.678
##     Sts303D (.24.)    0.661    0.016   40.248    0.000    0.629
##     Stst31b (.25.)    0.671    0.025   26.409    0.000    0.621
##     Stst37b (.26.)    0.134    0.022    6.019    0.000    0.090
##  ci.upper   Std.lv  Std.all
##                            
##     0.572    0.490    0.476
##     0.696    0.669    0.737
##     0.693    0.665    0.670
##     0.767    0.742    0.767
##     0.837    0.808    0.801
##     0.868    0.835    0.721
##     0.687    0.655    0.577
##     0.673    0.597    0.564
##     0.351    0.309    0.260
##     0.364    0.289    0.251
##                            
##     0.453    0.363    0.352
##     0.758    0.724    0.697
##     0.587    0.559    0.674
##     0.432    0.349    0.330
##     0.653    0.622    0.750
##     0.655    0.623    0.794
##     0.332    0.252    0.219
##                            
##     0.526    0.484    0.420
##     1.262    1.193    0.715
##     0.833    0.784    0.608
##     0.773    0.722    0.583
##                            
##     0.661    0.625    0.727
##     0.748    0.713    0.640
##     0.693    0.661    0.694
##     0.721    0.671    0.566
##     0.177    0.134    0.108
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english ~~                                                   
##     math              0.869    0.010   86.350    0.000    0.849
##     speed             0.353    0.024   14.525    0.000    0.306
##     spatial           0.689    0.017   40.224    0.000    0.655
##   math ~~                                                      
##     speed             0.319    0.025   12.763    0.000    0.270
##     spatial           0.737    0.017   43.609    0.000    0.704
##   speed ~~                                                     
##     spatial           0.368    0.028   13.255    0.000    0.314
##  ci.upper   Std.lv  Std.all
##                            
##     0.888    0.869    0.869
##     0.401    0.353    0.353
##     0.722    0.689    0.689
##                            
##     0.368    0.319    0.319
##     0.771    0.737    0.737
##                            
##     0.423    0.368    0.368
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stest1vocab      -1.155    0.023  -50.360    0.000   -1.200
##    .Stst19dsgsdwrd   -0.992    0.018  -53.776    0.000   -1.028
##    .Stest20spellng   -0.848    0.021  -39.900    0.000   -0.890
##    .Stest21cptlztn   -1.167    0.020  -58.007    0.000   -1.206
##    .Stest22puncttn   -1.226    0.021  -57.496    0.000   -1.268
##    .Stest23english   -1.062    0.026  -41.362    0.000   -1.113
##    .Stest24exprssn   -0.965    0.025  -38.928    0.000   -1.014
##    .Stst26rdngcmpr   -1.292    0.023  -56.802    0.000   -1.337
##    .Stst31bstrctrs   -1.070    0.024  -43.766    0.000   -1.118
##    .Stst34rthcmptt   -1.153    0.025  -46.702    0.000   -1.201
##    .Stest5math       -0.814    0.022  -36.442    0.000   -0.857
##    .Stst25wrdfnctn   -0.871    0.017  -52.726    0.000   -0.903
##    .Stst32rthrsnng   -1.052    0.018  -59.194    0.000   -1.087
##    .Stst33hghschlm   -0.875    0.016  -53.483    0.000   -0.907
##    .Stest35tblrdng   -0.712    0.037  -19.463    0.000   -0.784
##    .Stst36clrclchc   -0.032    0.028   -1.139    0.255   -0.086
##    .Stst37bjctnspc   -0.318    0.027  -11.957    0.000   -0.370
##    .Stst28mchnclrs   -0.715    0.019  -36.895    0.000   -0.753
##    .Stst29vslztn2D   -0.512    0.023  -22.047    0.000   -0.557
##    .Stst30vslztn3D   -0.723    0.020  -35.874    0.000   -0.762
##  ci.upper   Std.lv  Std.all
##    -1.110   -1.155   -1.122
##    -0.956   -0.992   -1.092
##    -0.806   -0.848   -0.855
##    -1.128   -1.167   -1.207
##    -1.184   -1.226   -1.215
##    -1.012   -1.062   -0.917
##    -0.916   -0.965   -0.850
##    -1.248   -1.292   -1.222
##    -1.022   -1.070   -0.903
##    -1.104   -1.153   -1.001
##    -0.770   -0.814   -0.783
##    -0.838   -0.871   -1.050
##    -1.017   -1.052   -1.267
##    -0.843   -0.875   -1.114
##    -0.640   -0.712   -0.427
##     0.023   -0.032   -0.025
##    -0.266   -0.318   -0.257
##    -0.677   -0.715   -0.832
##    -0.466   -0.512   -0.459
##    -0.683   -0.723   -0.760
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stest1vocab       0.378    0.013   28.551    0.000    0.353
##    .Stst19dsgsdwrd    0.377    0.014   26.911    0.000    0.349
##    .Stest20spellng    0.542    0.017   31.525    0.000    0.508
##    .Stest21cptlztn    0.385    0.015   25.142    0.000    0.355
##    .Stest22puncttn    0.365    0.013   29.218    0.000    0.341
##    .Stest23english    0.645    0.024   27.175    0.000    0.599
##    .Stest24exprssn    0.860    0.025   33.905    0.000    0.810
##    .Stst26rdngcmpr    0.279    0.011   25.149    0.000    0.257
##    .Stst31bstrctrs    0.574    0.022   26.015    0.000    0.530
##    .Stst34rthcmptt    0.642    0.030   21.327    0.000    0.583
##    .Stest5math        0.555    0.021   26.584    0.000    0.514
##    .Stst25wrdfnctn    0.376    0.012   31.211    0.000    0.352
##    .Stst32rthrsnng    0.302    0.011   28.467    0.000    0.281
##    .Stst33hghschlm    0.228    0.009   25.416    0.000    0.211
##    .Stest35tblrdng    1.361    0.076   17.939    0.000    1.212
##    .Stst36clrclchc    1.047    0.041   25.343    0.000    0.966
##    .Stst37bjctnspc    0.925    0.036   25.958    0.000    0.855
##    .Stst28mchnclrs    0.348    0.016   21.868    0.000    0.317
##    .Stst29vslztn2D    0.732    0.026   28.058    0.000    0.681
##    .Stst30vslztn3D    0.469    0.017   27.506    0.000    0.435
##     english           1.000                               1.000
##     math              1.000                               1.000
##     speed             1.000                               1.000
##     spatial           1.000                               1.000
##  ci.upper   Std.lv  Std.all
##     0.404    0.378    0.357
##     0.404    0.377    0.457
##     0.575    0.542    0.550
##     0.415    0.385    0.412
##     0.390    0.365    0.359
##     0.692    0.645    0.481
##     0.909    0.860    0.667
##     0.300    0.279    0.249
##     0.617    0.574    0.409
##     0.701    0.642    0.484
##     0.596    0.555    0.514
##     0.399    0.376    0.546
##     0.322    0.302    0.438
##     0.246    0.228    0.370
##     1.509    1.361    0.489
##     1.128    1.047    0.630
##     0.995    0.925    0.602
##     0.380    0.348    0.471
##     0.783    0.732    0.590
##     0.502    0.469    0.518
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
## 
## 
## Group 2 [1]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english =~                                                   
##     Stst1vc (.p1.)    0.490    0.042   11.781    0.000    0.408
##     Stst19d (.p2.)    0.669    0.014   48.664    0.000    0.642
##     Stst20s (.p3.)    0.665    0.014   46.410    0.000    0.637
##     Stst21c (.p4.)    0.742    0.013   56.244    0.000    0.716
##     Stst22p (.p5.)    0.808    0.014   55.773    0.000    0.780
##     Stst23n (.p6.)    0.835    0.017   49.265    0.000    0.802
##     Stst24x (.p7.)    0.655    0.016   40.443    0.000    0.624
##     Stst26r (.p8.)    0.597    0.039   15.399    0.000    0.521
##     Stst31b (.p9.)    0.309    0.022   14.145    0.000    0.266
##     Stst34r (.10.)    0.289    0.038    7.650    0.000    0.215
##   math =~                                                      
##     Stst1vc (.11.)    0.363    0.046    7.858    0.000    0.272
##     Stst5mt (.12.)    0.724    0.017   41.584    0.000    0.690
##     Stst25w (.13.)    0.559    0.014   39.318    0.000    0.531
##     Stst26r (.14.)    0.349    0.042    8.287    0.000    0.267
##     Stst32r (.15.)    0.622    0.016   39.121    0.000    0.591
##     Stst33h (.16.)    0.623    0.016   39.334    0.000    0.592
##     Stst34r (.17.)    0.252    0.041    6.213    0.000    0.173
##   speed =~                                                     
##     Stst34r (.18.)    0.484    0.021   22.561    0.000    0.442
##     Stst35t (.19.)    1.193    0.035   33.611    0.000    1.123
##     Stst36c (.20.)    0.784    0.025   31.453    0.000    0.735
##     Stst37b (.21.)    0.722    0.026   28.068    0.000    0.672
##   spatial =~                                                   
##     Stst28m (.22.)    0.625    0.018   34.353    0.000    0.589
##     Sts292D (.23.)    0.713    0.018   39.987    0.000    0.678
##     Sts303D (.24.)    0.661    0.016   40.248    0.000    0.629
##     Stst31b (.25.)    0.671    0.025   26.409    0.000    0.621
##     Stst37b (.26.)    0.134    0.022    6.019    0.000    0.090
##  ci.upper   Std.lv  Std.all
##                            
##     0.572    0.478    0.506
##     0.696    0.653    0.713
##     0.693    0.649    0.671
##     0.767    0.723    0.728
##     0.837    0.788    0.806
##     0.868    0.815    0.734
##     0.687    0.639    0.582
##     0.673    0.582    0.594
##     0.351    0.301    0.284
##     0.364    0.282    0.245
##                            
##     0.453    0.304    0.322
##     0.758    0.608    0.612
##     0.587    0.469    0.614
##     0.432    0.293    0.299
##     0.653    0.522    0.701
##     0.655    0.523    0.753
##     0.332    0.212    0.184
##                            
##     0.526    0.479    0.416
##     1.262    1.181    0.727
##     0.833    0.776    0.604
##     0.773    0.715    0.623
##                            
##     0.661    0.434    0.683
##     0.748    0.495    0.509
##     0.693    0.459    0.595
##     0.721    0.466    0.440
##     0.177    0.093    0.081
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english ~~                                                   
##     math              0.685    0.031   22.212    0.000    0.624
##     speed             0.379    0.025   15.243    0.000    0.330
##     spatial           0.471    0.022   21.366    0.000    0.427
##   math ~~                                                      
##     speed             0.243    0.020   12.367    0.000    0.205
##     spatial           0.442    0.025   17.586    0.000    0.392
##   speed ~~                                                     
##     spatial           0.228    0.020   11.578    0.000    0.190
##  ci.upper   Std.lv  Std.all
##                            
##     0.745    0.836    0.836
##     0.427    0.392    0.392
##     0.514    0.695    0.695
##                            
##     0.282    0.293    0.293
##     0.491    0.758    0.758
##                            
##     0.267    0.332    0.332
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stest1vocab      -1.339    0.016  -83.554    0.000   -1.370
##    .Stst19dsgsdwrd   -0.878    0.016  -54.059    0.000   -0.910
##    .Stest20spellng   -0.450    0.017  -26.686    0.000   -0.483
##    .Stest21cptlztn   -0.899    0.017  -51.477    0.000   -0.934
##    .Stest22puncttn   -0.929    0.017  -53.286    0.000   -0.963
##    .Stest23english   -0.744    0.019  -38.449    0.000   -0.781
##    .Stest24exprssn   -0.704    0.019  -37.099    0.000   -0.742
##    .Stst26rdngcmpr   -1.226    0.017  -72.842    0.000   -1.259
##    .Stst31bstrctrs   -1.260    0.019  -65.843    0.000   -1.297
##    .Stst34rthcmptt   -1.004    0.021  -47.990    0.000   -1.045
##    .Stest5math       -0.965    0.017  -55.615    0.000   -0.999
##    .Stst25wrdfnctn   -0.788    0.014  -57.181    0.000   -0.816
##    .Stst32rthrsnng   -1.184    0.013  -92.849    0.000   -1.209
##    .Stst33hghschlm   -0.942    0.012  -78.389    0.000   -0.966
##    .Stest35tblrdng   -0.524    0.029  -17.830    0.000   -0.582
##    .Stst36clrclchc    0.300    0.023   13.284    0.000    0.256
##    .Stst37bjctnspc   -0.217    0.021  -10.567    0.000   -0.257
##    .Stst28mchnclrs   -1.323    0.011 -124.285    0.000   -1.344
##    .Stst29vslztn2D   -0.916    0.017  -52.801    0.000   -0.950
##    .Stst30vslztn3D   -0.982    0.014  -72.639    0.000   -1.008
##  ci.upper   Std.lv  Std.all
##    -1.307   -1.339   -1.417
##    -0.846   -0.878   -0.960
##    -0.417   -0.450   -0.466
##    -0.865   -0.899   -0.905
##    -0.895   -0.929   -0.949
##    -0.706   -0.744   -0.670
##    -0.667   -0.704   -0.641
##    -1.193   -1.226   -1.250
##    -1.222   -1.260   -1.189
##    -0.963   -1.004   -0.871
##    -0.931   -0.965   -0.971
##    -0.761   -0.788   -1.033
##    -1.159   -1.184   -1.589
##    -0.919   -0.942   -1.357
##    -0.466   -0.524   -0.323
##     0.344    0.300    0.233
##    -0.176   -0.217   -0.189
##    -1.303   -1.323   -2.083
##    -0.882   -0.916   -0.942
##    -0.955   -0.982   -1.274
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stest1vocab       0.328    0.010   33.988    0.000    0.309
##    .Stst19dsgsdwrd    0.412    0.012   34.908    0.000    0.388
##    .Stest20spellng    0.514    0.014   37.489    0.000    0.487
##    .Stest21cptlztn    0.464    0.014   33.629    0.000    0.437
##    .Stest22puncttn    0.336    0.011   30.650    0.000    0.315
##    .Stest23english    0.568    0.017   33.821    0.000    0.535
##    .Stest24exprssn    0.800    0.021   37.830    0.000    0.758
##    .Stst26rdngcmpr    0.252    0.008   30.313    0.000    0.235
##    .Stst31bstrctrs    0.620    0.017   35.902    0.000    0.586
##    .Stst34rthcmptt    0.707    0.027   26.023    0.000    0.654
##    .Stest5math        0.618    0.017   35.613    0.000    0.584
##    .Stst25wrdfnctn    0.363    0.011   34.531    0.000    0.342
##    .Stst32rthrsnng    0.282    0.008   34.254    0.000    0.266
##    .Stst33hghschlm    0.209    0.007   29.344    0.000    0.195
##    .Stest35tblrdng    1.241    0.067   18.544    0.000    1.110
##    .Stst36clrclchc    1.050    0.033   32.026    0.000    0.986
##    .Stst37bjctnspc    0.753    0.028   26.583    0.000    0.697
##    .Stst28mchnclrs    0.215    0.007   32.089    0.000    0.202
##    .Stst29vslztn2D    0.700    0.019   36.866    0.000    0.663
##    .Stst30vslztn3D    0.383    0.011   34.809    0.000    0.362
##     english           0.952    0.038   25.049    0.000    0.877
##     math              0.705    0.043   16.345    0.000    0.620
##     speed             0.981    0.059   16.623    0.000    0.865
##     spatial           0.482    0.028   17.114    0.000    0.427
##  ci.upper   Std.lv  Std.all
##     0.347    0.328    0.367
##     0.435    0.412    0.491
##     0.540    0.514    0.549
##     0.491    0.464    0.470
##     0.358    0.336    0.351
##     0.601    0.568    0.461
##     0.841    0.800    0.662
##     0.268    0.252    0.261
##     0.654    0.620    0.552
##     0.761    0.707    0.533
##     0.652    0.618    0.626
##     0.384    0.363    0.623
##     0.298    0.282    0.508
##     0.223    0.209    0.432
##     1.373    1.241    0.471
##     1.114    1.050    0.635
##     0.808    0.753    0.571
##     0.229    0.215    0.534
##     0.737    0.700    0.741
##     0.405    0.383    0.645
##     1.026    1.000    1.000
##     0.789    1.000    1.000
##     1.096    1.000    1.000
##     0.537    1.000    1.000
lavTestScore(metric, release = 1:26) 
## Warning: lavaan->lavTestScore():  
##    se is not `standard'; not implemented yet; falling back to 
##    ordinary score test
## $test
## 
## total score test:
## 
##    test      X2 df p.value
## 1 score 304.318 26       0
## 
## $uni
## 
## univariate score tests:
## 
##      lhs op    rhs     X2 df p.value
## 1   .p1. ==  .p81. 31.462  1   0.000
## 2   .p2. ==  .p82. 31.410  1   0.000
## 3   .p3. ==  .p83.  0.479  1   0.489
## 4   .p4. ==  .p84. 13.716  1   0.000
## 5   .p5. ==  .p85.  3.070  1   0.080
## 6   .p6. ==  .p86. 14.217  1   0.000
## 7   .p7. ==  .p87. 14.056  1   0.000
## 8   .p8. ==  .p88.  7.267  1   0.007
## 9   .p9. ==  .p89. 37.614  1   0.000
## 10 .p10. ==  .p90.  0.316  1   0.574
## 11 .p11. ==  .p91. 30.202  1   0.000
## 12 .p12. ==  .p92.  1.979  1   0.159
## 13 .p13. ==  .p93. 92.543  1   0.000
## 14 .p14. ==  .p94.  9.880  1   0.002
## 15 .p15. ==  .p95.  4.008  1   0.045
## 16 .p16. ==  .p96.  0.001  1   0.979
## 17 .p17. ==  .p97.  0.033  1   0.856
## 18 .p18. ==  .p98.  1.365  1   0.243
## 19 .p19. ==  .p99.  0.000  1   0.994
## 20 .p20. == .p100.  0.961  1   0.327
## 21 .p21. == .p101.  0.000  1   0.994
## 22 .p22. == .p102. 94.547  1   0.000
## 23 .p23. == .p103. 16.481  1   0.000
## 24 .p24. == .p104.  0.645  1   0.422
## 25 .p25. == .p105. 46.734  1   0.000
## 26 .p26. == .p106.  0.504  1   0.478
metric2<-cfa(chc.factor.model, data=dgroup, group="sex", meanstructure=TRUE, sampling.weights="BY_WTA", std.lv=T, group.equal=c("loadings"), group.partial=c("spatial=~Stest28mechanicalreasoning", "math=~Stest25wordfunctions"))
fitMeasures(metric2, c("chisq", "df", "pvalue", "cfi", "rmsea", "srmr", "aic", "bic"))
##      chisq         df     pvalue        cfi      rmsea       srmr 
##   3481.375    336.000      0.000      0.945      0.055      0.046 
##        aic        bic 
## 291375.106 292207.590
Mc(metric2)
## [1] 0.7722124
summary(metric2, standardized=T, ci=T)
## lavaan 0.6-18 ended normally after 81 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                       148
##   Number of equality constraints                    24
## 
##   Number of observations per group:                   
##     0                                             2443
##     1                                             3642
##   Sampling weights variable                     BY_WTA
## 
## Model Test User Model:
##                                               Standard      Scaled
##   Test Statistic                              3481.375    3092.289
##   Degrees of freedom                               336         336
##   P-value (Chi-square)                           0.000       0.000
##   Scaling correction factor                                  1.126
##     Yuan-Bentler correction (Mplus variant)                       
##   Test statistic for each group:
##     0                                         1503.010    1335.030
##     1                                         1978.365    1757.258
## 
## Parameter Estimates:
## 
##   Standard errors                             Sandwich
##   Information bread                           Observed
##   Observed information based on                Hessian
## 
## 
## Group 1 [0]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english =~                                                   
##     Stst1vc (.p1.)    0.487    0.039   12.472    0.000    0.410
##     Stst19d (.p2.)    0.668    0.014   48.564    0.000    0.641
##     Stst20s (.p3.)    0.664    0.014   46.262    0.000    0.636
##     Stst21c (.p4.)    0.740    0.013   56.045    0.000    0.715
##     Stst22p (.p5.)    0.807    0.015   55.471    0.000    0.778
##     Stst23n (.p6.)    0.834    0.017   49.016    0.000    0.800
##     Stst24x (.p7.)    0.654    0.016   40.291    0.000    0.622
##     Stst26r (.p8.)    0.597    0.036   16.371    0.000    0.525
##     Stst31b (.p9.)    0.283    0.023   12.511    0.000    0.238
##     Stst34r (.10.)    0.297    0.037    8.075    0.000    0.225
##   math =~                                                      
##     Stst1vc (.11.)    0.377    0.044    8.573    0.000    0.291
##     Stst5mt (.12.)    0.743    0.017   43.201    0.000    0.709
##     Stst25w           0.476    0.018   26.562    0.000    0.441
##     Stst26r (.14.)    0.359    0.040    8.942    0.000    0.280
##     Stst32r (.15.)    0.640    0.016   40.041    0.000    0.609
##     Stst33h (.16.)    0.640    0.016   40.312    0.000    0.609
##     Stst34r (.17.)    0.250    0.041    6.168    0.000    0.170
##   speed =~                                                     
##     Stst34r (.18.)    0.484    0.021   22.614    0.000    0.442
##     Stst35t (.19.)    1.194    0.036   33.616    0.000    1.124
##     Stst36c (.20.)    0.785    0.025   31.411    0.000    0.736
##     Stst37b (.21.)    0.722    0.026   28.013    0.000    0.671
##   spatial =~                                                   
##     Stst28m           0.708    0.018   39.675    0.000    0.673
##     Sts292D (.23.)    0.667    0.019   36.006    0.000    0.631
##     Sts303D (.24.)    0.611    0.017   35.794    0.000    0.577
##     Stst31b (.25.)    0.657    0.026   25.323    0.000    0.606
##     Stst37b (.26.)    0.126    0.021    6.073    0.000    0.085
##  ci.upper   Std.lv  Std.all
##                            
##     0.563    0.487    0.470
##     0.695    0.668    0.736
##     0.692    0.664    0.670
##     0.766    0.740    0.766
##     0.835    0.807    0.800
##     0.867    0.834    0.720
##     0.686    0.654    0.576
##     0.668    0.597    0.561
##     0.327    0.283    0.243
##     0.369    0.297    0.257
##                            
##     0.463    0.377    0.364
##     0.777    0.743    0.708
##     0.511    0.476    0.611
##     0.438    0.359    0.337
##     0.672    0.640    0.761
##     0.671    0.640    0.803
##     0.329    0.250    0.216
##                            
##     0.525    0.484    0.419
##     1.263    1.194    0.715
##     0.834    0.785    0.609
##     0.772    0.722    0.583
##                            
##     0.743    0.708    0.787
##     0.703    0.667    0.609
##     0.644    0.611    0.657
##     0.708    0.657    0.565
##     0.167    0.126    0.102
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english ~~                                                   
##     math              0.865    0.010   83.548    0.000    0.845
##     speed             0.353    0.024   14.531    0.000    0.306
##     spatial           0.699    0.017   41.691    0.000    0.666
##   math ~~                                                      
##     speed             0.319    0.025   12.833    0.000    0.270
##     spatial           0.747    0.016   45.273    0.000    0.714
##   speed ~~                                                     
##     spatial           0.364    0.027   13.272    0.000    0.311
##  ci.upper   Std.lv  Std.all
##                            
##     0.885    0.865    0.865
##     0.401    0.353    0.353
##     0.732    0.699    0.699
##                            
##     0.367    0.319    0.319
##     0.779    0.747    0.747
##                            
##     0.418    0.364    0.364
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stest1vocab      -1.155    0.023  -50.360    0.000   -1.200
##    .Stst19dsgsdwrd   -0.992    0.018  -53.776    0.000   -1.028
##    .Stest20spellng   -0.848    0.021  -39.900    0.000   -0.890
##    .Stest21cptlztn   -1.167    0.020  -58.007    0.000   -1.206
##    .Stest22puncttn   -1.226    0.021  -57.496    0.000   -1.268
##    .Stest23english   -1.062    0.026  -41.362    0.000   -1.113
##    .Stest24exprssn   -0.965    0.025  -38.928    0.000   -1.014
##    .Stst26rdngcmpr   -1.292    0.023  -56.802    0.000   -1.337
##    .Stst31bstrctrs   -1.070    0.024  -43.766    0.000   -1.118
##    .Stst34rthcmptt   -1.153    0.025  -46.702    0.000   -1.201
##    .Stest5math       -0.814    0.022  -36.442    0.000   -0.857
##    .Stst25wrdfnctn   -0.871    0.017  -52.726    0.000   -0.903
##    .Stst32rthrsnng   -1.052    0.018  -59.194    0.000   -1.087
##    .Stst33hghschlm   -0.875    0.016  -53.483    0.000   -0.907
##    .Stest35tblrdng   -0.712    0.037  -19.463    0.000   -0.784
##    .Stst36clrclchc   -0.032    0.028   -1.139    0.255   -0.086
##    .Stst37bjctnspc   -0.318    0.027  -11.957    0.000   -0.370
##    .Stst28mchnclrs   -0.715    0.019  -36.895    0.000   -0.753
##    .Stst29vslztn2D   -0.512    0.023  -22.047    0.000   -0.557
##    .Stst30vslztn3D   -0.723    0.020  -35.874    0.000   -0.762
##  ci.upper   Std.lv  Std.all
##    -1.110   -1.155   -1.115
##    -0.956   -0.992   -1.094
##    -0.806   -0.848   -0.855
##    -1.128   -1.167   -1.208
##    -1.184   -1.226   -1.216
##    -1.012   -1.062   -0.918
##    -0.916   -0.965   -0.850
##    -1.248   -1.292   -1.214
##    -1.022   -1.070   -0.919
##    -1.104   -1.153   -0.998
##    -0.770   -0.814   -0.775
##    -0.838   -0.871   -1.119
##    -1.017   -1.052   -1.250
##    -0.843   -0.875   -1.098
##    -0.640   -0.712   -0.427
##     0.023   -0.032   -0.025
##    -0.266   -0.318   -0.257
##    -0.677   -0.715   -0.795
##    -0.466   -0.512   -0.468
##    -0.683   -0.723   -0.778
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stest1vocab       0.375    0.013   28.283    0.000    0.349
##    .Stst19dsgsdwrd    0.376    0.014   26.905    0.000    0.349
##    .Stest20spellng    0.542    0.017   31.530    0.000    0.508
##    .Stest21cptlztn    0.385    0.015   25.159    0.000    0.355
##    .Stest22puncttn    0.366    0.013   29.233    0.000    0.341
##    .Stest23english    0.645    0.024   27.165    0.000    0.598
##    .Stest24exprssn    0.860    0.025   33.906    0.000    0.810
##    .Stst26rdngcmpr    0.277    0.011   25.007    0.000    0.255
##    .Stst31bstrctrs    0.584    0.022   26.364    0.000    0.540
##    .Stst34rthcmptt    0.642    0.030   21.363    0.000    0.583
##    .Stest5math        0.550    0.021   26.495    0.000    0.510
##    .Stst25wrdfnctn    0.379    0.012   31.876    0.000    0.356
##    .Stst32rthrsnng    0.298    0.011   28.079    0.000    0.277
##    .Stst33hghschlm    0.226    0.009   25.073    0.000    0.208
##    .Stest35tblrdng    1.360    0.076   17.898    0.000    1.211
##    .Stst36clrclchc    1.046    0.041   25.302    0.000    0.965
##    .Stst37bjctnspc    0.927    0.036   25.987    0.000    0.858
##    .Stst28mchnclrs    0.308    0.015   20.057    0.000    0.278
##    .Stst29vslztn2D    0.753    0.026   28.940    0.000    0.702
##    .Stst30vslztn3D    0.490    0.017   28.556    0.000    0.457
##     english           1.000                               1.000
##     math              1.000                               1.000
##     speed             1.000                               1.000
##     spatial           1.000                               1.000
##  ci.upper   Std.lv  Std.all
##     0.401    0.375    0.350
##     0.404    0.376    0.458
##     0.576    0.542    0.551
##     0.415    0.385    0.413
##     0.390    0.366    0.360
##     0.691    0.645    0.481
##     0.909    0.860    0.668
##     0.299    0.277    0.244
##     0.627    0.584    0.431
##     0.701    0.642    0.481
##     0.591    0.550    0.499
##     0.403    0.379    0.626
##     0.319    0.298    0.421
##     0.243    0.226    0.355
##     1.509    1.360    0.488
##     1.127    1.046    0.629
##     0.997    0.927    0.606
##     0.338    0.308    0.381
##     0.804    0.753    0.629
##     0.524    0.490    0.568
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
## 
## 
## Group 2 [1]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english =~                                                   
##     Stst1vc (.p1.)    0.487    0.039   12.472    0.000    0.410
##     Stst19d (.p2.)    0.668    0.014   48.564    0.000    0.641
##     Stst20s (.p3.)    0.664    0.014   46.262    0.000    0.636
##     Stst21c (.p4.)    0.740    0.013   56.045    0.000    0.715
##     Stst22p (.p5.)    0.807    0.015   55.471    0.000    0.778
##     Stst23n (.p6.)    0.834    0.017   49.016    0.000    0.800
##     Stst24x (.p7.)    0.654    0.016   40.291    0.000    0.622
##     Stst26r (.p8.)    0.597    0.036   16.371    0.000    0.525
##     Stst31b (.p9.)    0.283    0.023   12.511    0.000    0.238
##     Stst34r (.10.)    0.297    0.037    8.075    0.000    0.225
##   math =~                                                      
##     Stst1vc (.11.)    0.377    0.044    8.573    0.000    0.291
##     Stst5mt (.12.)    0.743    0.017   43.201    0.000    0.709
##     Stst25w           0.676    0.021   32.070    0.000    0.635
##     Stst26r (.14.)    0.359    0.040    8.942    0.000    0.280
##     Stst32r (.15.)    0.640    0.016   40.041    0.000    0.609
##     Stst33h (.16.)    0.640    0.016   40.312    0.000    0.609
##     Stst34r (.17.)    0.250    0.041    6.168    0.000    0.170
##   speed =~                                                     
##     Stst34r (.18.)    0.484    0.021   22.614    0.000    0.442
##     Stst35t (.19.)    1.194    0.036   33.616    0.000    1.124
##     Stst36c (.20.)    0.785    0.025   31.411    0.000    0.736
##     Stst37b (.21.)    0.722    0.026   28.013    0.000    0.671
##   spatial =~                                                   
##     Stst28m           0.467    0.021   22.632    0.000    0.427
##     Sts292D (.23.)    0.667    0.019   36.006    0.000    0.631
##     Sts303D (.24.)    0.611    0.017   35.794    0.000    0.577
##     Stst31b (.25.)    0.657    0.026   25.323    0.000    0.606
##     Stst37b (.26.)    0.126    0.021    6.073    0.000    0.085
##  ci.upper   Std.lv  Std.all
##                            
##     0.563    0.476    0.506
##     0.695    0.654    0.714
##     0.692    0.650    0.672
##     0.766    0.725    0.729
##     0.835    0.790    0.806
##     0.867    0.816    0.734
##     0.686    0.640    0.582
##     0.668    0.584    0.598
##     0.327    0.277    0.257
##     0.369    0.291    0.253
##                            
##     0.463    0.300    0.319
##     0.777    0.591    0.600
##     0.717    0.537    0.674
##     0.438    0.286    0.292
##     0.672    0.509    0.691
##     0.671    0.509    0.741
##     0.329    0.199    0.173
##                            
##     0.525    0.478    0.416
##     1.263    1.180    0.727
##     0.834    0.776    0.604
##     0.772    0.714    0.621
##                            
##     0.508    0.380    0.620
##     0.703    0.542    0.549
##     0.644    0.496    0.633
##     0.708    0.534    0.496
##     0.167    0.103    0.089
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english ~~                                                   
##     math              0.652    0.029   22.348    0.000    0.595
##     speed             0.378    0.025   15.140    0.000    0.329
##     spatial           0.549    0.025   21.792    0.000    0.499
##   math ~~                                                      
##     speed             0.229    0.019   12.286    0.000    0.193
##     spatial           0.484    0.026   18.359    0.000    0.432
##   speed ~~                                                     
##     spatial           0.267    0.023   11.530    0.000    0.222
##  ci.upper   Std.lv  Std.all
##                            
##     0.709    0.838    0.838
##     0.427    0.390    0.390
##     0.598    0.690    0.690
##                            
##     0.266    0.292    0.292
##     0.536    0.750    0.750
##                            
##     0.313    0.332    0.332
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stest1vocab      -1.339    0.016  -83.554    0.000   -1.370
##    .Stst19dsgsdwrd   -0.878    0.016  -54.059    0.000   -0.910
##    .Stest20spellng   -0.450    0.017  -26.686    0.000   -0.483
##    .Stest21cptlztn   -0.899    0.017  -51.477    0.000   -0.934
##    .Stest22puncttn   -0.929    0.017  -53.286    0.000   -0.963
##    .Stest23english   -0.744    0.019  -38.449    0.000   -0.781
##    .Stest24exprssn   -0.704    0.019  -37.099    0.000   -0.742
##    .Stst26rdngcmpr   -1.226    0.017  -72.842    0.000   -1.259
##    .Stst31bstrctrs   -1.260    0.019  -65.843    0.000   -1.297
##    .Stst34rthcmptt   -1.004    0.021  -47.990    0.000   -1.045
##    .Stest5math       -0.965    0.017  -55.615    0.000   -0.999
##    .Stst25wrdfnctn   -0.788    0.014  -57.181    0.000   -0.816
##    .Stst32rthrsnng   -1.184    0.013  -92.849    0.000   -1.209
##    .Stst33hghschlm   -0.942    0.012  -78.389    0.000   -0.966
##    .Stest35tblrdng   -0.524    0.029  -17.830    0.000   -0.582
##    .Stst36clrclchc    0.300    0.023   13.284    0.000    0.256
##    .Stst37bjctnspc   -0.217    0.021  -10.567    0.000   -0.257
##    .Stst28mchnclrs   -1.323    0.011 -124.285    0.000   -1.344
##    .Stst29vslztn2D   -0.916    0.017  -52.801    0.000   -0.950
##    .Stst30vslztn3D   -0.982    0.014  -72.639    0.000   -1.008
##  ci.upper   Std.lv  Std.all
##    -1.307   -1.339   -1.423
##    -0.846   -0.878   -0.959
##    -0.417   -0.450   -0.466
##    -0.865   -0.899   -0.905
##    -0.895   -0.929   -0.949
##    -0.706   -0.744   -0.669
##    -0.667   -0.704   -0.641
##    -1.193   -1.226   -1.255
##    -1.222   -1.260   -1.170
##    -0.963   -1.004   -0.873
##    -0.931   -0.965   -0.980
##    -0.761   -0.788   -0.989
##    -1.159   -1.184   -1.607
##    -0.919   -0.942   -1.373
##    -0.466   -0.524   -0.323
##     0.344    0.300    0.233
##    -0.176   -0.217   -0.189
##    -1.303   -1.323   -2.162
##    -0.882   -0.916   -0.928
##    -0.955   -0.982   -1.252
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stest1vocab       0.329    0.010   34.123    0.000    0.310
##    .Stst19dsgsdwrd    0.412    0.012   34.906    0.000    0.388
##    .Stest20spellng    0.513    0.014   37.506    0.000    0.486
##    .Stest21cptlztn    0.464    0.014   33.658    0.000    0.437
##    .Stest22puncttn    0.336    0.011   30.746    0.000    0.314
##    .Stest23english    0.568    0.017   33.822    0.000    0.535
##    .Stest24exprssn    0.800    0.021   37.836    0.000    0.758
##    .Stst26rdngcmpr    0.253    0.008   30.333    0.000    0.236
##    .Stst31bstrctrs    0.594    0.018   33.961    0.000    0.560
##    .Stst34rthcmptt    0.708    0.027   26.041    0.000    0.655
##    .Stest5math        0.621    0.017   35.726    0.000    0.587
##    .Stst25wrdfnctn    0.347    0.010   33.771    0.000    0.327
##    .Stst32rthrsnng    0.284    0.008   34.625    0.000    0.268
##    .Stst33hghschlm    0.212    0.007   30.197    0.000    0.199
##    .Stest35tblrdng    1.243    0.067   18.514    0.000    1.111
##    .Stst36clrclchc    1.049    0.033   31.908    0.000    0.985
##    .Stst37bjctnspc    0.752    0.028   26.583    0.000    0.696
##    .Stst28mchnclrs    0.231    0.007   33.555    0.000    0.217
##    .Stst29vslztn2D    0.679    0.019   35.425    0.000    0.641
##    .Stst30vslztn3D    0.369    0.011   33.327    0.000    0.347
##     english           0.957    0.038   24.914    0.000    0.882
##     math              0.632    0.038   16.464    0.000    0.557
##     speed             0.978    0.059   16.618    0.000    0.863
##     spatial           0.660    0.040   16.519    0.000    0.582
##  ci.upper   Std.lv  Std.all
##     0.348    0.329    0.371
##     0.435    0.412    0.491
##     0.540    0.513    0.549
##     0.491    0.464    0.469
##     0.357    0.336    0.350
##     0.601    0.568    0.461
##     0.841    0.800    0.661
##     0.269    0.253    0.265
##     0.629    0.594    0.512
##     0.761    0.708    0.536
##     0.655    0.621    0.640
##     0.368    0.347    0.546
##     0.300    0.284    0.523
##     0.226    0.212    0.451
##     1.374    1.243    0.471
##     1.114    1.049    0.635
##     0.807    0.752    0.569
##     0.244    0.231    0.616
##     0.717    0.679    0.698
##     0.391    0.369    0.600
##     1.033    1.000    1.000
##     0.707    1.000    1.000
##     1.093    1.000    1.000
##     0.738    1.000    1.000
lavTestScore(metric2, release = 1:24) 
## Warning: lavaan->lavTestScore():  
##    se is not `standard'; not implemented yet; falling back to 
##    ordinary score test
## $test
## 
## total score test:
## 
##    test      X2 df p.value
## 1 score 120.134 24       0
## 
## $uni
## 
## univariate score tests:
## 
##      lhs op    rhs     X2 df p.value
## 1   .p1. ==  .p81. 23.012  1   0.000
## 2   .p2. ==  .p82. 29.788  1   0.000
## 3   .p3. ==  .p83.  0.618  1   0.432
## 4   .p4. ==  .p84. 12.670  1   0.000
## 5   .p5. ==  .p85.  2.597  1   0.107
## 6   .p6. ==  .p86. 15.494  1   0.000
## 7   .p7. ==  .p87. 14.748  1   0.000
## 8   .p8. ==  .p88.  2.959  1   0.085
## 9   .p9. ==  .p89. 11.849  1   0.001
## 10 .p10. ==  .p90.  1.100  1   0.294
## 11 .p11. ==  .p91. 22.250  1   0.000
## 12 .p12. ==  .p92.  0.166  1   0.684
## 13 .p14. ==  .p94.  4.450  1   0.035
## 14 .p15. ==  .p95.  0.155  1   0.694
## 15 .p16. ==  .p96.  8.430  1   0.004
## 16 .p17. ==  .p97.  0.471  1   0.492
## 17 .p18. ==  .p98.  1.946  1   0.163
## 18 .p19. ==  .p99.  0.004  1   0.952
## 19 .p20. == .p100.  0.881  1   0.348
## 20 .p21. == .p101.  0.083  1   0.773
## 21 .p23. == .p103.  0.428  1   0.513
## 22 .p24. == .p104. 16.178  1   0.000
## 23 .p25. == .p105. 12.499  1   0.000
## 24 .p26. == .p106.  0.084  1   0.773
scalar<-cfa(chc.factor.model, data=dgroup, group="sex", meanstructure=TRUE, sampling.weights="BY_WTA", std.lv=T, group.equal=c("loadings", "intercepts"), group.partial=c("spatial=~Stest28mechanicalreasoning", "math=~Stest25wordfunctions"))
fitMeasures(scalar, c("chisq", "df", "pvalue", "cfi", "rmsea", "srmr", "aic", "bic"))
##      chisq         df     pvalue        cfi      rmsea       srmr 
##   4344.202    352.000      0.000      0.930      0.061      0.051 
##        aic        bic 
## 292205.933 292930.999
Mc(scalar)
## [1] 0.720298
summary(scalar, standardized=T, ci=T)
## lavaan 0.6-18 ended normally after 81 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                       152
##   Number of equality constraints                    44
## 
##   Number of observations per group:                   
##     0                                             2443
##     1                                             3642
##   Sampling weights variable                     BY_WTA
## 
## Model Test User Model:
##                                               Standard      Scaled
##   Test Statistic                              4344.202    3872.484
##   Degrees of freedom                               352         352
##   P-value (Chi-square)                           0.000       0.000
##   Scaling correction factor                                  1.122
##     Yuan-Bentler correction (Mplus variant)                       
##   Test statistic for each group:
##     0                                         1938.876    1728.342
##     1                                         2405.326    2144.142
## 
## Parameter Estimates:
## 
##   Standard errors                             Sandwich
##   Information bread                           Observed
##   Observed information based on                Hessian
## 
## 
## Group 1 [0]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english =~                                                   
##     Stst1vc (.p1.)    0.186    0.042    4.429    0.000    0.104
##     Stst19d (.p2.)    0.647    0.014   47.366    0.000    0.621
##     Stst20s (.p3.)    0.672    0.014   46.870    0.000    0.644
##     Stst21c (.p4.)    0.737    0.013   55.913    0.000    0.711
##     Stst22p (.p5.)    0.805    0.015   54.515    0.000    0.776
##     Stst23n (.p6.)    0.828    0.017   48.083    0.000    0.794
##     Stst24x (.p7.)    0.651    0.016   40.123    0.000    0.619
##     Stst26r (.p8.)    0.437    0.032   13.650    0.000    0.374
##     Stst31b (.p9.)    0.377    0.016   22.930    0.000    0.345
##     Stst34r (.10.)    0.285    0.031    9.060    0.000    0.223
##   math =~                                                      
##     Stst1vc (.11.)    0.706    0.047   15.168    0.000    0.615
##     Stst5mt (.12.)    0.735    0.017   43.160    0.000    0.701
##     Stst25w           0.461    0.018   25.254    0.000    0.426
##     Stst26r (.14.)    0.529    0.035   15.247    0.000    0.461
##     Stst32r (.15.)    0.628    0.016   38.782    0.000    0.596
##     Stst33h (.16.)    0.620    0.016   38.892    0.000    0.589
##     Stst34r (.17.)    0.256    0.035    7.419    0.000    0.189
##   speed =~                                                     
##     Stst34r (.18.)    0.480    0.022   22.259    0.000    0.438
##     Stst35t (.19.)    1.176    0.036   32.804    0.000    1.106
##     Stst36c (.20.)    0.798    0.024   32.649    0.000    0.750
##     Stst37b (.21.)    0.731    0.024   30.758    0.000    0.684
##   spatial =~                                                   
##     Stst28m           0.717    0.019   37.587    0.000    0.679
##     Sts292D (.23.)    0.682    0.019   36.457    0.000    0.645
##     Sts303D (.24.)    0.601    0.018   34.279    0.000    0.566
##     Stst31b (.25.)    0.569    0.020   28.747    0.000    0.530
##     Stst37b (.26.)    0.127    0.019    6.549    0.000    0.089
##  ci.upper   Std.lv  Std.all
##                            
##     0.268    0.186    0.175
##     0.674    0.647    0.723
##     0.700    0.672    0.672
##     0.763    0.737    0.767
##     0.834    0.805    0.803
##     0.862    0.828    0.718
##     0.682    0.651    0.574
##     0.500    0.437    0.407
##     0.409    0.377    0.323
##     0.347    0.285    0.247
##                            
##     0.798    0.706    0.663
##     0.768    0.735    0.700
##     0.497    0.461    0.590
##     0.597    0.529    0.493
##     0.660    0.628    0.747
##     0.651    0.620    0.780
##     0.324    0.256    0.222
##                            
##     0.522    0.480    0.416
##     1.246    1.176    0.706
##     0.846    0.798    0.615
##     0.777    0.731    0.590
##                            
##     0.754    0.717    0.786
##     0.718    0.682    0.619
##     0.635    0.601    0.645
##     0.608    0.569    0.487
##     0.164    0.127    0.102
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english ~~                                                   
##     math              0.889    0.011   78.857    0.000    0.867
##     speed             0.357    0.025   14.446    0.000    0.309
##     spatial           0.687    0.017   39.653    0.000    0.653
##   math ~~                                                      
##     speed             0.319    0.025   12.796    0.000    0.270
##     spatial           0.748    0.016   45.527    0.000    0.715
##   speed ~~                                                     
##     spatial           0.365    0.028   13.124    0.000    0.311
##  ci.upper   Std.lv  Std.all
##                            
##     0.912    0.889    0.889
##     0.405    0.357    0.357
##     0.721    0.687    0.687
##                            
##     0.368    0.319    0.319
##     0.780    0.748    0.748
##                            
##     0.420    0.365    0.365
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stst1vc (.57.)   -1.297    0.027  -47.511    0.000   -1.351
##    .Stst19d (.58.)   -1.101    0.018  -61.328    0.000   -1.136
##    .Stst20s (.59.)   -0.794    0.021  -37.150    0.000   -0.836
##    .Stst21c (.60.)   -1.211    0.021  -57.826    0.000   -1.252
##    .Stst22p (.61.)   -1.272    0.023  -54.912    0.000   -1.317
##    .Stst23n (.62.)   -1.101    0.025  -43.196    0.000   -1.151
##    .Stst24x (.63.)   -0.989    0.022  -44.677    0.000   -1.033
##    .Stst26r (.64.)   -1.357    0.026  -51.432    0.000   -1.409
##    .Stst31b (.65.)   -1.083    0.026  -41.699    0.000   -1.134
##    .Stst34r (.66.)   -1.216    0.025  -48.085    0.000   -1.266
##    .Stst5mt (.67.)   -0.879    0.022  -40.477    0.000   -0.922
##    .Stst25w (.68.)   -0.792    0.017  -47.547    0.000   -0.825
##    .Stst32r (.69.)   -1.111    0.018  -62.550    0.000   -1.146
##    .Stst33h (.70.)   -0.895    0.017  -51.763    0.000   -0.929
##    .Stst35t (.71.)   -0.804    0.035  -22.805    0.000   -0.873
##    .Stst36c (.72.)    0.030    0.026    1.141    0.254   -0.021
##    .Stst37b (.73.)   -0.337    0.025  -13.698    0.000   -0.385
##    .Stst28m (.74.)   -0.861    0.028  -30.946    0.000   -0.915
##    .Sts292D (.75.)   -0.506    0.023  -22.416    0.000   -0.550
##    .Sts303D (.76.)   -0.652    0.019  -33.484    0.000   -0.690
##  ci.upper   Std.lv  Std.all
##    -1.244   -1.297   -1.218
##    -1.066   -1.101   -1.229
##    -0.752   -0.794   -0.794
##    -1.170   -1.211   -1.261
##    -1.226   -1.272   -1.268
##    -1.051   -1.101   -0.954
##    -0.946   -0.989   -0.873
##    -1.305   -1.357   -1.263
##    -1.032   -1.083   -0.927
##    -1.167   -1.216   -1.055
##    -0.837   -0.879   -0.839
##    -0.759   -0.792   -1.013
##    -1.076   -1.111   -1.321
##    -0.861   -0.895   -1.126
##    -0.735   -0.804   -0.483
##     0.080    0.030    0.023
##    -0.289   -0.337   -0.272
##    -0.806   -0.861   -0.945
##    -0.462   -0.506   -0.459
##    -0.614   -0.652   -0.700
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stest1vocab       0.367    0.015   23.953    0.000    0.337
##    .Stst19dsgsdwrd    0.383    0.015   26.073    0.000    0.355
##    .Stest20spellng    0.548    0.018   31.250    0.000    0.514
##    .Stest21cptlztn    0.380    0.015   24.942    0.000    0.351
##    .Stest22puncttn    0.358    0.012   28.987    0.000    0.334
##    .Stest23english    0.646    0.024   27.080    0.000    0.599
##    .Stest24exprssn    0.860    0.025   33.757    0.000    0.810
##    .Stst26rdngcmpr    0.272    0.011   23.915    0.000    0.249
##    .Stst31bstrctrs    0.605    0.022   27.892    0.000    0.563
##    .Stst34rthcmptt    0.645    0.030   21.480    0.000    0.586
##    .Stest5math        0.560    0.021   26.691    0.000    0.519
##    .Stst25wrdfnctn    0.399    0.013   31.459    0.000    0.374
##    .Stst32rthrsnng    0.313    0.011   27.868    0.000    0.291
##    .Stst33hghschlm    0.247    0.009   26.135    0.000    0.228
##    .Stest35tblrdng    1.392    0.075   18.649    0.000    1.246
##    .Stst36clrclchc    1.045    0.042   24.793    0.000    0.962
##    .Stst37bjctnspc    0.918    0.036   25.692    0.000    0.848
##    .Stst28mchnclrs    0.317    0.017   18.355    0.000    0.283
##    .Stst29vslztn2D    0.748    0.026   28.392    0.000    0.696
##    .Stst30vslztn3D    0.507    0.018   28.601    0.000    0.472
##     english           1.000                               1.000
##     math              1.000                               1.000
##     speed             1.000                               1.000
##     spatial           1.000                               1.000
##  ci.upper   Std.lv  Std.all
##     0.397    0.367    0.324
##     0.412    0.383    0.478
##     0.582    0.548    0.548
##     0.410    0.380    0.412
##     0.382    0.358    0.356
##     0.692    0.646    0.485
##     0.910    0.860    0.670
##     0.294    0.272    0.235
##     0.648    0.605    0.443
##     0.704    0.645    0.486
##     0.601    0.560    0.509
##     0.424    0.399    0.652
##     0.335    0.313    0.442
##     0.265    0.247    0.391
##     1.538    1.392    0.502
##     1.127    1.045    0.621
##     0.988    0.918    0.598
##     0.350    0.317    0.381
##     0.800    0.748    0.617
##     0.542    0.507    0.584
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
## 
## 
## Group 2 [1]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english =~                                                   
##     Stst1vc (.p1.)    0.186    0.042    4.429    0.000    0.104
##     Stst19d (.p2.)    0.647    0.014   47.366    0.000    0.621
##     Stst20s (.p3.)    0.672    0.014   46.870    0.000    0.644
##     Stst21c (.p4.)    0.737    0.013   55.913    0.000    0.711
##     Stst22p (.p5.)    0.805    0.015   54.515    0.000    0.776
##     Stst23n (.p6.)    0.828    0.017   48.083    0.000    0.794
##     Stst24x (.p7.)    0.651    0.016   40.123    0.000    0.619
##     Stst26r (.p8.)    0.437    0.032   13.650    0.000    0.374
##     Stst31b (.p9.)    0.377    0.016   22.930    0.000    0.345
##     Stst34r (.10.)    0.285    0.031    9.060    0.000    0.223
##   math =~                                                      
##     Stst1vc (.11.)    0.706    0.047   15.168    0.000    0.615
##     Stst5mt (.12.)    0.735    0.017   43.160    0.000    0.701
##     Stst25w           0.644    0.021   31.210    0.000    0.604
##     Stst26r (.14.)    0.529    0.035   15.247    0.000    0.461
##     Stst32r (.15.)    0.628    0.016   38.782    0.000    0.596
##     Stst33h (.16.)    0.620    0.016   38.892    0.000    0.589
##     Stst34r (.17.)    0.256    0.035    7.419    0.000    0.189
##   speed =~                                                     
##     Stst34r (.18.)    0.480    0.022   22.259    0.000    0.438
##     Stst35t (.19.)    1.176    0.036   32.804    0.000    1.106
##     Stst36c (.20.)    0.798    0.024   32.649    0.000    0.750
##     Stst37b (.21.)    0.731    0.024   30.758    0.000    0.684
##   spatial =~                                                   
##     Stst28m           0.648    0.033   19.787    0.000    0.584
##     Sts292D (.23.)    0.682    0.019   36.457    0.000    0.645
##     Sts303D (.24.)    0.601    0.018   34.279    0.000    0.566
##     Stst31b (.25.)    0.569    0.020   28.747    0.000    0.530
##     Stst37b (.26.)    0.127    0.019    6.549    0.000    0.089
##  ci.upper   Std.lv  Std.all
##                            
##     0.268    0.185    0.200
##     0.674    0.645    0.706
##     0.700    0.670    0.682
##     0.763    0.734    0.735
##     0.834    0.803    0.816
##     0.862    0.825    0.740
##     0.682    0.649    0.588
##     0.500    0.436    0.448
##     0.409    0.376    0.352
##     0.347    0.284    0.247
##                            
##     0.798    0.565    0.609
##     0.768    0.588    0.595
##     0.685    0.516    0.648
##     0.597    0.423    0.436
##     0.660    0.502    0.679
##     0.651    0.496    0.721
##     0.324    0.205    0.178
##                            
##     0.522    0.475    0.413
##     1.246    1.164    0.718
##     0.846    0.789    0.611
##     0.777    0.723    0.630
##                            
##     0.712    0.453    0.703
##     0.718    0.477    0.492
##     0.635    0.420    0.553
##     0.608    0.398    0.372
##     0.164    0.088    0.077
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english ~~                                                   
##     math              0.696    0.030   22.828    0.000    0.636
##     speed             0.388    0.025   15.252    0.000    0.338
##     spatial           0.480    0.027   17.525    0.000    0.427
##   math ~~                                                      
##     speed             0.241    0.019   12.673    0.000    0.204
##     spatial           0.424    0.026   16.199    0.000    0.372
##   speed ~~                                                     
##     spatial           0.228    0.022   10.452    0.000    0.186
##  ci.upper   Std.lv  Std.all
##                            
##     0.756    0.873    0.873
##     0.438    0.394    0.394
##     0.534    0.690    0.690
##                            
##     0.279    0.305    0.305
##     0.475    0.757    0.757
##                            
##     0.271    0.330    0.330
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stst1vc (.57.)   -1.297    0.027  -47.511    0.000   -1.351
##    .Stst19d (.58.)   -1.101    0.018  -61.328    0.000   -1.136
##    .Stst20s (.59.)   -0.794    0.021  -37.150    0.000   -0.836
##    .Stst21c (.60.)   -1.211    0.021  -57.826    0.000   -1.252
##    .Stst22p (.61.)   -1.272    0.023  -54.912    0.000   -1.317
##    .Stst23n (.62.)   -1.101    0.025  -43.196    0.000   -1.151
##    .Stst24x (.63.)   -0.989    0.022  -44.677    0.000   -1.033
##    .Stst26r (.64.)   -1.357    0.026  -51.432    0.000   -1.409
##    .Stst31b (.65.)   -1.083    0.026  -41.699    0.000   -1.134
##    .Stst34r (.66.)   -1.216    0.025  -48.085    0.000   -1.266
##    .Stst5mt (.67.)   -0.879    0.022  -40.477    0.000   -0.922
##    .Stst25w (.68.)   -0.792    0.017  -47.547    0.000   -0.825
##    .Stst32r (.69.)   -1.111    0.018  -62.550    0.000   -1.146
##    .Stst33h (.70.)   -0.895    0.017  -51.763    0.000   -0.929
##    .Stst35t (.71.)   -0.804    0.035  -22.805    0.000   -0.873
##    .Stst36c (.72.)    0.030    0.026    1.141    0.254   -0.021
##    .Stst37b (.73.)   -0.337    0.025  -13.698    0.000   -0.385
##    .Stst28m (.74.)   -0.861    0.028  -30.946    0.000   -0.915
##    .Sts292D (.75.)   -0.506    0.023  -22.416    0.000   -0.550
##    .Sts303D (.76.)   -0.652    0.019  -33.484    0.000   -0.690
##     english           0.423    0.036   11.789    0.000    0.353
##     math             -0.099    0.031   -3.167    0.002   -0.160
##     speed             0.271    0.037    7.324    0.000    0.198
##     spatial          -0.644    0.033  -19.590    0.000   -0.708
##  ci.upper   Std.lv  Std.all
##    -1.244   -1.297   -1.398
##    -1.066   -1.101   -1.204
##    -0.752   -0.794   -0.809
##    -1.170   -1.211   -1.212
##    -1.226   -1.272   -1.293
##    -1.051   -1.101   -0.987
##    -0.946   -0.989   -0.896
##    -1.305   -1.357   -1.397
##    -1.032   -1.083   -1.015
##    -1.167   -1.216   -1.057
##    -0.837   -0.879   -0.890
##    -0.759   -0.792   -0.996
##    -1.076   -1.111   -1.502
##    -0.861   -0.895   -1.301
##    -0.735   -0.804   -0.496
##     0.080    0.030    0.023
##    -0.289   -0.337   -0.293
##    -0.806   -0.861   -1.336
##    -0.462   -0.506   -0.523
##    -0.614   -0.652   -0.859
##     0.494    0.425    0.425
##    -0.038   -0.123   -0.123
##     0.343    0.274    0.274
##    -0.579   -0.921   -0.921
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stest1vocab       0.325    0.011   30.042    0.000    0.304
##    .Stst19dsgsdwrd    0.420    0.012   35.078    0.000    0.396
##    .Stest20spellng    0.515    0.014   37.148    0.000    0.488
##    .Stest21cptlztn    0.459    0.014   33.703    0.000    0.432
##    .Stest22puncttn    0.324    0.011   30.604    0.000    0.303
##    .Stest23english    0.563    0.017   33.614    0.000    0.530
##    .Stest24exprssn    0.797    0.021   37.751    0.000    0.755
##    .Stst26rdngcmpr    0.253    0.008   30.128    0.000    0.236
##    .Stst31bstrctrs    0.635    0.018   35.704    0.000    0.600
##    .Stst34rthcmptt    0.708    0.027   26.200    0.000    0.655
##    .Stest5math        0.631    0.018   35.887    0.000    0.597
##    .Stst25wrdfnctn    0.366    0.011   34.235    0.000    0.345
##    .Stst32rthrsnng    0.295    0.009   34.337    0.000    0.278
##    .Stst33hghschlm    0.227    0.007   31.060    0.000    0.212
##    .Stest35tblrdng    1.270    0.067   18.923    0.000    1.138
##    .Stst36clrclchc    1.045    0.033   31.685    0.000    0.980
##    .Stst37bjctnspc    0.746    0.028   26.918    0.000    0.691
##    .Stst28mchnclrs    0.210    0.008   27.044    0.000    0.195
##    .Stst29vslztn2D    0.710    0.020   35.081    0.000    0.671
##    .Stst30vslztn3D    0.400    0.012   33.395    0.000    0.376
##     english           0.994    0.040   25.010    0.000    0.916
##     math              0.640    0.034   18.654    0.000    0.573
##     speed             0.979    0.058   16.774    0.000    0.864
##     spatial           0.488    0.044   11.162    0.000    0.403
##  ci.upper   Std.lv  Std.all
##     0.346    0.325    0.377
##     0.443    0.420    0.502
##     0.542    0.515    0.534
##     0.486    0.459    0.460
##     0.345    0.324    0.335
##     0.596    0.563    0.453
##     0.838    0.797    0.655
##     0.269    0.253    0.268
##     0.670    0.635    0.557
##     0.761    0.708    0.535
##     0.666    0.631    0.646
##     0.387    0.366    0.580
##     0.312    0.295    0.539
##     0.241    0.227    0.480
##     1.401    1.270    0.484
##     1.110    1.045    0.626
##     0.800    0.746    0.566
##     0.225    0.210    0.506
##     0.750    0.710    0.758
##     0.423    0.400    0.694
##     1.072    1.000    1.000
##     0.707    1.000    1.000
##     1.093    1.000    1.000
##     0.574    1.000    1.000
lavTestScore(scalar, release = 25:44) 
## Warning: lavaan->lavTestScore():  
##    se is not `standard'; not implemented yet; falling back to 
##    ordinary score test
## $test
## 
## total score test:
## 
##    test      X2 df p.value
## 1 score 811.527 20       0
## 
## $uni
## 
## univariate score tests:
## 
##      lhs op    rhs      X2 df p.value
## 1  .p57. == .p137. 159.014  1   0.000
## 2  .p58. == .p138.  66.786  1   0.000
## 3  .p59. == .p139.  76.309  1   0.000
## 4  .p60. == .p140.   0.000  1   0.985
## 5  .p61. == .p141.   0.130  1   0.718
## 6  .p62. == .p142.   0.947  1   0.330
## 7  .p63. == .p143.   1.142  1   0.285
## 8  .p64. == .p144.   0.292  1   0.589
## 9  .p65. == .p145.  33.469  1   0.000
## 10 .p66. == .p146.   4.032  1   0.045
## 11 .p67. == .p147.   2.519  1   0.113
## 12 .p68. == .p148. 151.028  1   0.000
## 13 .p69. == .p149.   4.780  1   0.029
## 14 .p70. == .p150.  10.606  1   0.001
## 15 .p71. == .p151.  21.643  1   0.000
## 16 .p72. == .p152.  35.696  1   0.000
## 17 .p73. == .p153.   0.327  1   0.567
## 18 .p74. == .p154. 333.514  1   0.000
## 19 .p75. == .p155.  17.610  1   0.000
## 20 .p76. == .p156. 138.215  1   0.000
scalar2<-cfa(chc.factor.model, data=dgroup, group="sex", meanstructure=TRUE, sampling.weights="BY_WTA", std.lv=T, group.equal=c("loadings", "intercepts"), group.partial=c("spatial=~Stest28mechanicalreasoning", "math=~Stest25wordfunctions", "Stest28mechanicalreasoning~1", "Stest1vocab~1", "Stest25wordfunctions~1"))
fitMeasures(scalar2, c("chisq", "df", "pvalue", "cfi", "rmsea", "srmr", "aic", "bic"))
##      chisq         df     pvalue        cfi      rmsea       srmr 
##   3701.089    349.000      0.000      0.941      0.056      0.048 
##        aic        bic 
## 291568.819 292314.027
Mc(scalar2)
## [1] 0.7592046
summary(scalar2, standardized=T, ci=T)
## lavaan 0.6-18 ended normally after 82 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                       152
##   Number of equality constraints                    41
## 
##   Number of observations per group:                   
##     0                                             2443
##     1                                             3642
##   Sampling weights variable                     BY_WTA
## 
## Model Test User Model:
##                                               Standard      Scaled
##   Test Statistic                              3701.089    3285.760
##   Degrees of freedom                               349         349
##   P-value (Chi-square)                           0.000       0.000
##   Scaling correction factor                                  1.126
##     Yuan-Bentler correction (Mplus variant)                       
##   Test statistic for each group:
##     0                                         1619.009    1437.328
##     1                                         2082.079    1848.432
## 
## Parameter Estimates:
## 
##   Standard errors                             Sandwich
##   Information bread                           Observed
##   Observed information based on                Hessian
## 
## 
## Group 1 [0]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english =~                                                   
##     Stst1vc (.p1.)    0.446    0.035   12.894    0.000    0.378
##     Stst19d (.p2.)    0.654    0.014   48.104    0.000    0.627
##     Stst20s (.p3.)    0.677    0.014   47.856    0.000    0.650
##     Stst21c (.p4.)    0.740    0.013   56.921    0.000    0.715
##     Stst22p (.p5.)    0.808    0.015   55.465    0.000    0.779
##     Stst23n (.p6.)    0.835    0.017   48.930    0.000    0.801
##     Stst24x (.p7.)    0.655    0.016   40.591    0.000    0.624
##     Stst26r (.p8.)    0.525    0.026   19.840    0.000    0.473
##     Stst31b (.p9.)    0.297    0.018   16.243    0.000    0.261
##     Stst34r (.10.)    0.283    0.029    9.647    0.000    0.226
##   math =~                                                      
##     Stst1vc (.11.)    0.422    0.039   10.791    0.000    0.346
##     Stst5mt (.12.)    0.742    0.017   43.911    0.000    0.709
##     Stst25w           0.475    0.018   26.540    0.000    0.440
##     Stst26r (.14.)    0.438    0.030   14.739    0.000    0.380
##     Stst32r (.15.)    0.639    0.016   40.087    0.000    0.608
##     Stst33h (.16.)    0.633    0.016   40.514    0.000    0.602
##     Stst34r (.17.)    0.267    0.032    8.327    0.000    0.204
##   speed =~                                                     
##     Stst34r (.18.)    0.482    0.021   22.475    0.000    0.440
##     Stst35t (.19.)    1.177    0.036   32.708    0.000    1.107
##     Stst36c (.20.)    0.799    0.025   32.395    0.000    0.751
##     Stst37b (.21.)    0.722    0.024   29.908    0.000    0.675
##   spatial =~                                                   
##     Stst28m           0.709    0.018   39.724    0.000    0.674
##     Sts292D (.23.)    0.681    0.018   37.724    0.000    0.646
##     Sts303D (.24.)    0.605    0.017   36.124    0.000    0.572
##     Stst31b (.25.)    0.641    0.022   29.632    0.000    0.598
##     Stst37b (.26.)    0.132    0.019    6.819    0.000    0.094
##  ci.upper   Std.lv  Std.all
##                            
##     0.514    0.446    0.430
##     0.680    0.654    0.726
##     0.705    0.677    0.675
##     0.766    0.740    0.767
##     0.836    0.808    0.802
##     0.868    0.835    0.721
##     0.687    0.655    0.577
##     0.577    0.525    0.491
##     0.332    0.297    0.255
##     0.341    0.283    0.245
##                            
##     0.499    0.422    0.407
##     0.775    0.742    0.706
##     0.510    0.475    0.610
##     0.496    0.438    0.410
##     0.671    0.639    0.759
##     0.663    0.633    0.796
##     0.329    0.267    0.231
##                            
##     0.524    0.482    0.418
##     1.248    1.177    0.707
##     0.848    0.799    0.616
##     0.770    0.722    0.584
##                            
##     0.744    0.709    0.788
##     0.716    0.681    0.618
##     0.638    0.605    0.653
##     0.683    0.641    0.551
##     0.170    0.132    0.107
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english ~~                                                   
##     math              0.867    0.010   83.162    0.000    0.847
##     speed             0.351    0.025   14.275    0.000    0.303
##     spatial           0.695    0.017   41.627    0.000    0.662
##   math ~~                                                      
##     speed             0.312    0.025   12.419    0.000    0.263
##     spatial           0.747    0.016   45.824    0.000    0.715
##   speed ~~                                                     
##     spatial           0.360    0.028   13.006    0.000    0.306
##  ci.upper   Std.lv  Std.all
##                            
##     0.887    0.867    0.867
##     0.399    0.351    0.351
##     0.727    0.695    0.695
##                            
##     0.361    0.312    0.312
##     0.779    0.747    0.747
##                            
##     0.415    0.360    0.360
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stst1vc          -1.155    0.023  -50.361    0.000   -1.200
##    .Stst19d (.58.)   -1.061    0.016  -67.747    0.000   -1.091
##    .Stst20s (.59.)   -0.752    0.019  -40.069    0.000   -0.789
##    .Stst21c (.60.)   -1.165    0.018  -63.972    0.000   -1.201
##    .Stst22p (.61.)   -1.220    0.020  -61.472    0.000   -1.259
##    .Stst23n (.62.)   -1.049    0.022  -46.960    0.000   -1.093
##    .Stst24x (.63.)   -0.948    0.020  -47.823    0.000   -0.987
##    .Stst26r (.64.)   -1.318    0.022  -59.422    0.000   -1.362
##    .Stst31b (.65.)   -1.060    0.023  -45.830    0.000   -1.105
##    .Stst34r (.66.)   -1.164    0.022  -51.809    0.000   -1.208
##    .Stst5mt (.67.)   -0.823    0.019  -42.704    0.000   -0.861
##    .Stst25w          -0.871    0.017  -52.726    0.000   -0.903
##    .Stst32r (.69.)   -1.062    0.016  -65.712    0.000   -1.094
##    .Stst33h (.70.)   -0.846    0.016  -54.505    0.000   -0.877
##    .Stst35t (.71.)   -0.772    0.034  -22.881    0.000   -0.838
##    .Stst36c (.72.)    0.051    0.025    2.044    0.041    0.002
##    .Stst37b (.73.)   -0.324    0.023  -13.987    0.000   -0.369
##    .Stst28m          -0.715    0.019  -36.895    0.000   -0.753
##    .Sts292D (.75.)   -0.556    0.021  -26.509    0.000   -0.597
##    .Sts303D (.76.)   -0.699    0.018  -38.478    0.000   -0.734
##  ci.upper   Std.lv  Std.all
##    -1.110   -1.155   -1.113
##    -1.030   -1.061   -1.179
##    -0.715   -0.752   -0.749
##    -1.129   -1.165   -1.207
##    -1.181   -1.220   -1.212
##    -1.005   -1.049   -0.906
##    -0.909   -0.948   -0.835
##    -1.275   -1.318   -1.233
##    -1.014   -1.060   -0.912
##    -1.120   -1.164   -1.008
##    -0.785   -0.823   -0.784
##    -0.838   -0.871   -1.119
##    -1.030   -1.062   -1.261
##    -0.816   -0.846   -1.064
##    -0.706   -0.772   -0.463
##     0.100    0.051    0.040
##    -0.278   -0.324   -0.262
##    -0.677   -0.715   -0.795
##    -0.515   -0.556   -0.505
##    -0.663   -0.699   -0.754
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stest1vocab       0.373    0.013   28.081    0.000    0.347
##    .Stst19dsgsdwrd    0.382    0.015   26.172    0.000    0.354
##    .Stest20spellng    0.549    0.018   31.251    0.000    0.515
##    .Stest21cptlztn    0.383    0.015   25.032    0.000    0.353
##    .Stest22puncttn    0.362    0.012   29.130    0.000    0.338
##    .Stest23english    0.643    0.024   27.124    0.000    0.596
##    .Stest24exprssn    0.859    0.025   33.817    0.000    0.809
##    .Stst26rdngcmpr    0.277    0.011   24.623    0.000    0.255
##    .Stst31bstrctrs    0.588    0.022   27.043    0.000    0.545
##    .Stst34rthcmptt    0.642    0.030   21.373    0.000    0.583
##    .Stest5math        0.553    0.021   26.561    0.000    0.512
##    .Stst25wrdfnctn    0.380    0.012   31.966    0.000    0.357
##    .Stst32rthrsnng    0.300    0.011   28.101    0.000    0.279
##    .Stst33hghschlm    0.232    0.009   25.933    0.000    0.214
##    .Stest35tblrdng    1.390    0.075   18.563    0.000    1.243
##    .Stst36clrclchc    1.043    0.042   24.703    0.000    0.960
##    .Stst37bjctnspc    0.923    0.036   25.827    0.000    0.853
##    .Stst28mchnclrs    0.306    0.015   19.975    0.000    0.276
##    .Stst29vslztn2D    0.751    0.026   28.630    0.000    0.700
##    .Stst30vslztn3D    0.493    0.017   28.932    0.000    0.459
##     english           1.000                               1.000
##     math              1.000                               1.000
##     speed             1.000                               1.000
##     spatial           1.000                               1.000
##  ci.upper   Std.lv  Std.all
##     0.399    0.373    0.346
##     0.411    0.382    0.472
##     0.583    0.549    0.545
##     0.413    0.383    0.411
##     0.387    0.362    0.357
##     0.689    0.643    0.480
##     0.909    0.859    0.667
##     0.299    0.277    0.242
##     0.631    0.588    0.435
##     0.701    0.642    0.482
##     0.593    0.553    0.501
##     0.404    0.380    0.628
##     0.321    0.300    0.423
##     0.249    0.232    0.366
##     1.536    1.390    0.501
##     1.126    1.043    0.620
##     0.993    0.923    0.603
##     0.336    0.306    0.379
##     0.803    0.751    0.618
##     0.526    0.493    0.574
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
## 
## 
## Group 2 [1]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english =~                                                   
##     Stst1vc (.p1.)    0.446    0.035   12.894    0.000    0.378
##     Stst19d (.p2.)    0.654    0.014   48.104    0.000    0.627
##     Stst20s (.p3.)    0.677    0.014   47.856    0.000    0.650
##     Stst21c (.p4.)    0.740    0.013   56.921    0.000    0.715
##     Stst22p (.p5.)    0.808    0.015   55.465    0.000    0.779
##     Stst23n (.p6.)    0.835    0.017   48.930    0.000    0.801
##     Stst24x (.p7.)    0.655    0.016   40.591    0.000    0.624
##     Stst26r (.p8.)    0.525    0.026   19.840    0.000    0.473
##     Stst31b (.p9.)    0.297    0.018   16.243    0.000    0.261
##     Stst34r (.10.)    0.283    0.029    9.647    0.000    0.226
##   math =~                                                      
##     Stst1vc (.11.)    0.422    0.039   10.791    0.000    0.346
##     Stst5mt (.12.)    0.742    0.017   43.911    0.000    0.709
##     Stst25w           0.672    0.021   32.493    0.000    0.632
##     Stst26r (.14.)    0.438    0.030   14.739    0.000    0.380
##     Stst32r (.15.)    0.639    0.016   40.087    0.000    0.608
##     Stst33h (.16.)    0.633    0.016   40.514    0.000    0.602
##     Stst34r (.17.)    0.267    0.032    8.327    0.000    0.204
##   speed =~                                                     
##     Stst34r (.18.)    0.482    0.021   22.475    0.000    0.440
##     Stst35t (.19.)    1.177    0.036   32.708    0.000    1.107
##     Stst36c (.20.)    0.799    0.025   32.395    0.000    0.751
##     Stst37b (.21.)    0.722    0.024   29.908    0.000    0.675
##   spatial =~                                                   
##     Stst28m           0.468    0.021   22.527    0.000    0.427
##     Sts292D (.23.)    0.681    0.018   37.724    0.000    0.646
##     Sts303D (.24.)    0.605    0.017   36.124    0.000    0.572
##     Stst31b (.25.)    0.641    0.022   29.632    0.000    0.598
##     Stst37b (.26.)    0.132    0.019    6.819    0.000    0.094
##  ci.upper   Std.lv  Std.all
##                            
##     0.514    0.439    0.467
##     0.680    0.643    0.705
##     0.705    0.666    0.680
##     0.766    0.728    0.731
##     0.836    0.794    0.810
##     0.868    0.821    0.737
##     0.687    0.644    0.585
##     0.577    0.516    0.531
##     0.332    0.292    0.271
##     0.341    0.278    0.242
##                            
##     0.499    0.336    0.358
##     0.775    0.590    0.599
##     0.713    0.535    0.671
##     0.496    0.348    0.358
##     0.671    0.509    0.689
##     0.663    0.503    0.734
##     0.329    0.212    0.185
##                            
##     0.524    0.477    0.416
##     1.248    1.165    0.719
##     0.848    0.791    0.612
##     0.770    0.715    0.622
##                            
##     0.509    0.380    0.621
##     0.716    0.553    0.558
##     0.638    0.491    0.628
##     0.683    0.520    0.483
##     0.170    0.107    0.093
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english ~~                                                   
##     math              0.659    0.029   22.646    0.000    0.602
##     speed             0.378    0.025   14.976    0.000    0.328
##     spatial           0.547    0.025   21.861    0.000    0.498
##   math ~~                                                      
##     speed             0.227    0.019   12.077    0.000    0.190
##     spatial           0.483    0.026   18.620    0.000    0.433
##   speed ~~                                                     
##     spatial           0.264    0.023   11.330    0.000    0.219
##  ci.upper   Std.lv  Std.all
##                            
##     0.716    0.842    0.842
##     0.427    0.388    0.388
##     0.596    0.685    0.685
##                            
##     0.264    0.289    0.289
##     0.534    0.749    0.749
##                            
##     0.310    0.329    0.329
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stst1vc          -1.421    0.027  -53.038    0.000   -1.474
##    .Stst19d (.58.)   -1.061    0.016  -67.747    0.000   -1.091
##    .Stst20s (.59.)   -0.752    0.019  -40.069    0.000   -0.789
##    .Stst21c (.60.)   -1.165    0.018  -63.972    0.000   -1.201
##    .Stst22p (.61.)   -1.220    0.020  -61.472    0.000   -1.259
##    .Stst23n (.62.)   -1.049    0.022  -46.960    0.000   -1.093
##    .Stst24x (.63.)   -0.948    0.020  -47.823    0.000   -0.987
##    .Stst26r (.64.)   -1.318    0.022  -59.422    0.000   -1.362
##    .Stst31b (.65.)   -1.060    0.023  -45.830    0.000   -1.105
##    .Stst34r (.66.)   -1.164    0.022  -51.809    0.000   -1.208
##    .Stst5mt (.67.)   -0.823    0.019  -42.704    0.000   -0.861
##    .Stst25w          -0.667    0.020  -33.985    0.000   -0.705
##    .Stst32r (.69.)   -1.062    0.016  -65.712    0.000   -1.094
##    .Stst33h (.70.)   -0.846    0.016  -54.505    0.000   -0.877
##    .Stst35t (.71.)   -0.772    0.034  -22.881    0.000   -0.838
##    .Stst36c (.72.)    0.051    0.025    2.044    0.041    0.002
##    .Stst37b (.73.)   -0.324    0.023  -13.987    0.000   -0.369
##    .Stst28m          -1.095    0.019  -56.172    0.000   -1.133
##    .Sts292D (.75.)   -0.556    0.021  -26.509    0.000   -0.597
##    .Sts303D (.76.)   -0.699    0.018  -38.478    0.000   -0.734
##     english           0.356    0.031   11.414    0.000    0.295
##     math             -0.181    0.027   -6.820    0.000   -0.233
##     speed             0.241    0.036    6.758    0.000    0.171
##     spatial          -0.489    0.033  -14.655    0.000   -0.554
##  ci.upper   Std.lv  Std.all
##    -1.369   -1.421   -1.513
##    -1.030   -1.061   -1.164
##    -0.715   -0.752   -0.768
##    -1.129   -1.165   -1.170
##    -1.181   -1.220   -1.244
##    -1.005   -1.049   -0.942
##    -0.909   -0.948   -0.861
##    -1.275   -1.318   -1.356
##    -1.014   -1.060   -0.983
##    -1.120   -1.164   -1.014
##    -0.785   -0.823   -0.835
##    -0.628   -0.667   -0.836
##    -1.030   -1.062   -1.440
##    -0.816   -0.846   -1.235
##    -0.706   -0.772   -0.476
##     0.100    0.051    0.040
##    -0.278   -0.324   -0.282
##    -1.057   -1.095   -1.788
##    -0.515   -0.556   -0.561
##    -0.663   -0.699   -0.894
##     0.417    0.362    0.362
##    -0.129   -0.227   -0.227
##     0.311    0.244    0.244
##    -0.423   -0.602   -0.602
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stest1vocab       0.329    0.010   33.898    0.000    0.310
##    .Stst19dsgsdwrd    0.417    0.012   35.283    0.000    0.394
##    .Stest20spellng    0.515    0.014   37.207    0.000    0.488
##    .Stest21cptlztn    0.461    0.014   33.861    0.000    0.435
##    .Stest22puncttn    0.332    0.011   30.968    0.000    0.311
##    .Stest23english    0.565    0.017   33.686    0.000    0.532
##    .Stest24exprssn    0.799    0.021   37.775    0.000    0.757
##    .Stst26rdngcmpr    0.255    0.008   30.451    0.000    0.238
##    .Stst31bstrctrs    0.597    0.017   34.466    0.000    0.563
##    .Stst34rthcmptt    0.708    0.027   26.131    0.000    0.655
##    .Stest5math        0.623    0.017   35.887    0.000    0.589
##    .Stst25wrdfnctn    0.350    0.010   33.984    0.000    0.330
##    .Stst32rthrsnng    0.286    0.008   34.649    0.000    0.269
##    .Stst33hghschlm    0.216    0.007   30.920    0.000    0.203
##    .Stest35tblrdng    1.267    0.068   18.741    0.000    1.134
##    .Stst36clrclchc    1.043    0.033   31.292    0.000    0.977
##    .Stst37bjctnspc    0.747    0.028   27.025    0.000    0.693
##    .Stst28mchnclrs    0.230    0.007   33.374    0.000    0.217
##    .Stst29vslztn2D    0.676    0.019   34.939    0.000    0.638
##    .Stst30vslztn3D    0.370    0.011   33.455    0.000    0.348
##     english           0.967    0.038   25.189    0.000    0.892
##     math              0.633    0.037   16.918    0.000    0.560
##     speed             0.979    0.059   16.702    0.000    0.864
##     spatial           0.659    0.040   16.446    0.000    0.580
##  ci.upper   Std.lv  Std.all
##     0.348    0.329    0.373
##     0.441    0.417    0.502
##     0.542    0.515    0.537
##     0.488    0.461    0.465
##     0.353    0.332    0.345
##     0.598    0.565    0.456
##     0.840    0.799    0.658
##     0.271    0.255    0.269
##     0.631    0.597    0.515
##     0.761    0.708    0.536
##     0.657    0.623    0.641
##     0.370    0.350    0.550
##     0.302    0.286    0.525
##     0.230    0.216    0.461
##     1.399    1.267    0.483
##     1.108    1.043    0.625
##     0.801    0.747    0.566
##     0.244    0.230    0.615
##     0.714    0.676    0.689
##     0.391    0.370    0.605
##     1.043    1.000    1.000
##     0.706    1.000    1.000
##     1.094    1.000    1.000
##     0.737    1.000    1.000
lavTestScore(scalar2, release = 25:41) 
## Warning: lavaan->lavTestScore():  
##    se is not `standard'; not implemented yet; falling back to 
##    ordinary score test
## $test
## 
## total score test:
## 
##    test      X2 df p.value
## 1 score 216.626 17       0
## 
## $uni
## 
## univariate score tests:
## 
##      lhs op    rhs     X2 df p.value
## 1  .p58. == .p138. 63.451  1   0.000
## 2  .p59. == .p139. 78.141  1   0.000
## 3  .p60. == .p140.  0.065  1   0.798
## 4  .p61. == .p141.  0.540  1   0.463
## 5  .p62. == .p142.  1.354  1   0.245
## 6  .p63. == .p143.  1.434  1   0.231
## 7  .p64. == .p144. 19.174  1   0.000
## 8  .p65. == .p145.  1.751  1   0.186
## 9  .p66. == .p146.  1.664  1   0.197
## 10 .p67. == .p147.  0.901  1   0.342
## 11 .p69. == .p149.  1.931  1   0.165
## 12 .p70. == .p150. 24.142  1   0.000
## 13 .p71. == .p151. 18.580  1   0.000
## 14 .p72. == .p152. 37.320  1   0.000
## 15 .p73. == .p153.  0.200  1   0.655
## 16 .p75. == .p155. 17.076  1   0.000
## 17 .p76. == .p156.  8.604  1   0.003
strict<-cfa(chc.factor.model, data=dgroup, group="sex", meanstructure=TRUE, sampling.weights="BY_WTA", std.lv=T, group.equal=c("loadings", "intercepts", "residuals"), group.partial=c("spatial=~Stest28mechanicalreasoning", "math=~Stest25wordfunctions", "Stest28mechanicalreasoning~1", "Stest1vocab~1", "Stest25wordfunctions~1"))
fitMeasures(strict, c("chisq", "df", "pvalue", "cfi", "rmsea", "srmr", "aic", "bic"))
##      chisq         df     pvalue        cfi      rmsea       srmr 
##   3893.336    369.000      0.000      0.938      0.056      0.049 
##        aic        bic 
## 291721.067 292332.003
Mc(strict)
## [1] 0.7485332
chc.cov<-cfa(chc.factor.model, data=dgroup, group="sex", meanstructure=TRUE, sampling.weights="BY_WTA", std.lv=T, group.equal=c("loadings", "intercepts", "lv.covariances"), group.partial=c("spatial=~Stest28mechanicalreasoning", "math=~Stest25wordfunctions", "Stest28mechanicalreasoning~1", "Stest1vocab~1", "Stest25wordfunctions~1"))
fitMeasures(chc.cov, c("chisq", "df", "pvalue", "cfi", "rmsea", "srmr", "aic", "bic"))
##      chisq         df     pvalue        cfi      rmsea       srmr 
##   3797.809    355.000      0.000      0.939      0.056      0.065 
##        aic        bic 
## 291653.540 292358.466
Mc(chc.cov)
## [1] 0.7535653
chc.vcov<-cfa(chc.factor.model, data=dgroup, group="sex", meanstructure=TRUE, sampling.weights="BY_WTA", std.lv=T, group.equal=c("loadings", "intercepts", "lv.variances", "lv.covariances"), group.partial=c("spatial=~Stest28mechanicalreasoning", "math=~Stest25wordfunctions", "Stest28mechanicalreasoning~1", "Stest1vocab~1", "Stest25wordfunctions~1"))
fitMeasures(chc.vcov, c("chisq", "df", "pvalue", "cfi", "rmsea", "srmr", "aic", "bic"))
##      chisq         df     pvalue        cfi      rmsea       srmr 
##   3857.530    359.000      0.000      0.938      0.057      0.066 
##        aic        bic 
## 291705.261 292383.333
Mc(chc.vcov)
## [1] 0.7501224
summary(chc.vcov, standardized=T, ci=T)
## lavaan 0.6-18 ended normally after 58 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                       148
##   Number of equality constraints                    47
## 
##   Number of observations per group:                   
##     0                                             2443
##     1                                             3642
##   Sampling weights variable                     BY_WTA
## 
## Model Test User Model:
##                                               Standard      Scaled
##   Test Statistic                              3857.530    3417.796
##   Degrees of freedom                               359         359
##   P-value (Chi-square)                           0.000       0.000
##   Scaling correction factor                                  1.129
##     Yuan-Bentler correction (Mplus variant)                       
##   Test statistic for each group:
##     0                                         1707.701    1513.034
##     1                                         2149.830    1904.763
## 
## Parameter Estimates:
## 
##   Standard errors                             Sandwich
##   Information bread                           Observed
##   Observed information based on                Hessian
## 
## 
## Group 1 [0]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english =~                                                   
##     Stst1vc (.p1.)    0.462    0.033   14.177    0.000    0.398
##     Stst19d (.p2.)    0.646    0.011   57.094    0.000    0.623
##     Stst20s (.p3.)    0.671    0.011   58.695    0.000    0.649
##     Stst21c (.p4.)    0.731    0.010   71.665    0.000    0.711
##     Stst22p (.p5.)    0.799    0.011   73.368    0.000    0.778
##     Stst23n (.p6.)    0.828    0.013   64.089    0.000    0.803
##     Stst24x (.p7.)    0.650    0.013   49.063    0.000    0.624
##     Stst26r (.p8.)    0.528    0.025   21.419    0.000    0.480
##     Stst31b (.p9.)    0.293    0.018   16.279    0.000    0.257
##     Stst34r (.10.)    0.274    0.029    9.390    0.000    0.217
##   math =~                                                      
##     Stst1vc (.11.)    0.351    0.034   10.443    0.000    0.285
##     Stst5mt (.12.)    0.657    0.012   54.397    0.000    0.633
##     Stst25w           0.443    0.015   28.836    0.000    0.413
##     Stst26r (.14.)    0.377    0.025   14.821    0.000    0.327
##     Stst32r (.15.)    0.564    0.012   48.281    0.000    0.541
##     Stst33h (.16.)    0.559    0.011   49.308    0.000    0.537
##     Stst34r (.17.)    0.243    0.029    8.450    0.000    0.186
##   speed =~                                                     
##     Stst34r (.18.)    0.480    0.020   24.043    0.000    0.441
##     Stst35t (.19.)    1.168    0.029   40.066    0.000    1.111
##     Stst36c (.20.)    0.796    0.020   40.207    0.000    0.757
##     Stst37b (.21.)    0.718    0.020   35.968    0.000    0.678
##   spatial =~                                                   
##     Stst28m           0.673    0.016   42.494    0.000    0.642
##     Sts292D (.23.)    0.607    0.013   45.093    0.000    0.580
##     Sts303D (.24.)    0.534    0.012   45.331    0.000    0.511
##     Stst31b (.25.)    0.574    0.019   30.698    0.000    0.537
##     Stst37b (.26.)    0.119    0.017    6.886    0.000    0.085
##  ci.upper   Std.lv  Std.all
##                            
##     0.526    0.462    0.465
##     0.668    0.646    0.723
##     0.693    0.671    0.671
##     0.751    0.731    0.763
##     0.821    0.799    0.799
##     0.854    0.828    0.720
##     0.676    0.650    0.575
##     0.577    0.528    0.518
##     0.328    0.293    0.262
##     0.331    0.274    0.242
##                            
##     0.416    0.351    0.353
##     0.681    0.657    0.660
##     0.473    0.443    0.584
##     0.427    0.377    0.370
##     0.587    0.564    0.715
##     0.582    0.559    0.756
##     0.299    0.243    0.214
##                            
##     0.519    0.480    0.423
##     1.225    1.168    0.703
##     0.835    0.796    0.615
##     0.757    0.718    0.583
##                            
##     0.704    0.673    0.776
##     0.633    0.607    0.570
##     0.558    0.534    0.600
##     0.611    0.574    0.515
##     0.153    0.119    0.097
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english ~~                                                   
##     math    (.51.)    0.849    0.007  115.504    0.000    0.835
##     speed   (.52.)    0.372    0.017   21.717    0.000    0.339
##     spatial (.53.)    0.686    0.012   57.959    0.000    0.663
##   math ~~                                                      
##     speed   (.54.)    0.297    0.017   17.076    0.000    0.263
##     spatial (.55.)    0.745    0.012   61.604    0.000    0.721
##   speed ~~                                                     
##     spatial (.56.)    0.340    0.020   16.908    0.000    0.301
##  ci.upper   Std.lv  Std.all
##                            
##     0.864    0.849    0.849
##     0.406    0.372    0.372
##     0.709    0.686    0.686
##                            
##     0.331    0.297    0.297
##     0.769    0.745    0.745
##                            
##     0.379    0.340    0.340
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stst1vc          -1.155    0.023  -50.360    0.000   -1.200
##    .Stst19d (.58.)   -1.060    0.016  -67.795    0.000   -1.090
##    .Stst20s (.59.)   -0.752    0.019  -40.006    0.000   -0.788
##    .Stst21c (.60.)   -1.164    0.018  -64.027    0.000   -1.200
##    .Stst22p (.61.)   -1.220    0.020  -61.385    0.000   -1.259
##    .Stst23n (.62.)   -1.049    0.022  -46.823    0.000   -1.093
##    .Stst24x (.63.)   -0.948    0.020  -47.743    0.000   -0.987
##    .Stst26r (.64.)   -1.321    0.022  -59.654    0.000   -1.364
##    .Stst31b (.65.)   -1.058    0.023  -45.663    0.000   -1.103
##    .Stst34r (.66.)   -1.162    0.022  -51.742    0.000   -1.206
##    .Stst5mt (.67.)   -0.823    0.019  -42.522    0.000   -0.861
##    .Stst25w          -0.871    0.017  -52.726    0.000   -0.903
##    .Stst32r (.69.)   -1.062    0.016  -65.764    0.000   -1.094
##    .Stst33h (.70.)   -0.845    0.016  -54.403    0.000   -0.876
##    .Stst35t (.71.)   -0.773    0.034  -22.904    0.000   -0.839
##    .Stst36c (.72.)    0.050    0.025    1.998    0.046    0.001
##    .Stst37b (.73.)   -0.324    0.023  -13.965    0.000   -0.369
##    .Stst28m          -0.715    0.019  -36.895    0.000   -0.753
##    .Sts292D (.75.)   -0.556    0.021  -26.449    0.000   -0.598
##    .Sts303D (.76.)   -0.700    0.018  -38.657    0.000   -0.735
##  ci.upper   Std.lv  Std.all
##    -1.110   -1.155   -1.162
##    -1.029   -1.060   -1.186
##    -0.715   -0.752   -0.752
##    -1.128   -1.164   -1.215
##    -1.181   -1.220   -1.219
##    -1.005   -1.049   -0.911
##    -0.909   -0.948   -0.838
##    -1.278   -1.321   -1.296
##    -1.012   -1.058   -0.949
##    -1.118   -1.162   -1.025
##    -0.785   -0.823   -0.827
##    -0.838   -0.871   -1.148
##    -1.030   -1.062   -1.347
##    -0.815   -0.845   -1.142
##    -0.707   -0.773   -0.466
##     0.100    0.050    0.039
##    -0.278   -0.324   -0.263
##    -0.677   -0.715   -0.824
##    -0.515   -0.556   -0.523
##    -0.664   -0.700   -0.785
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stest1vocab       0.376    0.013   28.548    0.000    0.350
##    .Stst19dsgsdwrd    0.381    0.015   26.241    0.000    0.353
##    .Stest20spellng    0.549    0.018   31.215    0.000    0.515
##    .Stest21cptlztn    0.384    0.015   25.048    0.000    0.354
##    .Stest22puncttn    0.362    0.012   29.044    0.000    0.338
##    .Stest23english    0.638    0.024   27.158    0.000    0.592
##    .Stest24exprssn    0.857    0.025   33.781    0.000    0.808
##    .Stst26rdngcmpr    0.279    0.011   25.031    0.000    0.258
##    .Stst31bstrctrs    0.598    0.022   27.799    0.000    0.556
##    .Stst34rthcmptt    0.643    0.030   21.320    0.000    0.584
##    .Stest5math        0.559    0.021   26.624    0.000    0.518
##    .Stst25wrdfnctn    0.379    0.012   31.829    0.000    0.355
##    .Stst32rthrsnng    0.304    0.011   28.286    0.000    0.283
##    .Stst33hghschlm    0.235    0.009   25.899    0.000    0.217
##    .Stest35tblrdng    1.392    0.075   18.627    0.000    1.246
##    .Stst36clrclchc    1.043    0.041   25.195    0.000    0.962
##    .Stst37bjctnspc    0.928    0.035   26.258    0.000    0.859
##    .Stst28mchnclrs    0.300    0.015   19.659    0.000    0.270
##    .Stst29vslztn2D    0.765    0.025   30.076    0.000    0.716
##    .Stst30vslztn3D    0.509    0.017   30.581    0.000    0.476
##     english           1.000                               1.000
##     math              1.000                               1.000
##     speed             1.000                               1.000
##     spatial           1.000                               1.000
##  ci.upper   Std.lv  Std.all
##     0.402    0.376    0.381
##     0.410    0.381    0.478
##     0.584    0.549    0.550
##     0.414    0.384    0.418
##     0.387    0.362    0.362
##     0.685    0.638    0.482
##     0.907    0.857    0.670
##     0.301    0.279    0.269
##     0.640    0.598    0.481
##     0.702    0.643    0.499
##     0.600    0.559    0.564
##     0.402    0.379    0.659
##     0.325    0.304    0.489
##     0.252    0.235    0.429
##     1.538    1.392    0.505
##     1.124    1.043    0.622
##     0.998    0.928    0.613
##     0.330    0.300    0.398
##     0.815    0.765    0.675
##     0.541    0.509    0.640
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
## 
## 
## Group 2 [1]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english =~                                                   
##     Stst1vc (.p1.)    0.462    0.033   14.177    0.000    0.398
##     Stst19d (.p2.)    0.646    0.011   57.094    0.000    0.623
##     Stst20s (.p3.)    0.671    0.011   58.695    0.000    0.649
##     Stst21c (.p4.)    0.731    0.010   71.665    0.000    0.711
##     Stst22p (.p5.)    0.799    0.011   73.368    0.000    0.778
##     Stst23n (.p6.)    0.828    0.013   64.089    0.000    0.803
##     Stst24x (.p7.)    0.650    0.013   49.063    0.000    0.624
##     Stst26r (.p8.)    0.528    0.025   21.419    0.000    0.480
##     Stst31b (.p9.)    0.293    0.018   16.279    0.000    0.257
##     Stst34r (.10.)    0.274    0.029    9.390    0.000    0.217
##   math =~                                                      
##     Stst1vc (.11.)    0.351    0.034   10.443    0.000    0.285
##     Stst5mt (.12.)    0.657    0.012   54.397    0.000    0.633
##     Stst25w           0.565    0.014   39.316    0.000    0.537
##     Stst26r (.14.)    0.377    0.025   14.821    0.000    0.327
##     Stst32r (.15.)    0.564    0.012   48.281    0.000    0.541
##     Stst33h (.16.)    0.559    0.011   49.308    0.000    0.537
##     Stst34r (.17.)    0.243    0.029    8.450    0.000    0.186
##   speed =~                                                     
##     Stst34r (.18.)    0.480    0.020   24.043    0.000    0.441
##     Stst35t (.19.)    1.168    0.029   40.066    0.000    1.111
##     Stst36c (.20.)    0.796    0.020   40.207    0.000    0.757
##     Stst37b (.21.)    0.718    0.020   35.968    0.000    0.678
##   spatial =~                                                   
##     Stst28m           0.392    0.013   29.688    0.000    0.366
##     Sts292D (.23.)    0.607    0.013   45.093    0.000    0.580
##     Sts303D (.24.)    0.534    0.012   45.331    0.000    0.511
##     Stst31b (.25.)    0.574    0.019   30.698    0.000    0.537
##     Stst37b (.26.)    0.119    0.017    6.886    0.000    0.085
##  ci.upper   Std.lv  Std.all
##                            
##     0.526    0.462    0.477
##     0.668    0.646    0.706
##     0.693    0.671    0.683
##     0.751    0.731    0.732
##     0.821    0.799    0.811
##     0.854    0.828    0.741
##     0.676    0.650    0.588
##     0.577    0.528    0.525
##     0.328    0.293    0.264
##     0.331    0.274    0.236
##                            
##     0.416    0.351    0.362
##     0.681    0.657    0.641
##     0.593    0.565    0.690
##     0.427    0.377    0.374
##     0.587    0.564    0.727
##     0.582    0.559    0.773
##     0.299    0.243    0.209
##                            
##     0.519    0.480    0.413
##     1.225    1.168    0.719
##     0.835    0.796    0.616
##     0.757    0.718    0.622
##                            
##     0.418    0.392    0.630
##     0.633    0.607    0.597
##     0.558    0.534    0.664
##     0.611    0.574    0.517
##     0.153    0.119    0.103
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english ~~                                                   
##     math    (.51.)    0.849    0.007  115.504    0.000    0.835
##     speed   (.52.)    0.372    0.017   21.717    0.000    0.339
##     spatial (.53.)    0.686    0.012   57.959    0.000    0.663
##   math ~~                                                      
##     speed   (.54.)    0.297    0.017   17.076    0.000    0.263
##     spatial (.55.)    0.745    0.012   61.604    0.000    0.721
##   speed ~~                                                     
##     spatial (.56.)    0.340    0.020   16.908    0.000    0.301
##  ci.upper   Std.lv  Std.all
##                            
##     0.864    0.849    0.849
##     0.406    0.372    0.372
##     0.709    0.686    0.686
##                            
##     0.331    0.297    0.297
##     0.769    0.745    0.745
##                            
##     0.379    0.340    0.340
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stst1vc          -1.432    0.027  -53.612    0.000   -1.485
##    .Stst19d (.58.)   -1.060    0.016  -67.795    0.000   -1.090
##    .Stst20s (.59.)   -0.752    0.019  -40.006    0.000   -0.788
##    .Stst21c (.60.)   -1.164    0.018  -64.027    0.000   -1.200
##    .Stst22p (.61.)   -1.220    0.020  -61.385    0.000   -1.259
##    .Stst23n (.62.)   -1.049    0.022  -46.823    0.000   -1.093
##    .Stst24x (.63.)   -0.948    0.020  -47.743    0.000   -0.987
##    .Stst26r (.64.)   -1.321    0.022  -59.654    0.000   -1.364
##    .Stst31b (.65.)   -1.058    0.023  -45.663    0.000   -1.103
##    .Stst34r (.66.)   -1.162    0.022  -51.742    0.000   -1.206
##    .Stst5mt (.67.)   -0.823    0.019  -42.522    0.000   -0.861
##    .Stst25w          -0.672    0.019  -35.878    0.000   -0.709
##    .Stst32r (.69.)   -1.062    0.016  -65.764    0.000   -1.094
##    .Stst33h (.70.)   -0.845    0.016  -54.403    0.000   -0.876
##    .Stst35t (.71.)   -0.773    0.034  -22.904    0.000   -0.839
##    .Stst36c (.72.)    0.050    0.025    1.998    0.046    0.001
##    .Stst37b (.73.)   -0.324    0.023  -13.965    0.000   -0.369
##    .Stst28m          -1.108    0.018  -61.081    0.000   -1.144
##    .Sts292D (.75.)   -0.556    0.021  -26.449    0.000   -0.598
##    .Sts303D (.76.)   -0.700    0.018  -38.657    0.000   -0.735
##     english           0.359    0.030   11.829    0.000    0.300
##     math             -0.206    0.032   -6.498    0.000   -0.268
##     speed             0.245    0.035    6.952    0.000    0.176
##     spatial          -0.549    0.039  -14.183    0.000   -0.625
##  ci.upper   Std.lv  Std.all
##    -1.380   -1.432   -1.477
##    -1.029   -1.060   -1.158
##    -0.715   -0.752   -0.765
##    -1.128   -1.164   -1.166
##    -1.181   -1.220   -1.237
##    -1.005   -1.049   -0.938
##    -0.909   -0.948   -0.858
##    -1.278   -1.321   -1.312
##    -1.012   -1.058   -0.953
##    -1.118   -1.162   -1.000
##    -0.785   -0.823   -0.803
##    -0.636   -0.672   -0.822
##    -1.030   -1.062   -1.370
##    -0.815   -0.845   -1.168
##    -0.707   -0.773   -0.476
##     0.100    0.050    0.039
##    -0.278   -0.324   -0.281
##    -1.073   -1.108   -1.780
##    -0.515   -0.556   -0.547
##    -0.664   -0.700   -0.869
##     0.418    0.359    0.359
##    -0.144   -0.206   -0.206
##     0.314    0.245    0.245
##    -0.473   -0.549   -0.549
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stest1vocab       0.328    0.010   33.891    0.000    0.309
##    .Stst19dsgsdwrd    0.420    0.012   35.357    0.000    0.397
##    .Stest20spellng    0.515    0.014   37.209    0.000    0.488
##    .Stest21cptlztn    0.463    0.014   34.108    0.000    0.437
##    .Stest22puncttn    0.334    0.011   31.073    0.000    0.313
##    .Stest23english    0.565    0.017   33.632    0.000    0.532
##    .Stest24exprssn    0.798    0.021   37.788    0.000    0.756
##    .Stst26rdngcmpr    0.254    0.008   30.352    0.000    0.238
##    .Stst31bstrctrs    0.587    0.017   34.565    0.000    0.554
##    .Stst34rthcmptt    0.707    0.027   25.998    0.000    0.654
##    .Stest5math        0.618    0.017   35.836    0.000    0.584
##    .Stst25wrdfnctn    0.351    0.010   34.163    0.000    0.331
##    .Stst32rthrsnng    0.283    0.008   34.479    0.000    0.267
##    .Stst33hghschlm    0.211    0.007   30.509    0.000    0.198
##    .Stest35tblrdng    1.274    0.068   18.758    0.000    1.141
##    .Stst36clrclchc    1.038    0.033   31.533    0.000    0.974
##    .Stst37bjctnspc    0.743    0.027   27.066    0.000    0.689
##    .Stst28mchnclrs    0.234    0.007   33.990    0.000    0.220
##    .Stst29vslztn2D    0.665    0.019   34.743    0.000    0.627
##    .Stst30vslztn3D    0.362    0.011   33.364    0.000    0.341
##     english           1.000                               1.000
##     math              1.000                               1.000
##     speed             1.000                               1.000
##     spatial           1.000                               1.000
##  ci.upper   Std.lv  Std.all
##     0.347    0.328    0.349
##     0.444    0.420    0.502
##     0.542    0.515    0.533
##     0.490    0.463    0.465
##     0.355    0.334    0.343
##     0.598    0.565    0.452
##     0.839    0.798    0.654
##     0.271    0.254    0.251
##     0.620    0.587    0.476
##     0.760    0.707    0.523
##     0.652    0.618    0.589
##     0.371    0.351    0.524
##     0.299    0.283    0.471
##     0.225    0.211    0.403
##     1.407    1.274    0.483
##     1.103    1.038    0.621
##     0.796    0.743    0.558
##     0.247    0.234    0.603
##     0.702    0.665    0.644
##     0.383    0.362    0.559
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
tests<-lavTestLRT(configural, metric2, scalar2, chc.cov, chc.vcov)
Td=tests[2:5,"Chisq diff"]
Td
## [1] 102.15504 192.50532  85.79648  44.98320
dfd=tests[2:5,"Df diff"]
dfd
## [1] 20 13  6  4
lambda<-Td-dfd
ld<-lambda/dfd
G<-2 # number of groups
N<- 2443 + 3642 # sample size
RMSEAD<-sqrt((ld)*G/(N-G))
RMSEAD
## [1] 0.03675007 0.06737877 0.06612601 0.05804022
RMSEA.CI(T=Td[1],df=dfd[1],N=N,G=2)
## [1] 0.02986334 0.04396147
RMSEA.CI(T=Td[2],df=dfd[2],N=N,G=2)
## [1] 0.05913788 0.07595623
RMSEA.CI(T=Td[3],df=dfd[3],N=N,G=2)
## [1] 0.05413869 0.07887196
RMSEA.CI(T=Td[4],df=dfd[4],N=N,G=2)
## [1] 0.04349355 0.07387053
round(pvals(T=Td[1],df=dfd[1],N=N,G=2),3)
##   RMSEA>0 RMSEA>.01 RMSEA>.05 RMSEA>.06 RMSEA>.08 RMSEA>.10 
##     1.000     1.000     0.001     0.000     0.000     0.000
round(pvals(T=Td[2],df=dfd[2],N=N,G=2),3)
##   RMSEA>0 RMSEA>.01 RMSEA>.05 RMSEA>.06 RMSEA>.08 RMSEA>.10 
##     1.000     1.000     1.000     0.930     0.007     0.000
round(pvals(T=Td[3],df=dfd[3],N=N,G=2),3)
##   RMSEA>0 RMSEA>.01 RMSEA>.05 RMSEA>.06 RMSEA>.08 RMSEA>.10 
##     1.000     1.000     0.986     0.807     0.036     0.000
round(pvals(T=Td[4],df=dfd[4],N=N,G=2),3)
##   RMSEA>0 RMSEA>.01 RMSEA>.05 RMSEA>.06 RMSEA>.08 RMSEA>.10 
##     1.000     1.000     0.828     0.446     0.010     0.000
tests<-lavTestLRT(configural, metric2, scalar)
Td=tests[2:3,"Chisq diff"]
Td
## [1] 102.1550 831.5914
dfd=tests[2:3,"Df diff"]
dfd
## [1] 20 16
lambda<-Td-dfd
ld<-lambda/dfd
G<-2 # number of groups
N<- 2443 + 3642 # sample size
RMSEAD<-sqrt((ld)*G/(N-G))
RMSEAD
## [1] 0.03675007 0.12945905
RMSEA.CI(T=Td[1],df=dfd[1],N=N,G=2)
## [1] 0.02986334 0.04396147
RMSEA.CI(T=Td[2],df=dfd[2],N=N,G=2)
## [1] 0.1220363 0.1370161
round(pvals(T=Td[1],df=dfd[1],N=N,G=2),3)
##   RMSEA>0 RMSEA>.01 RMSEA>.05 RMSEA>.06 RMSEA>.08 RMSEA>.10 
##     1.000     1.000     0.001     0.000     0.000     0.000
round(pvals(T=Td[2],df=dfd[2],N=N,G=2),3)
##   RMSEA>0 RMSEA>.01 RMSEA>.05 RMSEA>.06 RMSEA>.08 RMSEA>.10 
##         1         1         1         1         1         1
tests<-lavTestLRT(configural, metric2, scalar2, strict)
Td=tests[2:4,"Chisq diff"]
Td
## [1] 102.1550 192.5053 157.8302
dfd=tests[2:4,"Df diff"]
dfd
## [1] 20 13 20
lambda<-Td-dfd
ld<-lambda/dfd
G<-2 # number of groups
N<- 2443 + 3642 # sample size
RMSEAD<-sqrt((ld)*G/(N-G))
RMSEAD
## [1] 0.03675007 0.06737877 0.04760069
RMSEA.CI(T=Td[1],df=dfd[1],N=N,G=2)
## [1] 0.02986334 0.04396147
RMSEA.CI(T=Td[2],df=dfd[2],N=N,G=2)
## [1] 0.05913788 0.07595623
RMSEA.CI(T=Td[3],df=dfd[3],N=N,G=2)
## [1] 0.04084678 0.05463936
round(pvals(T=Td[1],df=dfd[1],N=N,G=2),3)
##   RMSEA>0 RMSEA>.01 RMSEA>.05 RMSEA>.06 RMSEA>.08 RMSEA>.10 
##     1.000     1.000     0.001     0.000     0.000     0.000
round(pvals(T=Td[2],df=dfd[2],N=N,G=2),3)
##   RMSEA>0 RMSEA>.01 RMSEA>.05 RMSEA>.06 RMSEA>.08 RMSEA>.10 
##     1.000     1.000     1.000     0.930     0.007     0.000
round(pvals(T=Td[3],df=dfd[3],N=N,G=2),3)
##   RMSEA>0 RMSEA>.01 RMSEA>.05 RMSEA>.06 RMSEA>.08 RMSEA>.10 
##     1.000     1.000     0.297     0.002     0.000     0.000

CHC higher order models

chc.hof.model <-'
english =~ Stest1vocab + Stest19disguisedwords + Stest20spelling + Stest21capitalization + Stest22punctuation + Stest23english + Stest24expression + Stest26readingcomprehension + Stest31abstractreasoning + Stest34arithcomputation
math =~ Stest1vocab + Stest5math + Stest25wordfunctions + Stest26readingcomprehension + Stest32arithreasoning + Stest33highschoolmath + Stest34arithcomputation
speed =~ Stest34arithcomputation + Stest35tablereading + Stest36clericalchecking + Stest37objectinspection
spatial =~ Stest28mechanicalreasoning + Stest29visualization2D + Stest30visualization3D + Stest31abstractreasoning + Stest37objectinspection
g =~ english + math + speed + spatial
'

baseline<-cfa(chc.hof.model, data=dgroup, meanstructure=TRUE, sampling.weights="BY_WTA")
fitMeasures(baseline, c("chisq", "df", "pvalue", "cfi", "rmsea", "srmr", "aic", "bic"))
##      chisq         df     pvalue        cfi      rmsea       srmr 
##   3521.742    160.000      0.000      0.941      0.059      0.046 
##        aic        bic 
## 294631.745 295101.696
Mc(baseline)
## [1] 0.7586026
configural<-cfa(chc.hof.model, data=dgroup, group="sex", meanstructure=TRUE, sampling.weights="BY_WTA", std.lv=T)
fitMeasures(configural, c("chisq", "df", "pvalue", "cfi", "rmsea", "srmr", "aic", "bic"))
##      chisq         df     pvalue        cfi      rmsea       srmr 
##   3440.210    320.000      0.000      0.945      0.057      0.044 
##        aic        bic 
## 291365.940 292305.842
Mc(configural)
## [1] 0.7738111
summary(configural, standardized=T, ci=T)
## lavaan 0.6-18 ended normally after 117 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                       140
## 
##   Number of observations per group:                   
##     0                                             2443
##     1                                             3642
##   Sampling weights variable                     BY_WTA
## 
## Model Test User Model:
##                                               Standard      Scaled
##   Test Statistic                              3440.210    3068.656
##   Degrees of freedom                               320         320
##   P-value (Chi-square)                           0.000       0.000
##   Scaling correction factor                                  1.121
##     Yuan-Bentler correction (Mplus variant)                       
##   Test statistic for each group:
##     0                                         1461.162    1303.351
##     1                                         1979.048    1765.304
## 
## Parameter Estimates:
## 
##   Standard errors                             Sandwich
##   Information bread                           Observed
##   Observed information based on                Hessian
## 
## 
## Group 1 [0]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english =~                                                   
##     Stest1vocab       0.237    0.028    8.582    0.000    0.183
##     Stst19dsgsdwrd    0.261    0.016   16.445    0.000    0.230
##     Stest20spellng    0.283    0.019   14.824    0.000    0.246
##     Stest21cptlztn    0.299    0.019   16.098    0.000    0.263
##     Stest22puncttn    0.334    0.021   16.221    0.000    0.294
##     Stest23english    0.374    0.024   15.846    0.000    0.327
##     Stest24exprssn    0.301    0.019   15.597    0.000    0.263
##     Stst26rdngcmpr    0.263    0.028    9.484    0.000    0.209
##     Stst31bstrctrs    0.102    0.016    6.246    0.000    0.070
##     Stst34rthcmptt    0.116    0.029    3.928    0.000    0.058
##   math =~                                                      
##     Stest1vocab       0.111    0.023    4.784    0.000    0.066
##     Stest5math        0.238    0.024    9.763    0.000    0.190
##     Stst25wrdfnctn    0.152    0.015    9.863    0.000    0.122
##     Stst26rdngcmpr    0.112    0.022    4.991    0.000    0.068
##     Stst32rthrsnng    0.205    0.021    9.783    0.000    0.164
##     Stst33hghschlm    0.201    0.021    9.589    0.000    0.160
##     Stst34rthcmptt    0.087    0.024    3.601    0.000    0.040
##   speed =~                                                     
##     Stst34rthcmptt    0.436    0.029   14.949    0.000    0.379
##     Stest35tblrdng    1.103    0.039   28.513    0.000    1.027
##     Stst36clrclchc    0.753    0.035   21.768    0.000    0.685
##     Stst37bjctnspc    0.667    0.033   19.948    0.000    0.602
##   spatial =~                                                   
##     Stst28mchnclrs    0.437    0.017   26.301    0.000    0.405
##     Stst29vslztn2D    0.403    0.019   20.846    0.000    0.365
##     Stst30vslztn3D    0.399    0.018   22.480    0.000    0.364
##     Stst31bstrctrs    0.406    0.022   18.835    0.000    0.364
##     Stst37bjctnspc    0.085    0.019    4.550    0.000    0.048
##   g =~                                                         
##     english           2.145    0.154   13.940    0.000    1.844
##     math              2.955    0.328    9.016    0.000    2.313
##     speed             0.397    0.034   11.751    0.000    0.331
##     spatial           1.274    0.069   18.461    0.000    1.139
##  ci.upper   Std.lv  Std.all
##                            
##     0.291    0.562    0.527
##     0.292    0.618    0.708
##     0.321    0.670    0.672
##     0.335    0.708    0.750
##     0.375    0.792    0.793
##     0.420    0.884    0.743
##     0.339    0.712    0.612
##     0.317    0.623    0.579
##     0.135    0.242    0.212
##     0.174    0.274    0.239
##                            
##     0.157    0.348    0.326
##     0.285    0.742    0.708
##     0.183    0.476    0.611
##     0.156    0.349    0.324
##     0.246    0.638    0.760
##     0.242    0.626    0.797
##     0.134    0.271    0.237
##                            
##     0.493    0.469    0.409
##     1.179    1.187    0.711
##     0.820    0.810    0.625
##     0.733    0.718    0.581
##                            
##     0.470    0.709    0.788
##     0.441    0.653    0.599
##     0.434    0.647    0.682
##     0.449    0.658    0.576
##     0.121    0.137    0.111
##                            
##     2.447    0.906    0.906
##     3.597    0.947    0.947
##     0.464    0.369    0.369
##     1.409    0.787    0.787
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stest1vocab      -1.155    0.023  -50.360    0.000   -1.200
##    .Stst19dsgsdwrd   -0.992    0.018  -53.776    0.000   -1.028
##    .Stest20spellng   -0.848    0.021  -39.900    0.000   -0.890
##    .Stest21cptlztn   -1.167    0.020  -58.007    0.000   -1.206
##    .Stest22puncttn   -1.226    0.021  -57.496    0.000   -1.268
##    .Stest23english   -1.062    0.026  -41.362    0.000   -1.113
##    .Stest24exprssn   -0.965    0.025  -38.928    0.000   -1.014
##    .Stst26rdngcmpr   -1.292    0.023  -56.802    0.000   -1.337
##    .Stst31bstrctrs   -1.070    0.024  -43.766    0.000   -1.118
##    .Stst34rthcmptt   -1.153    0.025  -46.702    0.000   -1.201
##    .Stest5math       -0.814    0.022  -36.442    0.000   -0.857
##    .Stst25wrdfnctn   -0.871    0.017  -52.726    0.000   -0.903
##    .Stst32rthrsnng   -1.052    0.018  -59.194    0.000   -1.087
##    .Stst33hghschlm   -0.875    0.016  -53.483    0.000   -0.907
##    .Stest35tblrdng   -0.712    0.037  -19.463    0.000   -0.784
##    .Stst36clrclchc   -0.032    0.028   -1.139    0.255   -0.086
##    .Stst37bjctnspc   -0.318    0.027  -11.957    0.000   -0.370
##    .Stst28mchnclrs   -0.715    0.019  -36.895    0.000   -0.753
##    .Stst29vslztn2D   -0.512    0.023  -22.047    0.000   -0.557
##    .Stst30vslztn3D   -0.723    0.020  -35.874    0.000   -0.762
##  ci.upper   Std.lv  Std.all
##    -1.110   -1.155   -1.083
##    -0.956   -0.992   -1.136
##    -0.806   -0.848   -0.851
##    -1.128   -1.167   -1.236
##    -1.184   -1.226   -1.229
##    -1.012   -1.062   -0.893
##    -0.916   -0.965   -0.829
##    -1.248   -1.292   -1.202
##    -1.022   -1.070   -0.937
##    -1.104   -1.153   -1.006
##    -0.770   -0.814   -0.777
##    -0.838   -0.871   -1.119
##    -1.017   -1.052   -1.253
##    -0.843   -0.875   -1.115
##    -0.640   -0.712   -0.427
##     0.023   -0.032   -0.025
##    -0.266   -0.318   -0.257
##    -0.677   -0.715   -0.795
##    -0.466   -0.512   -0.469
##    -0.683   -0.723   -0.763
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stest1vocab       0.366    0.013   27.385    0.000    0.340
##    .Stst19dsgsdwrd    0.380    0.014   27.160    0.000    0.353
##    .Stest20spellng    0.544    0.018   30.626    0.000    0.510
##    .Stest21cptlztn    0.390    0.016   25.078    0.000    0.360
##    .Stest22puncttn    0.369    0.013   27.832    0.000    0.343
##    .Stest23english    0.633    0.023   27.043    0.000    0.587
##    .Stest24exprssn    0.848    0.026   32.983    0.000    0.798
##    .Stst26rdngcmpr    0.274    0.011   24.183    0.000    0.251
##    .Stst31bstrctrs    0.584    0.023   25.401    0.000    0.539
##    .Stst34rthcmptt    0.643    0.029   21.854    0.000    0.585
##    .Stest5math        0.547    0.021   26.321    0.000    0.507
##    .Stst25wrdfnctn    0.380    0.012   31.705    0.000    0.356
##    .Stst32rthrsnng    0.297    0.011   27.430    0.000    0.276
##    .Stst33hghschlm    0.225    0.009   23.765    0.000    0.207
##    .Stest35tblrdng    1.375    0.091   15.157    0.000    1.197
##    .Stst36clrclchc    1.022    0.049   21.002    0.000    0.927
##    .Stst37bjctnspc    0.938    0.039   24.183    0.000    0.862
##    .Stst28mchnclrs    0.307    0.015   19.878    0.000    0.277
##    .Stst29vslztn2D    0.762    0.027   28.484    0.000    0.710
##    .Stst30vslztn3D    0.480    0.017   27.461    0.000    0.446
##    .english           1.000                               1.000
##    .math              1.000                               1.000
##    .speed             1.000                               1.000
##    .spatial           1.000                               1.000
##     g                 1.000                               1.000
##  ci.upper   Std.lv  Std.all
##     0.392    0.366    0.322
##     0.408    0.380    0.499
##     0.579    0.544    0.548
##     0.421    0.390    0.438
##     0.395    0.369    0.371
##     0.679    0.633    0.447
##     0.898    0.848    0.626
##     0.296    0.274    0.237
##     0.629    0.584    0.448
##     0.700    0.643    0.489
##     0.588    0.547    0.499
##     0.403    0.380    0.627
##     0.319    0.297    0.422
##     0.244    0.225    0.366
##     1.553    1.375    0.494
##     1.118    1.022    0.609
##     1.014    0.938    0.613
##     0.337    0.307    0.379
##     0.815    0.762    0.641
##     0.514    0.480    0.534
##     1.000    0.179    0.179
##     1.000    0.103    0.103
##     1.000    0.864    0.864
##     1.000    0.381    0.381
##     1.000    1.000    1.000
## 
## 
## Group 2 [1]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english =~                                                   
##     Stest1vocab       0.225    0.022   10.251    0.000    0.182
##     Stst19dsgsdwrd    0.293    0.016   18.694    0.000    0.262
##     Stest20spellng    0.273    0.016   17.415    0.000    0.242
##     Stest21cptlztn    0.320    0.017   18.460    0.000    0.286
##     Stest22puncttn    0.340    0.018   18.723    0.000    0.305
##     Stest23english    0.334    0.019   17.985    0.000    0.298
##     Stest24exprssn    0.257    0.015   16.979    0.000    0.227
##     Stst26rdngcmpr    0.279    0.021   13.215    0.000    0.238
##     Stst31bstrctrs    0.114    0.015    7.689    0.000    0.085
##     Stst34rthcmptt    0.140    0.023    6.022    0.000    0.094
##   math =~                                                      
##     Stest1vocab       0.080    0.019    4.197    0.000    0.043
##     Stest5math        0.222    0.017   12.999    0.000    0.188
##     Stst25wrdfnctn    0.200    0.015   13.168    0.000    0.170
##     Stst26rdngcmpr    0.074    0.017    4.378    0.000    0.041
##     Stst32rthrsnng    0.189    0.015   13.018    0.000    0.161
##     Stst33hghschlm    0.195    0.015   12.858    0.000    0.166
##     Stst34rthcmptt    0.063    0.019    3.295    0.001    0.025
##   speed =~                                                     
##     Stst34rthcmptt    0.451    0.024   18.436    0.000    0.403
##     Stest35tblrdng    1.093    0.031   34.907    0.000    1.031
##     Stst36clrclchc    0.710    0.028   25.410    0.000    0.656
##     Stst37bjctnspc    0.650    0.027   24.283    0.000    0.598
##   spatial =~                                                   
##     Stst28mchnclrs    0.232    0.010   23.156    0.000    0.212
##     Stst29vslztn2D    0.334    0.018   18.383    0.000    0.299
##     Stst30vslztn3D    0.288    0.015   19.229    0.000    0.259
##     Stst31bstrctrs    0.350    0.020   17.319    0.000    0.311
##     Stst37bjctnspc    0.070    0.015    4.554    0.000    0.040
##   g =~                                                         
##     english           2.121    0.135   15.656    0.000    1.855
##     math              2.505    0.212   11.825    0.000    2.090
##     speed             0.413    0.029   14.145    0.000    0.355
##     spatial           1.292    0.075   17.127    0.000    1.144
##  ci.upper   Std.lv  Std.all
##                            
##     0.268    0.527    0.573
##     0.324    0.687    0.732
##     0.304    0.640    0.664
##     0.354    0.749    0.741
##     0.376    0.798    0.809
##     0.371    0.784    0.719
##     0.287    0.603    0.558
##     0.320    0.654    0.675
##     0.144    0.268    0.245
##     0.185    0.327    0.283
##                            
##     0.117    0.215    0.234
##     0.255    0.598    0.606
##     0.229    0.539    0.676
##     0.107    0.200    0.206
##     0.218    0.510    0.692
##     0.225    0.527    0.759
##     0.100    0.169    0.146
##                            
##     0.499    0.488    0.422
##     1.154    1.182    0.728
##     0.765    0.768    0.600
##     0.703    0.703    0.613
##                            
##     0.251    0.378    0.618
##     0.370    0.546    0.552
##     0.317    0.470    0.608
##     0.390    0.572    0.523
##     0.100    0.115    0.100
##                            
##     2.386    0.904    0.904
##     2.921    0.929    0.929
##     0.470    0.381    0.381
##     1.440    0.791    0.791
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stest1vocab      -1.339    0.016  -83.554    0.000   -1.370
##    .Stst19dsgsdwrd   -0.878    0.016  -54.059    0.000   -0.910
##    .Stest20spellng   -0.450    0.017  -26.686    0.000   -0.483
##    .Stest21cptlztn   -0.899    0.017  -51.477    0.000   -0.934
##    .Stest22puncttn   -0.929    0.017  -53.286    0.000   -0.963
##    .Stest23english   -0.744    0.019  -38.449    0.000   -0.781
##    .Stest24exprssn   -0.704    0.019  -37.099    0.000   -0.742
##    .Stst26rdngcmpr   -1.226    0.017  -72.842    0.000   -1.259
##    .Stst31bstrctrs   -1.260    0.019  -65.843    0.000   -1.297
##    .Stst34rthcmptt   -1.004    0.021  -47.990    0.000   -1.045
##    .Stest5math       -0.965    0.017  -55.615    0.000   -0.999
##    .Stst25wrdfnctn   -0.788    0.014  -57.181    0.000   -0.816
##    .Stst32rthrsnng   -1.184    0.013  -92.849    0.000   -1.209
##    .Stst33hghschlm   -0.942    0.012  -78.389    0.000   -0.966
##    .Stest35tblrdng   -0.524    0.029  -17.830    0.000   -0.582
##    .Stst36clrclchc    0.300    0.023   13.284    0.000    0.256
##    .Stst37bjctnspc   -0.217    0.021  -10.567    0.000   -0.257
##    .Stst28mchnclrs   -1.323    0.011 -124.285    0.000   -1.344
##    .Stst29vslztn2D   -0.916    0.017  -52.801    0.000   -0.950
##    .Stst30vslztn3D   -0.982    0.014  -72.639    0.000   -1.008
##  ci.upper   Std.lv  Std.all
##    -1.307   -1.339   -1.455
##    -0.846   -0.878   -0.935
##    -0.417   -0.450   -0.467
##    -0.865   -0.899   -0.889
##    -0.895   -0.929   -0.942
##    -0.706   -0.744   -0.682
##    -0.667   -0.704   -0.652
##    -1.193   -1.226   -1.265
##    -1.222   -1.260   -1.151
##    -0.963   -1.004   -0.869
##    -0.931   -0.965   -0.978
##    -0.761   -0.788   -0.989
##    -1.159   -1.184   -1.604
##    -0.919   -0.942   -1.356
##    -0.466   -0.524   -0.323
##     0.344    0.300    0.234
##    -0.176   -0.217   -0.189
##    -1.303   -1.323   -2.162
##    -0.882   -0.916   -0.926
##    -0.955   -0.982   -1.270
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stest1vocab       0.331    0.010   34.359    0.000    0.312
##    .Stst19dsgsdwrd    0.410    0.012   34.685    0.000    0.387
##    .Stest20spellng    0.519    0.014   37.426    0.000    0.492
##    .Stest21cptlztn    0.461    0.014   32.742    0.000    0.434
##    .Stest22puncttn    0.335    0.011   30.447    0.000    0.314
##    .Stest23english    0.576    0.017   34.050    0.000    0.543
##    .Stest24exprssn    0.804    0.021   37.862    0.000    0.762
##    .Stst26rdngcmpr    0.253    0.009   29.539    0.000    0.236
##    .Stst31bstrctrs    0.578    0.019   30.850    0.000    0.541
##    .Stst34rthcmptt    0.700    0.026   26.444    0.000    0.648
##    .Stest5math        0.616    0.017   35.549    0.000    0.582
##    .Stst25wrdfnctn    0.346    0.010   33.692    0.000    0.326
##    .Stst32rthrsnng    0.284    0.008   34.461    0.000    0.268
##    .Stst33hghschlm    0.205    0.007   29.123    0.000    0.191
##    .Stest35tblrdng    1.240    0.074   16.825    0.000    1.096
##    .Stst36clrclchc    1.051    0.037   28.711    0.000    0.979
##    .Stst37bjctnspc    0.760    0.030   24.951    0.000    0.701
##    .Stst28mchnclrs    0.232    0.007   33.675    0.000    0.218
##    .Stst29vslztn2D    0.679    0.020   34.073    0.000    0.640
##    .Stst30vslztn3D    0.377    0.011   33.065    0.000    0.354
##    .english           1.000                               1.000
##    .math              1.000                               1.000
##    .speed             1.000                               1.000
##    .spatial           1.000                               1.000
##     g                 1.000                               1.000
##  ci.upper   Std.lv  Std.all
##     0.350    0.331    0.391
##     0.433    0.410    0.465
##     0.546    0.519    0.559
##     0.489    0.461    0.451
##     0.357    0.335    0.345
##     0.609    0.576    0.484
##     0.845    0.804    0.689
##     0.270    0.253    0.269
##     0.615    0.578    0.483
##     0.752    0.700    0.524
##     0.650    0.616    0.633
##     0.366    0.346    0.544
##     0.301    0.284    0.522
##     0.219    0.205    0.425
##     1.384    1.240    0.470
##     1.123    1.051    0.640
##     0.820    0.760    0.577
##     0.245    0.232    0.618
##     0.718    0.679    0.695
##     0.399    0.377    0.630
##     1.000    0.182    0.182
##     1.000    0.137    0.137
##     1.000    0.855    0.855
##     1.000    0.375    0.375
##     1.000    1.000    1.000
modificationIndices(configural, sort=T, maximum.number=30)
##                         lhs op                         rhs block group
## 439                 english =~         Stest35tablereading     2     2
## 503                       g =~         Stest35tablereading     2     2
## 452                    math =~         Stest35tablereading     2     2
## 459                   speed =~       Stest19disguisedwords     2     2
## 515             Stest1vocab ~~ Stest26readingcomprehension     2     2
## 229                       g =~         Stest35tablereading     1     1
## 541   Stest19disguisedwords ~~     Stest36clericalchecking     2     2
## 487                 spatial =~         Stest35tablereading     2     2
## 476                 spatial =~             Stest20spelling     2     2
## 178                    math =~         Stest35tablereading     1     1
## 213                 spatial =~         Stest35tablereading     1     1
## 241             Stest1vocab ~~ Stest26readingcomprehension     1     1
## 165                 english =~         Stest35tablereading     1     1
## 504                       g =~     Stest36clericalchecking     2     2
## 453                    math =~     Stest36clericalchecking     2     2
## 202                 spatial =~             Stest20spelling     1     1
## 689 Stest36clericalchecking ~~     Stest37objectinspection     2     2
## 180                    math =~     Stest37objectinspection     1     1
## 440                 english =~     Stest36clericalchecking     2     2
## 488                 spatial =~     Stest36clericalchecking     2     2
## 231                       g =~     Stest37objectinspection     1     1
## 455                    math =~  Stest28mechanicalreasoning     2     2
## 506                       g =~  Stest28mechanicalreasoning     2     2
## 198                   speed =~      Stest29visualization2D     1     1
## 185                   speed =~       Stest19disguisedwords     1     1
## 454                    math =~     Stest37objectinspection     2     2
## 505                       g =~     Stest37objectinspection     2     2
## 647 Stest34arithcomputation ~~       Stest33highschoolmath     2     2
## 512             Stest1vocab ~~          Stest22punctuation     2     2
## 214                 spatial =~     Stest36clericalchecking     1     1
##     level      mi    epc sepc.lv sepc.all sepc.nox
## 439     1 271.873  0.243   0.569    0.350    0.350
## 503     1 270.559  0.627   0.627    0.386    0.386
## 452     1 218.517  0.200   0.541    0.333    0.333
## 459     1 209.951  0.193   0.208    0.222    0.222
## 515     1 202.044  0.083   0.083    0.288    0.288
## 229     1 184.618  0.615   0.615    0.369    0.369
## 541     1 181.924  0.167   0.167    0.254    0.254
## 487     1 178.931  0.300   0.490    0.302    0.302
## 476     1 174.776 -0.210  -0.344   -0.357   -0.357
## 178     1 170.769  0.184   0.574    0.344    0.344
## 213     1 156.715  0.324   0.525    0.315    0.315
## 241     1 148.644  0.097   0.097    0.307    0.307
## 165     1 148.249  0.215   0.510    0.305    0.305
## 504     1 136.179 -0.301  -0.301   -0.235   -0.235
## 453     1 135.653 -0.109  -0.294   -0.229   -0.229
## 202     1 128.511 -0.205  -0.332   -0.333   -0.333
## 689     1 119.736  0.265   0.265    0.296    0.296
## 180     1 112.799 -0.149  -0.465   -0.376   -0.376
## 440     1 110.384 -0.108  -0.253   -0.197   -0.197
## 488     1 110.147 -0.166  -0.272   -0.212   -0.212
## 231     1 106.574 -0.518  -0.518   -0.419   -0.419
## 455     1  99.960  0.086   0.232    0.378    0.378
## 506     1  94.505  0.279   0.279    0.456    0.456
## 198     1  88.546  0.207   0.223    0.204    0.204
## 185     1  88.304  0.147   0.158    0.181    0.181
## 454     1  84.409 -0.120  -0.322   -0.281   -0.281
## 505     1  80.467 -0.376  -0.376   -0.328   -0.328
## 647     1  79.890  0.073   0.073    0.193    0.193
## 512     1  78.722 -0.060  -0.060   -0.180   -0.180
## 214     1  74.596 -0.163  -0.263   -0.203   -0.203
metric<-cfa(chc.hof.model, data=dgroup, group="sex", meanstructure=TRUE, sampling.weights="BY_WTA", std.lv=T, group.equal=c("loadings"))
fitMeasures(metric, c("chisq", "df", "pvalue", "cfi", "rmsea", "srmr", "aic", "bic"))
##      chisq         df     pvalue        cfi      rmsea       srmr 
##   3824.723    345.000      0.000      0.939      0.058      0.056 
##        aic        bic 
## 291700.454 292472.516
Mc(metric)
## [1] 0.7512827
summary(metric, standardized=T, ci=T)
## lavaan 0.6-18 ended normally after 106 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                       145
##   Number of equality constraints                    30
## 
##   Number of observations per group:                   
##     0                                             2443
##     1                                             3642
##   Sampling weights variable                     BY_WTA
## 
## Model Test User Model:
##                                               Standard      Scaled
##   Test Statistic                              3824.723    3394.340
##   Degrees of freedom                               345         345
##   P-value (Chi-square)                           0.000       0.000
##   Scaling correction factor                                  1.127
##     Yuan-Bentler correction (Mplus variant)                       
##   Test statistic for each group:
##     0                                         1672.258    1484.084
##     1                                         2152.465    1910.255
## 
## Parameter Estimates:
## 
##   Standard errors                             Sandwich
##   Information bread                           Observed
##   Observed information based on                Hessian
## 
## 
## Group 1 [0]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english =~                                                   
##     Stst1vc (.p1.)    0.188    0.020    9.263    0.000    0.148
##     Stst19d (.p2.)    0.240    0.018   13.338    0.000    0.204
##     Stst20s (.p3.)    0.239    0.018   12.915    0.000    0.203
##     Stst21c (.p4.)    0.267    0.020   13.276    0.000    0.227
##     Stst22p (.p5.)    0.291    0.022   13.301    0.000    0.248
##     Stst23n (.p6.)    0.301    0.023   13.113    0.000    0.256
##     Stst24x (.p7.)    0.237    0.018   12.972    0.000    0.201
##     Stst26r (.p8.)    0.227    0.022   10.409    0.000    0.184
##     Stst31b (.p9.)    0.107    0.011    9.830    0.000    0.085
##     Stst34r (.10.)    0.115    0.017    6.905    0.000    0.083
##   math =~                                                      
##     Stst1vc (.11.)    0.115    0.019    6.159    0.000    0.079
##     Stst5mt (.12.)    0.256    0.021   12.148    0.000    0.215
##     Stst25w (.13.)    0.197    0.016   12.590    0.000    0.167
##     Stst26r (.14.)    0.110    0.017    6.321    0.000    0.076
##     Stst32r (.15.)    0.219    0.018   12.273    0.000    0.184
##     Stst33h (.16.)    0.221    0.018   12.169    0.000    0.185
##     Stst34r (.17.)    0.078    0.016    4.748    0.000    0.046
##   speed =~                                                     
##     Stst34r (.18.)    0.448    0.020   22.019    0.000    0.408
##     Stst35t (.19.)    1.103    0.032   34.111    0.000    1.040
##     Stst36c (.20.)    0.735    0.026   28.020    0.000    0.683
##     Stst37b (.21.)    0.662    0.025   26.495    0.000    0.613
##   spatial =~                                                   
##     Stst28m (.22.)    0.406    0.015   27.273    0.000    0.376
##     Sts292D (.23.)    0.469    0.018   26.694    0.000    0.435
##     Sts303D (.24.)    0.435    0.016   27.006    0.000    0.404
##     Stst31b (.25.)    0.453    0.018   25.218    0.000    0.418
##     Stst37b (.26.)    0.101    0.015    6.665    0.000    0.072
##   g =~                                                         
##     english (.27.)    2.656    0.218   12.201    0.000    2.229
##     math    (.28.)    2.619    0.229   11.422    0.000    2.169
##     speed   (.29.)    0.430    0.025   17.021    0.000    0.381
##     spatial (.30.)    1.041    0.049   21.278    0.000    0.945
##  ci.upper   Std.lv  Std.all
##                            
##     0.228    0.533    0.515
##     0.275    0.680    0.742
##     0.275    0.678    0.676
##     0.306    0.757    0.772
##     0.334    0.826    0.807
##     0.346    0.855    0.729
##     0.272    0.672    0.587
##     0.270    0.645    0.605
##     0.128    0.303    0.261
##     0.148    0.328    0.282
##                            
##     0.152    0.324    0.313
##     0.298    0.719    0.696
##     0.228    0.553    0.671
##     0.144    0.308    0.289
##     0.254    0.614    0.744
##     0.256    0.619    0.793
##     0.111    0.220    0.189
##                            
##     0.488    0.488    0.419
##     1.166    1.201    0.717
##     0.786    0.800    0.618
##     0.711    0.721    0.581
##                            
##     0.435    0.585    0.699
##     0.503    0.677    0.620
##     0.467    0.628    0.677
##     0.488    0.654    0.563
##     0.131    0.146    0.118
##                            
##     3.082    0.936    0.936
##     3.068    0.934    0.934
##     0.480    0.395    0.395
##     1.137    0.721    0.721
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stest1vocab      -1.155    0.023  -50.360    0.000   -1.200
##    .Stst19dsgsdwrd   -0.992    0.018  -53.776    0.000   -1.028
##    .Stest20spellng   -0.848    0.021  -39.900    0.000   -0.890
##    .Stest21cptlztn   -1.167    0.020  -58.007    0.000   -1.206
##    .Stest22puncttn   -1.226    0.021  -57.496    0.000   -1.268
##    .Stest23english   -1.062    0.026  -41.362    0.000   -1.113
##    .Stest24exprssn   -0.965    0.025  -38.928    0.000   -1.014
##    .Stst26rdngcmpr   -1.292    0.023  -56.802    0.000   -1.337
##    .Stst31bstrctrs   -1.070    0.024  -43.766    0.000   -1.118
##    .Stst34rthcmptt   -1.153    0.025  -46.702    0.000   -1.201
##    .Stest5math       -0.814    0.022  -36.442    0.000   -0.857
##    .Stst25wrdfnctn   -0.871    0.017  -52.726    0.000   -0.903
##    .Stst32rthrsnng   -1.052    0.018  -59.194    0.000   -1.087
##    .Stst33hghschlm   -0.875    0.016  -53.483    0.000   -0.907
##    .Stest35tblrdng   -0.712    0.037  -19.463    0.000   -0.784
##    .Stst36clrclchc   -0.032    0.028   -1.139    0.255   -0.086
##    .Stst37bjctnspc   -0.318    0.027  -11.957    0.000   -0.370
##    .Stst28mchnclrs   -0.715    0.019  -36.895    0.000   -0.753
##    .Stst29vslztn2D   -0.512    0.023  -22.047    0.000   -0.557
##    .Stst30vslztn3D   -0.723    0.020  -35.874    0.000   -0.762
##  ci.upper   Std.lv  Std.all
##    -1.110   -1.155   -1.117
##    -0.956   -0.992   -1.082
##    -0.806   -0.848   -0.846
##    -1.128   -1.167   -1.191
##    -1.184   -1.226   -1.197
##    -1.012   -1.062   -0.906
##    -0.916   -0.965   -0.843
##    -1.248   -1.292   -1.212
##    -1.022   -1.070   -0.921
##    -1.104   -1.153   -0.991
##    -0.770   -0.814   -0.787
##    -0.838   -0.871   -1.056
##    -1.017   -1.052   -1.275
##    -0.843   -0.875   -1.121
##    -0.640   -0.712   -0.425
##     0.023   -0.032   -0.025
##    -0.266   -0.318   -0.256
##    -0.677   -0.715   -0.854
##    -0.466   -0.512   -0.469
##    -0.683   -0.723   -0.779
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stest1vocab       0.379    0.013   28.708    0.000    0.353
##    .Stst19dsgsdwrd    0.378    0.014   26.993    0.000    0.351
##    .Stest20spellng    0.545    0.017   31.687    0.000    0.512
##    .Stest21cptlztn    0.387    0.015   25.159    0.000    0.357
##    .Stest22puncttn    0.366    0.013   29.258    0.000    0.342
##    .Stest23english    0.646    0.024   27.268    0.000    0.599
##    .Stest24exprssn    0.858    0.025   33.888    0.000    0.809
##    .Stst26rdngcmpr    0.279    0.011   25.194    0.000    0.257
##    .Stst31bstrctrs    0.564    0.022   25.458    0.000    0.520
##    .Stst34rthcmptt    0.636    0.030   21.343    0.000    0.578
##    .Stest5math        0.551    0.021   26.470    0.000    0.510
##    .Stst25wrdfnctn    0.374    0.012   31.213    0.000    0.351
##    .Stst32rthrsnng    0.303    0.011   28.556    0.000    0.283
##    .Stst33hghschlm    0.227    0.009   25.550    0.000    0.209
##    .Stest35tblrdng    1.363    0.077   17.692    0.000    1.212
##    .Stst36clrclchc    1.036    0.042   24.824    0.000    0.954
##    .Stst37bjctnspc    0.940    0.035   26.630    0.000    0.871
##    .Stst28mchnclrs    0.358    0.016   22.394    0.000    0.327
##    .Stst29vslztn2D    0.734    0.026   28.204    0.000    0.683
##    .Stst30vslztn3D    0.466    0.017   27.106    0.000    0.432
##    .english           1.000                               1.000
##    .math              1.000                               1.000
##    .speed             1.000                               1.000
##    .spatial           1.000                               1.000
##     g                 1.000                               1.000
##  ci.upper   Std.lv  Std.all
##     0.404    0.379    0.354
##     0.406    0.378    0.450
##     0.579    0.545    0.543
##     0.417    0.387    0.403
##     0.391    0.366    0.349
##     0.692    0.646    0.469
##     0.908    0.858    0.656
##     0.301    0.279    0.245
##     0.607    0.564    0.417
##     0.695    0.636    0.470
##     0.592    0.551    0.516
##     0.398    0.374    0.550
##     0.324    0.303    0.446
##     0.244    0.227    0.372
##     1.514    1.363    0.486
##     1.117    1.036    0.618
##     1.009    0.940    0.610
##     0.389    0.358    0.511
##     0.785    0.734    0.616
##     0.499    0.466    0.541
##     1.000    0.124    0.124
##     1.000    0.127    0.127
##     1.000    0.844    0.844
##     1.000    0.480    0.480
##     1.000    1.000    1.000
## 
## 
## Group 2 [1]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english =~                                                   
##     Stst1vc (.p1.)    0.188    0.020    9.263    0.000    0.148
##     Stst19d (.p2.)    0.240    0.018   13.338    0.000    0.204
##     Stst20s (.p3.)    0.239    0.018   12.915    0.000    0.203
##     Stst21c (.p4.)    0.267    0.020   13.276    0.000    0.227
##     Stst22p (.p5.)    0.291    0.022   13.301    0.000    0.248
##     Stst23n (.p6.)    0.301    0.023   13.113    0.000    0.256
##     Stst24x (.p7.)    0.237    0.018   12.972    0.000    0.201
##     Stst26r (.p8.)    0.227    0.022   10.409    0.000    0.184
##     Stst31b (.p9.)    0.107    0.011    9.830    0.000    0.085
##     Stst34r (.10.)    0.115    0.017    6.905    0.000    0.083
##   math =~                                                      
##     Stst1vc (.11.)    0.115    0.019    6.159    0.000    0.079
##     Stst5mt (.12.)    0.256    0.021   12.148    0.000    0.215
##     Stst25w (.13.)    0.197    0.016   12.590    0.000    0.167
##     Stst26r (.14.)    0.110    0.017    6.321    0.000    0.076
##     Stst32r (.15.)    0.219    0.018   12.273    0.000    0.184
##     Stst33h (.16.)    0.221    0.018   12.169    0.000    0.185
##     Stst34r (.17.)    0.078    0.016    4.748    0.000    0.046
##   speed =~                                                     
##     Stst34r (.18.)    0.448    0.020   22.019    0.000    0.408
##     Stst35t (.19.)    1.103    0.032   34.111    0.000    1.040
##     Stst36c (.20.)    0.735    0.026   28.020    0.000    0.683
##     Stst37b (.21.)    0.662    0.025   26.495    0.000    0.613
##   spatial =~                                                   
##     Stst28m (.22.)    0.406    0.015   27.273    0.000    0.376
##     Sts292D (.23.)    0.469    0.018   26.694    0.000    0.435
##     Sts303D (.24.)    0.435    0.016   27.006    0.000    0.404
##     Stst31b (.25.)    0.453    0.018   25.218    0.000    0.418
##     Stst37b (.26.)    0.101    0.015    6.665    0.000    0.072
##   g =~                                                         
##     english (.27.)    2.656    0.218   12.201    0.000    2.229
##     math    (.28.)    2.619    0.229   11.422    0.000    2.169
##     speed   (.29.)    0.430    0.025   17.021    0.000    0.381
##     spatial (.30.)    1.041    0.049   21.278    0.000    0.945
##  ci.upper   Std.lv  Std.all
##                            
##     0.228    0.498    0.530
##     0.275    0.635    0.701
##     0.275    0.633    0.661
##     0.306    0.707    0.720
##     0.334    0.772    0.799
##     0.346    0.798    0.727
##     0.272    0.627    0.575
##     0.270    0.602    0.620
##     0.128    0.283    0.265
##     0.148    0.306    0.268
##                            
##     0.152    0.278    0.296
##     0.298    0.617    0.619
##     0.228    0.475    0.619
##     0.144    0.264    0.272
##     0.254    0.527    0.704
##     0.256    0.531    0.761
##     0.111    0.188    0.165
##                            
##     0.488    0.474    0.416
##     1.166    1.169    0.722
##     0.786    0.778    0.607
##     0.711    0.702    0.614
##                            
##     0.435    0.446    0.691
##     0.503    0.515    0.525
##     0.467    0.478    0.612
##     0.488    0.498    0.466
##     0.131    0.111    0.097
##                            
##     3.082    0.870    0.870
##     3.068    0.945    0.945
##     0.480    0.352    0.352
##     1.137    0.822    0.822
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stest1vocab      -1.339    0.016  -83.554    0.000   -1.370
##    .Stst19dsgsdwrd   -0.878    0.016  -54.059    0.000   -0.910
##    .Stest20spellng   -0.450    0.017  -26.686    0.000   -0.483
##    .Stest21cptlztn   -0.899    0.017  -51.477    0.000   -0.934
##    .Stest22puncttn   -0.929    0.017  -53.286    0.000   -0.963
##    .Stest23english   -0.744    0.019  -38.449    0.000   -0.781
##    .Stest24exprssn   -0.704    0.019  -37.099    0.000   -0.742
##    .Stst26rdngcmpr   -1.226    0.017  -72.842    0.000   -1.259
##    .Stst31bstrctrs   -1.260    0.019  -65.843    0.000   -1.297
##    .Stst34rthcmptt   -1.004    0.021  -47.990    0.000   -1.045
##    .Stest5math       -0.965    0.017  -55.615    0.000   -0.999
##    .Stst25wrdfnctn   -0.788    0.014  -57.181    0.000   -0.816
##    .Stst32rthrsnng   -1.184    0.013  -92.849    0.000   -1.209
##    .Stst33hghschlm   -0.942    0.012  -78.389    0.000   -0.966
##    .Stest35tblrdng   -0.524    0.029  -17.830    0.000   -0.582
##    .Stst36clrclchc    0.300    0.023   13.284    0.000    0.256
##    .Stst37bjctnspc   -0.217    0.021  -10.567    0.000   -0.257
##    .Stst28mchnclrs   -1.323    0.011 -124.285    0.000   -1.344
##    .Stst29vslztn2D   -0.916    0.017  -52.801    0.000   -0.950
##    .Stst30vslztn3D   -0.982    0.014  -72.639    0.000   -1.008
##  ci.upper   Std.lv  Std.all
##    -1.307   -1.339   -1.427
##    -0.846   -0.878   -0.969
##    -0.417   -0.450   -0.470
##    -0.865   -0.899   -0.916
##    -0.895   -0.929   -0.962
##    -0.706   -0.744   -0.677
##    -0.667   -0.704   -0.645
##    -1.193   -1.226   -1.262
##    -1.222   -1.260   -1.179
##    -0.963   -1.004   -0.880
##    -0.931   -0.965   -0.967
##    -0.761   -0.788   -1.029
##    -1.159   -1.184   -1.582
##    -0.919   -0.942   -1.351
##    -0.466   -0.524   -0.324
##     0.344    0.300    0.234
##    -0.176   -0.217   -0.190
##    -1.303   -1.323   -2.053
##    -0.882   -0.916   -0.932
##    -0.955   -0.982   -1.256
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stest1vocab       0.328    0.010   34.155    0.000    0.310
##    .Stst19dsgsdwrd    0.417    0.012   34.949    0.000    0.394
##    .Stest20spellng    0.516    0.014   37.434    0.000    0.489
##    .Stest21cptlztn    0.465    0.014   33.570    0.000    0.438
##    .Stest22puncttn    0.336    0.011   30.719    0.000    0.315
##    .Stest23english    0.567    0.017   33.753    0.000    0.534
##    .Stest24exprssn    0.798    0.021   37.747    0.000    0.756
##    .Stst26rdngcmpr    0.251    0.008   30.053    0.000    0.235
##    .Stst31bstrctrs    0.613    0.017   35.558    0.000    0.579
##    .Stst34rthcmptt    0.705    0.027   26.032    0.000    0.652
##    .Stest5math        0.613    0.017   35.594    0.000    0.580
##    .Stst25wrdfnctn    0.362    0.010   34.582    0.000    0.342
##    .Stst32rthrsnng    0.282    0.008   34.380    0.000    0.266
##    .Stst33hghschlm    0.205    0.007   29.657    0.000    0.191
##    .Stest35tblrdng    1.257    0.068   18.503    0.000    1.124
##    .Stst36clrclchc    1.038    0.033   31.200    0.000    0.973
##    .Stst37bjctnspc    0.757    0.028   27.206    0.000    0.702
##    .Stst28mchnclrs    0.217    0.007   32.673    0.000    0.204
##    .Stst29vslztn2D    0.699    0.019   36.957    0.000    0.662
##    .Stst30vslztn3D    0.383    0.011   34.955    0.000    0.361
##    .english           1.713    0.255    6.729    0.000    1.214
##    .math              0.621    0.142    4.365    0.000    0.342
##    .speed             0.983    0.065   15.188    0.000    0.856
##    .spatial           0.391    0.038   10.423    0.000    0.317
##     g                 0.753    0.035   21.320    0.000    0.684
##  ci.upper   Std.lv  Std.all
##     0.347    0.328    0.373
##     0.441    0.417    0.508
##     0.543    0.516    0.563
##     0.492    0.465    0.482
##     0.358    0.336    0.361
##     0.600    0.567    0.471
##     0.839    0.798    0.670
##     0.267    0.251    0.266
##     0.647    0.613    0.537
##     0.758    0.705    0.541
##     0.647    0.613    0.617
##     0.383    0.362    0.616
##     0.299    0.282    0.504
##     0.219    0.205    0.421
##     1.391    1.257    0.479
##     1.103    1.038    0.631
##     0.811    0.757    0.579
##     0.230    0.217    0.522
##     0.736    0.699    0.725
##     0.404    0.383    0.626
##     2.212    0.244    0.244
##     0.900    0.107    0.107
##     1.110    0.876    0.876
##     0.464    0.324    0.324
##     0.822    1.000    1.000
lavTestScore(metric, release = 1:30) 
## Warning: lavaan->lavTestScore():  
##    se is not `standard'; not implemented yet; falling back to 
##    ordinary score test
## $test
## 
## total score test:
## 
##    test      X2 df p.value
## 1 score 359.705 30       0
## 
## $uni
## 
## univariate score tests:
## 
##      lhs op    rhs      X2 df p.value
## 1   .p1. ==  .p81.  28.307  1   0.000
## 2   .p2. ==  .p82.  38.562  1   0.000
## 3   .p3. ==  .p83.   0.017  1   0.897
## 4   .p4. ==  .p84.  21.921  1   0.000
## 5   .p5. ==  .p85.   8.879  1   0.003
## 6   .p6. ==  .p86.   7.482  1   0.006
## 7   .p7. ==  .p87.   9.463  1   0.002
## 8   .p8. ==  .p88.   4.678  1   0.031
## 9   .p9. ==  .p89.  20.850  1   0.000
## 10 .p10. ==  .p90.   1.448  1   0.229
## 11 .p11. ==  .p91.  26.994  1   0.000
## 12 .p12. ==  .p92.   3.985  1   0.046
## 13 .p13. ==  .p93.  78.112  1   0.000
## 14 .p14. ==  .p94.   7.026  1   0.008
## 15 .p15. ==  .p95.   7.274  1   0.007
## 16 .p16. ==  .p96.   0.559  1   0.455
## 17 .p17. ==  .p97.   0.290  1   0.590
## 18 .p18. ==  .p98.   1.672  1   0.196
## 19 .p19. ==  .p99.   0.004  1   0.949
## 20 .p20. == .p100.   0.489  1   0.485
## 21 .p21. == .p101.   0.282  1   0.596
## 22 .p22. == .p102. 123.827  1   0.000
## 23 .p23. == .p103.   5.906  1   0.015
## 24 .p24. == .p104.   2.021  1   0.155
## 25 .p25. == .p105.  30.313  1   0.000
## 26 .p26. == .p106.   0.166  1   0.684
## 27 .p27. == .p107.  35.986  1   0.000
## 28 .p28. == .p108.   3.117  1   0.077
## 29 .p29. == .p109.   2.782  1   0.095
## 30 .p30. == .p110.  31.816  1   0.000
metric2<-cfa(chc.hof.model, data=dgroup, group="sex", meanstructure=TRUE, sampling.weights="BY_WTA", std.lv=T, group.equal=c("loadings"), group.partial=c("spatial=~Stest28mechanicalreasoning", "math=~Stest25wordfunctions"))
fitMeasures(metric2, c("chisq", "df", "pvalue", "cfi", "rmsea", "srmr", "aic", "bic"))
##      chisq         df     pvalue        cfi      rmsea       srmr 
##   3611.485    343.000      0.000      0.943      0.056      0.050 
##        aic        bic 
## 291491.216 292276.705
Mc(metric2)
## [1] 0.7644389
summary(metric2, standardized=T, ci=T)
## lavaan 0.6-18 ended normally after 114 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                       145
##   Number of equality constraints                    28
## 
##   Number of observations per group:                   
##     0                                             2443
##     1                                             3642
##   Sampling weights variable                     BY_WTA
## 
## Model Test User Model:
##                                               Standard      Scaled
##   Test Statistic                              3611.485    3207.091
##   Degrees of freedom                               343         343
##   P-value (Chi-square)                           0.000       0.000
##   Scaling correction factor                                  1.126
##     Yuan-Bentler correction (Mplus variant)                       
##   Test statistic for each group:
##     0                                         1553.071    1379.166
##     1                                         2058.415    1827.924
## 
## Parameter Estimates:
## 
##   Standard errors                             Sandwich
##   Information bread                           Observed
##   Observed information based on                Hessian
## 
## 
## Group 1 [0]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english =~                                                   
##     Stst1vc (.p1.)    0.187    0.019    9.716    0.000    0.149
##     Stst19d (.p2.)    0.240    0.017   13.888    0.000    0.206
##     Stst20s (.p3.)    0.239    0.018   13.420    0.000    0.204
##     Stst21c (.p4.)    0.267    0.019   13.837    0.000    0.229
##     Stst22p (.p5.)    0.292    0.021   13.847    0.000    0.250
##     Stst23n (.p6.)    0.302    0.022   13.616    0.000    0.258
##     Stst24x (.p7.)    0.237    0.018   13.475    0.000    0.202
##     Stst26r (.p8.)    0.227    0.021   10.902    0.000    0.186
##     Stst31b (.p9.)    0.101    0.011    9.570    0.000    0.080
##     Stst34r (.10.)    0.117    0.017    7.079    0.000    0.084
##   math =~                                                      
##     Stst1vc (.11.)    0.129    0.019    6.757    0.000    0.091
##     Stst5mt (.12.)    0.282    0.020   14.226    0.000    0.243
##     Stst25w           0.183    0.013   14.460    0.000    0.158
##     Stst26r (.14.)    0.122    0.018    6.928    0.000    0.087
##     Stst32r (.15.)    0.241    0.017   14.325    0.000    0.208
##     Stst33h (.16.)    0.242    0.017   14.225    0.000    0.209
##     Stst34r (.17.)    0.085    0.017    4.859    0.000    0.050
##   speed =~                                                     
##     Stst34r (.18.)    0.448    0.020   22.028    0.000    0.408
##     Stst35t (.19.)    1.102    0.032   34.134    0.000    1.039
##     Stst36c (.20.)    0.734    0.026   27.977    0.000    0.683
##     Stst37b (.21.)    0.662    0.025   26.505    0.000    0.613
##   spatial =~                                                   
##     Stst28m           0.450    0.015   29.971    0.000    0.421
##     Sts292D (.23.)    0.415    0.018   23.396    0.000    0.380
##     Sts303D (.24.)    0.381    0.016   23.617    0.000    0.350
##     Stst31b (.25.)    0.414    0.018   22.488    0.000    0.378
##     Stst37b (.26.)    0.089    0.014    6.566    0.000    0.063
##   g =~                                                         
##     english (.27.)    2.650    0.208   12.763    0.000    2.243
##     math    (.28.)    2.375    0.183   13.004    0.000    2.017
##     speed   (.29.)    0.429    0.025   16.974    0.000    0.380
##     spatial (.30.)    1.209    0.059   20.653    0.000    1.094
##  ci.upper   Std.lv  Std.all
##                            
##     0.225    0.530    0.512
##     0.274    0.680    0.742
##     0.274    0.677    0.676
##     0.305    0.756    0.773
##     0.333    0.826    0.807
##     0.345    0.854    0.729
##     0.271    0.671    0.587
##     0.267    0.642    0.602
##     0.121    0.285    0.245
##     0.149    0.331    0.284
##                            
##     0.166    0.331    0.320
##     0.321    0.726    0.701
##     0.208    0.472    0.609
##     0.156    0.314    0.295
##     0.274    0.621    0.751
##     0.276    0.625    0.798
##     0.119    0.218    0.188
##                            
##     0.487    0.487    0.419
##     1.166    1.200    0.717
##     0.786    0.799    0.617
##     0.711    0.720    0.580
##                            
##     0.480    0.707    0.789
##     0.450    0.651    0.599
##     0.413    0.598    0.649
##     0.450    0.649    0.558
##     0.116    0.140    0.113
##                            
##     3.057    0.936    0.936
##     2.732    0.922    0.922
##     0.479    0.395    0.395
##     1.324    0.771    0.771
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stest1vocab      -1.155    0.023  -50.360    0.000   -1.200
##    .Stst19dsgsdwrd   -0.992    0.018  -53.776    0.000   -1.028
##    .Stest20spellng   -0.848    0.021  -39.900    0.000   -0.890
##    .Stest21cptlztn   -1.167    0.020  -58.007    0.000   -1.206
##    .Stest22puncttn   -1.226    0.021  -57.496    0.000   -1.268
##    .Stest23english   -1.062    0.026  -41.362    0.000   -1.113
##    .Stest24exprssn   -0.965    0.025  -38.928    0.000   -1.014
##    .Stst26rdngcmpr   -1.292    0.023  -56.802    0.000   -1.337
##    .Stst31bstrctrs   -1.070    0.024  -43.766    0.000   -1.118
##    .Stst34rthcmptt   -1.153    0.025  -46.702    0.000   -1.201
##    .Stest5math       -0.814    0.022  -36.442    0.000   -0.857
##    .Stst25wrdfnctn   -0.871    0.017  -52.726    0.000   -0.903
##    .Stst32rthrsnng   -1.052    0.018  -59.194    0.000   -1.087
##    .Stst33hghschlm   -0.875    0.016  -53.483    0.000   -0.907
##    .Stest35tblrdng   -0.712    0.037  -19.463    0.000   -0.784
##    .Stst36clrclchc   -0.032    0.028   -1.139    0.255   -0.086
##    .Stst37bjctnspc   -0.318    0.027  -11.957    0.000   -0.370
##    .Stst28mchnclrs   -0.715    0.019  -36.895    0.000   -0.753
##    .Stst29vslztn2D   -0.512    0.023  -22.047    0.000   -0.557
##    .Stst30vslztn3D   -0.723    0.020  -35.874    0.000   -0.762
##  ci.upper   Std.lv  Std.all
##    -1.110   -1.155   -1.117
##    -0.956   -0.992   -1.082
##    -0.806   -0.848   -0.846
##    -1.128   -1.167   -1.192
##    -1.184   -1.226   -1.198
##    -1.012   -1.062   -0.906
##    -0.916   -0.965   -0.844
##    -1.248   -1.292   -1.212
##    -1.022   -1.070   -0.920
##    -1.104   -1.153   -0.991
##    -0.770   -0.814   -0.785
##    -0.838   -0.871   -1.123
##    -1.017   -1.052   -1.271
##    -0.843   -0.875   -1.118
##    -0.640   -0.712   -0.426
##     0.023   -0.032   -0.025
##    -0.266   -0.318   -0.256
##    -0.677   -0.715   -0.798
##    -0.466   -0.512   -0.470
##    -0.683   -0.723   -0.784
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stest1vocab       0.376    0.013   28.554    0.000    0.350
##    .Stst19dsgsdwrd    0.378    0.014   27.004    0.000    0.350
##    .Stest20spellng    0.547    0.017   31.669    0.000    0.513
##    .Stest21cptlztn    0.386    0.015   25.153    0.000    0.356
##    .Stest22puncttn    0.366    0.013   29.187    0.000    0.341
##    .Stest23english    0.644    0.024   27.249    0.000    0.597
##    .Stest24exprssn    0.858    0.025   33.866    0.000    0.809
##    .Stst26rdngcmpr    0.278    0.011   25.187    0.000    0.257
##    .Stst31bstrctrs    0.583    0.022   26.152    0.000    0.539
##    .Stst34rthcmptt    0.637    0.030   21.364    0.000    0.579
##    .Stest5math        0.546    0.021   26.354    0.000    0.506
##    .Stst25wrdfnctn    0.378    0.012   31.716    0.000    0.355
##    .Stst32rthrsnng    0.299    0.011   28.115    0.000    0.278
##    .Stst33hghschlm    0.223    0.009   25.066    0.000    0.205
##    .Stest35tblrdng    1.361    0.077   17.689    0.000    1.211
##    .Stst36clrclchc    1.036    0.042   24.826    0.000    0.954
##    .Stst37bjctnspc    0.942    0.035   26.666    0.000    0.873
##    .Stst28mchnclrs    0.303    0.015   19.713    0.000    0.273
##    .Stst29vslztn2D    0.758    0.026   29.349    0.000    0.708
##    .Stst30vslztn3D    0.493    0.017   28.783    0.000    0.459
##    .english           1.000                               1.000
##    .math              1.000                               1.000
##    .speed             1.000                               1.000
##    .spatial           1.000                               1.000
##     g                 1.000                               1.000
##  ci.upper   Std.lv  Std.all
##     0.402    0.376    0.352
##     0.405    0.378    0.450
##     0.581    0.547    0.544
##     0.417    0.386    0.403
##     0.391    0.366    0.349
##     0.690    0.644    0.469
##     0.908    0.858    0.656
##     0.300    0.278    0.245
##     0.627    0.583    0.431
##     0.696    0.637    0.471
##     0.587    0.546    0.509
##     0.402    0.378    0.629
##     0.320    0.299    0.437
##     0.240    0.223    0.363
##     1.512    1.361    0.486
##     1.118    1.036    0.619
##     1.011    0.942    0.611
##     0.334    0.303    0.378
##     0.809    0.758    0.641
##     0.526    0.493    0.579
##     1.000    0.125    0.125
##     1.000    0.151    0.151
##     1.000    0.844    0.844
##     1.000    0.406    0.406
##     1.000    1.000    1.000
## 
## 
## Group 2 [1]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english =~                                                   
##     Stst1vc (.p1.)    0.187    0.019    9.716    0.000    0.149
##     Stst19d (.p2.)    0.240    0.017   13.888    0.000    0.206
##     Stst20s (.p3.)    0.239    0.018   13.420    0.000    0.204
##     Stst21c (.p4.)    0.267    0.019   13.837    0.000    0.229
##     Stst22p (.p5.)    0.292    0.021   13.847    0.000    0.250
##     Stst23n (.p6.)    0.302    0.022   13.616    0.000    0.258
##     Stst24x (.p7.)    0.237    0.018   13.475    0.000    0.202
##     Stst26r (.p8.)    0.227    0.021   10.902    0.000    0.186
##     Stst31b (.p9.)    0.101    0.011    9.570    0.000    0.080
##     Stst34r (.10.)    0.117    0.017    7.079    0.000    0.084
##   math =~                                                      
##     Stst1vc (.11.)    0.129    0.019    6.757    0.000    0.091
##     Stst5mt (.12.)    0.282    0.020   14.226    0.000    0.243
##     Stst25w           0.249    0.018   13.513    0.000    0.213
##     Stst26r (.14.)    0.122    0.018    6.928    0.000    0.087
##     Stst32r (.15.)    0.241    0.017   14.325    0.000    0.208
##     Stst33h (.16.)    0.242    0.017   14.225    0.000    0.209
##     Stst34r (.17.)    0.085    0.017    4.859    0.000    0.050
##   speed =~                                                     
##     Stst34r (.18.)    0.448    0.020   22.028    0.000    0.408
##     Stst35t (.19.)    1.102    0.032   34.134    0.000    1.039
##     Stst36c (.20.)    0.734    0.026   27.977    0.000    0.683
##     Stst37b (.21.)    0.662    0.025   26.505    0.000    0.613
##   spatial =~                                                   
##     Stst28m           0.289    0.016   18.534    0.000    0.258
##     Sts292D (.23.)    0.415    0.018   23.396    0.000    0.380
##     Sts303D (.24.)    0.381    0.016   23.617    0.000    0.350
##     Stst31b (.25.)    0.414    0.018   22.488    0.000    0.378
##     Stst37b (.26.)    0.089    0.014    6.566    0.000    0.063
##   g =~                                                         
##     english (.27.)    2.650    0.208   12.763    0.000    2.243
##     math    (.28.)    2.375    0.183   13.004    0.000    2.017
##     speed   (.29.)    0.429    0.025   16.974    0.000    0.380
##     spatial (.30.)    1.209    0.059   20.653    0.000    1.094
##  ci.upper   Std.lv  Std.all
##                            
##     0.225    0.495    0.528
##     0.274    0.636    0.701
##     0.274    0.633    0.662
##     0.305    0.707    0.720
##     0.333    0.772    0.800
##     0.345    0.799    0.728
##     0.271    0.627    0.575
##     0.267    0.600    0.618
##     0.121    0.266    0.247
##     0.149    0.309    0.271
##                            
##     0.166    0.278    0.296
##     0.321    0.608    0.612
##     0.286    0.539    0.674
##     0.156    0.263    0.271
##     0.274    0.520    0.699
##     0.276    0.523    0.753
##     0.119    0.183    0.160
##                            
##     0.487    0.475    0.416
##     1.166    1.169    0.722
##     0.786    0.779    0.607
##     0.711    0.702    0.614
##                            
##     0.319    0.381    0.621
##     0.450    0.547    0.553
##     0.413    0.503    0.638
##     0.450    0.545    0.506
##     0.116    0.118    0.103
##                            
##     3.057    0.868    0.868
##     2.732    0.955    0.955
##     0.479    0.351    0.351
##     1.324    0.796    0.796
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stest1vocab      -1.339    0.016  -83.554    0.000   -1.370
##    .Stst19dsgsdwrd   -0.878    0.016  -54.059    0.000   -0.910
##    .Stest20spellng   -0.450    0.017  -26.686    0.000   -0.483
##    .Stest21cptlztn   -0.899    0.017  -51.477    0.000   -0.934
##    .Stest22puncttn   -0.929    0.017  -53.286    0.000   -0.963
##    .Stest23english   -0.744    0.019  -38.449    0.000   -0.781
##    .Stest24exprssn   -0.704    0.019  -37.099    0.000   -0.742
##    .Stst26rdngcmpr   -1.226    0.017  -72.842    0.000   -1.259
##    .Stst31bstrctrs   -1.260    0.019  -65.843    0.000   -1.297
##    .Stst34rthcmptt   -1.004    0.021  -47.990    0.000   -1.045
##    .Stest5math       -0.965    0.017  -55.615    0.000   -0.999
##    .Stst25wrdfnctn   -0.788    0.014  -57.181    0.000   -0.816
##    .Stst32rthrsnng   -1.184    0.013  -92.849    0.000   -1.209
##    .Stst33hghschlm   -0.942    0.012  -78.389    0.000   -0.966
##    .Stest35tblrdng   -0.524    0.029  -17.830    0.000   -0.582
##    .Stst36clrclchc    0.300    0.023   13.284    0.000    0.256
##    .Stst37bjctnspc   -0.217    0.021  -10.567    0.000   -0.257
##    .Stst28mchnclrs   -1.323    0.011 -124.285    0.000   -1.344
##    .Stst29vslztn2D   -0.916    0.017  -52.801    0.000   -0.950
##    .Stst30vslztn3D   -0.982    0.014  -72.639    0.000   -1.008
##  ci.upper   Std.lv  Std.all
##    -1.307   -1.339   -1.428
##    -0.846   -0.878   -0.969
##    -0.417   -0.450   -0.470
##    -0.865   -0.899   -0.916
##    -0.895   -0.929   -0.962
##    -0.706   -0.744   -0.677
##    -0.667   -0.704   -0.645
##    -1.193   -1.226   -1.263
##    -1.222   -1.260   -1.170
##    -0.963   -1.004   -0.880
##    -0.931   -0.965   -0.971
##    -0.761   -0.788   -0.987
##    -1.159   -1.184   -1.590
##    -0.919   -0.942   -1.357
##    -0.466   -0.524   -0.323
##     0.344    0.300    0.234
##    -0.176   -0.217   -0.189
##    -1.303   -1.323   -2.159
##    -0.882   -0.916   -0.925
##    -0.955   -0.982   -1.246
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stest1vocab       0.329    0.010   34.227    0.000    0.310
##    .Stst19dsgsdwrd    0.418    0.012   34.935    0.000    0.394
##    .Stest20spellng    0.515    0.014   37.421    0.000    0.488
##    .Stest21cptlztn    0.465    0.014   33.610    0.000    0.438
##    .Stest22puncttn    0.336    0.011   30.815    0.000    0.315
##    .Stest23english    0.568    0.017   33.760    0.000    0.535
##    .Stest24exprssn    0.798    0.021   37.776    0.000    0.756
##    .Stst26rdngcmpr    0.252    0.008   30.048    0.000    0.235
##    .Stst31bstrctrs    0.590    0.017   33.841    0.000    0.556
##    .Stst34rthcmptt    0.705    0.027   26.029    0.000    0.652
##    .Stest5math        0.616    0.017   35.718    0.000    0.583
##    .Stst25wrdfnctn    0.349    0.010   33.868    0.000    0.328
##    .Stst32rthrsnng    0.284    0.008   34.723    0.000    0.268
##    .Stst33hghschlm    0.209    0.007   30.268    0.000    0.195
##    .Stest35tblrdng    1.259    0.068   18.487    0.000    1.125
##    .Stst36clrclchc    1.037    0.033   31.122    0.000    0.972
##    .Stst37bjctnspc    0.755    0.028   27.178    0.000    0.701
##    .Stst28mchnclrs    0.231    0.007   33.858    0.000    0.218
##    .Stst29vslztn2D    0.681    0.019   35.545    0.000    0.643
##    .Stst30vslztn3D    0.369    0.011   33.334    0.000    0.347
##    .english           1.726    0.249    6.935    0.000    1.238
##    .math              0.412    0.102    4.028    0.000    0.212
##    .speed             0.986    0.065   15.203    0.000    0.859
##    .spatial           0.637    0.069    9.237    0.000    0.502
##     g                 0.753    0.034   21.921    0.000    0.686
##  ci.upper   Std.lv  Std.all
##     0.348    0.329    0.374
##     0.441    0.418    0.508
##     0.542    0.515    0.562
##     0.492    0.465    0.482
##     0.357    0.336    0.360
##     0.600    0.568    0.471
##     0.839    0.798    0.670
##     0.268    0.252    0.267
##     0.625    0.590    0.509
##     0.758    0.705    0.542
##     0.650    0.616    0.625
##     0.369    0.349    0.546
##     0.300    0.284    0.512
##     0.222    0.209    0.432
##     1.392    1.259    0.479
##     1.103    1.037    0.631
##     0.810    0.755    0.577
##     0.244    0.231    0.614
##     0.718    0.681    0.694
##     0.390    0.369    0.593
##     2.214    0.246    0.246
##     0.613    0.089    0.089
##     1.113    0.877    0.877
##     0.772    0.367    0.367
##     0.820    1.000    1.000
lavTestScore(metric2, release = 1:28) 
## Warning: lavaan->lavTestScore():  
##    se is not `standard'; not implemented yet; falling back to 
##    ordinary score test
## $test
## 
## total score test:
## 
##    test      X2 df p.value
## 1 score 167.523 28       0
## 
## $uni
## 
## univariate score tests:
## 
##      lhs op    rhs     X2 df p.value
## 1   .p1. ==  .p81. 24.994  1   0.000
## 2   .p2. ==  .p82. 37.529  1   0.000
## 3   .p3. ==  .p83.  0.037  1   0.847
## 4   .p4. ==  .p84. 21.163  1   0.000
## 5   .p5. ==  .p85.  8.608  1   0.003
## 6   .p6. ==  .p86.  8.153  1   0.004
## 7   .p7. ==  .p87.  9.699  1   0.002
## 8   .p8. ==  .p88.  3.038  1   0.081
## 9   .p9. ==  .p89.  9.322  1   0.002
## 10 .p10. ==  .p90.  2.124  1   0.145
## 11 .p11. ==  .p91. 24.183  1   0.000
## 12 .p12. ==  .p92.  1.000  1   0.317
## 13 .p14. ==  .p94.  4.951  1   0.026
## 14 .p15. ==  .p95.  2.145  1   0.143
## 15 .p16. ==  .p96.  0.419  1   0.517
## 16 .p17. ==  .p97.  0.567  1   0.451
## 17 .p18. ==  .p98.  2.028  1   0.154
## 18 .p19. ==  .p99.  0.000  1   0.987
## 19 .p20. == .p100.  0.420  1   0.517
## 20 .p21. == .p101.  0.078  1   0.781
## 21 .p23. == .p103.  0.007  1   0.934
## 22 .p24. == .p104. 19.907  1   0.000
## 23 .p25. == .p105.  9.603  1   0.002
## 24 .p26. == .p106.  0.117  1   0.732
## 25 .p27. == .p107. 35.149  1   0.000
## 26 .p28. == .p108. 27.942  1   0.000
## 27 .p29. == .p109.  2.056  1   0.152
## 28 .p30. == .p110.  1.933  1   0.164
scalar<-cfa(chc.hof.model, data=dgroup, group="sex", meanstructure=TRUE, sampling.weights="BY_WTA", std.lv=T, group.equal=c("loadings", "intercepts"), group.partial=c("spatial=~Stest28mechanicalreasoning", "math=~Stest25wordfunctions"))
## Warning: lavaan->lav_model_vcov():  
##    The variance-covariance matrix of the estimated parameters (vcov) 
##    does not appear to be positive definite! The smallest eigenvalue 
##    (= 5.569568e-14) is close to zero. This may be a symptom that the 
##    model is not identified.
fitMeasures(scalar, c("chisq", "df", "pvalue", "cfi", "rmsea", "srmr", "aic", "bic"))
##      chisq         df     pvalue        cfi      rmsea       srmr 
##   4525.936    358.000      0.000      0.927      0.062      0.055 
##        aic        bic 
## 292375.667 293060.452
Mc(scalar)
## [1] 0.70997
summary(scalar, standardized=T, ci=T)
## lavaan 0.6-18 ended normally after 139 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                       150
##   Number of equality constraints                    48
## 
##   Number of observations per group:                   
##     0                                             2443
##     1                                             3642
##   Sampling weights variable                     BY_WTA
## 
## Model Test User Model:
##                                               Standard      Scaled
##   Test Statistic                              4525.936    4020.142
##   Degrees of freedom                               358         358
##   P-value (Chi-square)                           0.000       0.000
##   Scaling correction factor                                  1.126
##     Yuan-Bentler correction (Mplus variant)                       
##   Test statistic for each group:
##     0                                         2048.268    1819.364
##     1                                         2477.668    2200.778
## 
## Parameter Estimates:
## 
##   Standard errors                             Sandwich
##   Information bread                           Observed
##   Observed information based on                Hessian
## 
## 
## Group 1 [0]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english =~                                                   
##     Stst1vc (.p1.)    0.070    0.017    4.121    0.000    0.037
##     Stst19d (.p2.)    0.212    0.021   10.139    0.000    0.171
##     Stst20s (.p3.)    0.221    0.022    9.926    0.000    0.178
##     Stst21c (.p4.)    0.243    0.024   10.128    0.000    0.196
##     Stst22p (.p5.)    0.266    0.026   10.134    0.000    0.215
##     Stst23n (.p6.)    0.274    0.027   10.015    0.000    0.221
##     Stst24x (.p7.)    0.216    0.022    9.956    0.000    0.173
##     Stst26r (.p8.)    0.152    0.021    7.412    0.000    0.112
##     Stst31b (.p9.)    0.123    0.013    9.759    0.000    0.099
##     Stst34r (.10.)    0.101    0.015    6.806    0.000    0.072
##   math =~                                                      
##     Stst1vc (.11.)    0.229    0.022   10.329    0.000    0.185
##     Stst5mt (.12.)    0.251    0.022   11.209    0.000    0.207
##     Stst25w           0.158    0.014   11.256    0.000    0.131
##     Stst26r (.14.)    0.170    0.017    9.851    0.000    0.136
##     Stst32r (.15.)    0.213    0.019   11.229    0.000    0.176
##     Stst33h (.16.)    0.211    0.019   11.136    0.000    0.174
##     Stst34r (.17.)    0.080    0.014    5.592    0.000    0.052
##   speed =~                                                     
##     Stst34r (.18.)    0.445    0.020   22.111    0.000    0.406
##     Stst35t (.19.)    1.089    0.033   33.295    0.000    1.025
##     Stst36c (.20.)    0.750    0.026   28.987    0.000    0.699
##     Stst37b (.21.)    0.673    0.024   28.470    0.000    0.626
##   spatial =~                                                   
##     Stst28m           0.482    0.015   32.724    0.000    0.453
##     Sts292D (.23.)    0.433    0.019   22.741    0.000    0.396
##     Sts303D (.24.)    0.381    0.017   22.685    0.000    0.348
##     Stst31b (.25.)    0.364    0.018   20.714    0.000    0.330
##     Stst37b (.26.)    0.092    0.013    7.008    0.000    0.066
##   g =~                                                         
##     english (.27.)    2.958    0.308    9.591    0.000    2.354
##     math    (.28.)    2.712    0.261   10.405    0.000    2.201
##     speed   (.29.)    0.421    0.025   16.549    0.000    0.371
##     spatial (.30.)    1.079    0.058   18.482    0.000    0.965
##  ci.upper   Std.lv  Std.all
##                            
##     0.104    0.220    0.208
##     0.253    0.663    0.731
##     0.265    0.691    0.681
##     0.290    0.759    0.776
##     0.318    0.832    0.812
##     0.328    0.857    0.730
##     0.258    0.674    0.589
##     0.192    0.475    0.442
##     0.148    0.385    0.334
##     0.130    0.316    0.271
##                            
##     0.272    0.661    0.626
##     0.294    0.724    0.697
##     0.186    0.458    0.587
##     0.204    0.492    0.457
##     0.250    0.615    0.740
##     0.248    0.610    0.777
##     0.109    0.233    0.200
##                            
##     0.485    0.483    0.416
##     1.153    1.182    0.707
##     0.800    0.813    0.625
##     0.719    0.730    0.588
##                            
##     0.511    0.709    0.786
##     0.471    0.637    0.591
##     0.414    0.560    0.615
##     0.398    0.536    0.465
##     0.117    0.135    0.109
##                            
##     3.563    0.947    0.947
##     3.223    0.938    0.938
##     0.471    0.388    0.388
##     1.194    0.734    0.734
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stst1vc (.56.)   -1.315    0.027  -49.293    0.000   -1.367
##    .Stst19d (.57.)   -1.108    0.018  -61.652    0.000   -1.144
##    .Stst20s (.58.)   -0.803    0.022  -37.216    0.000   -0.845
##    .Stst21c (.59.)   -1.222    0.021  -57.917    0.000   -1.263
##    .Stst22p (.60.)   -1.283    0.023  -54.801    0.000   -1.329
##    .Stst23n (.61.)   -1.113    0.026  -43.261    0.000   -1.164
##    .Stst24x (.62.)   -0.999    0.022  -44.813    0.000   -1.043
##    .Stst26r (.63.)   -1.375    0.026  -53.208    0.000   -1.426
##    .Stst31b (.64.)   -1.093    0.026  -41.466    0.000   -1.145
##    .Stst34r (.65.)   -1.232    0.025  -49.229    0.000   -1.281
##    .Stst5mt (.66.)   -0.885    0.021  -41.530    0.000   -0.927
##    .Stst25w (.67.)   -0.797    0.016  -49.013    0.000   -0.829
##    .Stst32r (.68.)   -1.116    0.017  -64.343    0.000   -1.150
##    .Stst33h (.69.)   -0.899    0.017  -53.211    0.000   -0.932
##    .Stst35t (.70.)   -0.813    0.035  -23.204    0.000   -0.882
##    .Stst36c (.71.)    0.021    0.026    0.812    0.417   -0.030
##    .Stst37b (.72.)   -0.337    0.024  -13.752    0.000   -0.384
##    .Stst28m (.73.)   -0.883    0.026  -34.379    0.000   -0.934
##    .Sts292D (.74.)   -0.514    0.023  -22.564    0.000   -0.558
##    .Sts303D (.75.)   -0.658    0.020  -33.598    0.000   -0.696
##  ci.upper   Std.lv  Std.all
##    -1.262   -1.315   -1.244
##    -1.073   -1.108   -1.221
##    -0.761   -0.803   -0.790
##    -1.180   -1.222   -1.249
##    -1.238   -1.283   -1.253
##    -1.063   -1.113   -0.949
##    -0.955   -0.999   -0.873
##    -1.324   -1.375   -1.278
##    -1.041   -1.093   -0.948
##    -1.183   -1.232   -1.060
##    -0.843   -0.885   -0.852
##    -0.765   -0.797   -1.022
##    -1.082   -1.116   -1.342
##    -0.866   -0.899   -1.146
##    -0.745   -0.813   -0.487
##     0.072    0.021    0.016
##    -0.289   -0.337   -0.271
##    -0.833   -0.883   -0.979
##    -0.469   -0.514   -0.476
##    -0.620   -0.658   -0.723
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stest1vocab       0.372    0.015   24.347    0.000    0.342
##    .Stst19dsgsdwrd    0.384    0.015   26.226    0.000    0.355
##    .Stest20spellng    0.554    0.018   31.369    0.000    0.519
##    .Stest21cptlztn    0.381    0.015   24.934    0.000    0.351
##    .Stest22puncttn    0.357    0.012   28.943    0.000    0.333
##    .Stest23english    0.642    0.024   27.163    0.000    0.596
##    .Stest24exprssn    0.857    0.025   33.668    0.000    0.807
##    .Stst26rdngcmpr    0.274    0.011   24.206    0.000    0.252
##    .Stst31bstrctrs    0.606    0.022   27.715    0.000    0.563
##    .Stst34rthcmptt    0.640    0.030   21.341    0.000    0.581
##    .Stest5math        0.554    0.021   26.553    0.000    0.513
##    .Stst25wrdfnctn    0.398    0.013   31.360    0.000    0.373
##    .Stst32rthrsnng    0.313    0.011   27.904    0.000    0.291
##    .Stst33hghschlm    0.244    0.009   25.858    0.000    0.226
##    .Stest35tblrdng    1.395    0.076   18.401    0.000    1.246
##    .Stst36clrclchc    1.031    0.043   24.154    0.000    0.948
##    .Stst37bjctnspc    0.933    0.035   26.310    0.000    0.864
##    .Stst28mchnclrs    0.311    0.018   17.141    0.000    0.276
##    .Stst29vslztn2D    0.758    0.026   28.839    0.000    0.706
##    .Stst30vslztn3D    0.515    0.018   28.623    0.000    0.480
##    .english           1.000                               1.000
##    .math              1.000                               1.000
##    .speed             1.000                               1.000
##    .spatial           1.000                               1.000
##     g                 1.000                               1.000
##  ci.upper   Std.lv  Std.all
##     0.402    0.372    0.333
##     0.413    0.384    0.466
##     0.588    0.554    0.537
##     0.411    0.381    0.398
##     0.382    0.357    0.341
##     0.688    0.642    0.467
##     0.907    0.857    0.654
##     0.296    0.274    0.237
##     0.649    0.606    0.456
##     0.698    0.640    0.474
##     0.595    0.554    0.514
##     0.423    0.398    0.655
##     0.335    0.313    0.453
##     0.263    0.244    0.397
##     1.543    1.395    0.500
##     1.115    1.031    0.609
##     1.003    0.933    0.606
##     0.347    0.311    0.382
##     0.809    0.758    0.651
##     0.551    0.515    0.622
##     1.000    0.103    0.103
##     1.000    0.120    0.120
##     1.000    0.849    0.849
##     1.000    0.462    0.462
##     1.000    1.000    1.000
## 
## 
## Group 2 [1]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english =~                                                   
##     Stst1vc (.p1.)    0.070    0.017    4.121    0.000    0.037
##     Stst19d (.p2.)    0.212    0.021   10.139    0.000    0.171
##     Stst20s (.p3.)    0.221    0.022    9.926    0.000    0.178
##     Stst21c (.p4.)    0.243    0.024   10.128    0.000    0.196
##     Stst22p (.p5.)    0.266    0.026   10.134    0.000    0.215
##     Stst23n (.p6.)    0.274    0.027   10.015    0.000    0.221
##     Stst24x (.p7.)    0.216    0.022    9.956    0.000    0.173
##     Stst26r (.p8.)    0.152    0.021    7.412    0.000    0.112
##     Stst31b (.p9.)    0.123    0.013    9.759    0.000    0.099
##     Stst34r (.10.)    0.101    0.015    6.806    0.000    0.072
##   math =~                                                      
##     Stst1vc (.11.)    0.229    0.022   10.329    0.000    0.185
##     Stst5mt (.12.)    0.251    0.022   11.209    0.000    0.207
##     Stst25w           0.215    0.020   10.809    0.000    0.176
##     Stst26r (.14.)    0.170    0.017    9.851    0.000    0.136
##     Stst32r (.15.)    0.213    0.019   11.229    0.000    0.176
##     Stst33h (.16.)    0.211    0.019   11.136    0.000    0.174
##     Stst34r (.17.)    0.080    0.014    5.592    0.000    0.052
##   speed =~                                                     
##     Stst34r (.18.)    0.445    0.020   22.111    0.000    0.406
##     Stst35t (.19.)    1.089    0.033   33.295    0.000    1.025
##     Stst36c (.20.)    0.750    0.026   28.987    0.000    0.699
##     Stst37b (.21.)    0.673    0.024   28.470    0.000    0.626
##   spatial =~                                                   
##     Stst28m           0.389    0.022   17.364    0.000    0.345
##     Sts292D (.23.)    0.433    0.019   22.741    0.000    0.396
##     Sts303D (.24.)    0.381    0.017   22.685    0.000    0.348
##     Stst31b (.25.)    0.364    0.018   20.714    0.000    0.330
##     Stst37b (.26.)    0.092    0.013    7.008    0.000    0.066
##   g =~                                                         
##     english (.27.)    2.958    0.308    9.591    0.000    2.354
##     math    (.28.)    2.712    0.261   10.405    0.000    2.201
##     speed   (.29.)    0.421    0.025   16.549    0.000    0.371
##     spatial (.30.)    1.079    0.058   18.482    0.000    0.965
##  ci.upper   Std.lv  Std.all
##                            
##     0.104    0.207    0.222
##     0.253    0.623    0.690
##     0.265    0.649    0.670
##     0.290    0.712    0.725
##     0.318    0.781    0.809
##     0.328    0.804    0.732
##     0.258    0.633    0.579
##     0.192    0.446    0.462
##     0.148    0.362    0.337
##     0.130    0.296    0.260
##                            
##     0.272    0.549    0.590
##     0.294    0.602    0.605
##     0.255    0.517    0.650
##     0.204    0.408    0.423
##     0.250    0.511    0.686
##     0.248    0.506    0.732
##     0.109    0.193    0.170
##                            
##     0.485    0.471    0.414
##     1.153    1.152    0.713
##     0.800    0.793    0.616
##     0.719    0.712    0.622
##                            
##     0.433    0.457    0.702
##     0.471    0.508    0.518
##     0.414    0.446    0.580
##     0.398    0.427    0.397
##     0.117    0.107    0.094
##                            
##     3.563    0.873    0.873
##     3.223    0.977    0.977
##     0.471    0.344    0.344
##     1.194    0.796    0.796
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stst1vc (.56.)   -1.315    0.027  -49.293    0.000   -1.367
##    .Stst19d (.57.)   -1.108    0.018  -61.652    0.000   -1.144
##    .Stst20s (.58.)   -0.803    0.022  -37.216    0.000   -0.845
##    .Stst21c (.59.)   -1.222    0.021  -57.917    0.000   -1.263
##    .Stst22p (.60.)   -1.283    0.023  -54.801    0.000   -1.329
##    .Stst23n (.61.)   -1.113    0.026  -43.261    0.000   -1.164
##    .Stst24x (.62.)   -0.999    0.022  -44.813    0.000   -1.043
##    .Stst26r (.63.)   -1.375    0.026  -53.208    0.000   -1.426
##    .Stst31b (.64.)   -1.093    0.026  -41.466    0.000   -1.145
##    .Stst34r (.65.)   -1.232    0.025  -49.229    0.000   -1.281
##    .Stst5mt (.66.)   -0.885    0.021  -41.530    0.000   -0.927
##    .Stst25w (.67.)   -0.797    0.016  -49.013    0.000   -0.829
##    .Stst32r (.68.)   -1.116    0.017  -64.343    0.000   -1.150
##    .Stst33h (.69.)   -0.899    0.017  -53.211    0.000   -0.932
##    .Stst35t (.70.)   -0.813    0.035  -23.204    0.000   -0.882
##    .Stst36c (.71.)    0.021    0.026    0.812    0.417   -0.030
##    .Stst37b (.72.)   -0.337    0.024  -13.752    0.000   -0.384
##    .Stst28m (.73.)   -0.883    0.026  -34.379    0.000   -0.934
##    .Sts292D (.74.)   -0.514    0.023  -22.564    0.000   -0.558
##    .Sts303D (.75.)   -0.658    0.020  -33.598    0.000   -0.696
##    .english           1.146    0.067   17.070    0.000    1.014
##    .math             -0.435    0.060   -7.287    0.000   -0.552
##    .speed             0.278    0.038    7.231    0.000    0.202
##    .spatial          -1.062    0.056  -19.016    0.000   -1.171
##     g                 0.059    0.037    1.582    0.114   -0.014
##  ci.upper   Std.lv  Std.all
##    -1.262   -1.315   -1.412
##    -1.073   -1.108   -1.228
##    -0.761   -0.803   -0.829
##    -1.180   -1.222   -1.243
##    -1.238   -1.283   -1.330
##    -1.063   -1.113   -1.014
##    -0.955   -0.999   -0.915
##    -1.324   -1.375   -1.425
##    -1.041   -1.093   -1.017
##    -1.183   -1.232   -1.083
##    -0.843   -0.885   -0.890
##    -0.765   -0.797   -1.001
##    -1.082   -1.116   -1.498
##    -0.866   -0.899   -1.299
##    -0.745   -0.813   -0.503
##     0.072    0.021    0.016
##    -0.289   -0.337   -0.294
##    -0.833   -0.883   -1.359
##    -0.469   -0.514   -0.524
##    -0.620   -0.658   -0.855
##     1.277    0.391    0.391
##    -0.318   -0.181   -0.181
##     0.353    0.262    0.262
##    -0.952   -0.905   -0.905
##     0.132    0.068    0.068
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stest1vocab       0.329    0.011   30.858    0.000    0.308
##    .Stst19dsgsdwrd    0.428    0.012   35.131    0.000    0.404
##    .Stest20spellng    0.516    0.014   37.062    0.000    0.489
##    .Stest21cptlztn    0.459    0.014   33.679    0.000    0.432
##    .Stest22puncttn    0.322    0.011   30.578    0.000    0.301
##    .Stest23english    0.559    0.017   33.463    0.000    0.527
##    .Stest24exprssn    0.793    0.021   37.653    0.000    0.752
##    .Stst26rdngcmpr    0.255    0.008   30.429    0.000    0.238
##    .Stst31bstrctrs    0.626    0.017   36.001    0.000    0.592
##    .Stst34rthcmptt    0.706    0.027   26.230    0.000    0.653
##    .Stest5math        0.626    0.017   35.867    0.000    0.591
##    .Stst25wrdfnctn    0.366    0.011   34.168    0.000    0.345
##    .Stst32rthrsnng    0.294    0.009   34.332    0.000    0.277
##    .Stst33hghschlm    0.223    0.007   30.791    0.000    0.209
##    .Stest35tblrdng    1.285    0.068   18.795    0.000    1.151
##    .Stst36clrclchc    1.031    0.033   30.859    0.000    0.965
##    .Stst37bjctnspc    0.750    0.027   27.435    0.000    0.696
##    .Stst28mchnclrs    0.214    0.007   29.056    0.000    0.200
##    .Stst29vslztn2D    0.704    0.020   35.770    0.000    0.665
##    .Stst30vslztn3D    0.394    0.012   34.027    0.000    0.371
##    .english           2.042    0.367    5.563    0.000    1.322
##    .math              0.258    0.104    2.480    0.013    0.054
##    .speed             0.987    0.064   15.346    0.000    0.861
##    .spatial           0.503    0.064    7.872    0.000    0.378
##     g                 0.749    0.034   22.124    0.000    0.682
##  ci.upper   Std.lv  Std.all
##     0.350    0.329    0.379
##     0.451    0.428    0.524
##     0.543    0.516    0.551
##     0.485    0.459    0.475
##     0.342    0.322    0.345
##     0.592    0.559    0.464
##     0.834    0.793    0.665
##     0.271    0.255    0.274
##     0.660    0.626    0.543
##     0.759    0.706    0.545
##     0.660    0.626    0.633
##     0.387    0.366    0.578
##     0.310    0.294    0.529
##     0.237    0.223    0.465
##     1.419    1.285    0.492
##     1.096    1.031    0.621
##     0.803    0.750    0.572
##     0.229    0.214    0.507
##     0.743    0.704    0.732
##     0.416    0.394    0.664
##     2.761    0.238    0.238
##     0.462    0.045    0.045
##     1.113    0.881    0.881
##     0.628    0.366    0.366
##     0.815    1.000    1.000
lavTestScore(scalar, release = 29:48) 
## Warning: lavaan->lavTestScore():  
##    se is not `standard'; not implemented yet; falling back to 
##    ordinary score test
## $test
## 
## total score test:
## 
##    test      X2 df p.value
## 1 score 859.512 20       0
## 
## $uni
## 
## univariate score tests:
## 
##      lhs op    rhs      X2 df p.value
## 1  .p56. == .p136. 179.043  1   0.000
## 2  .p57. == .p137.  61.444  1   0.000
## 3  .p58. == .p138.  79.357  1   0.000
## 4  .p59. == .p139.   0.048  1   0.826
## 5  .p60. == .p140.   0.347  1   0.556
## 6  .p61. == .p141.   1.247  1   0.264
## 7  .p62. == .p142.   1.327  1   0.249
## 8  .p63. == .p143.   2.025  1   0.155
## 9  .p64. == .p144.  44.154  1   0.000
## 10 .p65. == .p145.   7.056  1   0.008
## 11 .p66. == .p146.   1.778  1   0.182
## 12 .p67. == .p147. 151.454  1   0.000
## 13 .p68. == .p148.   3.698  1   0.054
## 14 .p69. == .p149.  13.339  1   0.000
## 15 .p70. == .p150.  22.520  1   0.000
## 16 .p71. == .p151.  33.968  1   0.000
## 17 .p72. == .p152.   1.526  1   0.217
## 18 .p73. == .p153. 356.031  1   0.000
## 19 .p74. == .p154.  19.300  1   0.000
## 20 .p75. == .p155. 140.958  1   0.000
scalar2<-cfa(chc.hof.model, data=dgroup, group="sex", meanstructure=TRUE, sampling.weights="BY_WTA", std.lv=T, group.equal=c("loadings", "intercepts"), group.partial=c("spatial=~Stest28mechanicalreasoning", "math=~Stest25wordfunctions", "Stest28mechanicalreasoning~1", "Stest1vocab~1", "Stest25wordfunctions~1", "Stest20spelling~1"))
## Warning: lavaan->lav_model_vcov():  
##    The variance-covariance matrix of the estimated parameters (vcov) 
##    does not appear to be positive definite! The smallest eigenvalue 
##    (= 2.568926e-14) is close to zero. This may be a symptom that the 
##    model is not identified.
fitMeasures(scalar2, c("chisq", "df", "pvalue", "cfi", "rmsea", "srmr", "aic", "bic"))
##      chisq         df     pvalue        cfi      rmsea       srmr 
##   3759.229    354.000      0.000      0.940      0.056      0.051 
##        aic        bic 
## 291616.959 292328.599
Mc(scalar2)
## [1] 0.7558963
summary(scalar2, standardized=T, ci=T)
## lavaan 0.6-18 ended normally after 128 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                       150
##   Number of equality constraints                    44
## 
##   Number of observations per group:                   
##     0                                             2443
##     1                                             3642
##   Sampling weights variable                     BY_WTA
## 
## Model Test User Model:
##                                               Standard      Scaled
##   Test Statistic                              3759.229    3327.059
##   Degrees of freedom                               354         354
##   P-value (Chi-square)                           0.000       0.000
##   Scaling correction factor                                  1.130
##     Yuan-Bentler correction (Mplus variant)                       
##   Test statistic for each group:
##     0                                         1628.849    1441.593
##     1                                         2130.380    1885.466
## 
## Parameter Estimates:
## 
##   Standard errors                             Sandwich
##   Information bread                           Observed
##   Observed information based on                Hessian
## 
## 
## Group 1 [0]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english =~                                                   
##     Stst1vc (.p1.)    0.174    0.018    9.479    0.000    0.138
##     Stst19d (.p2.)    0.237    0.017   13.556    0.000    0.202
##     Stst20s (.p3.)    0.239    0.018   13.115    0.000    0.204
##     Stst21c (.p4.)    0.268    0.020   13.526    0.000    0.230
##     Stst22p (.p5.)    0.293    0.022   13.519    0.000    0.251
##     Stst23n (.p6.)    0.304    0.023   13.298    0.000    0.259
##     Stst24x (.p7.)    0.239    0.018   13.161    0.000    0.203
##     Stst26r (.p8.)    0.203    0.018   11.010    0.000    0.167
##     Stst31b (.p9.)    0.108    0.010   10.798    0.000    0.088
##     Stst34r (.10.)    0.112    0.014    7.910    0.000    0.084
##   math =~                                                      
##     Stst1vc (.11.)    0.144    0.018    8.137    0.000    0.109
##     Stst5mt (.12.)    0.280    0.020   14.025    0.000    0.241
##     Stst25w           0.181    0.013   14.173    0.000    0.156
##     Stst26r (.14.)    0.149    0.015    9.844    0.000    0.119
##     Stst32r (.15.)    0.239    0.017   14.088    0.000    0.206
##     Stst33h (.16.)    0.238    0.017   13.990    0.000    0.205
##     Stst34r (.17.)    0.091    0.014    6.319    0.000    0.063
##   speed =~                                                     
##     Stst34r (.18.)    0.446    0.020   22.196    0.000    0.407
##     Stst35t (.19.)    1.089    0.033   33.253    0.000    1.025
##     Stst36c (.20.)    0.750    0.026   28.750    0.000    0.699
##     Stst37b (.21.)    0.665    0.024   27.827    0.000    0.618
##   spatial =~                                                   
##     Stst28m           0.454    0.015   31.149    0.000    0.426
##     Sts292D (.23.)    0.427    0.017   24.449    0.000    0.393
##     Sts303D (.24.)    0.380    0.016   24.529    0.000    0.350
##     Stst31b (.25.)    0.402    0.017   23.521    0.000    0.368
##     Stst37b (.26.)    0.093    0.013    7.232    0.000    0.068
##   g =~                                                         
##     english (.27.)    2.645    0.212   12.492    0.000    2.230
##     math    (.28.)    2.396    0.187   12.783    0.000    2.029
##     speed   (.29.)    0.422    0.026   16.497    0.000    0.372
##     spatial (.30.)    1.194    0.056   21.167    0.000    1.083
##  ci.upper   Std.lv  Std.all
##                            
##     0.210    0.491    0.474
##     0.271    0.669    0.735
##     0.275    0.677    0.676
##     0.307    0.759    0.775
##     0.336    0.830    0.809
##     0.348    0.859    0.731
##     0.274    0.675    0.589
##     0.239    0.574    0.537
##     0.127    0.305    0.263
##     0.139    0.315    0.271
##                            
##     0.178    0.373    0.360
##     0.319    0.726    0.700
##     0.207    0.471    0.608
##     0.178    0.387    0.362
##     0.273    0.621    0.750
##     0.272    0.619    0.792
##     0.120    0.237    0.204
##                            
##     0.486    0.484    0.417
##     1.153    1.182    0.708
##     0.801    0.814    0.625
##     0.712    0.722    0.581
##                            
##     0.483    0.708    0.790
##     0.461    0.665    0.607
##     0.411    0.592    0.644
##     0.435    0.625    0.539
##     0.118    0.145    0.116
##                            
##     3.060    0.935    0.935
##     2.764    0.923    0.923
##     0.472    0.389    0.389
##     1.304    0.767    0.767
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stst1vc          -1.155    0.023  -50.360    0.000   -1.200
##    .Stst19d (.57.)   -1.047    0.016  -66.268    0.000   -1.078
##    .Stst20s          -0.848    0.021  -39.900    0.000   -0.890
##    .Stst21c (.59.)   -1.151    0.018  -62.631    0.000   -1.187
##    .Stst22p (.60.)   -1.203    0.020  -60.306    0.000   -1.242
##    .Stst23n (.61.)   -1.031    0.022  -46.025    0.000   -1.075
##    .Stst24x (.62.)   -0.935    0.020  -47.002    0.000   -0.974
##    .Stst26r (.63.)   -1.319    0.022  -60.053    0.000   -1.362
##    .Stst31b (.64.)   -1.056    0.023  -45.756    0.000   -1.101
##    .Stst34r (.65.)   -1.166    0.022  -52.444    0.000   -1.210
##    .Stst5mt (.66.)   -0.824    0.019  -42.554    0.000   -0.862
##    .Stst25w          -0.871    0.017  -52.726    0.000   -0.903
##    .Stst32r (.68.)   -1.063    0.016  -65.835    0.000   -1.095
##    .Stst33h (.69.)   -0.847    0.016  -54.408    0.000   -0.877
##    .Stst35t (.70.)   -0.773    0.034  -22.898    0.000   -0.839
##    .Stst36c (.71.)    0.049    0.025    1.925    0.054   -0.001
##    .Stst37b (.72.)   -0.320    0.023  -13.815    0.000   -0.365
##    .Stst28m          -0.715    0.019  -36.895    0.000   -0.753
##    .Sts292D (.74.)   -0.559    0.021  -26.704    0.000   -0.600
##    .Sts303D (.75.)   -0.701    0.018  -38.563    0.000   -0.736
##  ci.upper   Std.lv  Std.all
##    -1.110   -1.155   -1.115
##    -1.016   -1.047   -1.150
##    -0.806   -0.848   -0.846
##    -1.115   -1.151   -1.174
##    -1.164   -1.203   -1.173
##    -0.987   -1.031   -0.878
##    -0.896   -0.935   -0.816
##    -1.276   -1.319   -1.235
##    -1.011   -1.056   -0.910
##    -1.123   -1.166   -1.004
##    -0.786   -0.824   -0.795
##    -0.838   -0.871   -1.123
##    -1.031   -1.063   -1.283
##    -0.816   -0.847   -1.083
##    -0.707   -0.773   -0.463
##     0.098    0.049    0.037
##    -0.274   -0.320   -0.257
##    -0.677   -0.715   -0.798
##    -0.518   -0.559   -0.510
##    -0.665   -0.701   -0.762
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stest1vocab       0.375    0.013   28.397    0.000    0.349
##    .Stst19dsgsdwrd    0.382    0.014   26.449    0.000    0.353
##    .Stest20spellng    0.545    0.017   31.652    0.000    0.512
##    .Stest21cptlztn    0.384    0.015   25.106    0.000    0.354
##    .Stest22puncttn    0.363    0.013   28.981    0.000    0.339
##    .Stest23english    0.641    0.024   27.117    0.000    0.595
##    .Stest24exprssn    0.858    0.025   33.700    0.000    0.808
##    .Stst26rdngcmpr    0.279    0.011   25.036    0.000    0.257
##    .Stst31bstrctrs    0.589    0.022   26.946    0.000    0.546
##    .Stst34rthcmptt    0.638    0.030   21.272    0.000    0.579
##    .Stest5math        0.548    0.021   26.400    0.000    0.507
##    .Stst25wrdfnctn    0.379    0.012   31.796    0.000    0.356
##    .Stst32rthrsnng    0.301    0.011   28.116    0.000    0.280
##    .Stst33hghschlm    0.228    0.009   25.730    0.000    0.211
##    .Stest35tblrdng    1.392    0.076   18.358    0.000    1.244
##    .Stst36clrclchc    1.031    0.043   24.145    0.000    0.948
##    .Stst37bjctnspc    0.937    0.035   26.414    0.000    0.867
##    .Stst28mchnclrs    0.301    0.015   19.590    0.000    0.271
##    .Stst29vslztn2D    0.757    0.026   28.974    0.000    0.706
##    .Stst30vslztn3D    0.495    0.017   29.091    0.000    0.461
##    .english           1.000                               1.000
##    .math              1.000                               1.000
##    .speed             1.000                               1.000
##    .spatial           1.000                               1.000
##     g                 1.000                               1.000
##  ci.upper   Std.lv  Std.all
##     0.401    0.375    0.350
##     0.410    0.382    0.460
##     0.579    0.545    0.543
##     0.414    0.384    0.400
##     0.388    0.363    0.345
##     0.688    0.641    0.465
##     0.908    0.858    0.653
##     0.301    0.279    0.245
##     0.631    0.589    0.437
##     0.696    0.638    0.472
##     0.588    0.548    0.509
##     0.402    0.379    0.630
##     0.322    0.301    0.438
##     0.246    0.228    0.373
##     1.541    1.392    0.499
##     1.115    1.031    0.609
##     1.006    0.937    0.608
##     0.331    0.301    0.375
##     0.808    0.757    0.631
##     0.528    0.495    0.585
##     1.000    0.125    0.125
##     1.000    0.148    0.148
##     1.000    0.849    0.849
##     1.000    0.412    0.412
##     1.000    1.000    1.000
## 
## 
## Group 2 [1]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english =~                                                   
##     Stst1vc (.p1.)    0.174    0.018    9.479    0.000    0.138
##     Stst19d (.p2.)    0.237    0.017   13.556    0.000    0.202
##     Stst20s (.p3.)    0.239    0.018   13.115    0.000    0.204
##     Stst21c (.p4.)    0.268    0.020   13.526    0.000    0.230
##     Stst22p (.p5.)    0.293    0.022   13.519    0.000    0.251
##     Stst23n (.p6.)    0.304    0.023   13.298    0.000    0.259
##     Stst24x (.p7.)    0.239    0.018   13.161    0.000    0.203
##     Stst26r (.p8.)    0.203    0.018   11.010    0.000    0.167
##     Stst31b (.p9.)    0.108    0.010   10.798    0.000    0.088
##     Stst34r (.10.)    0.112    0.014    7.910    0.000    0.084
##   math =~                                                      
##     Stst1vc (.11.)    0.144    0.018    8.137    0.000    0.109
##     Stst5mt (.12.)    0.280    0.020   14.025    0.000    0.241
##     Stst25w           0.247    0.019   13.330    0.000    0.211
##     Stst26r (.14.)    0.149    0.015    9.844    0.000    0.119
##     Stst32r (.15.)    0.239    0.017   14.088    0.000    0.206
##     Stst33h (.16.)    0.238    0.017   13.990    0.000    0.205
##     Stst34r (.17.)    0.091    0.014    6.319    0.000    0.063
##   speed =~                                                     
##     Stst34r (.18.)    0.446    0.020   22.196    0.000    0.407
##     Stst35t (.19.)    1.089    0.033   33.253    0.000    1.025
##     Stst36c (.20.)    0.750    0.026   28.750    0.000    0.699
##     Stst37b (.21.)    0.665    0.024   27.827    0.000    0.618
##   spatial =~                                                   
##     Stst28m           0.291    0.016   18.719    0.000    0.261
##     Sts292D (.23.)    0.427    0.017   24.449    0.000    0.393
##     Sts303D (.24.)    0.380    0.016   24.529    0.000    0.350
##     Stst31b (.25.)    0.402    0.017   23.521    0.000    0.368
##     Stst37b (.26.)    0.093    0.013    7.232    0.000    0.068
##   g =~                                                         
##     english (.27.)    2.645    0.212   12.492    0.000    2.230
##     math    (.28.)    2.396    0.187   12.783    0.000    2.029
##     speed   (.29.)    0.422    0.026   16.497    0.000    0.372
##     spatial (.30.)    1.194    0.056   21.167    0.000    1.083
##  ci.upper   Std.lv  Std.all
##                            
##     0.210    0.461    0.492
##     0.271    0.628    0.695
##     0.275    0.635    0.663
##     0.307    0.712    0.723
##     0.336    0.778    0.804
##     0.348    0.806    0.731
##     0.274    0.633    0.579
##     0.239    0.538    0.556
##     0.127    0.286    0.266
##     0.139    0.296    0.260
##                            
##     0.178    0.312    0.333
##     0.319    0.607    0.611
##     0.283    0.537    0.671
##     0.178    0.323    0.334
##     0.273    0.520    0.697
##     0.272    0.518    0.747
##     0.120    0.198    0.174
##                            
##     0.486    0.473    0.415
##     1.153    1.154    0.713
##     0.801    0.794    0.616
##     0.712    0.704    0.616
##                            
##     0.321    0.382    0.622
##     0.461    0.560    0.562
##     0.411    0.499    0.635
##     0.435    0.527    0.489
##     0.118    0.122    0.106
##                            
##     3.060    0.866    0.866
##     2.764    0.959    0.959
##     0.472    0.346    0.346
##     1.304    0.791    0.791
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stst1vc          -1.424    0.026  -55.430    0.000   -1.474
##    .Stst19d (.57.)   -1.047    0.016  -66.268    0.000   -1.078
##    .Stst20s          -0.663    0.021  -31.842    0.000   -0.703
##    .Stst21c (.59.)   -1.151    0.018  -62.631    0.000   -1.187
##    .Stst22p (.60.)   -1.203    0.020  -60.306    0.000   -1.242
##    .Stst23n (.61.)   -1.031    0.022  -46.025    0.000   -1.075
##    .Stst24x (.62.)   -0.935    0.020  -47.002    0.000   -0.974
##    .Stst26r (.63.)   -1.319    0.022  -60.053    0.000   -1.362
##    .Stst31b (.64.)   -1.056    0.023  -45.756    0.000   -1.101
##    .Stst34r (.65.)   -1.166    0.022  -52.444    0.000   -1.210
##    .Stst5mt (.66.)   -0.824    0.019  -42.554    0.000   -0.862
##    .Stst25w          -0.671    0.019  -34.829    0.000   -0.709
##    .Stst32r (.68.)   -1.063    0.016  -65.835    0.000   -1.095
##    .Stst33h (.69.)   -0.847    0.016  -54.408    0.000   -0.877
##    .Stst35t (.70.)   -0.773    0.034  -22.898    0.000   -0.839
##    .Stst36c (.71.)    0.049    0.025    1.925    0.054   -0.001
##    .Stst37b (.72.)   -0.320    0.023  -13.815    0.000   -0.365
##    .Stst28m          -1.100    0.019  -57.480    0.000   -1.137
##    .Sts292D (.74.)   -0.559    0.021  -26.704    0.000   -0.600
##    .Sts303D (.75.)   -0.701    0.018  -38.563    0.000   -0.736
##    .english           0.971    0.049   19.844    0.000    0.875
##    .math             -0.400    0.044   -9.018    0.000   -0.487
##    .speed             0.277    0.037    7.423    0.000    0.204
##    .spatial          -0.731    0.048  -15.382    0.000   -0.824
##     g                -0.032    0.030   -1.069    0.285   -0.090
##  ci.upper   Std.lv  Std.all
##    -1.374   -1.424   -1.520
##    -1.016   -1.047   -1.159
##    -0.622   -0.663   -0.692
##    -1.115   -1.151   -1.169
##    -1.164   -1.203   -1.243
##    -0.987   -1.031   -0.936
##    -0.896   -0.935   -0.854
##    -1.276   -1.319   -1.362
##    -1.011   -1.056   -0.980
##    -1.123   -1.166   -1.023
##    -0.786   -0.824   -0.829
##    -0.633   -0.671   -0.840
##    -1.031   -1.063   -1.426
##    -0.816   -0.847   -1.222
##    -0.707   -0.773   -0.478
##     0.098    0.049    0.038
##    -0.274   -0.320   -0.279
##    -1.062   -1.100   -1.793
##    -0.518   -0.559   -0.561
##    -0.665   -0.701   -0.892
##     1.067    0.366    0.366
##    -0.313   -0.184   -0.184
##     0.350    0.261    0.261
##    -0.638   -0.558   -0.558
##     0.027   -0.037   -0.037
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stest1vocab       0.330    0.010   34.167    0.000    0.311
##    .Stst19dsgsdwrd    0.422    0.012   35.254    0.000    0.399
##    .Stest20spellng    0.514    0.014   37.462    0.000    0.487
##    .Stest21cptlztn    0.462    0.014   33.716    0.000    0.435
##    .Stest22puncttn    0.332    0.011   31.016    0.000    0.311
##    .Stest23english    0.564    0.017   33.653    0.000    0.531
##    .Stest24exprssn    0.796    0.021   37.726    0.000    0.755
##    .Stst26rdngcmpr    0.255    0.008   30.477    0.000    0.238
##    .Stst31bstrctrs    0.594    0.017   34.436    0.000    0.561
##    .Stst34rthcmptt    0.705    0.027   26.169    0.000    0.652
##    .Stest5math        0.618    0.017   35.812    0.000    0.584
##    .Stst25wrdfnctn    0.351    0.010   34.003    0.000    0.330
##    .Stst32rthrsnng    0.285    0.008   34.685    0.000    0.269
##    .Stst33hghschlm    0.212    0.007   30.774    0.000    0.199
##    .Stest35tblrdng    1.284    0.069   18.651    0.000    1.149
##    .Stst36clrclchc    1.029    0.034   30.547    0.000    0.963
##    .Stst37bjctnspc    0.750    0.027   27.504    0.000    0.697
##    .Stst28mchnclrs    0.230    0.007   33.668    0.000    0.217
##    .Stst29vslztn2D    0.678    0.019   35.036    0.000    0.640
##    .Stst30vslztn3D    0.369    0.011   33.449    0.000    0.347
##    .english           1.757    0.257    6.846    0.000    1.254
##    .math              0.380    0.100    3.817    0.000    0.185
##    .speed             0.988    0.065   15.255    0.000    0.861
##    .spatial           0.643    0.070    9.230    0.000    0.507
##     g                 0.755    0.034   22.034    0.000    0.688
##  ci.upper   Std.lv  Std.all
##     0.349    0.330    0.376
##     0.446    0.422    0.517
##     0.541    0.514    0.560
##     0.489    0.462    0.477
##     0.353    0.332    0.354
##     0.597    0.564    0.465
##     0.838    0.796    0.665
##     0.271    0.255    0.272
##     0.628    0.594    0.512
##     0.758    0.705    0.543
##     0.652    0.618    0.626
##     0.371    0.351    0.549
##     0.301    0.285    0.514
##     0.226    0.212    0.442
##     1.419    1.284    0.491
##     1.095    1.029    0.620
##     0.804    0.750    0.574
##     0.244    0.230    0.613
##     0.715    0.678    0.684
##     0.390    0.369    0.597
##     2.260    0.250    0.250
##     0.576    0.081    0.081
##     1.115    0.880    0.880
##     0.780    0.374    0.374
##     0.822    1.000    1.000
lavTestScore(scalar2, release = 29:44) 
## Warning: lavaan->lavTestScore():  
##    se is not `standard'; not implemented yet; falling back to 
##    ordinary score test
## $test
## 
## total score test:
## 
##    test      X2 df p.value
## 1 score 145.572 16       0
## 
## $uni
## 
## univariate score tests:
## 
##      lhs op    rhs     X2 df p.value
## 1  .p57. == .p137. 41.483  1   0.000
## 2  .p59. == .p139.  3.937  1   0.047
## 3  .p60. == .p140.  8.218  1   0.004
## 4  .p61. == .p141.  7.325  1   0.007
## 5  .p62. == .p142.  4.698  1   0.030
## 6  .p63. == .p143. 19.142  1   0.000
## 7  .p64. == .p144.  3.177  1   0.075
## 8  .p65. == .p145.  2.272  1   0.132
## 9  .p66. == .p146.  1.012  1   0.314
## 10 .p68. == .p148.  2.317  1   0.128
## 11 .p69. == .p149. 24.102  1   0.000
## 12 .p70. == .p150. 19.191  1   0.000
## 13 .p71. == .p151. 35.719  1   0.000
## 14 .p72. == .p152.  0.013  1   0.908
## 15 .p74. == .p154. 18.927  1   0.000
## 16 .p75. == .p155.  7.254  1   0.007
strict<-cfa(chc.hof.model, data=dgroup, group="sex", meanstructure=TRUE, sampling.weights="BY_WTA", std.lv=T, group.equal=c("loadings", "intercepts", "residuals"), group.partial=c("spatial=~Stest28mechanicalreasoning", "math=~Stest25wordfunctions", "Stest28mechanicalreasoning~1", "Stest1vocab~1", "Stest25wordfunctions~1", "Stest20spelling~1"))
## Warning: lavaan->lav_model_vcov():  
##    The variance-covariance matrix of the estimated parameters (vcov) 
##    does not appear to be positive definite! The smallest eigenvalue 
##    (= 5.301684e-15) is close to zero. This may be a symptom that the 
##    model is not identified.
fitMeasures(strict, c("chisq", "df", "pvalue", "cfi", "rmsea", "srmr", "aic", "bic"))
##      chisq         df     pvalue        cfi      rmsea       srmr 
##   3954.351    374.000      0.000      0.937      0.056      0.052 
##        aic        bic 
## 291772.082 292349.450
Mc(strict)
## [1] 0.7450953
chc.hof<-cfa(chc.hof.model, data=dgroup, group="sex", meanstructure=TRUE, sampling.weights="BY_WTA", std.lv=T, group.equal=c("loadings", "intercepts", "lv.variances"), group.partial=c("spatial=~Stest28mechanicalreasoning", "math=~Stest25wordfunctions", "Stest28mechanicalreasoning~1", "Stest1vocab~1", "Stest25wordfunctions~1", "Stest20spelling~1"))
## Warning: lavaan->lav_model_vcov():  
##    The variance-covariance matrix of the estimated parameters (vcov) 
##    does not appear to be positive definite! The smallest eigenvalue 
##    (= 6.431896e-15) is close to zero. This may be a symptom that the 
##    model is not identified.
fitMeasures(chc.hof, c("chisq", "df", "pvalue", "cfi", "rmsea", "srmr", "aic", "bic"))
##      chisq         df     pvalue        cfi      rmsea       srmr 
##   3861.594    359.000      0.000      0.938      0.057      0.066 
##        aic        bic 
## 291709.325 292387.397
Mc(chc.hof)
## [1] 0.7498719
summary(chc.hof, standardized=T, ci=T)
## lavaan 0.6-18 ended normally after 87 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                       145
##   Number of equality constraints                    44
## 
##   Number of observations per group:                   
##     0                                             2443
##     1                                             3642
##   Sampling weights variable                     BY_WTA
## 
## Model Test User Model:
##                                               Standard      Scaled
##   Test Statistic                              3861.594    3411.698
##   Degrees of freedom                               359         359
##   P-value (Chi-square)                           0.000       0.000
##   Scaling correction factor                                  1.132
##     Yuan-Bentler correction (Mplus variant)                       
##   Test statistic for each group:
##     0                                         1690.065    1493.163
##     1                                         2171.530    1918.535
## 
## Parameter Estimates:
## 
##   Standard errors                             Sandwich
##   Information bread                           Observed
##   Observed information based on                Hessian
## 
## 
## Group 1 [0]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english =~                                                   
##     Stst1vc (.p1.)    0.209    0.016   12.695    0.000    0.177
##     Stst19d (.p2.)    0.281    0.011   26.142    0.000    0.260
##     Stst20s (.p3.)    0.285    0.012   24.322    0.000    0.262
##     Stst21c (.p4.)    0.319    0.012   26.060    0.000    0.295
##     Stst22p (.p5.)    0.349    0.013   26.660    0.000    0.324
##     Stst23n (.p6.)    0.362    0.014   25.679    0.000    0.334
##     Stst24x (.p7.)    0.284    0.012   24.418    0.000    0.261
##     Stst26r (.p8.)    0.243    0.015   16.695    0.000    0.215
##     Stst31b (.p9.)    0.127    0.009   13.777    0.000    0.109
##     Stst34r (.10.)    0.131    0.014    9.041    0.000    0.102
##   math =~                                                      
##     Stst1vc (.11.)    0.113    0.013    8.593    0.000    0.087
##     Stst5mt (.12.)    0.225    0.015   15.458    0.000    0.197
##     Stst25w           0.151    0.010   14.659    0.000    0.131
##     Stst26r (.14.)    0.118    0.011   10.883    0.000    0.097
##     Stst32r (.15.)    0.192    0.012   15.486    0.000    0.168
##     Stst33h (.16.)    0.192    0.013   15.243    0.000    0.167
##     Stst34r (.17.)    0.075    0.012    6.326    0.000    0.052
##   speed =~                                                     
##     Stst34r (.18.)    0.444    0.019   23.988    0.000    0.408
##     Stst35t (.19.)    1.085    0.024   44.398    0.000    1.037
##     Stst36c (.20.)    0.743    0.022   34.342    0.000    0.701
##     Stst37b (.21.)    0.660    0.020   33.104    0.000    0.621
##   spatial =~                                                   
##     Stst28m           0.423    0.013   31.784    0.000    0.397
##     Sts292D (.23.)    0.378    0.012   30.268    0.000    0.353
##     Sts303D (.24.)    0.334    0.011   31.245    0.000    0.313
##     Stst31b (.25.)    0.359    0.013   27.518    0.000    0.333
##     Stst37b (.26.)    0.081    0.011    7.262    0.000    0.059
##   g =~                                                         
##     english (.27.)    2.067    0.094   21.993    0.000    1.883
##     math    (.28.)    2.756    0.194   14.212    0.000    2.376
##     speed   (.29.)    0.398    0.022   17.735    0.000    0.354
##     spatial (.30.)    1.248    0.047   26.488    0.000    1.156
##  ci.upper   Std.lv  Std.all
##                            
##     0.242    0.481    0.484
##     0.303    0.646    0.723
##     0.308    0.654    0.664
##     0.343    0.733    0.764
##     0.375    0.802    0.800
##     0.389    0.831    0.720
##     0.307    0.653    0.576
##     0.272    0.559    0.548
##     0.145    0.291    0.261
##     0.159    0.300    0.265
##                            
##     0.139    0.332    0.334
##     0.254    0.660    0.664
##     0.171    0.443    0.584
##     0.139    0.345    0.339
##     0.217    0.563    0.715
##     0.216    0.562    0.760
##     0.098    0.219    0.193
##                            
##     0.481    0.478    0.422
##     1.132    1.167    0.704
##     0.786    0.800    0.618
##     0.699    0.710    0.577
##                            
##     0.449    0.677    0.779
##     0.402    0.605    0.567
##     0.355    0.535    0.600
##     0.384    0.574    0.514
##     0.103    0.130    0.106
##                            
##     2.251    0.900    0.900
##     3.136    0.940    0.940
##     0.442    0.370    0.370
##     1.341    0.780    0.780
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stst1vc          -1.155    0.023  -50.360    0.000   -1.200
##    .Stst19d (.57.)   -1.047    0.016  -66.292    0.000   -1.078
##    .Stst20s          -0.848    0.021  -39.900    0.000   -0.890
##    .Stst21c (.59.)   -1.150    0.018  -62.637    0.000   -1.186
##    .Stst22p (.60.)   -1.203    0.020  -60.251    0.000   -1.242
##    .Stst23n (.61.)   -1.031    0.022  -45.957    0.000   -1.075
##    .Stst24x (.62.)   -0.935    0.020  -46.962    0.000   -0.974
##    .Stst26r (.63.)   -1.320    0.022  -60.225    0.000   -1.363
##    .Stst31b (.64.)   -1.054    0.023  -45.471    0.000   -1.099
##    .Stst34r (.65.)   -1.165    0.022  -52.221    0.000   -1.209
##    .Stst5mt (.66.)   -0.824    0.019  -42.425    0.000   -0.862
##    .Stst25w          -0.871    0.017  -52.726    0.000   -0.903
##    .Stst32r (.68.)   -1.063    0.016  -65.865    0.000   -1.095
##    .Stst33h (.69.)   -0.846    0.016  -54.309    0.000   -0.877
##    .Stst35t (.70.)   -0.774    0.034  -22.908    0.000   -0.840
##    .Stst36c (.71.)    0.049    0.025    1.937    0.053   -0.001
##    .Stst37b (.72.)   -0.320    0.023  -13.822    0.000   -0.365
##    .Stst28m          -0.715    0.019  -36.895    0.000   -0.753
##    .Sts292D (.74.)   -0.560    0.021  -26.694    0.000   -0.601
##    .Sts303D (.75.)   -0.702    0.018  -38.744    0.000   -0.737
##  ci.upper   Std.lv  Std.all
##    -1.110   -1.155   -1.162
##    -1.016   -1.047   -1.171
##    -0.806   -0.848   -0.861
##    -1.114   -1.150   -1.199
##    -1.164   -1.203   -1.199
##    -0.987   -1.031   -0.894
##    -0.896   -0.935   -0.825
##    -1.277   -1.320   -1.295
##    -1.008   -1.054   -0.944
##    -1.121   -1.165   -1.028
##    -0.785   -0.824   -0.828
##    -0.838   -0.871   -1.148
##    -1.031   -1.063   -1.349
##    -0.816   -0.846   -1.144
##    -0.707   -0.774   -0.466
##     0.098    0.049    0.038
##    -0.275   -0.320   -0.260
##    -0.677   -0.715   -0.823
##    -0.519   -0.560   -0.525
##    -0.666   -0.702   -0.787
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stest1vocab       0.377    0.013   28.616    0.000    0.351
##    .Stst19dsgsdwrd    0.382    0.014   26.438    0.000    0.354
##    .Stest20spellng    0.543    0.017   31.575    0.000    0.509
##    .Stest21cptlztn    0.384    0.015   25.056    0.000    0.354
##    .Stest22puncttn    0.363    0.013   28.836    0.000    0.338
##    .Stest23english    0.639    0.024   27.048    0.000    0.593
##    .Stest24exprssn    0.856    0.025   33.686    0.000    0.806
##    .Stst26rdngcmpr    0.281    0.011   25.292    0.000    0.259
##    .Stst31bstrctrs    0.597    0.022   27.682    0.000    0.555
##    .Stst34rthcmptt    0.638    0.030   21.184    0.000    0.579
##    .Stest5math        0.554    0.021   26.512    0.000    0.513
##    .Stst25wrdfnctn    0.379    0.012   31.784    0.000    0.355
##    .Stst32rthrsnng    0.304    0.011   28.289    0.000    0.283
##    .Stst33hghschlm    0.232    0.009   25.788    0.000    0.214
##    .Stest35tblrdng    1.388    0.076   18.344    0.000    1.240
##    .Stst36clrclchc    1.036    0.042   24.775    0.000    0.954
##    .Stst37bjctnspc    0.941    0.035   26.789    0.000    0.872
##    .Stst28mchnclrs    0.297    0.015   19.506    0.000    0.267
##    .Stst29vslztn2D    0.770    0.025   30.194    0.000    0.720
##    .Stst30vslztn3D    0.509    0.017   30.573    0.000    0.476
##    .english           1.000                               1.000
##    .math              1.000                               1.000
##    .speed             1.000                               1.000
##    .spatial           1.000                               1.000
##     g                 1.000                               1.000
##  ci.upper   Std.lv  Std.all
##     0.403    0.377    0.382
##     0.410    0.382    0.478
##     0.577    0.543    0.559
##     0.414    0.384    0.417
##     0.387    0.363    0.361
##     0.686    0.639    0.481
##     0.906    0.856    0.668
##     0.303    0.281    0.270
##     0.640    0.597    0.479
##     0.697    0.638    0.497
##     0.595    0.554    0.559
##     0.402    0.379    0.658
##     0.325    0.304    0.489
##     0.249    0.232    0.423
##     1.536    1.388    0.505
##     1.118    1.036    0.618
##     1.010    0.941    0.621
##     0.327    0.297    0.394
##     0.820    0.770    0.678
##     0.541    0.509    0.640
##     1.000    0.190    0.190
##     1.000    0.116    0.116
##     1.000    0.863    0.863
##     1.000    0.391    0.391
##     1.000    1.000    1.000
## 
## 
## Group 2 [1]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english =~                                                   
##     Stst1vc (.p1.)    0.209    0.016   12.695    0.000    0.177
##     Stst19d (.p2.)    0.281    0.011   26.142    0.000    0.260
##     Stst20s (.p3.)    0.285    0.012   24.322    0.000    0.262
##     Stst21c (.p4.)    0.319    0.012   26.060    0.000    0.295
##     Stst22p (.p5.)    0.349    0.013   26.660    0.000    0.324
##     Stst23n (.p6.)    0.362    0.014   25.679    0.000    0.334
##     Stst24x (.p7.)    0.284    0.012   24.418    0.000    0.261
##     Stst26r (.p8.)    0.243    0.015   16.695    0.000    0.215
##     Stst31b (.p9.)    0.127    0.009   13.777    0.000    0.109
##     Stst34r (.10.)    0.131    0.014    9.041    0.000    0.102
##   math =~                                                      
##     Stst1vc (.11.)    0.113    0.013    8.593    0.000    0.087
##     Stst5mt (.12.)    0.225    0.015   15.458    0.000    0.197
##     Stst25w           0.193    0.013   15.076    0.000    0.168
##     Stst26r (.14.)    0.118    0.011   10.883    0.000    0.097
##     Stst32r (.15.)    0.192    0.012   15.486    0.000    0.168
##     Stst33h (.16.)    0.192    0.013   15.243    0.000    0.167
##     Stst34r (.17.)    0.075    0.012    6.326    0.000    0.052
##   speed =~                                                     
##     Stst34r (.18.)    0.444    0.019   23.988    0.000    0.408
##     Stst35t (.19.)    1.085    0.024   44.398    0.000    1.037
##     Stst36c (.20.)    0.743    0.022   34.342    0.000    0.701
##     Stst37b (.21.)    0.660    0.020   33.104    0.000    0.621
##   spatial =~                                                   
##     Stst28m           0.245    0.009   28.468    0.000    0.228
##     Sts292D (.23.)    0.378    0.012   30.268    0.000    0.353
##     Sts303D (.24.)    0.334    0.011   31.245    0.000    0.313
##     Stst31b (.25.)    0.359    0.013   27.518    0.000    0.333
##     Stst37b (.26.)    0.081    0.011    7.262    0.000    0.059
##   g =~                                                         
##     english (.27.)    2.067    0.094   21.993    0.000    1.883
##     math    (.28.)    2.756    0.194   14.212    0.000    2.376
##     speed   (.29.)    0.398    0.022   17.735    0.000    0.354
##     spatial (.30.)    1.248    0.047   26.488    0.000    1.156
##  ci.upper   Std.lv  Std.all
##                            
##     0.242    0.481    0.496
##     0.303    0.646    0.705
##     0.308    0.654    0.674
##     0.343    0.733    0.733
##     0.375    0.802    0.812
##     0.389    0.831    0.741
##     0.307    0.653    0.590
##     0.272    0.559    0.555
##     0.145    0.291    0.262
##     0.159    0.300    0.258
##                            
##     0.139    0.332    0.342
##     0.254    0.660    0.645
##     0.218    0.565    0.690
##     0.139    0.345    0.343
##     0.217    0.563    0.727
##     0.216    0.562    0.776
##     0.098    0.219    0.189
##                            
##     0.481    0.478    0.412
##     1.132    1.167    0.718
##     0.786    0.800    0.619
##     0.699    0.710    0.617
##                            
##     0.262    0.392    0.630
##     0.402    0.605    0.595
##     0.355    0.535    0.665
##     0.384    0.574    0.517
##     0.103    0.130    0.113
##                            
##     2.251    0.900    0.900
##     3.136    0.940    0.940
##     0.442    0.370    0.370
##     1.341    0.780    0.780
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stst1vc          -1.427    0.026  -55.108    0.000   -1.478
##    .Stst19d (.57.)   -1.047    0.016  -66.292    0.000   -1.078
##    .Stst20s          -0.662    0.021  -31.802    0.000   -0.703
##    .Stst21c (.59.)   -1.150    0.018  -62.637    0.000   -1.186
##    .Stst22p (.60.)   -1.203    0.020  -60.251    0.000   -1.242
##    .Stst23n (.61.)   -1.031    0.022  -45.957    0.000   -1.075
##    .Stst24x (.62.)   -0.935    0.020  -46.962    0.000   -0.974
##    .Stst26r (.63.)   -1.320    0.022  -60.225    0.000   -1.363
##    .Stst31b (.64.)   -1.054    0.023  -45.471    0.000   -1.099
##    .Stst34r (.65.)   -1.165    0.022  -52.221    0.000   -1.209
##    .Stst5mt (.66.)   -0.824    0.019  -42.425    0.000   -0.862
##    .Stst25w          -0.674    0.019  -35.921    0.000   -0.711
##    .Stst32r (.68.)   -1.063    0.016  -65.865    0.000   -1.095
##    .Stst33h (.69.)   -0.846    0.016  -54.309    0.000   -0.877
##    .Stst35t (.70.)   -0.774    0.034  -22.908    0.000   -0.840
##    .Stst36c (.71.)    0.049    0.025    1.937    0.053   -0.001
##    .Stst37b (.72.)   -0.320    0.023  -13.822    0.000   -0.365
##    .Stst28m          -1.111    0.018  -61.451    0.000   -1.146
##    .Sts292D (.74.)   -0.560    0.021  -26.694    0.000   -0.601
##    .Sts303D (.75.)   -0.702    0.018  -38.744    0.000   -0.737
##    .english           0.913    0.042   21.778    0.000    0.830
##    .math             -0.369    0.036  -10.364    0.000   -0.439
##    .speed             0.297    0.036    8.367    0.000    0.228
##    .spatial          -0.766    0.049  -15.573    0.000   -0.863
##     g                -0.082    0.030   -2.726    0.006   -0.140
##  ci.upper   Std.lv  Std.all
##    -1.376   -1.427   -1.472
##    -1.016   -1.047   -1.142
##    -0.622   -0.662   -0.682
##    -1.114   -1.150   -1.150
##    -1.164   -1.203   -1.218
##    -0.987   -1.031   -0.920
##    -0.896   -0.935   -0.845
##    -1.277   -1.320   -1.312
##    -1.008   -1.054   -0.949
##    -1.121   -1.165   -1.003
##    -0.785   -0.824   -0.804
##    -0.637   -0.674   -0.824
##    -1.031   -1.063   -1.371
##    -0.816   -0.846   -1.168
##    -0.707   -0.774   -0.476
##     0.098    0.049    0.038
##    -0.275   -0.320   -0.278
##    -1.075   -1.111   -1.786
##    -0.519   -0.560   -0.551
##    -0.666   -0.702   -0.872
##     0.995    0.397    0.397
##    -0.299   -0.126   -0.126
##     0.367    0.276    0.276
##    -0.670   -0.479   -0.479
##    -0.023   -0.082   -0.082
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stest1vocab       0.329    0.010   34.083    0.000    0.310
##    .Stst19dsgsdwrd    0.422    0.012   35.277    0.000    0.399
##    .Stest20spellng    0.516    0.014   37.592    0.000    0.489
##    .Stest21cptlztn    0.463    0.014   33.888    0.000    0.437
##    .Stest22puncttn    0.333    0.011   31.112    0.000    0.312
##    .Stest23english    0.565    0.017   33.656    0.000    0.532
##    .Stest24exprssn    0.797    0.021   37.747    0.000    0.755
##    .Stst26rdngcmpr    0.254    0.008   30.425    0.000    0.238
##    .Stst31bstrctrs    0.583    0.017   34.255    0.000    0.550
##    .Stst34rthcmptt    0.704    0.027   26.045    0.000    0.651
##    .Stest5math        0.614    0.017   35.740    0.000    0.580
##    .Stst25wrdfnctn    0.350    0.010   34.096    0.000    0.330
##    .Stst32rthrsnng    0.284    0.008   34.509    0.000    0.268
##    .Stst33hghschlm    0.209    0.007   30.406    0.000    0.196
##    .Stest35tblrdng    1.277    0.069   18.555    0.000    1.142
##    .Stst36clrclchc    1.031    0.033   30.930    0.000    0.966
##    .Stst37bjctnspc    0.750    0.027   27.583    0.000    0.697
##    .Stst28mchnclrs    0.233    0.007   34.012    0.000    0.220
##    .Stst29vslztn2D    0.667    0.019   34.791    0.000    0.630
##    .Stst30vslztn3D    0.362    0.011   33.404    0.000    0.340
##    .english           1.000                               1.000
##    .math              1.000                               1.000
##    .speed             1.000                               1.000
##    .spatial           1.000                               1.000
##     g                 1.000                               1.000
##  ci.upper   Std.lv  Std.all
##     0.348    0.329    0.350
##     0.446    0.422    0.503
##     0.542    0.516    0.546
##     0.490    0.463    0.463
##     0.354    0.333    0.341
##     0.598    0.565    0.450
##     0.838    0.797    0.652
##     0.271    0.254    0.251
##     0.617    0.583    0.474
##     0.757    0.704    0.521
##     0.647    0.614    0.585
##     0.371    0.350    0.523
##     0.300    0.284    0.472
##     0.223    0.209    0.398
##     1.412    1.277    0.484
##     1.097    1.031    0.617
##     0.803    0.750    0.566
##     0.247    0.233    0.603
##     0.705    0.667    0.646
##     0.383    0.362    0.558
##     1.000    0.190    0.190
##     1.000    0.116    0.116
##     1.000    0.863    0.863
##     1.000    0.391    0.391
##     1.000    1.000    1.000
standardizedSolution(chc.hof) # get the correct SEs for standardized solution
##                            lhs op                         rhs group
## 1                      english =~                 Stest1vocab     1
## 2                      english =~       Stest19disguisedwords     1
## 3                      english =~             Stest20spelling     1
## 4                      english =~       Stest21capitalization     1
## 5                      english =~          Stest22punctuation     1
## 6                      english =~              Stest23english     1
## 7                      english =~           Stest24expression     1
## 8                      english =~ Stest26readingcomprehension     1
## 9                      english =~    Stest31abstractreasoning     1
## 10                     english =~     Stest34arithcomputation     1
## 11                        math =~                 Stest1vocab     1
## 12                        math =~                  Stest5math     1
## 13                        math =~        Stest25wordfunctions     1
## 14                        math =~ Stest26readingcomprehension     1
## 15                        math =~       Stest32arithreasoning     1
## 16                        math =~       Stest33highschoolmath     1
## 17                        math =~     Stest34arithcomputation     1
## 18                       speed =~     Stest34arithcomputation     1
## 19                       speed =~         Stest35tablereading     1
## 20                       speed =~     Stest36clericalchecking     1
## 21                       speed =~     Stest37objectinspection     1
## 22                     spatial =~  Stest28mechanicalreasoning     1
## 23                     spatial =~      Stest29visualization2D     1
## 24                     spatial =~      Stest30visualization3D     1
## 25                     spatial =~    Stest31abstractreasoning     1
## 26                     spatial =~     Stest37objectinspection     1
## 27                           g =~                     english     1
## 28                           g =~                        math     1
## 29                           g =~                       speed     1
## 30                           g =~                     spatial     1
## 31                 Stest1vocab ~~                 Stest1vocab     1
## 32       Stest19disguisedwords ~~       Stest19disguisedwords     1
## 33             Stest20spelling ~~             Stest20spelling     1
## 34       Stest21capitalization ~~       Stest21capitalization     1
## 35          Stest22punctuation ~~          Stest22punctuation     1
## 36              Stest23english ~~              Stest23english     1
## 37           Stest24expression ~~           Stest24expression     1
## 38 Stest26readingcomprehension ~~ Stest26readingcomprehension     1
## 39    Stest31abstractreasoning ~~    Stest31abstractreasoning     1
## 40     Stest34arithcomputation ~~     Stest34arithcomputation     1
## 41                  Stest5math ~~                  Stest5math     1
## 42        Stest25wordfunctions ~~        Stest25wordfunctions     1
## 43       Stest32arithreasoning ~~       Stest32arithreasoning     1
## 44       Stest33highschoolmath ~~       Stest33highschoolmath     1
## 45         Stest35tablereading ~~         Stest35tablereading     1
## 46     Stest36clericalchecking ~~     Stest36clericalchecking     1
## 47     Stest37objectinspection ~~     Stest37objectinspection     1
## 48  Stest28mechanicalreasoning ~~  Stest28mechanicalreasoning     1
## 49      Stest29visualization2D ~~      Stest29visualization2D     1
## 50      Stest30visualization3D ~~      Stest30visualization3D     1
## 51                     english ~~                     english     1
## 52                        math ~~                        math     1
## 53                       speed ~~                       speed     1
## 54                     spatial ~~                     spatial     1
## 55                           g ~~                           g     1
## 56                 Stest1vocab ~1                                 1
## 57       Stest19disguisedwords ~1                                 1
## 58             Stest20spelling ~1                                 1
## 59       Stest21capitalization ~1                                 1
## 60          Stest22punctuation ~1                                 1
## 61              Stest23english ~1                                 1
## 62           Stest24expression ~1                                 1
## 63 Stest26readingcomprehension ~1                                 1
## 64    Stest31abstractreasoning ~1                                 1
## 65     Stest34arithcomputation ~1                                 1
## 66                  Stest5math ~1                                 1
## 67        Stest25wordfunctions ~1                                 1
## 68       Stest32arithreasoning ~1                                 1
## 69       Stest33highschoolmath ~1                                 1
## 70         Stest35tablereading ~1                                 1
## 71     Stest36clericalchecking ~1                                 1
## 72     Stest37objectinspection ~1                                 1
## 73  Stest28mechanicalreasoning ~1                                 1
## 74      Stest29visualization2D ~1                                 1
## 75      Stest30visualization3D ~1                                 1
## 76                     english ~1                                 1
## 77                        math ~1                                 1
## 78                       speed ~1                                 1
## 79                     spatial ~1                                 1
## 80                           g ~1                                 1
## 81                     english =~                 Stest1vocab     2
## 82                     english =~       Stest19disguisedwords     2
## 83                     english =~             Stest20spelling     2
## 84                     english =~       Stest21capitalization     2
## 85                     english =~          Stest22punctuation     2
## 86                     english =~              Stest23english     2
## 87                     english =~           Stest24expression     2
## 88                     english =~ Stest26readingcomprehension     2
## 89                     english =~    Stest31abstractreasoning     2
## 90                     english =~     Stest34arithcomputation     2
##    label est.std    se       z pvalue ci.lower ci.upper
## 1   .p1.   0.484 0.032  14.976  0.000    0.420    0.547
## 2   .p2.   0.723 0.008  85.466  0.000    0.706    0.739
## 3   .p3.   0.664 0.010  69.643  0.000    0.645    0.683
## 4   .p4.   0.764 0.008  95.573  0.000    0.748    0.779
## 5   .p5.   0.800 0.007 120.504  0.000    0.787    0.813
## 6   .p6.   0.720 0.008  85.545  0.000    0.704    0.737
## 7   .p7.   0.576 0.011  54.113  0.000    0.556    0.597
## 8   .p8.   0.548 0.024  22.989  0.000    0.502    0.595
## 9   .p9.   0.261 0.017  15.774  0.000    0.229    0.293
## 10 .p10.   0.265 0.026  10.281  0.000    0.214    0.315
## 11 .p11.   0.334 0.034   9.888  0.000    0.268    0.400
## 12 .p12.   0.664 0.011  62.543  0.000    0.643    0.685
## 13         0.584 0.015  38.183  0.000    0.554    0.614
## 14 .p14.   0.339 0.025  13.555  0.000    0.290    0.388
## 15 .p15.   0.715 0.010  69.512  0.000    0.695    0.735
## 16 .p16.   0.760 0.009  80.519  0.000    0.741    0.778
## 17 .p17.   0.193 0.026   7.557  0.000    0.143    0.244
## 18 .p18.   0.422 0.016  27.185  0.000    0.391    0.452
## 19 .p19.   0.704 0.016  45.300  0.000    0.673    0.734
## 20 .p20.   0.618 0.015  40.052  0.000    0.588    0.648
## 21 .p21.   0.577 0.015  38.383  0.000    0.547    0.606
## 22         0.779 0.013  62.101  0.000    0.754    0.803
## 23 .p23.   0.567 0.012  45.686  0.000    0.543    0.592
## 24 .p24.   0.600 0.012  49.675  0.000    0.576    0.624
## 25 .p25.   0.514 0.017  29.744  0.000    0.480    0.548
## 26 .p26.   0.106 0.014   7.752  0.000    0.079    0.133
## 27 .p27.   0.900 0.008 115.960  0.000    0.885    0.915
## 28 .p28.   0.940 0.008 122.137  0.000    0.925    0.955
## 29 .p29.   0.370 0.018  20.546  0.000    0.335    0.405
## 30 .p30.   0.780 0.012  67.770  0.000    0.758    0.803
## 31         0.382 0.012  31.971  0.000    0.358    0.405
## 32         0.478 0.012  39.093  0.000    0.454    0.502
## 33         0.559 0.013  44.131  0.000    0.534    0.584
## 34         0.417 0.012  34.155  0.000    0.393    0.441
## 35         0.361 0.011  33.985  0.000    0.340    0.381
## 36         0.481 0.012  39.640  0.000    0.457    0.505
## 37         0.668 0.012  54.369  0.000    0.644    0.692
## 38         0.270 0.010  27.587  0.000    0.251    0.290
## 39         0.479 0.013  36.611  0.000    0.454    0.505
## 40         0.497 0.015  33.810  0.000    0.468    0.526
## 41         0.559 0.014  39.710  0.000    0.532    0.587
## 42         0.658 0.018  36.799  0.000    0.623    0.693
## 43         0.489 0.015  33.259  0.000    0.460    0.518
## 44         0.423 0.014  29.528  0.000    0.395    0.451
## 45         0.505 0.022  23.071  0.000    0.462    0.547
## 46         0.618 0.019  32.402  0.000    0.581    0.655
## 47         0.621 0.017  36.824  0.000    0.588    0.654
## 48         0.394 0.020  20.153  0.000    0.355    0.432
## 49         0.678 0.014  48.102  0.000    0.650    0.706
## 50         0.640 0.014  44.150  0.000    0.612    0.668
## 51         0.190 0.014  13.571  0.000    0.162    0.217
## 52         0.116 0.014   8.041  0.000    0.088    0.145
## 53         0.863 0.013  64.821  0.000    0.837    0.889
## 54         0.391 0.018  21.742  0.000    0.356    0.426
## 55         1.000 0.000      NA     NA    1.000    1.000
## 56        -1.162 0.027 -42.519  0.000   -1.215   -1.108
## 57 .p57.  -1.171 0.028 -41.200  0.000   -1.226   -1.115
## 58        -0.861 0.025 -35.120  0.000   -0.909   -0.812
## 59 .p59.  -1.199 0.028 -42.898  0.000   -1.253   -1.144
## 60 .p60.  -1.199 0.024 -50.084  0.000   -1.246   -1.153
## 61 .p61.  -0.894 0.020 -44.009  0.000   -0.934   -0.855
## 62 .p62.  -0.825 0.018 -45.197  0.000   -0.861   -0.790
## 63 .p63.  -1.295 0.028 -46.603  0.000   -1.350   -1.241
## 64 .p64.  -0.944 0.024 -39.902  0.000   -0.990   -0.897
## 65 .p65.  -1.028 0.028 -36.602  0.000   -1.083   -0.973
## 66 .p66.  -0.828 0.020 -42.346  0.000   -0.866   -0.789
## 67        -1.148 0.031 -37.594  0.000   -1.208   -1.088
## 68 .p68.  -1.349 0.032 -42.513  0.000   -1.411   -1.287
## 69 .p69.  -1.144 0.032 -36.251  0.000   -1.206   -1.082
## 70 .p70.  -0.466 0.019 -23.997  0.000   -0.505   -0.428
## 71 .p71.   0.038 0.019   1.952  0.051    0.000    0.076
## 72 .p72.  -0.260 0.020 -13.150  0.000   -0.299   -0.221
## 73        -0.823 0.029 -28.694  0.000   -0.879   -0.767
## 74 .p74.  -0.525 0.022 -24.355  0.000   -0.568   -0.483
## 75 .p75.  -0.787 0.024 -32.879  0.000   -0.834   -0.740
## 76         0.000 0.000      NA     NA    0.000    0.000
## 77         0.000 0.000      NA     NA    0.000    0.000
## 78         0.000 0.000      NA     NA    0.000    0.000
## 79         0.000 0.000      NA     NA    0.000    0.000
## 80         0.000 0.000      NA     NA    0.000    0.000
## 81  .p1.   0.496 0.033  14.962  0.000    0.431    0.561
## 82  .p2.   0.705 0.009  82.222  0.000    0.688    0.722
## 83  .p3.   0.674 0.009  75.617  0.000    0.656    0.691
## 84  .p4.   0.733 0.008  94.864  0.000    0.718    0.748
## 85  .p5.   0.812 0.006 127.971  0.000    0.799    0.824
## 86  .p6.   0.741 0.007 103.673  0.000    0.727    0.755
## 87  .p7.   0.590 0.010  59.101  0.000    0.571    0.610
## 88  .p8.   0.555 0.024  22.688  0.000    0.507    0.603
## 89  .p9.   0.262 0.017  15.842  0.000    0.230    0.295
## 90 .p10.   0.258 0.025  10.374  0.000    0.209    0.307
##  [ reached 'max' / getOption("max.print") -- omitted 70 rows ]
tests<-lavTestLRT(configural, metric2, scalar2, chc.hof)
Td=tests[2:4,"Chisq diff"]
Td
## [1] 143.22533 118.34290  80.50238
dfd=tests[2:4,"Df diff"]
dfd
## [1] 23 11  5
lambda<-Td-dfd
ld<-lambda/dfd
G<-2 # number of groups
N<- 2443 + 3642 # sample size
RMSEAD<-sqrt((ld)*G/(N-G))
RMSEAD
## [1] 0.04145626 0.05664302 0.07046142
RMSEA.CI(T=Td[1],df=dfd[1],N=N,G=2)
## [1] 0.03509080 0.04808945
RMSEA.CI(T=Td[2],df=dfd[2],N=N,G=2)
## [1] 0.04767390 0.06607564
RMSEA.CI(T=Td[3],df=dfd[3],N=N,G=2)
## [1] 0.05737893 0.08440863
round(pvals(T=Td[1],df=dfd[1],N=N,G=2),3)
##   RMSEA>0 RMSEA>.01 RMSEA>.05 RMSEA>.06 RMSEA>.08 RMSEA>.10 
##     1.000     1.000     0.017     0.000     0.000     0.000
round(pvals(T=Td[2],df=dfd[2],N=N,G=2),3)
##   RMSEA>0 RMSEA>.01 RMSEA>.05 RMSEA>.06 RMSEA>.08 RMSEA>.10 
##     1.000     1.000     0.891     0.290     0.000     0.000
round(pvals(T=Td[3],df=dfd[3],N=N,G=2),3)
##   RMSEA>0 RMSEA>.01 RMSEA>.05 RMSEA>.06 RMSEA>.08 RMSEA>.10 
##     1.000     1.000     0.994     0.908     0.134     0.000
tests<-lavTestLRT(configural, metric2, scalar)
Td=tests[2:3,"Chisq diff"]
Td
## [1] 143.2253 816.8842
dfd=tests[2:3,"Df diff"]
dfd
## [1] 23 15
lambda<-Td-dfd
ld<-lambda/dfd
G<-2 # number of groups
N<- 2443 + 3642 # sample size
RMSEAD<-sqrt((ld)*G/(N-G))
RMSEAD
## [1] 0.04145626 0.13257642
RMSEA.CI(T=Td[1],df=dfd[1],N=N,G=2)
## [1] 0.03509080 0.04808945
RMSEA.CI(T=Td[2],df=dfd[2],N=N,G=2)
## [1] 0.1249128 0.1403804
round(pvals(T=Td[1],df=dfd[1],N=N,G=2),3)
##   RMSEA>0 RMSEA>.01 RMSEA>.05 RMSEA>.06 RMSEA>.08 RMSEA>.10 
##     1.000     1.000     0.017     0.000     0.000     0.000
round(pvals(T=Td[2],df=dfd[2],N=N,G=2),3)
##   RMSEA>0 RMSEA>.01 RMSEA>.05 RMSEA>.06 RMSEA>.08 RMSEA>.10 
##         1         1         1         1         1         1
tests<-lavTestLRT(configural, metric2, scalar2, strict)
Td=tests[2:4,"Chisq diff"]
Td
## [1] 143.2253 118.3429 160.2079
dfd=tests[2:4,"Df diff"]
dfd
## [1] 23 11 20
lambda<-Td-dfd
ld<-lambda/dfd
G<-2 # number of groups
N<- 2443 + 3642 # sample size
RMSEAD<-sqrt((ld)*G/(N-G))
RMSEAD
## [1] 0.04145626 0.05664302 0.04800951
RMSEA.CI(T=Td[1],df=dfd[1],N=N,G=2)
## [1] 0.03509080 0.04808945
RMSEA.CI(T=Td[2],df=dfd[2],N=N,G=2)
## [1] 0.04767390 0.06607564
RMSEA.CI(T=Td[3],df=dfd[3],N=N,G=2)
## [1] 0.04125861 0.05504353
round(pvals(T=Td[1],df=dfd[1],N=N,G=2),3)
##   RMSEA>0 RMSEA>.01 RMSEA>.05 RMSEA>.06 RMSEA>.08 RMSEA>.10 
##     1.000     1.000     0.017     0.000     0.000     0.000
round(pvals(T=Td[2],df=dfd[2],N=N,G=2),3)
##   RMSEA>0 RMSEA>.01 RMSEA>.05 RMSEA>.06 RMSEA>.08 RMSEA>.10 
##     1.000     1.000     0.891     0.290     0.000     0.000
round(pvals(T=Td[3],df=dfd[3],N=N,G=2),3)
##   RMSEA>0 RMSEA>.01 RMSEA>.05 RMSEA>.06 RMSEA>.08 RMSEA>.10 
##     1.000     1.000     0.332     0.002     0.000     0.000
hof.age <-'
english =~ Stest1vocab + Stest19disguisedwords + Stest20spelling + Stest21capitalization + Stest22punctuation + Stest23english + Stest24expression + Stest26readingcomprehension + Stest31abstractreasoning + Stest34arithcomputation
math =~ Stest1vocab + Stest5math + Stest25wordfunctions + Stest26readingcomprehension + Stest32arithreasoning + Stest33highschoolmath + Stest34arithcomputation
speed =~ Stest34arithcomputation + Stest35tablereading + Stest36clericalchecking + Stest37objectinspection
spatial =~ Stest28mechanicalreasoning + Stest29visualization2D + Stest30visualization3D + Stest31abstractreasoning + Stest37objectinspection
g =~ english + math + speed + spatial
g ~ age
'

hof.age2 <-'
english =~ Stest1vocab + Stest19disguisedwords + Stest20spelling + Stest21capitalization + Stest22punctuation + Stest23english + Stest24expression + Stest26readingcomprehension + Stest31abstractreasoning + Stest34arithcomputation
math =~ Stest1vocab + Stest5math + Stest25wordfunctions + Stest26readingcomprehension + Stest32arithreasoning + Stest33highschoolmath + Stest34arithcomputation
speed =~ Stest34arithcomputation + Stest35tablereading + Stest36clericalchecking + Stest37objectinspection
spatial =~ Stest28mechanicalreasoning + Stest29visualization2D + Stest30visualization3D + Stest31abstractreasoning + Stest37objectinspection
g =~ english + math + speed + spatial
g ~ age + age2 
'

sem.age<-sem(hof.age, data=dgroup, group="sex", meanstructure=TRUE, sampling.weights="BY_WTA", std.lv=T, group.equal=c("loadings", "intercepts", "lv.variances"), group.partial=c("spatial=~Stest28mechanicalreasoning", "math=~Stest25wordfunctions", "Stest28mechanicalreasoning~1", "Stest1vocab~1", "Stest25wordfunctions~1", "Stest20spelling~1"))
## Warning: lavaan->lav_model_vcov():  
##    The variance-covariance matrix of the estimated parameters (vcov) 
##    does not appear to be positive definite! The smallest eigenvalue 
##    (= 8.379761e-16) is close to zero. This may be a symptom that the 
##    model is not identified.
fitMeasures(sem.age, c("chisq", "df", "pvalue", "cfi", "rmsea", "srmr", "ecvi", "aic", "bic"))
##      chisq         df     pvalue        cfi      rmsea       srmr 
##   4066.353    397.000      0.000      0.936      0.055      0.064 
##       ecvi        aic        bic 
##      0.702 291710.827 292402.326
Mc(sem.age)
## [1] 0.7396652
summary(sem.age, standardized=T, ci=T) 
## lavaan 0.6-18 ended normally after 89 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                       147
##   Number of equality constraints                    44
## 
##   Number of observations per group:                   
##     0                                             2443
##     1                                             3642
##   Sampling weights variable                     BY_WTA
## 
## Model Test User Model:
##                                               Standard      Scaled
##   Test Statistic                              4066.353    3593.693
##   Degrees of freedom                               397         397
##   P-value (Chi-square)                           0.000       0.000
##   Scaling correction factor                                  1.132
##     Yuan-Bentler correction (Mplus variant)                       
##   Test statistic for each group:
##     0                                         1757.553    1553.260
##     1                                         2308.801    2040.433
## 
## Parameter Estimates:
## 
##   Standard errors                             Sandwich
##   Information bread                           Observed
##   Observed information based on                Hessian
## 
## 
## Group 1 [0]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english =~                                                   
##     Stst1vc (.p1.)    0.209    0.017   12.664    0.000    0.177
##     Stst19d (.p2.)    0.281    0.011   26.018    0.000    0.260
##     Stst20s (.p3.)    0.285    0.012   24.219    0.000    0.262
##     Stst21c (.p4.)    0.319    0.012   25.955    0.000    0.295
##     Stst22p (.p5.)    0.349    0.013   26.510    0.000    0.323
##     Stst23n (.p6.)    0.361    0.014   25.554    0.000    0.334
##     Stst24x (.p7.)    0.284    0.012   24.308    0.000    0.261
##     Stst26r (.p8.)    0.243    0.015   16.649    0.000    0.214
##     Stst31b (.p9.)    0.127    0.009   13.762    0.000    0.109
##     Stst34r (.10.)    0.130    0.014    9.025    0.000    0.102
##   math =~                                                      
##     Stst1vc (.11.)    0.113    0.013    8.589    0.000    0.087
##     Stst5mt (.12.)    0.226    0.015   15.486    0.000    0.197
##     Stst25w           0.151    0.010   14.682    0.000    0.131
##     Stst26r (.14.)    0.118    0.011   10.890    0.000    0.097
##     Stst32r (.15.)    0.193    0.012   15.519    0.000    0.168
##     Stst33h (.16.)    0.192    0.013   15.283    0.000    0.167
##     Stst34r (.17.)    0.075    0.012    6.333    0.000    0.052
##   speed =~                                                     
##     Stst34r (.18.)    0.444    0.019   23.988    0.000    0.408
##     Stst35t (.19.)    1.084    0.024   44.402    0.000    1.037
##     Stst36c (.20.)    0.743    0.022   34.344    0.000    0.701
##     Stst37b (.21.)    0.660    0.020   33.101    0.000    0.621
##   spatial =~                                                   
##     Stst28m           0.423    0.013   31.743    0.000    0.397
##     Sts292D (.23.)    0.378    0.012   30.242    0.000    0.354
##     Sts303D (.24.)    0.334    0.011   31.224    0.000    0.313
##     Stst31b (.25.)    0.359    0.013   27.516    0.000    0.333
##     Stst37b (.26.)    0.081    0.011    7.260    0.000    0.059
##   g =~                                                         
##     english (.27.)    2.070    0.095   21.888    0.000    1.884
##     math    (.28.)    2.749    0.193   14.234    0.000    2.370
##     speed   (.29.)    0.398    0.022   17.744    0.000    0.354
##     spatial (.30.)    1.248    0.047   26.435    0.000    1.155
##  ci.upper   Std.lv  Std.all
##                            
##     0.241    0.481    0.484
##     0.302    0.646    0.723
##     0.308    0.655    0.664
##     0.343    0.733    0.764
##     0.375    0.802    0.800
##     0.389    0.831    0.720
##     0.307    0.653    0.577
##     0.272    0.559    0.548
##     0.145    0.291    0.261
##     0.159    0.300    0.264
##                            
##     0.139    0.332    0.334
##     0.254    0.661    0.664
##     0.172    0.443    0.585
##     0.139    0.346    0.339
##     0.217    0.564    0.715
##     0.217    0.562    0.760
##     0.098    0.219    0.194
##                            
##     0.481    0.478    0.422
##     1.132    1.167    0.704
##     0.786    0.800    0.618
##     0.699    0.710    0.577
##                            
##     0.449    0.677    0.779
##     0.403    0.605    0.568
##     0.355    0.535    0.600
##     0.384    0.574    0.514
##     0.103    0.130    0.106
##                            
##     2.255    0.901    0.901
##     3.127    0.940    0.940
##     0.442    0.370    0.370
##     1.340    0.781    0.781
## 
## Regressions:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   g ~                                                          
##     age              -0.023    0.016   -1.466    0.143   -0.053
##  ci.upper   Std.lv  Std.all
##                            
##     0.008   -0.023   -0.033
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stst1vc          -1.154    0.023  -50.350    0.000   -1.199
##    .Stst19d (.59.)   -1.046    0.016  -66.382    0.000   -1.077
##    .Stst20s          -0.847    0.021  -39.900    0.000   -0.889
##    .Stst21c (.61.)   -1.150    0.018  -62.677    0.000   -1.186
##    .Stst22p (.62.)   -1.202    0.020  -60.289    0.000   -1.241
##    .Stst23n (.63.)   -1.030    0.022  -45.961    0.000   -1.074
##    .Stst24x (.64.)   -0.934    0.020  -46.969    0.000   -0.973
##    .Stst26r (.65.)   -1.320    0.022  -60.267    0.000   -1.363
##    .Stst31b (.66.)   -1.053    0.023  -45.530    0.000   -1.098
##    .Stst34r (.67.)   -1.164    0.022  -52.280    0.000   -1.208
##    .Stst5mt (.68.)   -0.823    0.019  -42.416    0.000   -0.861
##    .Stst25w          -0.870    0.017  -52.706    0.000   -0.903
##    .Stst32r (.70.)   -1.062    0.016  -65.910    0.000   -1.094
##    .Stst33h (.71.)   -0.846    0.016  -54.354    0.000   -0.876
##    .Stst35t (.72.)   -0.773    0.034  -22.907    0.000   -0.839
##    .Stst36c (.73.)    0.049    0.025    1.950    0.051   -0.000
##    .Stst37b (.74.)   -0.320    0.023  -13.816    0.000   -0.365
##    .Stst28m          -0.714    0.019  -36.913    0.000   -0.752
##    .Sts292D (.76.)   -0.559    0.021  -26.686    0.000   -0.600
##    .Sts303D (.77.)   -0.701    0.018  -38.761    0.000   -0.737
##  ci.upper   Std.lv  Std.all
##    -1.109   -1.154   -1.161
##    -1.015   -1.046   -1.170
##    -0.806   -0.847   -0.860
##    -1.114   -1.150   -1.198
##    -1.163   -1.202   -1.199
##    -0.986   -1.030   -0.894
##    -0.895   -0.934   -0.825
##    -1.277   -1.320   -1.294
##    -1.008   -1.053   -0.943
##    -1.121   -1.164   -1.027
##    -0.785   -0.823   -0.827
##    -0.838   -0.870   -1.148
##    -1.031   -1.062   -1.348
##    -0.815   -0.846   -1.143
##    -0.707   -0.773   -0.466
##     0.099    0.049    0.038
##    -0.274   -0.320   -0.260
##    -0.676   -0.714   -0.822
##    -0.518   -0.559   -0.525
##    -0.666   -0.701   -0.786
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stest1vocab       0.377    0.013   28.621    0.000    0.351
##    .Stst19dsgsdwrd    0.382    0.014   26.429    0.000    0.354
##    .Stest20spellng    0.543    0.017   31.582    0.000    0.509
##    .Stest21cptlztn    0.384    0.015   25.056    0.000    0.354
##    .Stest22puncttn    0.363    0.013   28.838    0.000    0.338
##    .Stest23english    0.639    0.024   27.050    0.000    0.593
##    .Stest24exprssn    0.856    0.025   33.686    0.000    0.806
##    .Stst26rdngcmpr    0.281    0.011   25.289    0.000    0.259
##    .Stst31bstrctrs    0.597    0.022   27.672    0.000    0.555
##    .Stst34rthcmptt    0.638    0.030   21.184    0.000    0.579
##    .Stest5math        0.554    0.021   26.508    0.000    0.513
##    .Stst25wrdfnctn    0.379    0.012   31.786    0.000    0.355
##    .Stst32rthrsnng    0.304    0.011   28.291    0.000    0.283
##    .Stst33hghschlm    0.232    0.009   25.775    0.000    0.214
##    .Stest35tblrdng    1.388    0.076   18.345    0.000    1.240
##    .Stst36clrclchc    1.036    0.042   24.777    0.000    0.954
##    .Stst37bjctnspc    0.941    0.035   26.789    0.000    0.872
##    .Stst28mchnclrs    0.297    0.015   19.512    0.000    0.267
##    .Stst29vslztn2D    0.770    0.025   30.191    0.000    0.720
##    .Stst30vslztn3D    0.509    0.017   30.572    0.000    0.476
##    .english           1.000                               1.000
##    .math              1.000                               1.000
##    .speed             1.000                               1.000
##    .spatial           1.000                               1.000
##    .g                 1.000                               1.000
##  ci.upper   Std.lv  Std.all
##     0.403    0.377    0.382
##     0.410    0.382    0.478
##     0.577    0.543    0.559
##     0.414    0.384    0.417
##     0.388    0.363    0.361
##     0.686    0.639    0.481
##     0.906    0.856    0.668
##     0.303    0.281    0.270
##     0.640    0.597    0.479
##     0.697    0.638    0.497
##     0.595    0.554    0.559
##     0.402    0.379    0.658
##     0.325    0.304    0.489
##     0.249    0.232    0.423
##     1.536    1.388    0.505
##     1.118    1.036    0.618
##     1.010    0.941    0.621
##     0.327    0.297    0.394
##     0.820    0.770    0.678
##     0.541    0.509    0.640
##     1.000    0.189    0.189
##     1.000    0.117    0.117
##     1.000    0.863    0.863
##     1.000    0.391    0.391
##     1.000    0.999    0.999
## 
## 
## Group 2 [1]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english =~                                                   
##     Stst1vc (.p1.)    0.209    0.017   12.664    0.000    0.177
##     Stst19d (.p2.)    0.281    0.011   26.018    0.000    0.260
##     Stst20s (.p3.)    0.285    0.012   24.219    0.000    0.262
##     Stst21c (.p4.)    0.319    0.012   25.955    0.000    0.295
##     Stst22p (.p5.)    0.349    0.013   26.510    0.000    0.323
##     Stst23n (.p6.)    0.361    0.014   25.554    0.000    0.334
##     Stst24x (.p7.)    0.284    0.012   24.308    0.000    0.261
##     Stst26r (.p8.)    0.243    0.015   16.649    0.000    0.214
##     Stst31b (.p9.)    0.127    0.009   13.762    0.000    0.109
##     Stst34r (.10.)    0.130    0.014    9.025    0.000    0.102
##   math =~                                                      
##     Stst1vc (.11.)    0.113    0.013    8.589    0.000    0.087
##     Stst5mt (.12.)    0.226    0.015   15.486    0.000    0.197
##     Stst25w           0.193    0.013   15.103    0.000    0.168
##     Stst26r (.14.)    0.118    0.011   10.890    0.000    0.097
##     Stst32r (.15.)    0.193    0.012   15.519    0.000    0.168
##     Stst33h (.16.)    0.192    0.013   15.283    0.000    0.167
##     Stst34r (.17.)    0.075    0.012    6.333    0.000    0.052
##   speed =~                                                     
##     Stst34r (.18.)    0.444    0.019   23.988    0.000    0.408
##     Stst35t (.19.)    1.084    0.024   44.402    0.000    1.037
##     Stst36c (.20.)    0.743    0.022   34.344    0.000    0.701
##     Stst37b (.21.)    0.660    0.020   33.101    0.000    0.621
##   spatial =~                                                   
##     Stst28m           0.245    0.009   28.456    0.000    0.228
##     Sts292D (.23.)    0.378    0.012   30.242    0.000    0.354
##     Sts303D (.24.)    0.334    0.011   31.224    0.000    0.313
##     Stst31b (.25.)    0.359    0.013   27.516    0.000    0.333
##     Stst37b (.26.)    0.081    0.011    7.260    0.000    0.059
##   g =~                                                         
##     english (.27.)    2.070    0.095   21.888    0.000    1.884
##     math    (.28.)    2.749    0.193   14.234    0.000    2.370
##     speed   (.29.)    0.398    0.022   17.744    0.000    0.354
##     spatial (.30.)    1.248    0.047   26.435    0.000    1.155
##  ci.upper   Std.lv  Std.all
##                            
##     0.241    0.480    0.496
##     0.302    0.646    0.705
##     0.308    0.654    0.674
##     0.343    0.733    0.733
##     0.375    0.802    0.812
##     0.389    0.830    0.741
##     0.307    0.653    0.590
##     0.272    0.559    0.555
##     0.145    0.291    0.262
##     0.159    0.300    0.258
##                            
##     0.139    0.332    0.342
##     0.254    0.660    0.644
##     0.218    0.565    0.690
##     0.139    0.345    0.343
##     0.217    0.563    0.726
##     0.217    0.562    0.776
##     0.098    0.219    0.189
##                            
##     0.481    0.478    0.412
##     1.132    1.167    0.718
##     0.786    0.800    0.619
##     0.699    0.710    0.617
##                            
##     0.262    0.392    0.630
##     0.403    0.605    0.595
##     0.355    0.535    0.665
##     0.384    0.574    0.517
##     0.103    0.130    0.113
##                            
##     2.255    0.900    0.900
##     3.127    0.940    0.940
##     0.442    0.370    0.370
##     1.340    0.780    0.780
## 
## Regressions:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   g ~                                                          
##     age               0.006    0.013    0.462    0.644   -0.019
##  ci.upper   Std.lv  Std.all
##                            
##     0.031    0.006    0.008
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stst1vc          -1.426    0.026  -55.119    0.000   -1.477
##    .Stst19d (.59.)   -1.046    0.016  -66.382    0.000   -1.077
##    .Stst20s          -0.662    0.021  -31.805    0.000   -0.703
##    .Stst21c (.61.)   -1.150    0.018  -62.677    0.000   -1.186
##    .Stst22p (.62.)   -1.202    0.020  -60.289    0.000   -1.241
##    .Stst23n (.63.)   -1.030    0.022  -45.961    0.000   -1.074
##    .Stst24x (.64.)   -0.934    0.020  -46.969    0.000   -0.973
##    .Stst26r (.65.)   -1.320    0.022  -60.267    0.000   -1.363
##    .Stst31b (.66.)   -1.053    0.023  -45.530    0.000   -1.098
##    .Stst34r (.67.)   -1.164    0.022  -52.280    0.000   -1.208
##    .Stst5mt (.68.)   -0.823    0.019  -42.416    0.000   -0.861
##    .Stst25w          -0.674    0.019  -35.920    0.000   -0.710
##    .Stst32r (.70.)   -1.062    0.016  -65.910    0.000   -1.094
##    .Stst33h (.71.)   -0.846    0.016  -54.354    0.000   -0.876
##    .Stst35t (.72.)   -0.773    0.034  -22.907    0.000   -0.839
##    .Stst36c (.73.)    0.049    0.025    1.950    0.051   -0.000
##    .Stst37b (.74.)   -0.320    0.023  -13.816    0.000   -0.365
##    .Stst28m          -1.111    0.018  -61.455    0.000   -1.146
##    .Sts292D (.76.)   -0.559    0.021  -26.686    0.000   -0.600
##    .Sts303D (.77.)   -0.701    0.018  -38.761    0.000   -0.737
##    .english           0.908    0.042   21.689    0.000    0.826
##    .math             -0.376    0.036  -10.539    0.000   -0.446
##    .speed             0.296    0.036    8.337    0.000    0.227
##    .spatial          -0.769    0.049  -15.638    0.000   -0.866
##    .g                -0.078    0.030   -2.595    0.009   -0.138
##  ci.upper   Std.lv  Std.all
##    -1.376   -1.426   -1.472
##    -1.015   -1.046   -1.142
##    -0.621   -0.662   -0.681
##    -1.114   -1.150   -1.150
##    -1.163   -1.202   -1.217
##    -0.986   -1.030   -0.920
##    -0.895   -0.934   -0.845
##    -1.277   -1.320   -1.311
##    -1.008   -1.053   -0.949
##    -1.121   -1.164   -1.002
##    -0.785   -0.823   -0.803
##    -0.637   -0.674   -0.823
##    -1.031   -1.062   -1.370
##    -0.815   -0.846   -1.168
##    -0.707   -0.773   -0.476
##     0.099    0.049    0.038
##    -0.274   -0.320   -0.278
##    -1.075   -1.111   -1.785
##    -0.518   -0.559   -0.550
##    -0.666   -0.701   -0.871
##     0.990    0.395    0.395
##    -0.306   -0.129   -0.129
##     0.366    0.275    0.275
##    -0.673   -0.481   -0.481
##    -0.019   -0.078   -0.078
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stest1vocab       0.329    0.010   34.080    0.000    0.310
##    .Stst19dsgsdwrd    0.422    0.012   35.277    0.000    0.399
##    .Stest20spellng    0.516    0.014   37.592    0.000    0.489
##    .Stest21cptlztn    0.463    0.014   33.888    0.000    0.437
##    .Stest22puncttn    0.333    0.011   31.115    0.000    0.312
##    .Stest23english    0.565    0.017   33.650    0.000    0.532
##    .Stest24exprssn    0.797    0.021   37.748    0.000    0.755
##    .Stst26rdngcmpr    0.254    0.008   30.422    0.000    0.238
##    .Stst31bstrctrs    0.583    0.017   34.253    0.000    0.550
##    .Stst34rthcmptt    0.704    0.027   26.045    0.000    0.651
##    .Stest5math        0.614    0.017   35.742    0.000    0.580
##    .Stst25wrdfnctn    0.350    0.010   34.093    0.000    0.330
##    .Stst32rthrsnng    0.284    0.008   34.506    0.000    0.268
##    .Stst33hghschlm    0.209    0.007   30.367    0.000    0.196
##    .Stest35tblrdng    1.277    0.069   18.554    0.000    1.142
##    .Stst36clrclchc    1.031    0.033   30.933    0.000    0.966
##    .Stst37bjctnspc    0.750    0.027   27.584    0.000    0.697
##    .Stst28mchnclrs    0.233    0.007   34.010    0.000    0.220
##    .Stst29vslztn2D    0.667    0.019   34.788    0.000    0.630
##    .Stst30vslztn3D    0.362    0.011   33.404    0.000    0.340
##    .english           1.000                               1.000
##    .math              1.000                               1.000
##    .speed             1.000                               1.000
##    .spatial           1.000                               1.000
##    .g                 1.000                               1.000
##  ci.upper   Std.lv  Std.all
##     0.348    0.329    0.350
##     0.446    0.422    0.503
##     0.542    0.516    0.546
##     0.490    0.463    0.463
##     0.354    0.333    0.341
##     0.598    0.565    0.450
##     0.838    0.797    0.652
##     0.271    0.254    0.251
##     0.617    0.583    0.474
##     0.757    0.704    0.521
##     0.647    0.614    0.585
##     0.371    0.350    0.523
##     0.300    0.284    0.472
##     0.223    0.209    0.399
##     1.412    1.277    0.484
##     1.097    1.031    0.617
##     0.803    0.750    0.566
##     0.247    0.233    0.603
##     0.705    0.667    0.646
##     0.383    0.362    0.558
##     1.000    0.189    0.189
##     1.000    0.117    0.117
##     1.000    0.863    0.863
##     1.000    0.391    0.391
##     1.000    1.000    1.000
sem.age2<-sem(hof.age2, data=dgroup, group="sex", meanstructure=TRUE, sampling.weights="BY_WTA", std.lv=T, group.equal=c("loadings", "intercepts", "lv.variances"), group.partial=c("spatial=~Stest28mechanicalreasoning", "math=~Stest25wordfunctions", "Stest28mechanicalreasoning~1", "Stest1vocab~1", "Stest25wordfunctions~1", "Stest20spelling~1"))
## Warning: lavaan->lav_model_vcov():  
##    The variance-covariance matrix of the estimated parameters (vcov) 
##    does not appear to be positive definite! The smallest eigenvalue 
##    (= 5.347335e-15) is close to zero. This may be a symptom that the 
##    model is not identified.
fitMeasures(sem.age2, c("chisq", "df", "pvalue", "cfi", "rmsea", "srmr", "ecvi", "aic", "bic"))
##      chisq         df     pvalue        cfi      rmsea       srmr 
##   4152.567    435.000      0.000      0.935      0.053      0.060 
##       ecvi        aic        bic 
##      0.717 291656.675 292361.601
Mc(sem.age2)
## [1] 0.7367402
summary(sem.age2, standardized=T, ci=T) 
## lavaan 0.6-18 ended normally after 88 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                       149
##   Number of equality constraints                    44
## 
##   Number of observations per group:                   
##     0                                             2443
##     1                                             3642
##   Sampling weights variable                     BY_WTA
## 
## Model Test User Model:
##                                               Standard      Scaled
##   Test Statistic                              4152.567    3676.658
##   Degrees of freedom                               435         435
##   P-value (Chi-square)                           0.000       0.000
##   Scaling correction factor                                  1.129
##     Yuan-Bentler correction (Mplus variant)                       
##   Test statistic for each group:
##     0                                         1799.410    1593.187
##     1                                         2353.156    2083.471
## 
## Parameter Estimates:
## 
##   Standard errors                             Sandwich
##   Information bread                           Observed
##   Observed information based on                Hessian
## 
## 
## Group 1 [0]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english =~                                                   
##     Stst1vc (.p1.)    0.210    0.016   12.791    0.000    0.178
##     Stst19d (.p2.)    0.283    0.011   26.551    0.000    0.262
##     Stst20s (.p3.)    0.287    0.012   24.658    0.000    0.264
##     Stst21c (.p4.)    0.321    0.012   26.517    0.000    0.297
##     Stst22p (.p5.)    0.351    0.013   27.076    0.000    0.326
##     Stst23n (.p6.)    0.364    0.014   26.066    0.000    0.336
##     Stst24x (.p7.)    0.286    0.012   24.741    0.000    0.263
##     Stst26r (.p8.)    0.245    0.015   16.849    0.000    0.216
##     Stst31b (.p9.)    0.128    0.009   13.842    0.000    0.110
##     Stst34r (.10.)    0.132    0.014    9.111    0.000    0.103
##   math =~                                                      
##     Stst1vc (.11.)    0.113    0.013    8.596    0.000    0.087
##     Stst5mt (.12.)    0.224    0.015   15.343    0.000    0.196
##     Stst25w           0.150    0.010   14.559    0.000    0.130
##     Stst26r (.14.)    0.117    0.011   10.864    0.000    0.096
##     Stst32r (.15.)    0.191    0.012   15.343    0.000    0.167
##     Stst33h (.16.)    0.191    0.013   15.127    0.000    0.166
##     Stst34r (.17.)    0.074    0.012    6.318    0.000    0.051
##   speed =~                                                     
##     Stst34r (.18.)    0.444    0.019   23.970    0.000    0.408
##     Stst35t (.19.)    1.084    0.024   44.406    0.000    1.037
##     Stst36c (.20.)    0.743    0.022   34.349    0.000    0.701
##     Stst37b (.21.)    0.660    0.020   33.107    0.000    0.621
##   spatial =~                                                   
##     Stst28m           0.422    0.013   31.755    0.000    0.396
##     Sts292D (.23.)    0.378    0.012   30.242    0.000    0.353
##     Sts303D (.24.)    0.334    0.011   31.193    0.000    0.313
##     Stst31b (.25.)    0.358    0.013   27.505    0.000    0.333
##     Stst37b (.26.)    0.081    0.011    7.254    0.000    0.059
##   g =~                                                         
##     english (.27.)    2.042    0.092   22.289    0.000    1.863
##     math    (.28.)    2.756    0.196   14.093    0.000    2.373
##     speed   (.29.)    0.396    0.022   17.777    0.000    0.353
##     spatial (.30.)    1.243    0.047   26.459    0.000    1.151
##  ci.upper   Std.lv  Std.all
##                            
##     0.243    0.483    0.484
##     0.304    0.649    0.724
##     0.309    0.658    0.666
##     0.345    0.736    0.765
##     0.376    0.806    0.801
##     0.391    0.834    0.722
##     0.308    0.656    0.578
##     0.273    0.562    0.549
##     0.146    0.293    0.262
##     0.160    0.302    0.266
##                            
##     0.138    0.333    0.334
##     0.253    0.664    0.666
##     0.170    0.445    0.586
##     0.138    0.347    0.339
##     0.216    0.566    0.716
##     0.215    0.565    0.761
##     0.097    0.220    0.193
##                            
##     0.480    0.478    0.421
##     1.132    1.168    0.704
##     0.786    0.801    0.618
##     0.699    0.711    0.577
##                            
##     0.449    0.679    0.780
##     0.402    0.607    0.569
##     0.355    0.537    0.601
##     0.384    0.575    0.514
##     0.103    0.131    0.106
##                            
##     2.222    0.900    0.900
##     3.139    0.941    0.941
##     0.440    0.372    0.372
##     1.335    0.783    0.783
## 
## Regressions:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   g ~                                                          
##     age               0.009    0.017    0.513    0.608   -0.024
##     age2             -0.055    0.008   -7.039    0.000   -0.070
##  ci.upper   Std.lv  Std.all
##                            
##     0.042    0.009    0.012
##    -0.039   -0.054   -0.152
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stst1vc          -1.071    0.027  -39.728    0.000   -1.124
##    .Stst19d (.62.)   -0.981    0.019  -50.542    0.000   -1.019
##    .Stst20s          -0.782    0.024  -32.861    0.000   -0.828
##    .Stst21c (.64.)   -1.076    0.022  -48.405    0.000   -1.120
##    .Stst22p (.65.)   -1.122    0.024  -46.226    0.000   -1.169
##    .Stst23n (.66.)   -0.947    0.027  -35.667    0.000   -0.999
##    .Stst24x (.67.)   -0.869    0.023  -38.372    0.000   -0.913
##    .Stst26r (.68.)   -1.227    0.027  -45.132    0.000   -1.281
##    .Stst31b (.69.)   -0.974    0.027  -36.235    0.000   -1.026
##    .Stst34r (.70.)   -1.092    0.026  -42.471    0.000   -1.142
##    .Stst5mt (.71.)   -0.754    0.023  -32.580    0.000   -0.799
##    .Stst25w          -0.824    0.019  -43.589    0.000   -0.861
##    .Stst32r (.73.)   -1.003    0.020  -50.873    0.000   -1.042
##    .Stst33h (.74.)   -0.787    0.019  -40.784    0.000   -0.825
##    .Stst35t (.75.)   -0.725    0.034  -21.073    0.000   -0.792
##    .Stst36c (.76.)    0.082    0.026    3.181    0.001    0.032
##    .Stst37b (.77.)   -0.279    0.024  -11.443    0.000   -0.327
##    .Stst28m          -0.655    0.022  -29.297    0.000   -0.699
##    .Sts292D (.79.)   -0.506    0.023  -22.114    0.000   -0.551
##    .Sts303D (.80.)   -0.655    0.020  -32.794    0.000   -0.694
##  ci.upper   Std.lv  Std.all
##    -1.018   -1.071   -1.074
##    -0.943   -0.981   -1.095
##    -0.735   -0.782   -0.792
##    -1.032   -1.076   -1.118
##    -1.074   -1.122   -1.115
##    -0.895   -0.947   -0.819
##    -0.824   -0.869   -0.766
##    -1.174   -1.227   -1.199
##    -0.921   -0.974   -0.870
##    -1.041   -1.092   -0.961
##    -0.708   -0.754   -0.756
##    -0.787   -0.824   -1.085
##    -0.965   -1.003   -1.270
##    -0.749   -0.787   -1.061
##    -0.657   -0.725   -0.437
##     0.133    0.082    0.064
##    -0.231   -0.279   -0.226
##    -0.612   -0.655   -0.753
##    -0.462   -0.506   -0.475
##    -0.615   -0.655   -0.733
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stest1vocab       0.377    0.013   28.612    0.000    0.351
##    .Stst19dsgsdwrd    0.382    0.014   26.431    0.000    0.354
##    .Stest20spellng    0.543    0.017   31.562    0.000    0.509
##    .Stest21cptlztn    0.384    0.015   25.057    0.000    0.354
##    .Stest22puncttn    0.363    0.013   28.841    0.000    0.338
##    .Stest23english    0.640    0.024   27.052    0.000    0.593
##    .Stest24exprssn    0.856    0.025   33.692    0.000    0.806
##    .Stst26rdngcmpr    0.281    0.011   25.313    0.000    0.259
##    .Stst31bstrctrs    0.598    0.022   27.691    0.000    0.555
##    .Stst34rthcmptt    0.638    0.030   21.184    0.000    0.579
##    .Stest5math        0.553    0.021   26.491    0.000    0.513
##    .Stst25wrdfnctn    0.379    0.012   31.783    0.000    0.355
##    .Stst32rthrsnng    0.304    0.011   28.248    0.000    0.283
##    .Stst33hghschlm    0.231    0.009   25.794    0.000    0.214
##    .Stest35tblrdng    1.387    0.076   18.346    0.000    1.239
##    .Stst36clrclchc    1.036    0.042   24.779    0.000    0.954
##    .Stst37bjctnspc    0.941    0.035   26.792    0.000    0.872
##    .Stst28mchnclrs    0.297    0.015   19.496    0.000    0.267
##    .Stst29vslztn2D    0.770    0.025   30.205    0.000    0.720
##    .Stst30vslztn3D    0.509    0.017   30.563    0.000    0.476
##    .english           1.000                               1.000
##    .math              1.000                               1.000
##    .speed             1.000                               1.000
##    .spatial           1.000                               1.000
##    .g                 1.000                               1.000
##  ci.upper   Std.lv  Std.all
##     0.403    0.377    0.379
##     0.410    0.382    0.476
##     0.576    0.543    0.556
##     0.414    0.384    0.415
##     0.388    0.363    0.359
##     0.686    0.640    0.479
##     0.906    0.856    0.666
##     0.303    0.281    0.268
##     0.640    0.598    0.477
##     0.697    0.638    0.495
##     0.594    0.553    0.557
##     0.402    0.379    0.657
##     0.325    0.304    0.487
##     0.249    0.231    0.420
##     1.536    1.387    0.504
##     1.118    1.036    0.618
##     1.010    0.941    0.620
##     0.327    0.297    0.392
##     0.820    0.770    0.677
##     0.541    0.509    0.638
##     1.000    0.190    0.190
##     1.000    0.114    0.114
##     1.000    0.862    0.862
##     1.000    0.387    0.387
##     1.000    0.978    0.978
## 
## 
## Group 2 [1]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english =~                                                   
##     Stst1vc (.p1.)    0.210    0.016   12.791    0.000    0.178
##     Stst19d (.p2.)    0.283    0.011   26.551    0.000    0.262
##     Stst20s (.p3.)    0.287    0.012   24.658    0.000    0.264
##     Stst21c (.p4.)    0.321    0.012   26.517    0.000    0.297
##     Stst22p (.p5.)    0.351    0.013   27.076    0.000    0.326
##     Stst23n (.p6.)    0.364    0.014   26.066    0.000    0.336
##     Stst24x (.p7.)    0.286    0.012   24.741    0.000    0.263
##     Stst26r (.p8.)    0.245    0.015   16.849    0.000    0.216
##     Stst31b (.p9.)    0.128    0.009   13.842    0.000    0.110
##     Stst34r (.10.)    0.132    0.014    9.111    0.000    0.103
##   math =~                                                      
##     Stst1vc (.11.)    0.113    0.013    8.596    0.000    0.087
##     Stst5mt (.12.)    0.224    0.015   15.343    0.000    0.196
##     Stst25w           0.192    0.013   14.956    0.000    0.167
##     Stst26r (.14.)    0.117    0.011   10.864    0.000    0.096
##     Stst32r (.15.)    0.191    0.012   15.343    0.000    0.167
##     Stst33h (.16.)    0.191    0.013   15.127    0.000    0.166
##     Stst34r (.17.)    0.074    0.012    6.318    0.000    0.051
##   speed =~                                                     
##     Stst34r (.18.)    0.444    0.019   23.970    0.000    0.408
##     Stst35t (.19.)    1.084    0.024   44.406    0.000    1.037
##     Stst36c (.20.)    0.743    0.022   34.349    0.000    0.701
##     Stst37b (.21.)    0.660    0.020   33.107    0.000    0.621
##   spatial =~                                                   
##     Stst28m           0.245    0.009   28.426    0.000    0.228
##     Sts292D (.23.)    0.378    0.012   30.242    0.000    0.353
##     Sts303D (.24.)    0.334    0.011   31.193    0.000    0.313
##     Stst31b (.25.)    0.358    0.013   27.505    0.000    0.333
##     Stst37b (.26.)    0.081    0.011    7.254    0.000    0.059
##   g =~                                                         
##     english (.27.)    2.042    0.092   22.289    0.000    1.863
##     math    (.28.)    2.756    0.196   14.093    0.000    2.373
##     speed   (.29.)    0.396    0.022   17.777    0.000    0.353
##     spatial (.30.)    1.243    0.047   26.459    0.000    1.151
##  ci.upper   Std.lv  Std.all
##                            
##     0.243    0.479    0.495
##     0.304    0.644    0.704
##     0.309    0.653    0.673
##     0.345    0.731    0.732
##     0.376    0.800    0.811
##     0.391    0.828    0.740
##     0.308    0.651    0.589
##     0.273    0.558    0.555
##     0.146    0.291    0.262
##     0.160    0.300    0.258
##                            
##     0.138    0.330    0.342
##     0.253    0.658    0.643
##     0.217    0.563    0.689
##     0.138    0.344    0.343
##     0.216    0.562    0.725
##     0.215    0.560    0.775
##     0.097    0.218    0.188
##                            
##     0.480    0.478    0.412
##     1.132    1.167    0.718
##     0.786    0.800    0.619
##     0.699    0.710    0.617
##                            
##     0.262    0.391    0.629
##     0.402    0.603    0.594
##     0.355    0.534    0.664
##     0.384    0.572    0.516
##     0.103    0.130    0.113
##                            
##     2.222    0.898    0.898
##     3.139    0.940    0.940
##     0.440    0.369    0.369
##     1.335    0.780    0.780
## 
## Regressions:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   g ~                                                          
##     age               0.001    0.013    0.056    0.956   -0.024
##     age2             -0.028    0.007   -3.926    0.000   -0.042
##  ci.upper   Std.lv  Std.all
##                            
##     0.025    0.001    0.001
##    -0.014   -0.028   -0.063
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stst1vc          -1.343    0.030  -45.213    0.000   -1.402
##    .Stst19d (.62.)   -0.981    0.019  -50.542    0.000   -1.019
##    .Stst20s          -0.596    0.023  -25.403    0.000   -0.642
##    .Stst21c (.64.)   -1.076    0.022  -48.405    0.000   -1.120
##    .Stst22p (.65.)   -1.122    0.024  -46.226    0.000   -1.169
##    .Stst23n (.66.)   -0.947    0.027  -35.667    0.000   -0.999
##    .Stst24x (.67.)   -0.869    0.023  -38.372    0.000   -0.913
##    .Stst26r (.68.)   -1.227    0.027  -45.132    0.000   -1.281
##    .Stst31b (.69.)   -0.974    0.027  -36.235    0.000   -1.026
##    .Stst34r (.70.)   -1.092    0.026  -42.471    0.000   -1.142
##    .Stst5mt (.71.)   -0.754    0.023  -32.580    0.000   -0.799
##    .Stst25w          -0.614    0.022  -28.041    0.000   -0.657
##    .Stst32r (.73.)   -1.003    0.020  -50.873    0.000   -1.042
##    .Stst33h (.74.)   -0.787    0.019  -40.784    0.000   -0.825
##    .Stst35t (.75.)   -0.725    0.034  -21.073    0.000   -0.792
##    .Stst36c (.76.)    0.082    0.026    3.181    0.001    0.032
##    .Stst37b (.77.)   -0.279    0.024  -11.443    0.000   -0.327
##    .Stst28m          -1.076    0.020  -55.021    0.000   -1.115
##    .Sts292D (.79.)   -0.506    0.023  -22.114    0.000   -0.551
##    .Sts303D (.80.)   -0.655    0.020  -32.794    0.000   -0.694
##    .english           0.901    0.042   21.519    0.000    0.819
##    .math             -0.379    0.036  -10.580    0.000   -0.450
##    .speed             0.296    0.036    8.324    0.000    0.226
##    .spatial          -0.771    0.049  -15.633    0.000   -0.867
##    .g                -0.142    0.039   -3.686    0.000   -0.218
##  ci.upper   Std.lv  Std.all
##    -1.285   -1.343   -1.389
##    -0.943   -0.981   -1.072
##    -0.550   -0.596   -0.614
##    -1.032   -1.076   -1.078
##    -1.074   -1.122   -1.138
##    -0.895   -0.947   -0.847
##    -0.824   -0.869   -0.786
##    -1.174   -1.227   -1.223
##    -0.921   -0.974   -0.879
##    -1.041   -1.092   -0.941
##    -0.708   -0.754   -0.736
##    -0.571   -0.614   -0.751
##    -0.965   -1.003   -1.296
##    -0.749   -0.787   -1.088
##    -0.657   -0.725   -0.446
##     0.133    0.082    0.064
##    -0.231   -0.279   -0.242
##    -1.038   -1.076   -1.732
##    -0.462   -0.506   -0.499
##    -0.615   -0.655   -0.814
##     0.983    0.396    0.396
##    -0.309   -0.129   -0.129
##     0.366    0.275    0.275
##    -0.674   -0.482   -0.482
##    -0.067   -0.142   -0.142
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stest1vocab       0.329    0.010   34.072    0.000    0.310
##    .Stst19dsgsdwrd    0.422    0.012   35.272    0.000    0.399
##    .Stest20spellng    0.515    0.014   37.585    0.000    0.488
##    .Stest21cptlztn    0.463    0.014   33.885    0.000    0.437
##    .Stest22puncttn    0.333    0.011   31.114    0.000    0.312
##    .Stest23english    0.565    0.017   33.642    0.000    0.532
##    .Stest24exprssn    0.797    0.021   37.746    0.000    0.755
##    .Stst26rdngcmpr    0.254    0.008   30.428    0.000    0.238
##    .Stst31bstrctrs    0.583    0.017   34.269    0.000    0.550
##    .Stst34rthcmptt    0.704    0.027   26.049    0.000    0.651
##    .Stest5math        0.614    0.017   35.743    0.000    0.580
##    .Stst25wrdfnctn    0.350    0.010   34.085    0.000    0.330
##    .Stst32rthrsnng    0.284    0.008   34.509    0.000    0.268
##    .Stst33hghschlm    0.209    0.007   30.382    0.000    0.196
##    .Stest35tblrdng    1.277    0.069   18.558    0.000    1.142
##    .Stst36clrclchc    1.031    0.033   30.947    0.000    0.966
##    .Stst37bjctnspc    0.750    0.027   27.591    0.000    0.697
##    .Stst28mchnclrs    0.233    0.007   33.999    0.000    0.220
##    .Stst29vslztn2D    0.667    0.019   34.796    0.000    0.630
##    .Stst30vslztn3D    0.362    0.011   33.392    0.000    0.340
##    .english           1.000                               1.000
##    .math              1.000                               1.000
##    .speed             1.000                               1.000
##    .spatial           1.000                               1.000
##    .g                 1.000                               1.000
##  ci.upper   Std.lv  Std.all
##     0.348    0.329    0.352
##     0.446    0.422    0.504
##     0.542    0.515    0.547
##     0.490    0.463    0.465
##     0.354    0.333    0.342
##     0.598    0.565    0.452
##     0.838    0.797    0.653
##     0.271    0.254    0.252
##     0.617    0.583    0.475
##     0.757    0.704    0.523
##     0.648    0.614    0.586
##     0.371    0.350    0.525
##     0.300    0.284    0.474
##     0.223    0.209    0.400
##     1.412    1.277    0.484
##     1.097    1.031    0.617
##     0.803    0.750    0.567
##     0.247    0.233    0.604
##     0.705    0.667    0.647
##     0.383    0.362    0.559
##     1.000    0.193    0.193
##     1.000    0.116    0.116
##     1.000    0.864    0.864
##     1.000    0.392    0.392
##     1.000    0.996    0.996

CHC Bifactor models (vocabulary and reading comprehension load on english and math, given EFA, but these loadings are zero, because their loading on g is already very high)

chc.bifactor.failed<-'
english =~ Stest1vocab + Stest19disguisedwords + Stest20spelling + Stest21capitalization + Stest22punctuation + Stest23english + Stest24expression + Stest26readingcomprehension + Stest31abstractreasoning + Stest34arithcomputation
math =~ Stest5math + Stest25wordfunctions + Stest32arithreasoning + Stest33highschoolmath + Stest34arithcomputation
speed =~ Stest34arithcomputation + Stest35tablereading + Stest36clericalchecking + Stest37objectinspection
spatial =~ Stest28mechanicalreasoning + Stest29visualization2D + Stest30visualization3D + Stest31abstractreasoning + Stest37objectinspection
g=~ Stest1vocab + Stest5math + Stest19disguisedwords + Stest20spelling + Stest21capitalization + Stest22punctuation + Stest23english + Stest24expression + Stest25wordfunctions + Stest26readingcomprehension + Stest28mechanicalreasoning + Stest29visualization2D + Stest30visualization3D + Stest31abstractreasoning + Stest32arithreasoning + Stest33highschoolmath + Stest34arithcomputation + Stest35tablereading + Stest36clericalchecking + Stest37objectinspection
'

configural<-cfa(chc.bifactor.failed, data=dgroup, group="sex", meanstructure=TRUE, sampling.weights="BY_WTA", std.lv=T, orthogonal=T)
fitMeasures(configural, c("chisq", "df", "pvalue", "cfi", "rmsea", "srmr", "aic", "bic"))
##      chisq         df     pvalue        cfi      rmsea       srmr 
##   2390.689    292.000      0.000      0.963      0.049      0.030 
##        aic        bic 
## 290372.419 291500.301
Mc(configural)
## [1] 0.8415784
summary(configural, standardized=T, ci=T)
## lavaan 0.6-18 ended normally after 55 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                       168
## 
##   Number of observations per group:                   
##     0                                             2443
##     1                                             3642
##   Sampling weights variable                     BY_WTA
## 
## Model Test User Model:
##                                               Standard      Scaled
##   Test Statistic                              2390.689    2253.503
##   Degrees of freedom                               292         292
##   P-value (Chi-square)                           0.000       0.000
##   Scaling correction factor                                  1.061
##     Yuan-Bentler correction (Mplus variant)                       
##   Test statistic for each group:
##     0                                          997.257     940.031
##     1                                         1393.432    1313.472
## 
## Parameter Estimates:
## 
##   Standard errors                             Sandwich
##   Information bread                           Observed
##   Observed information based on                Hessian
## 
## 
## Group 1 [0]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english =~                                                   
##     Stest1vocab      -0.023    0.087   -0.264    0.791   -0.194
##     Stst19dsgsdwrd    0.098    0.069    1.426    0.154   -0.037
##     Stest20spellng    0.326    0.095    3.412    0.001    0.139
##     Stest21cptlztn    0.271    0.038    7.161    0.000    0.197
##     Stest22puncttn    0.315    0.027   11.743    0.000    0.262
##     Stest23english    0.285    0.080    3.545    0.000    0.127
##     Stest24exprssn    0.193    0.058    3.345    0.001    0.080
##     Stst26rdngcmpr   -0.005    0.090   -0.058    0.953   -0.182
##     Stst31bstrctrs    0.113    0.033    3.438    0.001    0.049
##     Stst34rthcmptt    0.257    0.045    5.702    0.000    0.169
##   math =~                                                      
##     Stest5math        0.231    0.027    8.409    0.000    0.177
##     Stst25wrdfnctn    0.135    0.023    5.913    0.000    0.090
##     Stst32rthrsnng    0.214    0.025    8.449    0.000    0.164
##     Stst33hghschlm    0.374    0.030   12.271    0.000    0.314
##     Stst34rthcmptt    0.245    0.039    6.323    0.000    0.169
##   speed =~                                                     
##     Stst34rthcmptt    0.447    0.029   15.573    0.000    0.391
##     Stest35tblrdng    0.955    0.043   22.337    0.000    0.871
##     Stst36clrclchc    0.867    0.029   30.265    0.000    0.811
##     Stst37bjctnspc    0.735    0.029   25.263    0.000    0.678
##   spatial =~                                                   
##     Stst28mchnclrs    0.385    0.022   17.337    0.000    0.342
##     Stst29vslztn2D    0.468    0.028   16.568    0.000    0.412
##     Stst30vslztn3D    0.509    0.025   20.210    0.000    0.459
##     Stst31bstrctrs    0.440    0.025   17.765    0.000    0.391
##     Stst37bjctnspc    0.318    0.028   11.315    0.000    0.263
##   g =~                                                         
##     Stest1vocab       0.904    0.017   52.243    0.000    0.870
##     Stest5math        0.691    0.020   33.740    0.000    0.651
##     Stst19dsgsdwrd    0.603    0.021   28.976    0.000    0.562
##     Stest20spellng    0.612    0.033   18.455    0.000    0.547
##     Stest21cptlztn    0.663    0.023   29.041    0.000    0.618
##     Stest22puncttn    0.744    0.025   30.350    0.000    0.696
##     Stest23english    0.832    0.029   28.733    0.000    0.775
##     Stest24exprssn    0.681    0.025   27.495    0.000    0.633
##     Stst25wrdfnctn    0.447    0.018   25.069    0.000    0.412
##     Stst26rdngcmpr    0.965    0.018   53.513    0.000    0.930
##     Stst28mchnclrs    0.568    0.021   27.349    0.000    0.527
##     Stst29vslztn2D    0.475    0.021   22.126    0.000    0.433
##     Stst30vslztn3D    0.451    0.022   20.700    0.000    0.408
##     Stst31bstrctrs    0.721    0.020   35.638    0.000    0.682
##     Stst32rthrsnng    0.589    0.019   30.691    0.000    0.551
##     Stst33hghschlm    0.561    0.018   30.867    0.000    0.525
##     Stst34rthcmptt    0.635    0.028   22.974    0.000    0.581
##     Stest35tblrdng    0.596    0.032   18.679    0.000    0.534
##     Stst36clrclchc    0.173    0.028    6.254    0.000    0.119
##     Stst37bjctnspc    0.250    0.026    9.508    0.000    0.199
##  ci.upper   Std.lv  Std.all
##                            
##     0.148   -0.023   -0.022
##     0.233    0.098    0.112
##     0.513    0.326    0.327
##     0.345    0.271    0.287
##     0.367    0.315    0.315
##     0.442    0.285    0.239
##     0.306    0.193    0.166
##     0.172   -0.005   -0.005
##     0.177    0.113    0.099
##     0.346    0.257    0.225
##                            
##     0.285    0.231    0.221
##     0.179    0.135    0.173
##     0.264    0.214    0.255
##     0.434    0.374    0.476
##     0.321    0.245    0.215
##                            
##     0.503    0.447    0.391
##     1.038    0.955    0.572
##     0.923    0.867    0.669
##     0.792    0.735    0.597
##                            
##     0.429    0.385    0.428
##     0.523    0.468    0.429
##     0.558    0.509    0.537
##     0.488    0.440    0.385
##     0.373    0.318    0.258
##                            
##     0.937    0.904    0.847
##     0.732    0.691    0.660
##     0.644    0.603    0.691
##     0.677    0.612    0.614
##     0.708    0.663    0.702
##     0.792    0.744    0.746
##     0.888    0.832    0.699
##     0.730    0.681    0.585
##     0.482    0.447    0.574
##     1.000    0.965    0.898
##     0.608    0.568    0.631
##     0.517    0.475    0.436
##     0.494    0.451    0.476
##     0.761    0.721    0.632
##     0.627    0.589    0.702
##     0.596    0.561    0.714
##     0.689    0.635    0.556
##     0.659    0.596    0.357
##     0.227    0.173    0.133
##     0.302    0.250    0.203
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english ~~                                                   
##     math              0.000                               0.000
##     speed             0.000                               0.000
##     spatial           0.000                               0.000
##     g                 0.000                               0.000
##   math ~~                                                      
##     speed             0.000                               0.000
##     spatial           0.000                               0.000
##     g                 0.000                               0.000
##   speed ~~                                                     
##     spatial           0.000                               0.000
##     g                 0.000                               0.000
##   spatial ~~                                                   
##     g                 0.000                               0.000
##  ci.upper   Std.lv  Std.all
##                            
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##                            
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##                            
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##                            
##     0.000    0.000    0.000
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stest1vocab      -1.155    0.023  -50.360    0.000   -1.200
##    .Stst19dsgsdwrd   -0.992    0.018  -53.776    0.000   -1.028
##    .Stest20spellng   -0.848    0.021  -39.900    0.000   -0.890
##    .Stest21cptlztn   -1.167    0.020  -58.007    0.000   -1.206
##    .Stest22puncttn   -1.226    0.021  -57.496    0.000   -1.268
##    .Stest23english   -1.062    0.026  -41.362    0.000   -1.113
##    .Stest24exprssn   -0.965    0.025  -38.928    0.000   -1.014
##    .Stst26rdngcmpr   -1.292    0.023  -56.802    0.000   -1.337
##    .Stst31bstrctrs   -1.070    0.024  -43.766    0.000   -1.118
##    .Stst34rthcmptt   -1.153    0.025  -46.702    0.000   -1.201
##    .Stest5math       -0.814    0.022  -36.442    0.000   -0.857
##    .Stst25wrdfnctn   -0.871    0.017  -52.726    0.000   -0.903
##    .Stst32rthrsnng   -1.052    0.018  -59.194    0.000   -1.087
##    .Stst33hghschlm   -0.875    0.016  -53.483    0.000   -0.907
##    .Stest35tblrdng   -0.712    0.037  -19.463    0.000   -0.784
##    .Stst36clrclchc   -0.032    0.028   -1.139    0.255   -0.086
##    .Stst37bjctnspc   -0.318    0.027  -11.957    0.000   -0.370
##    .Stst28mchnclrs   -0.715    0.019  -36.895    0.000   -0.753
##    .Stst29vslztn2D   -0.512    0.023  -22.047    0.000   -0.557
##    .Stst30vslztn3D   -0.723    0.020  -35.874    0.000   -0.762
##  ci.upper   Std.lv  Std.all
##    -1.110   -1.155   -1.083
##    -0.956   -0.992   -1.136
##    -0.806   -0.848   -0.851
##    -1.128   -1.167   -1.236
##    -1.184   -1.226   -1.229
##    -1.012   -1.062   -0.893
##    -0.916   -0.965   -0.829
##    -1.248   -1.292   -1.202
##    -1.022   -1.070   -0.937
##    -1.104   -1.153   -1.009
##    -0.770   -0.814   -0.777
##    -0.838   -0.871   -1.119
##    -1.017   -1.052   -1.253
##    -0.843   -0.875   -1.115
##    -0.640   -0.712   -0.427
##     0.023   -0.032   -0.025
##    -0.266   -0.318   -0.258
##    -0.677   -0.715   -0.795
##    -0.466   -0.512   -0.469
##    -0.683   -0.723   -0.763
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stest1vocab       0.321    0.017   18.557    0.000    0.287
##    .Stst19dsgsdwrd    0.389    0.014   27.413    0.000    0.361
##    .Stest20spellng    0.513    0.032   16.020    0.000    0.450
##    .Stest21cptlztn    0.378    0.016   23.495    0.000    0.346
##    .Stest22puncttn    0.343    0.023   15.121    0.000    0.298
##    .Stest23english    0.642    0.025   25.218    0.000    0.592
##    .Stest24exprssn    0.854    0.026   32.768    0.000    0.803
##    .Stst26rdngcmpr    0.225    0.019   11.999    0.000    0.188
##    .Stst31bstrctrs    0.577    0.023   24.854    0.000    0.532
##    .Stst34rthcmptt    0.576    0.031   18.729    0.000    0.516
##    .Stest5math        0.566    0.021   27.063    0.000    0.525
##    .Stst25wrdfnctn    0.388    0.012   32.251    0.000    0.364
##    .Stst32rthrsnng    0.312    0.012   26.317    0.000    0.289
##    .Stst33hghschlm    0.162    0.019    8.677    0.000    0.126
##    .Stest35tblrdng    1.516    0.075   20.200    0.000    1.369
##    .Stst36clrclchc    0.896    0.046   19.440    0.000    0.806
##    .Stst37bjctnspc    0.814    0.038   21.280    0.000    0.739
##    .Stst28mchnclrs    0.338    0.015   22.247    0.000    0.309
##    .Stst29vslztn2D    0.745    0.029   26.116    0.000    0.689
##    .Stst30vslztn3D    0.436    0.021   21.044    0.000    0.395
##     english           1.000                               1.000
##     math              1.000                               1.000
##     speed             1.000                               1.000
##     spatial           1.000                               1.000
##     g                 1.000                               1.000
##  ci.upper   Std.lv  Std.all
##     0.354    0.321    0.282
##     0.417    0.389    0.510
##     0.576    0.513    0.516
##     0.410    0.378    0.424
##     0.387    0.343    0.344
##     0.691    0.642    0.454
##     0.905    0.854    0.630
##     0.261    0.225    0.194
##     0.623    0.577    0.443
##     0.636    0.576    0.441
##     0.607    0.566    0.516
##     0.411    0.388    0.640
##     0.336    0.312    0.443
##     0.199    0.162    0.263
##     1.663    1.516    0.545
##     0.987    0.896    0.534
##     0.889    0.814    0.536
##     0.368    0.338    0.418
##     0.801    0.745    0.626
##     0.476    0.436    0.485
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
## 
## 
## Group 2 [1]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english =~                                                   
##     Stest1vocab       0.122    0.156    0.783    0.434   -0.183
##     Stst19dsgsdwrd    0.226    0.125    1.806    0.071   -0.019
##     Stest20spellng    0.423    0.109    3.901    0.000    0.211
##     Stest21cptlztn    0.292    0.039    7.446    0.000    0.215
##     Stest22puncttn    0.300    0.027   11.152    0.000    0.247
##     Stest23english    0.356    0.033   10.778    0.000    0.291
##     Stest24exprssn    0.235    0.036    6.589    0.000    0.165
##     Stst26rdngcmpr    0.161    0.142    1.135    0.257   -0.117
##     Stst31bstrctrs    0.085    0.036    2.355    0.018    0.014
##     Stst34rthcmptt    0.353    0.038    9.222    0.000    0.278
##   math =~                                                      
##     Stest5math        0.234    0.039    6.053    0.000    0.158
##     Stst25wrdfnctn    0.130    0.051    2.523    0.012    0.029
##     Stst32rthrsnng    0.136    0.044    3.107    0.002    0.050
##     Stst33hghschlm    0.318    0.034    9.275    0.000    0.251
##     Stst34rthcmptt    0.302    0.064    4.678    0.000    0.175
##   speed =~                                                     
##     Stst34rthcmptt    0.469    0.025   19.063    0.000    0.421
##     Stest35tblrdng    0.971    0.037   26.415    0.000    0.899
##     Stst36clrclchc    0.831    0.023   36.146    0.000    0.786
##     Stst37bjctnspc    0.703    0.023   30.373    0.000    0.658
##   spatial =~                                                   
##     Stst28mchnclrs    0.145    0.025    5.786    0.000    0.096
##     Stst29vslztn2D    0.401    0.030   13.547    0.000    0.343
##     Stst30vslztn3D    0.381    0.028   13.654    0.000    0.327
##     Stst31bstrctrs    0.344    0.041    8.371    0.000    0.264
##     Stst37bjctnspc    0.246    0.026    9.486    0.000    0.195
##   g =~                                                         
##     Stest1vocab       0.716    0.043   16.678    0.000    0.632
##     Stest5math        0.547    0.020   26.915    0.000    0.507
##     Stst19dsgsdwrd    0.644    0.042   15.438    0.000    0.562
##     Stest20spellng    0.538    0.054    9.952    0.000    0.432
##     Stest21cptlztn    0.688    0.024   28.779    0.000    0.641
##     Stest22puncttn    0.738    0.016   46.613    0.000    0.707
##     Stest23english    0.704    0.027   26.373    0.000    0.651
##     Stest24exprssn    0.553    0.021   26.663    0.000    0.513
##     Stst25wrdfnctn    0.505    0.024   21.118    0.000    0.459
##     Stst26rdngcmpr    0.823    0.040   20.494    0.000    0.744
##     Stst28mchnclrs    0.328    0.017   19.066    0.000    0.295
##     Stst29vslztn2D    0.405    0.023   17.320    0.000    0.359
##     Stst30vslztn3D    0.341    0.024   14.305    0.000    0.295
##     Stst31bstrctrs    0.697    0.026   27.311    0.000    0.647
##     Stst32rthrsnng    0.478    0.023   20.497    0.000    0.432
##     Stst33hghschlm    0.475    0.022   22.020    0.000    0.433
##     Stst34rthcmptt    0.557    0.038   14.777    0.000    0.483
##     Stest35tblrdng    0.605    0.029   20.724    0.000    0.548
##     Stst36clrclchc    0.131    0.028    4.626    0.000    0.075
##     Stst37bjctnspc    0.281    0.021   13.228    0.000    0.240
##  ci.upper   Std.lv  Std.all
##                            
##     0.427    0.122    0.133
##     0.472    0.226    0.241
##     0.636    0.423    0.439
##     0.369    0.292    0.289
##     0.352    0.300    0.304
##     0.421    0.356    0.327
##     0.305    0.235    0.218
##     0.439    0.161    0.166
##     0.156    0.085    0.078
##     0.428    0.353    0.307
##                            
##     0.309    0.234    0.237
##     0.230    0.130    0.163
##     0.221    0.136    0.184
##     0.385    0.318    0.458
##     0.428    0.302    0.262
##                            
##     0.517    0.469    0.408
##     1.043    0.971    0.598
##     0.876    0.831    0.649
##     0.749    0.703    0.614
##                            
##     0.194    0.145    0.236
##     0.459    0.401    0.406
##     0.436    0.381    0.493
##     0.425    0.344    0.314
##     0.296    0.246    0.214
##                            
##     0.800    0.716    0.778
##     0.587    0.547    0.554
##     0.726    0.644    0.685
##     0.644    0.538    0.558
##     0.735    0.688    0.680
##     0.769    0.738    0.749
##     0.756    0.704    0.645
##     0.594    0.553    0.512
##     0.552    0.505    0.634
##     0.901    0.823    0.848
##     0.362    0.328    0.537
##     0.451    0.405    0.410
##     0.388    0.341    0.441
##     0.747    0.697    0.637
##     0.524    0.478    0.648
##     0.517    0.475    0.683
##     0.631    0.557    0.484
##     0.662    0.605    0.372
##     0.186    0.131    0.102
##     0.323    0.281    0.245
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english ~~                                                   
##     math              0.000                               0.000
##     speed             0.000                               0.000
##     spatial           0.000                               0.000
##     g                 0.000                               0.000
##   math ~~                                                      
##     speed             0.000                               0.000
##     spatial           0.000                               0.000
##     g                 0.000                               0.000
##   speed ~~                                                     
##     spatial           0.000                               0.000
##     g                 0.000                               0.000
##   spatial ~~                                                   
##     g                 0.000                               0.000
##  ci.upper   Std.lv  Std.all
##                            
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##                            
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##                            
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##                            
##     0.000    0.000    0.000
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stest1vocab      -1.339    0.016  -83.554    0.000   -1.370
##    .Stst19dsgsdwrd   -0.878    0.016  -54.059    0.000   -0.910
##    .Stest20spellng   -0.450    0.017  -26.686    0.000   -0.483
##    .Stest21cptlztn   -0.899    0.017  -51.477    0.000   -0.934
##    .Stest22puncttn   -0.929    0.017  -53.286    0.000   -0.963
##    .Stest23english   -0.744    0.019  -38.449    0.000   -0.781
##    .Stest24exprssn   -0.704    0.019  -37.099    0.000   -0.742
##    .Stst26rdngcmpr   -1.226    0.017  -72.842    0.000   -1.259
##    .Stst31bstrctrs   -1.260    0.019  -65.843    0.000   -1.297
##    .Stst34rthcmptt   -1.004    0.021  -47.990    0.000   -1.045
##    .Stest5math       -0.965    0.017  -55.615    0.000   -0.999
##    .Stst25wrdfnctn   -0.788    0.014  -57.181    0.000   -0.816
##    .Stst32rthrsnng   -1.184    0.013  -92.849    0.000   -1.209
##    .Stst33hghschlm   -0.942    0.012  -78.389    0.000   -0.966
##    .Stest35tblrdng   -0.524    0.029  -17.830    0.000   -0.582
##    .Stst36clrclchc    0.300    0.023   13.284    0.000    0.256
##    .Stst37bjctnspc   -0.217    0.021  -10.567    0.000   -0.257
##    .Stst28mchnclrs   -1.323    0.011 -124.285    0.000   -1.344
##    .Stst29vslztn2D   -0.916    0.017  -52.801    0.000   -0.950
##    .Stst30vslztn3D   -0.982    0.014  -72.639    0.000   -1.008
##  ci.upper   Std.lv  Std.all
##    -1.307   -1.339   -1.455
##    -0.846   -0.878   -0.935
##    -0.417   -0.450   -0.467
##    -0.865   -0.899   -0.889
##    -0.895   -0.929   -0.942
##    -0.706   -0.744   -0.682
##    -0.667   -0.704   -0.652
##    -1.193   -1.226   -1.265
##    -1.222   -1.260   -1.151
##    -0.963   -1.004   -0.873
##    -0.931   -0.965   -0.978
##    -0.761   -0.788   -0.989
##    -1.159   -1.184   -1.604
##    -0.919   -0.942   -1.356
##    -0.466   -0.524   -0.323
##     0.344    0.300    0.234
##    -0.176   -0.217   -0.189
##    -1.303   -1.323   -2.162
##    -0.882   -0.916   -0.926
##    -0.955   -0.982   -1.270
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stest1vocab       0.319    0.022   14.469    0.000    0.276
##    .Stst19dsgsdwrd    0.417    0.013   31.793    0.000    0.391
##    .Stest20spellng    0.460    0.039   11.864    0.000    0.384
##    .Stest21cptlztn    0.464    0.016   29.074    0.000    0.433
##    .Stest22puncttn    0.338    0.020   16.851    0.000    0.298
##    .Stest23english    0.568    0.025   22.907    0.000    0.519
##    .Stest24exprssn    0.806    0.023   34.996    0.000    0.760
##    .Stst26rdngcmpr    0.237    0.018   12.868    0.000    0.201
##    .Stst31bstrctrs    0.586    0.018   32.188    0.000    0.550
##    .Stst34rthcmptt    0.577    0.041   13.973    0.000    0.496
##    .Stest5math        0.620    0.018   34.941    0.000    0.585
##    .Stst25wrdfnctn    0.364    0.012   29.622    0.000    0.340
##    .Stst32rthrsnng    0.298    0.010   29.348    0.000    0.278
##    .Stst33hghschlm    0.156    0.014   10.800    0.000    0.128
##    .Stest35tblrdng    1.329    0.062   21.406    0.000    1.207
##    .Stst36clrclchc    0.934    0.036   26.253    0.000    0.864
##    .Stst37bjctnspc    0.678    0.029   23.026    0.000    0.621
##    .Stst28mchnclrs    0.246    0.007   37.204    0.000    0.233
##    .Stst29vslztn2D    0.653    0.023   28.712    0.000    0.608
##    .Stst30vslztn3D    0.336    0.015   21.788    0.000    0.305
##     english           1.000                               1.000
##     math              1.000                               1.000
##     speed             1.000                               1.000
##     spatial           1.000                               1.000
##     g                 1.000                               1.000
##  ci.upper   Std.lv  Std.all
##     0.363    0.319    0.377
##     0.443    0.417    0.472
##     0.536    0.460    0.495
##     0.495    0.464    0.454
##     0.377    0.338    0.347
##     0.616    0.568    0.477
##     0.851    0.806    0.690
##     0.274    0.237    0.252
##     0.622    0.586    0.489
##     0.658    0.577    0.436
##     0.654    0.620    0.637
##     0.388    0.364    0.572
##     0.318    0.298    0.547
##     0.184    0.156    0.323
##     1.451    1.329    0.504
##     1.003    0.934    0.569
##     0.736    0.678    0.517
##     0.259    0.246    0.656
##     0.697    0.653    0.668
##     0.366    0.336    0.562
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
chc.bifactor.model <-'
english =~ Stest19disguisedwords + Stest20spelling + Stest21capitalization + Stest22punctuation + Stest23english + Stest24expression + Stest31abstractreasoning + Stest34arithcomputation
math =~ Stest5math + Stest25wordfunctions + Stest32arithreasoning + Stest33highschoolmath + Stest34arithcomputation
speed =~ Stest34arithcomputation + Stest35tablereading + Stest36clericalchecking + Stest37objectinspection
spatial =~ Stest28mechanicalreasoning + Stest29visualization2D + Stest30visualization3D + Stest31abstractreasoning + Stest37objectinspection
g=~ Stest1vocab + Stest5math + Stest19disguisedwords + Stest20spelling + Stest21capitalization + Stest22punctuation + Stest23english + Stest24expression + Stest25wordfunctions + Stest26readingcomprehension + Stest28mechanicalreasoning + Stest29visualization2D + Stest30visualization3D + Stest31abstractreasoning + Stest32arithreasoning + Stest33highschoolmath + Stest34arithcomputation + Stest35tablereading + Stest36clericalchecking + Stest37objectinspection
'

baseline<-cfa(chc.bifactor.model, data=dgroup, meanstructure=TRUE, sampling.weights="BY_WTA", std.lv=T, orthogonal=T)
fitMeasures(baseline, c("chisq", "df", "pvalue", "cfi", "rmsea", "srmr", "aic", "bic"))
##      chisq         df     pvalue        cfi      rmsea       srmr 
##   2554.784    148.000      0.000      0.958      0.052      0.034 
##        aic        bic 
## 293688.788 294239.301
Mc(baseline)
## [1] 0.820537
configural<-cfa(chc.bifactor.model, data=dgroup, group="sex", meanstructure=TRUE, sampling.weights="BY_WTA", std.lv=T, orthogonal=T)
fitMeasures(configural, c("chisq", "df", "pvalue", "cfi", "rmsea", "srmr", "aic", "bic"))
##      chisq         df     pvalue        cfi      rmsea       srmr 
##   2389.613    296.000      0.000      0.963      0.048      0.031 
##        aic        bic 
## 290363.343 291464.371
Mc(configural)
## [1] 0.8419296
summary(configural, standardized=T, ci=T)
## lavaan 0.6-18 ended normally after 39 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                       164
## 
##   Number of observations per group:                   
##     0                                             2443
##     1                                             3642
##   Sampling weights variable                     BY_WTA
## 
## Model Test User Model:
##                                               Standard      Scaled
##   Test Statistic                              2389.613    2133.878
##   Degrees of freedom                               296         296
##   P-value (Chi-square)                           0.000       0.000
##   Scaling correction factor                                  1.120
##     Yuan-Bentler correction (Mplus variant)                       
##   Test statistic for each group:
##     0                                          997.884     891.091
##     1                                         1391.729    1242.787
## 
## Parameter Estimates:
## 
##   Standard errors                             Sandwich
##   Information bread                           Observed
##   Observed information based on                Hessian
## 
## 
## Group 1 [0]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english =~                                                   
##     Stst19dsgsdwrd    0.105    0.029    3.662    0.000    0.049
##     Stest20spellng    0.337    0.035    9.705    0.000    0.269
##     Stest21cptlztn    0.275    0.024   11.566    0.000    0.228
##     Stest22puncttn    0.316    0.026   12.288    0.000    0.266
##     Stest23english    0.295    0.034    8.616    0.000    0.228
##     Stest24exprssn    0.198    0.035    5.598    0.000    0.129
##     Stst31bstrctrs    0.111    0.033    3.378    0.001    0.047
##     Stst34rthcmptt    0.263    0.034    7.642    0.000    0.196
##   math =~                                                      
##     Stest5math        0.230    0.023    9.906    0.000    0.184
##     Stst25wrdfnctn    0.133    0.022    6.126    0.000    0.091
##     Stst32rthrsnng    0.212    0.022    9.661    0.000    0.169
##     Stst33hghschlm    0.372    0.028   13.335    0.000    0.317
##     Stst34rthcmptt    0.249    0.030    8.429    0.000    0.191
##   speed =~                                                     
##     Stst34rthcmptt    0.447    0.028   15.726    0.000    0.392
##     Stest35tblrdng    0.955    0.043   22.422    0.000    0.872
##     Stst36clrclchc    0.867    0.029   30.258    0.000    0.811
##     Stst37bjctnspc    0.735    0.029   25.250    0.000    0.678
##   spatial =~                                                   
##     Stst28mchnclrs    0.384    0.019   19.846    0.000    0.346
##     Stst29vslztn2D    0.468    0.028   16.523    0.000    0.412
##     Stst30vslztn3D    0.508    0.024   21.532    0.000    0.462
##     Stst31bstrctrs    0.439    0.024   18.261    0.000    0.392
##     Stst37bjctnspc    0.318    0.028   11.291    0.000    0.262
##   g =~                                                         
##     Stest1vocab       0.901    0.017   53.764    0.000    0.868
##     Stest5math        0.692    0.019   36.114    0.000    0.654
##     Stst19dsgsdwrd    0.602    0.018   32.832    0.000    0.566
##     Stest20spellng    0.609    0.020   31.116    0.000    0.570
##     Stest21cptlztn    0.661    0.017   39.468    0.000    0.628
##     Stest22puncttn    0.742    0.018   40.297    0.000    0.706
##     Stest23english    0.829    0.021   38.964    0.000    0.787
##     Stest24exprssn    0.680    0.021   31.981    0.000    0.638
##     Stst25wrdfnctn    0.447    0.018   25.291    0.000    0.413
##     Stst26rdngcmpr    0.965    0.016   59.769    0.000    0.934
##     Stst28mchnclrs    0.568    0.018   30.997    0.000    0.533
##     Stst29vslztn2D    0.475    0.021   22.340    0.000    0.434
##     Stst30vslztn3D    0.452    0.020   23.031    0.000    0.414
##     Stst31bstrctrs    0.722    0.020   35.802    0.000    0.682
##     Stst32rthrsnng    0.590    0.018   33.510    0.000    0.556
##     Stst33hghschlm    0.562    0.017   32.309    0.000    0.528
##     Stst34rthcmptt    0.632    0.022   28.334    0.000    0.588
##     Stest35tblrdng    0.597    0.032   18.846    0.000    0.535
##     Stst36clrclchc    0.172    0.028    6.243    0.000    0.118
##     Stst37bjctnspc    0.250    0.026    9.526    0.000    0.199
##  ci.upper   Std.lv  Std.all
##                            
##     0.161    0.105    0.120
##     0.405    0.337    0.338
##     0.321    0.275    0.291
##     0.367    0.316    0.317
##     0.362    0.295    0.248
##     0.267    0.198    0.170
##     0.175    0.111    0.097
##     0.331    0.263    0.230
##                            
##     0.275    0.230    0.220
##     0.176    0.133    0.171
##     0.255    0.212    0.253
##     0.427    0.372    0.474
##     0.307    0.249    0.218
##                            
##     0.503    0.447    0.392
##     1.039    0.955    0.573
##     0.923    0.867    0.669
##     0.792    0.735    0.597
##                            
##     0.422    0.384    0.427
##     0.523    0.468    0.429
##     0.554    0.508    0.536
##     0.486    0.439    0.384
##     0.373    0.318    0.258
##                            
##     0.934    0.901    0.845
##     0.729    0.692    0.660
##     0.638    0.602    0.690
##     0.647    0.609    0.611
##     0.694    0.661    0.700
##     0.778    0.742    0.744
##     0.871    0.829    0.697
##     0.721    0.680    0.584
##     0.482    0.447    0.575
##     0.997    0.965    0.898
##     0.604    0.568    0.632
##     0.517    0.475    0.436
##     0.491    0.452    0.477
##     0.761    0.722    0.632
##     0.625    0.590    0.703
##     0.596    0.562    0.715
##     0.676    0.632    0.553
##     0.659    0.597    0.358
##     0.227    0.172    0.133
##     0.302    0.250    0.203
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english ~~                                                   
##     math              0.000                               0.000
##     speed             0.000                               0.000
##     spatial           0.000                               0.000
##     g                 0.000                               0.000
##   math ~~                                                      
##     speed             0.000                               0.000
##     spatial           0.000                               0.000
##     g                 0.000                               0.000
##   speed ~~                                                     
##     spatial           0.000                               0.000
##     g                 0.000                               0.000
##   spatial ~~                                                   
##     g                 0.000                               0.000
##  ci.upper   Std.lv  Std.all
##                            
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##                            
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##                            
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##                            
##     0.000    0.000    0.000
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stst19dsgsdwrd   -0.992    0.018  -53.776    0.000   -1.028
##    .Stest20spellng   -0.848    0.021  -39.900    0.000   -0.890
##    .Stest21cptlztn   -1.167    0.020  -58.007    0.000   -1.206
##    .Stest22puncttn   -1.226    0.021  -57.496    0.000   -1.268
##    .Stest23english   -1.062    0.026  -41.362    0.000   -1.113
##    .Stest24exprssn   -0.965    0.025  -38.928    0.000   -1.014
##    .Stst31bstrctrs   -1.070    0.024  -43.766    0.000   -1.118
##    .Stst34rthcmptt   -1.153    0.025  -46.702    0.000   -1.201
##    .Stest5math       -0.814    0.022  -36.442    0.000   -0.857
##    .Stst25wrdfnctn   -0.871    0.017  -52.726    0.000   -0.903
##    .Stst32rthrsnng   -1.052    0.018  -59.194    0.000   -1.087
##    .Stst33hghschlm   -0.875    0.016  -53.483    0.000   -0.907
##    .Stest35tblrdng   -0.712    0.037  -19.463    0.000   -0.784
##    .Stst36clrclchc   -0.032    0.028   -1.139    0.255   -0.086
##    .Stst37bjctnspc   -0.318    0.027  -11.957    0.000   -0.370
##    .Stst28mchnclrs   -0.715    0.019  -36.895    0.000   -0.753
##    .Stst29vslztn2D   -0.512    0.023  -22.047    0.000   -0.557
##    .Stst30vslztn3D   -0.723    0.020  -35.874    0.000   -0.762
##    .Stest1vocab      -1.155    0.023  -50.360    0.000   -1.200
##    .Stst26rdngcmpr   -1.292    0.023  -56.802    0.000   -1.337
##  ci.upper   Std.lv  Std.all
##    -0.956   -0.992   -1.136
##    -0.806   -0.848   -0.851
##    -1.128   -1.167   -1.236
##    -1.184   -1.226   -1.229
##    -1.012   -1.062   -0.893
##    -0.916   -0.965   -0.829
##    -1.022   -1.070   -0.937
##    -1.104   -1.153   -1.009
##    -0.770   -0.814   -0.777
##    -0.838   -0.871   -1.119
##    -1.017   -1.052   -1.253
##    -0.843   -0.875   -1.115
##    -0.640   -0.712   -0.427
##     0.023   -0.032   -0.025
##    -0.266   -0.318   -0.258
##    -0.677   -0.715   -0.795
##    -0.466   -0.512   -0.469
##    -0.683   -0.723   -0.763
##    -1.110   -1.155   -1.083
##    -1.248   -1.292   -1.202
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stst19dsgsdwrd    0.389    0.014   27.514    0.000    0.361
##    .Stest20spellng    0.510    0.022   23.302    0.000    0.467
##    .Stest21cptlztn    0.379    0.015   24.488    0.000    0.348
##    .Stest22puncttn    0.345    0.015   22.714    0.000    0.315
##    .Stest23english    0.640    0.025   26.078    0.000    0.592
##    .Stest24exprssn    0.854    0.026   32.820    0.000    0.803
##    .Stst31bstrctrs    0.578    0.023   25.282    0.000    0.533
##    .Stst34rthcmptt    0.573    0.030   19.412    0.000    0.516
##    .Stest5math        0.566    0.021   27.318    0.000    0.525
##    .Stst25wrdfnctn    0.388    0.012   32.327    0.000    0.364
##    .Stst32rthrsnng    0.312    0.011   27.446    0.000    0.289
##    .Stst33hghschlm    0.163    0.018    8.858    0.000    0.127
##    .Stest35tblrdng    1.514    0.074   20.455    0.000    1.369
##    .Stst36clrclchc    0.897    0.046   19.519    0.000    0.807
##    .Stst37bjctnspc    0.814    0.038   21.293    0.000    0.739
##    .Stst28mchnclrs    0.338    0.015   22.172    0.000    0.308
##    .Stst29vslztn2D    0.745    0.029   26.102    0.000    0.689
##    .Stst30vslztn3D    0.436    0.021   21.046    0.000    0.395
##    .Stest1vocab       0.325    0.013   25.300    0.000    0.300
##    .Stst26rdngcmpr    0.224    0.011   20.206    0.000    0.202
##     english           1.000                               1.000
##     math              1.000                               1.000
##     speed             1.000                               1.000
##     spatial           1.000                               1.000
##     g                 1.000                               1.000
##  ci.upper   Std.lv  Std.all
##     0.416    0.389    0.510
##     0.552    0.510    0.513
##     0.409    0.379    0.425
##     0.375    0.345    0.347
##     0.689    0.640    0.453
##     0.905    0.854    0.630
##     0.623    0.578    0.443
##     0.631    0.573    0.440
##     0.606    0.566    0.516
##     0.411    0.388    0.640
##     0.334    0.312    0.442
##     0.199    0.163    0.264
##     1.659    1.514    0.544
##     0.987    0.897    0.534
##     0.889    0.814    0.536
##     0.368    0.338    0.418
##     0.800    0.745    0.626
##     0.477    0.436    0.485
##     0.350    0.325    0.286
##     0.246    0.224    0.194
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
## 
## 
## Group 2 [1]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english =~                                                   
##     Stst19dsgsdwrd    0.099    0.027    3.672    0.000    0.046
##     Stest20spellng    0.286    0.034    8.288    0.000    0.218
##     Stest21cptlztn    0.248    0.023   10.975    0.000    0.203
##     Stest22puncttn    0.304    0.026   11.868    0.000    0.254
##     Stest23english    0.316    0.028   11.108    0.000    0.260
##     Stest24exprssn    0.211    0.035    6.065    0.000    0.143
##     Stst31bstrctrs    0.097    0.032    3.016    0.003    0.034
##     Stst34rthcmptt    0.276    0.038    7.330    0.000    0.202
##   math =~                                                      
##     Stest5math        0.267    0.024   11.341    0.000    0.221
##     Stst25wrdfnctn    0.173    0.025    6.929    0.000    0.124
##     Stst32rthrsnng    0.172    0.021    8.231    0.000    0.131
##     Stst33hghschlm    0.336    0.024   13.947    0.000    0.289
##     Stst34rthcmptt    0.228    0.027    8.481    0.000    0.176
##   speed =~                                                     
##     Stst34rthcmptt    0.467    0.025   18.870    0.000    0.418
##     Stest35tblrdng    0.959    0.034   27.973    0.000    0.892
##     Stst36clrclchc    0.834    0.023   36.430    0.000    0.790
##     Stst37bjctnspc    0.704    0.023   30.466    0.000    0.659
##   spatial =~                                                   
##     Stst28mchnclrs    0.165    0.013   12.237    0.000    0.139
##     Stst29vslztn2D    0.413    0.025   16.638    0.000    0.365
##     Stst30vslztn3D    0.396    0.020   19.358    0.000    0.356
##     Stst31bstrctrs    0.370    0.022   16.614    0.000    0.326
##     Stst37bjctnspc    0.253    0.024   10.531    0.000    0.206
##   g =~                                                         
##     Stest1vocab       0.738    0.014   53.399    0.000    0.711
##     Stest5math        0.532    0.017   31.693    0.000    0.499
##     Stst19dsgsdwrd    0.674    0.015   45.340    0.000    0.645
##     Stest20spellng    0.589    0.016   37.977    0.000    0.559
##     Stest21cptlztn    0.710    0.015   48.882    0.000    0.681
##     Stest22puncttn    0.752    0.014   51.955    0.000    0.724
##     Stest23english    0.731    0.016   44.645    0.000    0.699
##     Stest24exprssn    0.569    0.017   33.094    0.000    0.535
##     Stst25wrdfnctn    0.488    0.015   33.321    0.000    0.460
##     Stst26rdngcmpr    0.854    0.012   68.557    0.000    0.830
##     Stst28mchnclrs    0.316    0.012   26.650    0.000    0.293
##     Stst29vslztn2D    0.390    0.017   22.948    0.000    0.357
##     Stst30vslztn3D    0.325    0.014   22.653    0.000    0.297
##     Stst31bstrctrs    0.682    0.016   41.905    0.000    0.651
##     Stst32rthrsnng    0.461    0.015   31.544    0.000    0.433
##     Stst33hghschlm    0.460    0.013   34.670    0.000    0.434
##     Stst34rthcmptt    0.599    0.019   31.088    0.000    0.562
##     Stest35tblrdng    0.609    0.027   22.682    0.000    0.557
##     Stst36clrclchc    0.139    0.023    6.178    0.000    0.095
##     Stst37bjctnspc    0.280    0.021   13.400    0.000    0.239
##  ci.upper   Std.lv  Std.all
##                            
##     0.152    0.099    0.106
##     0.353    0.286    0.296
##     0.292    0.248    0.245
##     0.355    0.304    0.309
##     0.371    0.316    0.289
##     0.280    0.211    0.196
##     0.160    0.097    0.089
##     0.350    0.276    0.239
##                            
##     0.313    0.267    0.271
##     0.222    0.173    0.217
##     0.213    0.172    0.233
##     0.383    0.336    0.484
##     0.281    0.228    0.198
##                            
##     0.516    0.467    0.404
##     1.026    0.959    0.590
##     0.879    0.834    0.651
##     0.750    0.704    0.614
##                            
##     0.192    0.165    0.270
##     0.462    0.413    0.418
##     0.436    0.396    0.512
##     0.414    0.370    0.338
##     0.300    0.253    0.220
##                            
##     0.765    0.738    0.803
##     0.565    0.532    0.539
##     0.703    0.674    0.717
##     0.619    0.589    0.611
##     0.738    0.710    0.702
##     0.781    0.752    0.763
##     0.763    0.731    0.670
##     0.602    0.569    0.527
##     0.517    0.488    0.612
##     0.878    0.854    0.881
##     0.339    0.316    0.516
##     0.424    0.390    0.395
##     0.353    0.325    0.421
##     0.714    0.682    0.624
##     0.490    0.461    0.625
##     0.486    0.460    0.663
##     0.637    0.599    0.519
##     0.662    0.609    0.375
##     0.183    0.139    0.109
##     0.321    0.280    0.244
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english ~~                                                   
##     math              0.000                               0.000
##     speed             0.000                               0.000
##     spatial           0.000                               0.000
##     g                 0.000                               0.000
##   math ~~                                                      
##     speed             0.000                               0.000
##     spatial           0.000                               0.000
##     g                 0.000                               0.000
##   speed ~~                                                     
##     spatial           0.000                               0.000
##     g                 0.000                               0.000
##   spatial ~~                                                   
##     g                 0.000                               0.000
##  ci.upper   Std.lv  Std.all
##                            
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##                            
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##                            
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##                            
##     0.000    0.000    0.000
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stst19dsgsdwrd   -0.878    0.016  -54.059    0.000   -0.910
##    .Stest20spellng   -0.450    0.017  -26.686    0.000   -0.483
##    .Stest21cptlztn   -0.899    0.017  -51.477    0.000   -0.934
##    .Stest22puncttn   -0.929    0.017  -53.286    0.000   -0.963
##    .Stest23english   -0.744    0.019  -38.449    0.000   -0.781
##    .Stest24exprssn   -0.704    0.019  -37.099    0.000   -0.742
##    .Stst31bstrctrs   -1.260    0.019  -65.843    0.000   -1.297
##    .Stst34rthcmptt   -1.004    0.021  -47.990    0.000   -1.045
##    .Stest5math       -0.965    0.017  -55.615    0.000   -0.999
##    .Stst25wrdfnctn   -0.788    0.014  -57.181    0.000   -0.816
##    .Stst32rthrsnng   -1.184    0.013  -92.849    0.000   -1.209
##    .Stst33hghschlm   -0.942    0.012  -78.389    0.000   -0.966
##    .Stest35tblrdng   -0.524    0.029  -17.830    0.000   -0.582
##    .Stst36clrclchc    0.300    0.023   13.284    0.000    0.256
##    .Stst37bjctnspc   -0.217    0.021  -10.567    0.000   -0.257
##    .Stst28mchnclrs   -1.323    0.011 -124.285    0.000   -1.344
##    .Stst29vslztn2D   -0.916    0.017  -52.801    0.000   -0.950
##    .Stst30vslztn3D   -0.982    0.014  -72.639    0.000   -1.008
##    .Stest1vocab      -1.339    0.016  -83.554    0.000   -1.370
##    .Stst26rdngcmpr   -1.226    0.017  -72.842    0.000   -1.259
##  ci.upper   Std.lv  Std.all
##    -0.846   -0.878   -0.935
##    -0.417   -0.450   -0.467
##    -0.865   -0.899   -0.889
##    -0.895   -0.929   -0.942
##    -0.706   -0.744   -0.682
##    -0.667   -0.704   -0.652
##    -1.222   -1.260   -1.152
##    -0.963   -1.004   -0.869
##    -0.931   -0.965   -0.978
##    -0.761   -0.788   -0.989
##    -1.159   -1.184   -1.604
##    -0.919   -0.942   -1.356
##    -0.466   -0.524   -0.323
##     0.344    0.300    0.234
##    -0.176   -0.217   -0.189
##    -1.303   -1.323   -2.162
##    -0.882   -0.916   -0.926
##    -0.955   -0.982   -1.270
##    -1.307   -1.339   -1.455
##    -1.193   -1.226   -1.265
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stst19dsgsdwrd    0.419    0.012   34.963    0.000    0.395
##    .Stest20spellng    0.500    0.018   27.637    0.000    0.464
##    .Stest21cptlztn    0.458    0.014   32.202    0.000    0.430
##    .Stest22puncttn    0.313    0.014   22.435    0.000    0.286
##    .Stest23english    0.556    0.019   29.983    0.000    0.520
##    .Stest24exprssn    0.799    0.022   36.043    0.000    0.755
##    .Stst31bstrctrs    0.584    0.018   31.858    0.000    0.548
##    .Stst34rthcmptt    0.627    0.031   20.548    0.000    0.567
##    .Stest5math        0.619    0.018   34.402    0.000    0.584
##    .Stst25wrdfnctn    0.368    0.011   32.666    0.000    0.346
##    .Stst32rthrsnng    0.302    0.009   33.488    0.000    0.285
##    .Stst33hghschlm    0.158    0.016   10.142    0.000    0.127
##    .Stest35tblrdng    1.346    0.060   22.328    0.000    1.228
##    .Stst36clrclchc    0.926    0.035   26.369    0.000    0.857
##    .Stst37bjctnspc    0.676    0.029   22.975    0.000    0.618
##    .Stst28mchnclrs    0.248    0.007   37.617    0.000    0.235
##    .Stst29vslztn2D    0.654    0.022   29.492    0.000    0.611
##    .Stst30vslztn3D    0.335    0.015   22.649    0.000    0.306
##    .Stest1vocab       0.301    0.010   31.643    0.000    0.283
##    .Stst26rdngcmpr    0.211    0.008   25.505    0.000    0.195
##     english           1.000                               1.000
##     math              1.000                               1.000
##     speed             1.000                               1.000
##     spatial           1.000                               1.000
##     g                 1.000                               1.000
##  ci.upper   Std.lv  Std.all
##     0.442    0.419    0.474
##     0.535    0.500    0.538
##     0.486    0.458    0.448
##     0.340    0.313    0.322
##     0.592    0.556    0.467
##     0.842    0.799    0.684
##     0.620    0.584    0.488
##     0.687    0.627    0.471
##     0.654    0.619    0.636
##     0.390    0.368    0.578
##     0.320    0.302    0.555
##     0.188    0.158    0.327
##     1.464    1.346    0.511
##     0.995    0.926    0.564
##     0.733    0.676    0.514
##     0.261    0.248    0.661
##     0.698    0.654    0.669
##     0.364    0.335    0.561
##     0.320    0.301    0.356
##     0.227    0.211    0.224
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
modificationIndices(configural, sort=T, maximum.number=30)
##                       lhs op                         rhs block group
## 480                 speed =~       Stest19disguisedwords     2     2
## 523 Stest19disguisedwords ~~     Stest36clericalchecking     2     2
## 497               spatial =~             Stest20spelling     2     2
## 249               spatial =~             Stest20spelling     1     1
## 232                 speed =~       Stest19disguisedwords     1     1
## 244                 speed =~      Stest29visualization2D     1     1
## 175                  math ~~                     spatial     2     2
## 275 Stest19disguisedwords ~~     Stest36clericalchecking     1     1
## 396            Stest5math ~~                 Stest1vocab     1     1
## 468                  math =~          Stest22punctuation     2     2
## 492                 speed =~      Stest29visualization2D     2     2
## 700           Stest1vocab ~~ Stest26readingcomprehension     2     2
## 646  Stest25wordfunctions ~~       Stest32arithreasoning     2     2
## 509               spatial =~                 Stest1vocab     2     2
## 644            Stest5math ~~                 Stest1vocab     2     2
## 581        Stest23english ~~           Stest24expression     2     2
## 73                   math ~~                     spatial     1     1
## 511 Stest19disguisedwords ~~             Stest20spelling     2     2
## 259               spatial =~         Stest35tablereading     1     1
## 499               spatial =~          Stest22punctuation     2     2
## 263 Stest19disguisedwords ~~             Stest20spelling     1     1
## 505               spatial =~       Stest32arithreasoning     2     2
## 534       Stest20spelling ~~    Stest31abstractreasoning     2     2
## 247                 speed =~ Stest26readingcomprehension     1     1
## 506               spatial =~       Stest33highschoolmath     2     2
## 579    Stest22punctuation ~~                 Stest1vocab     2     2
## 535       Stest20spelling ~~     Stest34arithcomputation     2     2
## 262               spatial =~ Stest26readingcomprehension     1     1
## 452           Stest1vocab ~~ Stest26readingcomprehension     1     1
## 223                  math =~    Stest31abstractreasoning     1     1
##     level      mi    epc sepc.lv sepc.all sepc.nox
## 480     1 242.532  0.207   0.207    0.220    0.220
## 523     1 166.962  0.157   0.157    0.252    0.252
## 497     1 162.921 -0.224  -0.224   -0.232   -0.232
## 249     1 118.508 -0.219  -0.219   -0.219   -0.219
## 232     1  99.392  0.155   0.155    0.177    0.177
## 244     1  91.965  0.213   0.213    0.196    0.196
## 175     1  66.437  0.287   0.287    0.287    0.287
## 275     1  65.187  0.115   0.115    0.194    0.194
## 396     1  60.989  0.080   0.080    0.188    0.188
## 468     1  59.176  0.122   0.122    0.124    0.124
## 492     1  57.427  0.131   0.131    0.132    0.132
## 700     1  57.271  0.050   0.050    0.199    0.199
## 646     1  51.434  0.047   0.047    0.140    0.140
## 509     1  48.675 -0.100  -0.100   -0.109   -0.109
## 644     1  45.633  0.056   0.056    0.129    0.129
## 581     1  43.926  0.086   0.086    0.129    0.129
## 73      1  42.037  0.251   0.251    0.251    0.251
## 511     1  40.721  0.056   0.056    0.122    0.122
## 259     1  38.023  0.228   0.228    0.137    0.137
## 499     1  37.800  0.091   0.091    0.092    0.092
## 263     1  34.346  0.062   0.062    0.140    0.140
## 505     1  32.489  0.077   0.077    0.104    0.104
## 534     1  31.920 -0.060  -0.060   -0.111   -0.111
## 247     1  31.736 -0.078  -0.078   -0.073   -0.073
## 506     1  31.562  0.066   0.066    0.095    0.095
## 579     1  30.772 -0.036  -0.036   -0.117   -0.117
## 535     1  30.759  0.069   0.069    0.123    0.123
## 262     1  29.311 -0.086  -0.086   -0.080   -0.080
## 452     1  29.059  0.049   0.049    0.181    0.181
## 223     1  28.611  0.131   0.131    0.115    0.115
metric<-cfa(chc.bifactor.model, data=dgroup, group="sex", meanstructure=TRUE, sampling.weights="BY_WTA", std.lv=T, orthogonal=T, group.equal=c("loadings"))
fitMeasures(metric, c("chisq", "df", "pvalue", "cfi", "rmsea", "srmr", "aic", "bic"))
##      chisq         df     pvalue        cfi      rmsea       srmr 
##   2865.137    333.000      0.000      0.955      0.050      0.050 
##        aic        bic 
## 290764.868 291617.493
Mc(metric)
## [1] 0.8121274
summary(metric, standardized=T, ci=T)
## lavaan 0.6-18 ended normally after 80 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                       169
##   Number of equality constraints                    42
## 
##   Number of observations per group:                   
##     0                                             2443
##     1                                             3642
##   Sampling weights variable                     BY_WTA
## 
## Model Test User Model:
##                                               Standard      Scaled
##   Test Statistic                              2865.137    2542.778
##   Degrees of freedom                               333         333
##   P-value (Chi-square)                           0.000       0.000
##   Scaling correction factor                                  1.127
##     Yuan-Bentler correction (Mplus variant)                       
##   Test statistic for each group:
##     0                                         1263.735    1121.551
##     1                                         1601.402    1421.227
## 
## Parameter Estimates:
## 
##   Standard errors                             Sandwich
##   Information bread                           Observed
##   Observed information based on                Hessian
## 
## 
## Group 1 [0]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english =~                                                   
##     Stst19d (.p1.)    0.113    0.018    6.214    0.000    0.077
##     Stst20s (.p2.)    0.298    0.026   11.541    0.000    0.248
##     Stst21c (.p3.)    0.264    0.018   14.779    0.000    0.229
##     Stst22p (.p4.)    0.307    0.020   15.243    0.000    0.267
##     Stst23n (.p5.)    0.294    0.023   12.612    0.000    0.248
##     Stst24x (.p6.)    0.194    0.024    8.258    0.000    0.148
##     Stst31b (.p7.)    0.108    0.021    5.108    0.000    0.067
##     Stst34r (.p8.)    0.267    0.026   10.403    0.000    0.216
##   math =~                                                      
##     Stst5mt (.p9.)    0.259    0.018   14.510    0.000    0.224
##     Stst25w (.10.)    0.155    0.016    9.448    0.000    0.123
##     Stst32r (.11.)    0.194    0.017   11.282    0.000    0.161
##     Stst33h (.12.)    0.372    0.023   16.497    0.000    0.328
##     Stst34r (.13.)    0.250    0.021   11.837    0.000    0.209
##   speed =~                                                     
##     Stst34r (.14.)    0.461    0.020   22.919    0.000    0.422
##     Stst35t (.15.)    0.968    0.032   30.721    0.000    0.906
##     Stst36c (.16.)    0.853    0.024   35.174    0.000    0.805
##     Stst37b (.17.)    0.722    0.023   31.616    0.000    0.677
##   spatial =~                                                   
##     Stst28m (.18.)    0.311    0.019   16.767    0.000    0.274
##     Sts292D (.19.)    0.508    0.022   22.745    0.000    0.464
##     Sts303D (.20.)    0.530    0.020   25.966    0.000    0.490
##     Stst31b (.21.)    0.466    0.020   23.718    0.000    0.427
##     Stst37b (.22.)    0.326    0.022   14.745    0.000    0.283
##   g =~                                                         
##     Stst1vc (.23.)    0.861    0.016   54.710    0.000    0.830
##     Stst5mt (.24.)    0.644    0.016   41.322    0.000    0.613
##     Stst19d (.25.)    0.681    0.014   47.799    0.000    0.653
##     Stst20s (.26.)    0.637    0.015   43.045    0.000    0.608
##     Stst21c (.27.)    0.728    0.014   53.144    0.000    0.701
##     Stst22p (.28.)    0.798    0.015   53.871    0.000    0.769
##     Stst23n (.29.)    0.823    0.017   47.994    0.000    0.789
##     Stst24x (.30.)    0.657    0.017   39.318    0.000    0.624
##     Stst25w (.31.)    0.504    0.013   38.673    0.000    0.478
##     Stst26r (.32.)    0.965    0.016   61.691    0.000    0.934
##     Stst28m (.33.)    0.427    0.013   32.594    0.000    0.401
##     Sts292D (.34.)    0.449    0.015   29.907    0.000    0.420
##     Sts303D (.35.)    0.396    0.014   28.987    0.000    0.369
##     Stst31b (.36.)    0.738    0.016   47.029    0.000    0.707
##     Stst32r (.37.)    0.551    0.014   39.746    0.000    0.524
##     Stst33h (.38.)    0.538    0.013   40.998    0.000    0.512
##     Stst34r (.39.)    0.652    0.017   38.308    0.000    0.618
##     Stst35t (.40.)    0.644    0.023   28.129    0.000    0.599
##     Stst36c (.41.)    0.163    0.019    8.657    0.000    0.126
##     Stst37b (.42.)    0.282    0.018   15.945    0.000    0.248
##  ci.upper   Std.lv  Std.all
##                            
##     0.149    0.113    0.122
##     0.349    0.298    0.296
##     0.299    0.264    0.267
##     0.346    0.307    0.296
##     0.340    0.294    0.248
##     0.240    0.194    0.169
##     0.150    0.108    0.094
##     0.317    0.267    0.231
##                            
##     0.294    0.259    0.253
##     0.187    0.155    0.190
##     0.228    0.194    0.239
##     0.417    0.372    0.484
##     0.292    0.250    0.217
##                            
##     0.501    0.461    0.399
##     1.030    0.968    0.573
##     0.900    0.853    0.661
##     0.767    0.722    0.583
##                            
##     0.347    0.311    0.380
##     0.551    0.508    0.466
##     0.570    0.530    0.570
##     0.504    0.466    0.403
##     0.370    0.326    0.264
##                            
##     0.892    0.861    0.829
##     0.674    0.644    0.629
##     0.709    0.681    0.732
##     0.666    0.637    0.632
##     0.755    0.728    0.736
##     0.827    0.798    0.769
##     0.857    0.823    0.694
##     0.690    0.657    0.570
##     0.529    0.504    0.618
##     0.995    0.965    0.898
##     0.452    0.427    0.522
##     0.479    0.449    0.412
##     0.423    0.396    0.426
##     0.768    0.738    0.637
##     0.579    0.551    0.679
##     0.563    0.538    0.698
##     0.685    0.652    0.563
##     0.689    0.644    0.381
##     0.200    0.163    0.126
##     0.317    0.282    0.228
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english ~~                                                   
##     math              0.000                               0.000
##     speed             0.000                               0.000
##     spatial           0.000                               0.000
##     g                 0.000                               0.000
##   math ~~                                                      
##     speed             0.000                               0.000
##     spatial           0.000                               0.000
##     g                 0.000                               0.000
##   speed ~~                                                     
##     spatial           0.000                               0.000
##     g                 0.000                               0.000
##   spatial ~~                                                   
##     g                 0.000                               0.000
##  ci.upper   Std.lv  Std.all
##                            
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##                            
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##                            
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##                            
##     0.000    0.000    0.000
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stst19dsgsdwrd   -0.992    0.018  -53.776    0.000   -1.028
##    .Stest20spellng   -0.848    0.021  -39.900    0.000   -0.890
##    .Stest21cptlztn   -1.167    0.020  -58.007    0.000   -1.206
##    .Stest22puncttn   -1.226    0.021  -57.496    0.000   -1.268
##    .Stest23english   -1.062    0.026  -41.362    0.000   -1.113
##    .Stest24exprssn   -0.965    0.025  -38.928    0.000   -1.014
##    .Stst31bstrctrs   -1.070    0.024  -43.766    0.000   -1.118
##    .Stst34rthcmptt   -1.153    0.025  -46.702    0.000   -1.201
##    .Stest5math       -0.814    0.022  -36.442    0.000   -0.857
##    .Stst25wrdfnctn   -0.871    0.017  -52.726    0.000   -0.903
##    .Stst32rthrsnng   -1.052    0.018  -59.194    0.000   -1.087
##    .Stst33hghschlm   -0.875    0.016  -53.483    0.000   -0.907
##    .Stest35tblrdng   -0.712    0.037  -19.463    0.000   -0.784
##    .Stst36clrclchc   -0.032    0.028   -1.139    0.255   -0.086
##    .Stst37bjctnspc   -0.318    0.027  -11.957    0.000   -0.370
##    .Stst28mchnclrs   -0.715    0.019  -36.895    0.000   -0.753
##    .Stst29vslztn2D   -0.512    0.023  -22.047    0.000   -0.557
##    .Stst30vslztn3D   -0.723    0.020  -35.874    0.000   -0.762
##    .Stest1vocab      -1.155    0.023  -50.360    0.000   -1.200
##    .Stst26rdngcmpr   -1.292    0.023  -56.802    0.000   -1.337
##  ci.upper   Std.lv  Std.all
##    -0.956   -0.992   -1.067
##    -0.806   -0.848   -0.842
##    -1.128   -1.167   -1.180
##    -1.184   -1.226   -1.183
##    -1.012   -1.062   -0.896
##    -0.916   -0.965   -0.838
##    -1.022   -1.070   -0.925
##    -1.104   -1.153   -0.997
##    -0.770   -0.814   -0.795
##    -0.838   -0.871   -1.069
##    -1.017   -1.052   -1.295
##    -0.843   -0.875   -1.137
##    -0.640   -0.712   -0.422
##     0.023   -0.032   -0.025
##    -0.266   -0.318   -0.257
##    -0.677   -0.715   -0.875
##    -0.466   -0.512   -0.470
##    -0.683   -0.723   -0.778
##    -1.110   -1.155   -1.112
##    -1.248   -1.292   -1.204
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stst19dsgsdwrd    0.388    0.014   27.264    0.000    0.360
##    .Stest20spellng    0.520    0.019   27.623    0.000    0.483
##    .Stest21cptlztn    0.379    0.015   24.840    0.000    0.349
##    .Stest22puncttn    0.345    0.013   25.635    0.000    0.319
##    .Stest23english    0.642    0.024   26.689    0.000    0.595
##    .Stest24exprssn    0.857    0.025   33.773    0.000    0.808
##    .Stst31bstrctrs    0.566    0.022   25.649    0.000    0.523
##    .Stst34rthcmptt    0.566    0.029   19.499    0.000    0.509
##    .Stest5math        0.566    0.021   27.111    0.000    0.525
##    .Stst25wrdfnctn    0.386    0.012   32.102    0.000    0.362
##    .Stst32rthrsnng    0.319    0.011   29.525    0.000    0.297
##    .Stst33hghschlm    0.165    0.015   11.352    0.000    0.137
##    .Stest35tblrdng    1.499    0.069   21.694    0.000    1.363
##    .Stst36clrclchc    0.911    0.040   22.714    0.000    0.832
##    .Stst37bjctnspc    0.824    0.035   23.794    0.000    0.757
##    .Stst28mchnclrs    0.389    0.016   24.279    0.000    0.357
##    .Stst29vslztn2D    0.727    0.027   26.715    0.000    0.674
##    .Stst30vslztn3D    0.426    0.020   21.470    0.000    0.387
##    .Stest1vocab       0.337    0.013   26.586    0.000    0.313
##    .Stst26rdngcmpr    0.223    0.011   20.715    0.000    0.202
##     english           1.000                               1.000
##     math              1.000                               1.000
##     speed             1.000                               1.000
##     spatial           1.000                               1.000
##     g                 1.000                               1.000
##  ci.upper   Std.lv  Std.all
##     0.416    0.388    0.449
##     0.557    0.520    0.513
##     0.409    0.379    0.387
##     0.371    0.345    0.321
##     0.689    0.642    0.457
##     0.907    0.857    0.646
##     0.609    0.566    0.423
##     0.623    0.566    0.423
##     0.607    0.566    0.540
##     0.410    0.386    0.581
##     0.340    0.319    0.482
##     0.194    0.165    0.279
##     1.634    1.499    0.526
##     0.989    0.911    0.547
##     0.892    0.824    0.538
##     0.420    0.389    0.583
##     0.781    0.727    0.613
##     0.465    0.426    0.494
##     0.362    0.337    0.313
##     0.244    0.223    0.193
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
## 
## 
## Group 2 [1]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english =~                                                   
##     Stst19d (.p1.)    0.113    0.018    6.214    0.000    0.077
##     Stst20s (.p2.)    0.298    0.026   11.541    0.000    0.248
##     Stst21c (.p3.)    0.264    0.018   14.779    0.000    0.229
##     Stst22p (.p4.)    0.307    0.020   15.243    0.000    0.267
##     Stst23n (.p5.)    0.294    0.023   12.612    0.000    0.248
##     Stst24x (.p6.)    0.194    0.024    8.258    0.000    0.148
##     Stst31b (.p7.)    0.108    0.021    5.108    0.000    0.067
##     Stst34r (.p8.)    0.267    0.026   10.403    0.000    0.216
##   math =~                                                      
##     Stst5mt (.p9.)    0.259    0.018   14.510    0.000    0.224
##     Stst25w (.10.)    0.155    0.016    9.448    0.000    0.123
##     Stst32r (.11.)    0.194    0.017   11.282    0.000    0.161
##     Stst33h (.12.)    0.372    0.023   16.497    0.000    0.328
##     Stst34r (.13.)    0.250    0.021   11.837    0.000    0.209
##   speed =~                                                     
##     Stst34r (.14.)    0.461    0.020   22.919    0.000    0.422
##     Stst35t (.15.)    0.968    0.032   30.721    0.000    0.906
##     Stst36c (.16.)    0.853    0.024   35.174    0.000    0.805
##     Stst37b (.17.)    0.722    0.023   31.616    0.000    0.677
##   spatial =~                                                   
##     Stst28m (.18.)    0.311    0.019   16.767    0.000    0.274
##     Sts292D (.19.)    0.508    0.022   22.745    0.000    0.464
##     Sts303D (.20.)    0.530    0.020   25.966    0.000    0.490
##     Stst31b (.21.)    0.466    0.020   23.718    0.000    0.427
##     Stst37b (.22.)    0.326    0.022   14.745    0.000    0.283
##   g =~                                                         
##     Stst1vc (.23.)    0.861    0.016   54.710    0.000    0.830
##     Stst5mt (.24.)    0.644    0.016   41.322    0.000    0.613
##     Stst19d (.25.)    0.681    0.014   47.799    0.000    0.653
##     Stst20s (.26.)    0.637    0.015   43.045    0.000    0.608
##     Stst21c (.27.)    0.728    0.014   53.144    0.000    0.701
##     Stst22p (.28.)    0.798    0.015   53.871    0.000    0.769
##     Stst23n (.29.)    0.823    0.017   47.994    0.000    0.789
##     Stst24x (.30.)    0.657    0.017   39.318    0.000    0.624
##     Stst25w (.31.)    0.504    0.013   38.673    0.000    0.478
##     Stst26r (.32.)    0.965    0.016   61.691    0.000    0.934
##     Stst28m (.33.)    0.427    0.013   32.594    0.000    0.401
##     Sts292D (.34.)    0.449    0.015   29.907    0.000    0.420
##     Sts303D (.35.)    0.396    0.014   28.987    0.000    0.369
##     Stst31b (.36.)    0.738    0.016   47.029    0.000    0.707
##     Stst32r (.37.)    0.551    0.014   39.746    0.000    0.524
##     Stst33h (.38.)    0.538    0.013   40.998    0.000    0.512
##     Stst34r (.39.)    0.652    0.017   38.308    0.000    0.618
##     Stst35t (.40.)    0.644    0.023   28.129    0.000    0.599
##     Stst36c (.41.)    0.163    0.019    8.657    0.000    0.126
##     Stst37b (.42.)    0.282    0.018   15.945    0.000    0.248
##  ci.upper   Std.lv  Std.all
##                            
##     0.149    0.119    0.133
##     0.349    0.314    0.329
##     0.299    0.278    0.285
##     0.346    0.323    0.337
##     0.340    0.310    0.284
##     0.240    0.205    0.188
##     0.150    0.114    0.106
##     0.317    0.281    0.246
##                            
##     0.294    0.240    0.239
##     0.187    0.143    0.186
##     0.228    0.180    0.238
##     0.417    0.345    0.490
##     0.292    0.232    0.203
##                            
##     0.501    0.456    0.399
##     1.030    0.956    0.593
##     0.900    0.842    0.655
##     0.767    0.713    0.625
##                            
##     0.347    0.225    0.342
##     0.551    0.367    0.372
##     0.570    0.383    0.490
##     0.504    0.337    0.313
##     0.370    0.236    0.207
##                            
##     0.892    0.765    0.815
##     0.674    0.572    0.569
##     0.709    0.604    0.673
##     0.666    0.565    0.591
##     0.755    0.646    0.662
##     0.827    0.708    0.739
##     0.857    0.731    0.670
##     0.690    0.583    0.536
##     0.529    0.447    0.579
##     0.995    0.856    0.882
##     0.452    0.379    0.576
##     0.479    0.399    0.405
##     0.423    0.351    0.449
##     0.768    0.655    0.609
##     0.579    0.489    0.647
##     0.563    0.477    0.677
##     0.685    0.578    0.506
##     0.689    0.572    0.355
##     0.200    0.144    0.112
##     0.317    0.251    0.220
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english ~~                                                   
##     math              0.000                               0.000
##     speed             0.000                               0.000
##     spatial           0.000                               0.000
##     g                 0.000                               0.000
##   math ~~                                                      
##     speed             0.000                               0.000
##     spatial           0.000                               0.000
##     g                 0.000                               0.000
##   speed ~~                                                     
##     spatial           0.000                               0.000
##     g                 0.000                               0.000
##   spatial ~~                                                   
##     g                 0.000                               0.000
##  ci.upper   Std.lv  Std.all
##                            
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##                            
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##                            
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##                            
##     0.000    0.000    0.000
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stst19dsgsdwrd   -0.878    0.016  -54.059    0.000   -0.910
##    .Stest20spellng   -0.450    0.017  -26.686    0.000   -0.483
##    .Stest21cptlztn   -0.899    0.017  -51.477    0.000   -0.934
##    .Stest22puncttn   -0.929    0.017  -53.286    0.000   -0.963
##    .Stest23english   -0.744    0.019  -38.449    0.000   -0.781
##    .Stest24exprssn   -0.704    0.019  -37.099    0.000   -0.742
##    .Stst31bstrctrs   -1.260    0.019  -65.843    0.000   -1.297
##    .Stst34rthcmptt   -1.004    0.021  -47.990    0.000   -1.045
##    .Stest5math       -0.965    0.017  -55.615    0.000   -0.999
##    .Stst25wrdfnctn   -0.788    0.014  -57.181    0.000   -0.816
##    .Stst32rthrsnng   -1.184    0.013  -92.849    0.000   -1.209
##    .Stst33hghschlm   -0.942    0.012  -78.389    0.000   -0.966
##    .Stest35tblrdng   -0.524    0.029  -17.830    0.000   -0.582
##    .Stst36clrclchc    0.300    0.023   13.284    0.000    0.256
##    .Stst37bjctnspc   -0.217    0.021  -10.567    0.000   -0.257
##    .Stst28mchnclrs   -1.323    0.011 -124.285    0.000   -1.344
##    .Stst29vslztn2D   -0.916    0.017  -52.801    0.000   -0.950
##    .Stst30vslztn3D   -0.982    0.014  -72.639    0.000   -1.008
##    .Stest1vocab      -1.339    0.016  -83.554    0.000   -1.370
##    .Stst26rdngcmpr   -1.226    0.017  -72.842    0.000   -1.259
##  ci.upper   Std.lv  Std.all
##    -0.846   -0.878   -0.977
##    -0.417   -0.450   -0.471
##    -0.865   -0.899   -0.921
##    -0.895   -0.929   -0.969
##    -0.706   -0.744   -0.682
##    -0.667   -0.704   -0.648
##    -1.222   -1.260   -1.172
##    -0.963   -1.004   -0.879
##    -0.931   -0.965   -0.961
##    -0.761   -0.788   -1.020
##    -1.159   -1.184   -1.564
##    -0.919   -0.942   -1.337
##    -0.466   -0.524   -0.325
##     0.344    0.300    0.233
##    -0.176   -0.217   -0.190
##    -1.303   -1.323   -2.014
##    -0.882   -0.916   -0.929
##    -0.955   -0.982   -1.256
##    -1.307   -1.339   -1.426
##    -1.193   -1.226   -1.263
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stst19dsgsdwrd    0.428    0.012   35.541    0.000    0.404
##    .Stest20spellng    0.495    0.016   30.986    0.000    0.464
##    .Stest21cptlztn    0.459    0.014   32.634    0.000    0.431
##    .Stest22puncttn    0.313    0.013   24.751    0.000    0.288
##    .Stest23english    0.561    0.017   32.293    0.000    0.527
##    .Stest24exprssn    0.801    0.021   37.384    0.000    0.759
##    .Stst31bstrctrs    0.600    0.017   35.148    0.000    0.567
##    .Stst34rthcmptt    0.630    0.028   22.388    0.000    0.575
##    .Stest5math        0.624    0.017   35.783    0.000    0.590
##    .Stst25wrdfnctn    0.377    0.011   35.866    0.000    0.356
##    .Stst32rthrsnng    0.301    0.009   34.808    0.000    0.284
##    .Stst33hghschlm    0.150    0.012   12.502    0.000    0.127
##    .Stest35tblrdng    1.355    0.058   23.443    0.000    1.241
##    .Stst36clrclchc    0.921    0.032   28.611    0.000    0.858
##    .Stst37bjctnspc    0.675    0.027   24.945    0.000    0.622
##    .Stst28mchnclrs    0.238    0.007   35.239    0.000    0.225
##    .Stst29vslztn2D    0.677    0.020   34.519    0.000    0.639
##    .Stst30vslztn3D    0.341    0.012   27.520    0.000    0.317
##    .Stest1vocab       0.296    0.009   31.510    0.000    0.278
##    .Stst26rdngcmpr    0.209    0.008   26.166    0.000    0.193
##     english           1.109    0.123    8.985    0.000    0.867
##     math              0.859    0.093    9.273    0.000    0.678
##     speed             0.975    0.060   16.294    0.000    0.858
##     spatial           0.523    0.043   12.203    0.000    0.439
##     g                 0.788    0.033   24.140    0.000    0.724
##  ci.upper   Std.lv  Std.all
##     0.452    0.428    0.530
##     0.526    0.495    0.542
##     0.486    0.459    0.481
##     0.338    0.313    0.341
##     0.595    0.561    0.471
##     0.843    0.801    0.677
##     0.634    0.600    0.519
##     0.685    0.630    0.483
##     0.658    0.624    0.619
##     0.398    0.377    0.631
##     0.318    0.301    0.525
##     0.174    0.150    0.302
##     1.468    1.355    0.522
##     0.984    0.921    0.558
##     0.728    0.675    0.518
##     0.251    0.238    0.551
##     0.716    0.677    0.697
##     0.365    0.341    0.558
##     0.315    0.296    0.336
##     0.224    0.209    0.222
##     1.351    1.000    1.000
##     1.041    1.000    1.000
##     1.093    1.000    1.000
##     0.607    1.000    1.000
##     0.852    1.000    1.000
lavTestScore(metric, release = 1:42)
## Warning: lavaan->lavTestScore():  
##    se is not `standard'; not implemented yet; falling back to 
##    ordinary score test
## $test
## 
## total score test:
## 
##    test      X2 df p.value
## 1 score 467.332 42       0
## 
## $uni
## 
## univariate score tests:
## 
##      lhs op    rhs      X2 df p.value
## 1   .p1. == .p103.   3.739  1   0.053
## 2   .p2. == .p104.   3.176  1   0.075
## 3   .p3. == .p105.   0.002  1   0.965
## 4   .p4. == .p106.   0.003  1   0.953
## 5   .p5. == .p107.   0.120  1   0.729
## 6   .p6. == .p108.   0.000  1   0.988
## 7   .p7. == .p109.   0.214  1   0.644
## 8   .p8. == .p110.   0.039  1   0.844
## 9   .p9. == .p111.   0.935  1   0.334
## 10 .p10. == .p112.   7.033  1   0.008
## 11 .p11. == .p113.   6.693  1   0.010
## 12 .p12. == .p114.   0.146  1   0.702
## 13 .p13. == .p115.   0.015  1   0.903
## 14 .p14. == .p116.   0.999  1   0.317
## 15 .p15. == .p117.   0.204  1   0.651
## 16 .p16. == .p118.   0.529  1   0.467
## 17 .p17. == .p119.   0.298  1   0.585
## 18 .p18. == .p120.  64.864  1   0.000
## 19 .p19. == .p121.   8.553  1   0.003
## 20 .p20. == .p122.   2.104  1   0.147
## 21 .p21. == .p123.   6.644  1   0.010
## 22 .p22. == .p124.   1.405  1   0.236
## 23 .p23. == .p125.  19.880  1   0.000
## 24 .p24. == .p126.  10.559  1   0.001
## 25 .p25. == .p127.  61.526  1   0.000
## 26 .p26. == .p128.   0.023  1   0.880
## 27 .p27. == .p129.  29.579  1   0.000
## 28 .p28. == .p130.  15.174  1   0.000
## 29 .p29. == .p131.   4.995  1   0.025
## 30 .p30. == .p132.   6.757  1   0.009
## 31 .p31. == .p133.  44.352  1   0.000
## 32 .p32. == .p134.   0.074  1   0.786
## 33 .p33. == .p135. 147.712  1   0.000
## 34 .p34. == .p136.   0.385  1   0.535
## 35 .p35. == .p137.   4.457  1   0.035
## 36 .p36. == .p138.  13.873  1   0.000
## 37 .p37. == .p139.  14.625  1   0.000
## 38 .p38. == .p140.   4.661  1   0.031
## 39 .p39. == .p141.   0.002  1   0.961
## 40 .p40. == .p142.   2.347  1   0.125
## 41 .p41. == .p143.   5.489  1   0.019
## 42 .p42. == .p144.   8.659  1   0.003
metric2<-cfa(chc.bifactor.model, data=dgroup, group="sex", meanstructure=TRUE, sampling.weights="BY_WTA", std.lv=T, orthogonal=T, group.equal=c("loadings"), group.partial=c("g=~Stest28mechanicalreasoning", "g=~Stest19disguisedwords", "spatial=~Stest28mechanicalreasoning"))
fitMeasures(metric2, c("chisq", "df", "pvalue", "cfi", "rmsea", "srmr", "aic", "bic"))
##      chisq         df     pvalue        cfi      rmsea       srmr 
##   2603.557    330.000      0.000      0.960      0.048      0.041 
##        aic        bic 
## 290509.288 291382.054
Mc(metric2)
## [1] 0.8295704
summary(metric2, standardized=T, ci=T)
## lavaan 0.6-18 ended normally after 78 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                       169
##   Number of equality constraints                    39
## 
##   Number of observations per group:                   
##     0                                             2443
##     1                                             3642
##   Sampling weights variable                     BY_WTA
## 
## Model Test User Model:
##                                               Standard      Scaled
##   Test Statistic                              2603.557    2311.470
##   Degrees of freedom                               330         330
##   P-value (Chi-square)                           0.000       0.000
##   Scaling correction factor                                  1.126
##     Yuan-Bentler correction (Mplus variant)                       
##   Test statistic for each group:
##     0                                         1112.382     987.586
##     1                                         1491.176    1323.884
## 
## Parameter Estimates:
## 
##   Standard errors                             Sandwich
##   Information bread                           Observed
##   Observed information based on                Hessian
## 
## 
## Group 1 [0]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english =~                                                   
##     Stst19d (.p1.)    0.102    0.019    5.392    0.000    0.065
##     Stst20s (.p2.)    0.300    0.026   11.322    0.000    0.248
##     Stst21c (.p3.)    0.265    0.018   14.829    0.000    0.230
##     Stst22p (.p4.)    0.309    0.020   15.454    0.000    0.270
##     Stst23n (.p5.)    0.297    0.024   12.652    0.000    0.251
##     Stst24x (.p6.)    0.199    0.024    8.382    0.000    0.152
##     Stst31b (.p7.)    0.108    0.021    5.073    0.000    0.066
##     Stst34r (.p8.)    0.269    0.026   10.331    0.000    0.218
##   math =~                                                      
##     Stst5mt (.p9.)    0.259    0.018   14.556    0.000    0.224
##     Stst25w (.10.)    0.155    0.016    9.515    0.000    0.123
##     Stst32r (.11.)    0.194    0.017   11.366    0.000    0.160
##     Stst33h (.12.)    0.371    0.023   16.464    0.000    0.326
##     Stst34r (.13.)    0.248    0.021   11.770    0.000    0.207
##   speed =~                                                     
##     Stst34r (.14.)    0.463    0.020   22.947    0.000    0.423
##     Stst35t (.15.)    0.968    0.032   30.693    0.000    0.906
##     Stst36c (.16.)    0.854    0.024   35.279    0.000    0.806
##     Stst37b (.17.)    0.723    0.023   31.619    0.000    0.678
##   spatial =~                                                   
##     Stst28m           0.387    0.019   19.993    0.000    0.349
##     Sts292D (.19.)    0.484    0.022   21.699    0.000    0.440
##     Sts303D (.20.)    0.498    0.021   24.099    0.000    0.458
##     Stst31b (.21.)    0.443    0.020   22.396    0.000    0.404
##     Stst37b (.22.)    0.311    0.021   14.491    0.000    0.269
##   g =~                                                         
##     Stst1vc (.23.)    0.863    0.016   55.383    0.000    0.832
##     Stst5mt (.24.)    0.644    0.015   41.642    0.000    0.614
##     Stst19d           0.610    0.018   34.047    0.000    0.574
##     Stst20s (.26.)    0.638    0.015   42.999    0.000    0.609
##     Stst21c (.27.)    0.729    0.014   53.408    0.000    0.702
##     Stst22p (.28.)    0.799    0.015   54.244    0.000    0.771
##     Stst23n (.29.)    0.825    0.017   48.516    0.000    0.791
##     Stst24x (.30.)    0.658    0.017   39.600    0.000    0.625
##     Stst25w (.31.)    0.504    0.013   38.852    0.000    0.478
##     Stst26r (.32.)    0.965    0.015   62.525    0.000    0.935
##     Stst28m           0.558    0.018   31.515    0.000    0.524
##     Sts292D (.34.)    0.455    0.015   30.312    0.000    0.426
##     Sts303D (.35.)    0.399    0.014   29.413    0.000    0.373
##     Stst31b (.36.)    0.745    0.016   47.846    0.000    0.714
##     Stst32r (.37.)    0.552    0.014   40.158    0.000    0.525
##     Stst33h (.38.)    0.538    0.013   41.332    0.000    0.512
##     Stst34r (.39.)    0.653    0.017   38.302    0.000    0.620
##     Stst35t (.40.)    0.646    0.023   28.178    0.000    0.601
##     Stst36c (.41.)    0.165    0.019    8.727    0.000    0.128
##     Stst37b (.42.)    0.287    0.018   16.166    0.000    0.252
##  ci.upper   Std.lv  Std.all
##                            
##     0.139    0.102    0.116
##     0.352    0.300    0.297
##     0.301    0.265    0.268
##     0.349    0.309    0.298
##     0.344    0.297    0.251
##     0.245    0.199    0.172
##     0.150    0.108    0.094
##     0.320    0.269    0.232
##                            
##     0.294    0.259    0.253
##     0.187    0.155    0.191
##     0.227    0.194    0.239
##     0.415    0.371    0.481
##     0.290    0.248    0.215
##                            
##     0.502    0.463    0.400
##     1.030    0.968    0.573
##     0.901    0.854    0.661
##     0.768    0.723    0.585
##                            
##     0.425    0.387    0.432
##     0.527    0.484    0.445
##     0.539    0.498    0.539
##     0.482    0.443    0.383
##     0.353    0.311    0.252
##                            
##     0.893    0.863    0.830
##     0.674    0.644    0.629
##     0.645    0.610    0.695
##     0.667    0.638    0.633
##     0.755    0.729    0.736
##     0.828    0.799    0.770
##     0.858    0.825    0.695
##     0.690    0.658    0.571
##     0.529    0.504    0.618
##     0.995    0.965    0.898
##     0.593    0.558    0.624
##     0.484    0.455    0.419
##     0.426    0.399    0.432
##     0.775    0.745    0.644
##     0.579    0.552    0.679
##     0.563    0.538    0.699
##     0.687    0.653    0.564
##     0.691    0.646    0.383
##     0.202    0.165    0.127
##     0.321    0.287    0.232
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english ~~                                                   
##     math              0.000                               0.000
##     speed             0.000                               0.000
##     spatial           0.000                               0.000
##     g                 0.000                               0.000
##   math ~~                                                      
##     speed             0.000                               0.000
##     spatial           0.000                               0.000
##     g                 0.000                               0.000
##   speed ~~                                                     
##     spatial           0.000                               0.000
##     g                 0.000                               0.000
##   spatial ~~                                                   
##     g                 0.000                               0.000
##  ci.upper   Std.lv  Std.all
##                            
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##                            
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##                            
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##                            
##     0.000    0.000    0.000
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stst19dsgsdwrd   -0.992    0.018  -53.776    0.000   -1.028
##    .Stest20spellng   -0.848    0.021  -39.900    0.000   -0.890
##    .Stest21cptlztn   -1.167    0.020  -58.007    0.000   -1.206
##    .Stest22puncttn   -1.226    0.021  -57.496    0.000   -1.268
##    .Stest23english   -1.062    0.026  -41.362    0.000   -1.113
##    .Stest24exprssn   -0.965    0.025  -38.928    0.000   -1.014
##    .Stst31bstrctrs   -1.070    0.024  -43.766    0.000   -1.118
##    .Stst34rthcmptt   -1.153    0.025  -46.702    0.000   -1.201
##    .Stest5math       -0.814    0.022  -36.442    0.000   -0.857
##    .Stst25wrdfnctn   -0.871    0.017  -52.726    0.000   -0.903
##    .Stst32rthrsnng   -1.052    0.018  -59.194    0.000   -1.087
##    .Stst33hghschlm   -0.875    0.016  -53.483    0.000   -0.907
##    .Stest35tblrdng   -0.712    0.037  -19.463    0.000   -0.784
##    .Stst36clrclchc   -0.032    0.028   -1.139    0.255   -0.086
##    .Stst37bjctnspc   -0.318    0.027  -11.957    0.000   -0.370
##    .Stst28mchnclrs   -0.715    0.019  -36.895    0.000   -0.753
##    .Stst29vslztn2D   -0.512    0.023  -22.047    0.000   -0.557
##    .Stst30vslztn3D   -0.723    0.020  -35.874    0.000   -0.762
##    .Stest1vocab      -1.155    0.023  -50.360    0.000   -1.200
##    .Stst26rdngcmpr   -1.292    0.023  -56.802    0.000   -1.337
##  ci.upper   Std.lv  Std.all
##    -0.956   -0.992   -1.130
##    -0.806   -0.848   -0.841
##    -1.128   -1.167   -1.179
##    -1.184   -1.226   -1.181
##    -1.012   -1.062   -0.895
##    -0.916   -0.965   -0.837
##    -1.022   -1.070   -0.925
##    -1.104   -1.153   -0.995
##    -0.770   -0.814   -0.795
##    -0.838   -0.871   -1.068
##    -1.017   -1.052   -1.295
##    -0.843   -0.875   -1.137
##    -0.640   -0.712   -0.422
##     0.023   -0.032   -0.025
##    -0.266   -0.318   -0.257
##    -0.677   -0.715   -0.799
##    -0.466   -0.512   -0.471
##    -0.683   -0.723   -0.783
##    -1.110   -1.155   -1.111
##    -1.248   -1.292   -1.202
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stst19dsgsdwrd    0.388    0.014   27.477    0.000    0.361
##    .Stest20spellng    0.521    0.019   27.405    0.000    0.483
##    .Stest21cptlztn    0.379    0.015   24.831    0.000    0.349
##    .Stest22puncttn    0.343    0.013   25.448    0.000    0.317
##    .Stest23english    0.641    0.024   26.645    0.000    0.594
##    .Stest24exprssn    0.856    0.025   33.677    0.000    0.806
##    .Stst31bstrctrs    0.575    0.022   26.332    0.000    0.532
##    .Stst34rthcmptt    0.565    0.029   19.523    0.000    0.509
##    .Stest5math        0.566    0.021   27.083    0.000    0.525
##    .Stst25wrdfnctn    0.386    0.012   32.075    0.000    0.363
##    .Stst32rthrsnng    0.318    0.011   29.512    0.000    0.297
##    .Stst33hghschlm    0.166    0.014   11.460    0.000    0.137
##    .Stest35tblrdng    1.498    0.069   21.722    0.000    1.363
##    .Stst36clrclchc    0.911    0.040   22.709    0.000    0.832
##    .Stst37bjctnspc    0.826    0.035   23.882    0.000    0.758
##    .Stst28mchnclrs    0.339    0.015   22.171    0.000    0.309
##    .Stst29vslztn2D    0.738    0.027   27.656    0.000    0.685
##    .Stst30vslztn3D    0.445    0.019   23.212    0.000    0.408
##    .Stest1vocab       0.336    0.013   26.545    0.000    0.311
##    .Stst26rdngcmpr    0.224    0.011   20.842    0.000    0.203
##     english           1.000                               1.000
##     math              1.000                               1.000
##     speed             1.000                               1.000
##     spatial           1.000                               1.000
##     g                 1.000                               1.000
##  ci.upper   Std.lv  Std.all
##     0.416    0.388    0.504
##     0.558    0.521    0.511
##     0.409    0.379    0.386
##     0.370    0.343    0.318
##     0.688    0.641    0.455
##     0.906    0.856    0.645
##     0.618    0.575    0.430
##     0.622    0.565    0.422
##     0.606    0.566    0.540
##     0.410    0.386    0.581
##     0.339    0.318    0.482
##     0.194    0.166    0.280
##     1.633    1.498    0.525
##     0.989    0.911    0.546
##     0.893    0.826    0.541
##     0.368    0.339    0.423
##     0.790    0.738    0.626
##     0.483    0.445    0.522
##     0.361    0.336    0.311
##     0.245    0.224    0.194
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
## 
## 
## Group 2 [1]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english =~                                                   
##     Stst19d (.p1.)    0.102    0.019    5.392    0.000    0.065
##     Stst20s (.p2.)    0.300    0.026   11.322    0.000    0.248
##     Stst21c (.p3.)    0.265    0.018   14.829    0.000    0.230
##     Stst22p (.p4.)    0.309    0.020   15.454    0.000    0.270
##     Stst23n (.p5.)    0.297    0.024   12.652    0.000    0.251
##     Stst24x (.p6.)    0.199    0.024    8.382    0.000    0.152
##     Stst31b (.p7.)    0.108    0.021    5.073    0.000    0.066
##     Stst34r (.p8.)    0.269    0.026   10.331    0.000    0.218
##   math =~                                                      
##     Stst5mt (.p9.)    0.259    0.018   14.556    0.000    0.224
##     Stst25w (.10.)    0.155    0.016    9.515    0.000    0.123
##     Stst32r (.11.)    0.194    0.017   11.366    0.000    0.160
##     Stst33h (.12.)    0.371    0.023   16.464    0.000    0.326
##     Stst34r (.13.)    0.248    0.021   11.770    0.000    0.207
##   speed =~                                                     
##     Stst34r (.14.)    0.463    0.020   22.947    0.000    0.423
##     Stst35t (.15.)    0.968    0.032   30.693    0.000    0.906
##     Stst36c (.16.)    0.854    0.024   35.279    0.000    0.806
##     Stst37b (.17.)    0.723    0.023   31.619    0.000    0.678
##   spatial =~                                                   
##     Stst28m           0.200    0.018   11.126    0.000    0.165
##     Sts292D (.19.)    0.484    0.022   21.699    0.000    0.440
##     Sts303D (.20.)    0.498    0.021   24.099    0.000    0.458
##     Stst31b (.21.)    0.443    0.020   22.396    0.000    0.404
##     Stst37b (.22.)    0.311    0.021   14.491    0.000    0.269
##   g =~                                                         
##     Stst1vc (.23.)    0.863    0.016   55.383    0.000    0.832
##     Stst5mt (.24.)    0.644    0.015   41.642    0.000    0.614
##     Stst19d           0.754    0.019   40.617    0.000    0.717
##     Stst20s (.26.)    0.638    0.015   42.999    0.000    0.609
##     Stst21c (.27.)    0.729    0.014   53.408    0.000    0.702
##     Stst22p (.28.)    0.799    0.015   54.244    0.000    0.771
##     Stst23n (.29.)    0.825    0.017   48.516    0.000    0.791
##     Stst24x (.30.)    0.658    0.017   39.600    0.000    0.625
##     Stst25w (.31.)    0.504    0.013   38.852    0.000    0.478
##     Stst26r (.32.)    0.965    0.015   62.525    0.000    0.935
##     Stst28m           0.360    0.013   27.477    0.000    0.334
##     Sts292D (.34.)    0.455    0.015   30.312    0.000    0.426
##     Sts303D (.35.)    0.399    0.014   29.413    0.000    0.373
##     Stst31b (.36.)    0.745    0.016   47.846    0.000    0.714
##     Stst32r (.37.)    0.552    0.014   40.158    0.000    0.525
##     Stst33h (.38.)    0.538    0.013   41.332    0.000    0.512
##     Stst34r (.39.)    0.653    0.017   38.302    0.000    0.620
##     Stst35t (.40.)    0.646    0.023   28.178    0.000    0.601
##     Stst36c (.41.)    0.165    0.019    8.727    0.000    0.128
##     Stst37b (.42.)    0.287    0.018   16.166    0.000    0.252
##  ci.upper   Std.lv  Std.all
##                            
##     0.139    0.106    0.113
##     0.352    0.311    0.325
##     0.301    0.275    0.282
##     0.349    0.320    0.334
##     0.344    0.308    0.282
##     0.245    0.206    0.189
##     0.150    0.112    0.104
##     0.320    0.279    0.244
##                            
##     0.294    0.242    0.241
##     0.187    0.145    0.188
##     0.227    0.181    0.239
##     0.415    0.346    0.491
##     0.290    0.232    0.203
##                            
##     0.502    0.456    0.399
##     1.030    0.953    0.592
##     0.901    0.841    0.655
##     0.768    0.712    0.623
##                            
##     0.236    0.164    0.268
##     0.527    0.396    0.400
##     0.539    0.408    0.519
##     0.482    0.363    0.336
##     0.353    0.255    0.223
##                            
##     0.893    0.764    0.815
##     0.674    0.571    0.568
##     0.790    0.668    0.714
##     0.667    0.565    0.592
##     0.755    0.646    0.662
##     0.828    0.708    0.739
##     0.858    0.731    0.670
##     0.690    0.583    0.536
##     0.529    0.447    0.578
##     0.995    0.855    0.882
##     0.385    0.319    0.520
##     0.484    0.403    0.407
##     0.426    0.354    0.450
##     0.775    0.660    0.610
##     0.579    0.489    0.646
##     0.563    0.477    0.676
##     0.687    0.579    0.507
##     0.691    0.572    0.355
##     0.202    0.146    0.114
##     0.321    0.254    0.222
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english ~~                                                   
##     math              0.000                               0.000
##     speed             0.000                               0.000
##     spatial           0.000                               0.000
##     g                 0.000                               0.000
##   math ~~                                                      
##     speed             0.000                               0.000
##     spatial           0.000                               0.000
##     g                 0.000                               0.000
##   speed ~~                                                     
##     spatial           0.000                               0.000
##     g                 0.000                               0.000
##   spatial ~~                                                   
##     g                 0.000                               0.000
##  ci.upper   Std.lv  Std.all
##                            
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##                            
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##                            
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##                            
##     0.000    0.000    0.000
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stst19dsgsdwrd   -0.878    0.016  -54.059    0.000   -0.910
##    .Stest20spellng   -0.450    0.017  -26.686    0.000   -0.483
##    .Stest21cptlztn   -0.899    0.017  -51.477    0.000   -0.934
##    .Stest22puncttn   -0.929    0.017  -53.286    0.000   -0.963
##    .Stest23english   -0.744    0.019  -38.449    0.000   -0.781
##    .Stest24exprssn   -0.704    0.019  -37.099    0.000   -0.742
##    .Stst31bstrctrs   -1.260    0.019  -65.843    0.000   -1.297
##    .Stst34rthcmptt   -1.004    0.021  -47.990    0.000   -1.045
##    .Stest5math       -0.965    0.017  -55.615    0.000   -0.999
##    .Stst25wrdfnctn   -0.788    0.014  -57.181    0.000   -0.816
##    .Stst32rthrsnng   -1.184    0.013  -92.849    0.000   -1.209
##    .Stst33hghschlm   -0.942    0.012  -78.389    0.000   -0.966
##    .Stest35tblrdng   -0.524    0.029  -17.830    0.000   -0.582
##    .Stst36clrclchc    0.300    0.023   13.284    0.000    0.256
##    .Stst37bjctnspc   -0.217    0.021  -10.567    0.000   -0.257
##    .Stst28mchnclrs   -1.323    0.011 -124.285    0.000   -1.344
##    .Stst29vslztn2D   -0.916    0.017  -52.801    0.000   -0.950
##    .Stst30vslztn3D   -0.982    0.014  -72.639    0.000   -1.008
##    .Stest1vocab      -1.339    0.016  -83.554    0.000   -1.370
##    .Stst26rdngcmpr   -1.226    0.017  -72.842    0.000   -1.259
##  ci.upper   Std.lv  Std.all
##    -0.846   -0.878   -0.938
##    -0.417   -0.450   -0.472
##    -0.865   -0.899   -0.922
##    -0.895   -0.929   -0.969
##    -0.706   -0.744   -0.682
##    -0.667   -0.704   -0.648
##    -1.222   -1.260   -1.165
##    -0.963   -1.004   -0.879
##    -0.931   -0.965   -0.961
##    -0.761   -0.788   -1.020
##    -1.159   -1.184   -1.564
##    -0.919   -0.942   -1.337
##    -0.466   -0.524   -0.325
##     0.344    0.300    0.233
##    -0.176   -0.217   -0.189
##    -1.303   -1.323   -2.158
##    -0.882   -0.916   -0.924
##    -0.955   -0.982   -1.247
##    -1.307   -1.339   -1.427
##    -1.193   -1.226   -1.264
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stst19dsgsdwrd    0.419    0.012   35.100    0.000    0.395
##    .Stest20spellng    0.495    0.016   31.067    0.000    0.464
##    .Stest21cptlztn    0.460    0.014   32.690    0.000    0.432
##    .Stest22puncttn    0.314    0.013   24.680    0.000    0.289
##    .Stest23english    0.560    0.017   32.219    0.000    0.526
##    .Stest24exprssn    0.800    0.021   37.338    0.000    0.758
##    .Stst31bstrctrs    0.589    0.017   34.397    0.000    0.556
##    .Stst34rthcmptt    0.631    0.028   22.368    0.000    0.575
##    .Stest5math        0.624    0.017   35.749    0.000    0.590
##    .Stst25wrdfnctn    0.377    0.011   35.802    0.000    0.356
##    .Stst32rthrsnng    0.301    0.009   34.773    0.000    0.284
##    .Stst33hghschlm    0.150    0.012   12.476    0.000    0.126
##    .Stest35tblrdng    1.357    0.058   23.488    0.000    1.244
##    .Stst36clrclchc    0.921    0.032   28.629    0.000    0.858
##    .Stst37bjctnspc    0.671    0.027   24.794    0.000    0.618
##    .Stst28mchnclrs    0.248    0.007   37.712    0.000    0.235
##    .Stst29vslztn2D    0.663    0.020   33.287    0.000    0.624
##    .Stst30vslztn3D    0.327    0.013   25.521    0.000    0.302
##    .Stest1vocab       0.296    0.009   31.700    0.000    0.278
##    .Stst26rdngcmpr    0.209    0.008   26.399    0.000    0.194
##     english           1.072    0.118    9.052    0.000    0.840
##     math              0.874    0.094    9.314    0.000    0.690
##     speed             0.970    0.060   16.293    0.000    0.854
##     spatial           0.672    0.053   12.619    0.000    0.568
##     g                 0.785    0.032   24.587    0.000    0.723
##  ci.upper   Std.lv  Std.all
##     0.442    0.419    0.478
##     0.527    0.495    0.543
##     0.487    0.460    0.483
##     0.339    0.314    0.342
##     0.595    0.560    0.471
##     0.842    0.800    0.677
##     0.623    0.589    0.504
##     0.686    0.631    0.483
##     0.658    0.624    0.619
##     0.398    0.377    0.631
##     0.318    0.301    0.526
##     0.174    0.150    0.302
##     1.470    1.357    0.523
##     0.984    0.921    0.558
##     0.724    0.671    0.513
##     0.260    0.248    0.658
##     0.702    0.663    0.675
##     0.353    0.327    0.529
##     0.314    0.296    0.336
##     0.225    0.209    0.223
##     1.305    1.000    1.000
##     1.058    1.000    1.000
##     1.087    1.000    1.000
##     0.776    1.000    1.000
##     0.848    1.000    1.000
lavTestScore(metric2, release = 1:39)
## Warning: lavaan->lavTestScore():  
##    se is not `standard'; not implemented yet; falling back to 
##    ordinary score test
## $test
## 
## total score test:
## 
##    test      X2 df p.value
## 1 score 211.464 39       0
## 
## $uni
## 
## univariate score tests:
## 
##      lhs op    rhs     X2 df p.value
## 1   .p1. == .p103.  0.796  1   0.372
## 2   .p2. == .p104.  3.142  1   0.076
## 3   .p3. == .p105.  0.036  1   0.849
## 4   .p4. == .p106.  0.077  1   0.782
## 5   .p5. == .p107.  0.262  1   0.609
## 6   .p6. == .p108.  0.005  1   0.945
## 7   .p7. == .p109.  0.036  1   0.850
## 8   .p8. == .p110.  0.095  1   0.758
## 9   .p9. == .p111.  0.966  1   0.326
## 10 .p10. == .p112.  7.049  1   0.008
## 11 .p11. == .p113.  6.126  1   0.013
## 12 .p12. == .p114.  0.187  1   0.665
## 13 .p13. == .p115.  0.053  1   0.818
## 14 .p14. == .p116.  1.081  1   0.298
## 15 .p15. == .p117.  0.139  1   0.710
## 16 .p16. == .p118.  0.393  1   0.531
## 17 .p17. == .p119.  0.363  1   0.547
## 18 .p19. == .p121.  0.983  1   0.322
## 19 .p20. == .p122.  1.908  1   0.167
## 20 .p21. == .p123.  0.331  1   0.565
## 21 .p22. == .p124.  0.036  1   0.850
## 22 .p23. == .p125. 19.707  1   0.000
## 23 .p24. == .p126. 10.684  1   0.001
## 24 .p26. == .p128.  0.481  1   0.488
## 25 .p27. == .p129. 34.550  1   0.000
## 26 .p28. == .p130. 19.538  1   0.000
## 27 .p29. == .p131.  3.520  1   0.061
## 28 .p30. == .p132.  5.862  1   0.015
## 29 .p31. == .p133. 44.857  1   0.000
## 30 .p32. == .p134.  0.003  1   0.959
## 31 .p34. == .p136.  0.606  1   0.436
## 32 .p35. == .p137. 19.114  1   0.000
## 33 .p36. == .p138.  5.846  1   0.016
## 34 .p37. == .p139. 15.250  1   0.000
## 35 .p38. == .p140.  5.112  1   0.024
## 36 .p39. == .p141.  0.156  1   0.693
## 37 .p40. == .p142.  2.877  1   0.090
## 38 .p41. == .p143.  4.205  1   0.040
## 39 .p42. == .p144.  4.634  1   0.031
scalar<-cfa(chc.bifactor.model, data=dgroup, group="sex", meanstructure=TRUE, sampling.weights="BY_WTA", std.lv=T, orthogonal=T, group.equal=c("loadings", "intercepts"), group.partial=c("g=~Stest28mechanicalreasoning", "g=~Stest19disguisedwords", "spatial=~Stest28mechanicalreasoning"))
fitMeasures(scalar, c("chisq", "df", "pvalue", "cfi", "rmsea", "srmr", "aic", "bic"))
##      chisq         df     pvalue        cfi      rmsea       srmr 
##   3373.141    345.000      0.000      0.947      0.054      0.044 
##        aic        bic 
## 291248.872 292020.934
Mc(scalar)
## [1] 0.7796883
summary(scalar, standardized=T, ci=T) # +.008
## lavaan 0.6-18 ended normally after 92 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                       174
##   Number of equality constraints                    59
## 
##   Number of observations per group:                   
##     0                                             2443
##     1                                             3642
##   Sampling weights variable                     BY_WTA
## 
## Model Test User Model:
##                                               Standard      Scaled
##   Test Statistic                              3373.141    2998.976
##   Degrees of freedom                               345         345
##   P-value (Chi-square)                           0.000       0.000
##   Scaling correction factor                                  1.125
##     Yuan-Bentler correction (Mplus variant)                       
##   Test statistic for each group:
##     0                                         1379.950    1226.879
##     1                                         1993.192    1772.097
## 
## Parameter Estimates:
## 
##   Standard errors                             Sandwich
##   Information bread                           Observed
##   Observed information based on                Hessian
## 
## 
## Group 1 [0]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english =~                                                   
##     Stst19d (.p1.)    0.111    0.013    8.468    0.000    0.085
##     Stst20s (.p2.)    0.336    0.021   16.186    0.000    0.295
##     Stst21c (.p3.)    0.261    0.015   17.603    0.000    0.232
##     Stst22p (.p4.)    0.296    0.016   18.131    0.000    0.264
##     Stst23n (.p5.)    0.308    0.019   16.020    0.000    0.271
##     Stst24x (.p6.)    0.224    0.018   12.420    0.000    0.188
##     Stst31b (.p7.)    0.112    0.018    6.059    0.000    0.076
##     Stst34r (.p8.)    0.184    0.023    8.160    0.000    0.140
##   math =~                                                      
##     Stst5mt (.p9.)    0.271    0.018   14.883    0.000    0.235
##     Stst25w (.10.)    0.138    0.015    9.078    0.000    0.108
##     Stst32r (.11.)    0.204    0.018   11.590    0.000    0.169
##     Stst33h (.12.)    0.349    0.023   15.239    0.000    0.304
##     Stst34r (.13.)    0.258    0.024   10.564    0.000    0.210
##   speed =~                                                     
##     Stst34r (.14.)    0.446    0.020   21.962    0.000    0.406
##     Stst35t (.15.)    0.953    0.032   30.185    0.000    0.891
##     Stst36c (.16.)    0.864    0.024   36.376    0.000    0.817
##     Stst37b (.17.)    0.737    0.022   32.833    0.000    0.693
##   spatial =~                                                   
##     Stst28m           0.379    0.020   19.246    0.000    0.341
##     Sts292D (.19.)    0.520    0.022   23.875    0.000    0.477
##     Sts303D (.20.)    0.469    0.020   23.993    0.000    0.430
##     Stst31b (.21.)    0.455    0.021   21.480    0.000    0.413
##     Stst37b (.22.)    0.286    0.022   12.862    0.000    0.243
##   g =~                                                         
##     Stst1vc (.23.)    0.859    0.016   53.059    0.000    0.827
##     Stst5mt (.24.)    0.644    0.016   41.038    0.000    0.613
##     Stst19d           0.609    0.018   33.888    0.000    0.574
##     Stst20s (.26.)    0.633    0.015   43.171    0.000    0.604
##     Stst21c (.27.)    0.729    0.014   53.361    0.000    0.703
##     Stst22p (.28.)    0.802    0.015   54.354    0.000    0.773
##     Stst23n (.29.)    0.823    0.017   48.604    0.000    0.790
##     Stst24x (.30.)    0.655    0.016   39.894    0.000    0.623
##     Stst25w (.31.)    0.505    0.013   39.277    0.000    0.480
##     Stst26r (.32.)    0.961    0.015   63.053    0.000    0.931
##     Stst28m           0.564    0.018   31.590    0.000    0.529
##     Sts292D (.34.)    0.462    0.015   30.230    0.000    0.432
##     Sts303D (.35.)    0.409    0.014   29.730    0.000    0.382
##     Stst31b (.36.)    0.748    0.016   47.681    0.000    0.717
##     Stst32r (.37.)    0.552    0.014   39.742    0.000    0.525
##     Stst33h (.38.)    0.539    0.013   41.550    0.000    0.514
##     Stst34r (.39.)    0.663    0.017   38.259    0.000    0.629
##     Stst35t (.40.)    0.649    0.023   28.091    0.000    0.603
##     Stst36c (.41.)    0.164    0.019    8.737    0.000    0.127
##     Stst37b (.42.)    0.292    0.018   16.392    0.000    0.257
##  ci.upper   Std.lv  Std.all
##                            
##     0.136    0.111    0.126
##     0.377    0.336    0.332
##     0.290    0.261    0.263
##     0.328    0.296    0.285
##     0.346    0.308    0.260
##     0.259    0.224    0.194
##     0.148    0.112    0.096
##     0.228    0.184    0.159
##                            
##     0.307    0.271    0.264
##     0.168    0.138    0.169
##     0.238    0.204    0.250
##     0.393    0.349    0.454
##     0.306    0.258    0.223
##                            
##     0.486    0.446    0.386
##     1.015    0.953    0.565
##     0.910    0.864    0.667
##     0.781    0.737    0.595
##                            
##     0.418    0.379    0.423
##     0.563    0.520    0.474
##     0.507    0.469    0.508
##     0.496    0.455    0.391
##     0.330    0.286    0.231
##                            
##     0.891    0.859    0.823
##     0.674    0.644    0.628
##     0.644    0.609    0.694
##     0.662    0.633    0.626
##     0.756    0.729    0.737
##     0.831    0.802    0.772
##     0.857    0.823    0.694
##     0.687    0.655    0.567
##     0.530    0.505    0.618
##     0.991    0.961    0.894
##     0.599    0.564    0.628
##     0.491    0.462    0.421
##     0.436    0.409    0.443
##     0.779    0.748    0.644
##     0.580    0.552    0.678
##     0.565    0.539    0.702
##     0.697    0.663    0.574
##     0.694    0.649    0.385
##     0.201    0.164    0.127
##     0.327    0.292    0.236
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english ~~                                                   
##     math              0.000                               0.000
##     speed             0.000                               0.000
##     spatial           0.000                               0.000
##     g                 0.000                               0.000
##   math ~~                                                      
##     speed             0.000                               0.000
##     spatial           0.000                               0.000
##     g                 0.000                               0.000
##   speed ~~                                                     
##     spatial           0.000                               0.000
##     g                 0.000                               0.000
##   spatial ~~                                                   
##     g                 0.000                               0.000
##  ci.upper   Std.lv  Std.all
##                            
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##                            
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##                            
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##                            
##     0.000    0.000    0.000
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stst19d (.78.)   -1.005    0.018  -57.043    0.000   -1.040
##    .Stst20s (.79.)   -0.838    0.021  -40.031    0.000   -0.879
##    .Stst21c (.80.)   -1.187    0.019  -61.403    0.000   -1.225
##    .Stst22p (.81.)   -1.253    0.022  -58.210    0.000   -1.295
##    .Stst23n (.82.)   -1.085    0.025  -43.483    0.000   -1.134
##    .Stst24x (.83.)   -0.964    0.023  -41.576    0.000   -1.009
##    .Stst31b (.84.)   -1.051    0.023  -45.255    0.000   -1.096
##    .Stst34r (.85.)   -1.232    0.023  -54.004    0.000   -1.277
##    .Stst5mt (.86.)   -0.868    0.020  -43.190    0.000   -0.908
##    .Stst25w (.87.)   -0.806    0.014  -56.442    0.000   -0.834
##    .Stst32r (.88.)   -1.107    0.016  -68.457    0.000   -1.139
##    .Stst33h (.89.)   -0.866    0.017  -51.552    0.000   -0.899
##    .Stst35t (.90.)   -0.790    0.033  -23.802    0.000   -0.855
##    .Stst36c (.91.)    0.002    0.026    0.081    0.935   -0.049
##    .Stst37b (.92.)   -0.259    0.025  -10.171    0.000   -0.309
##    .Stst28m (.93.)   -0.755    0.023  -32.428    0.000   -0.801
##    .Sts292D (.94.)   -0.511    0.022  -23.168    0.000   -0.554
##    .Sts303D (.95.)   -0.657    0.018  -35.709    0.000   -0.693
##    .Stst1vc (.96.)   -1.283    0.022  -58.394    0.000   -1.326
##    .Stst26r (.97.)   -1.265    0.023  -54.000    0.000   -1.311
##  ci.upper   Std.lv  Std.all
##    -0.971   -1.005   -1.145
##    -0.797   -0.838   -0.828
##    -1.150   -1.187   -1.199
##    -1.211   -1.253   -1.207
##    -1.036   -1.085   -0.914
##    -0.918   -0.964   -0.835
##    -1.005   -1.051   -0.905
##    -1.188   -1.232   -1.067
##    -0.829   -0.868   -0.847
##    -0.778   -0.806   -0.986
##    -1.075   -1.107   -1.359
##    -0.834   -0.866   -1.127
##    -0.725   -0.790   -0.468
##     0.054    0.002    0.002
##    -0.209   -0.259   -0.209
##    -0.709   -0.755   -0.841
##    -0.468   -0.511   -0.466
##    -0.621   -0.657   -0.712
##    -1.240   -1.283   -1.229
##    -1.219   -1.265   -1.178
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stst19dsgsdwrd    0.388    0.014   27.415    0.000    0.360
##    .Stest20spellng    0.509    0.019   27.324    0.000    0.473
##    .Stest21cptlztn    0.380    0.016   24.373    0.000    0.350
##    .Stest22puncttn    0.348    0.012   27.890    0.000    0.323
##    .Stest23english    0.636    0.024   27.030    0.000    0.590
##    .Stest24exprssn    0.854    0.025   33.614    0.000    0.804
##    .Stst31bstrctrs    0.570    0.022   25.735    0.000    0.527
##    .Stst34rthcmptt    0.596    0.031   19.361    0.000    0.535
##    .Stest5math        0.564    0.021   26.547    0.000    0.522
##    .Stst25wrdfnctn    0.393    0.012   31.896    0.000    0.369
##    .Stst32rthrsnng    0.317    0.011   28.873    0.000    0.295
##    .Stst33hghschlm    0.178    0.014   12.814    0.000    0.151
##    .Stest35tblrdng    1.517    0.068   22.397    0.000    1.384
##    .Stst36clrclchc    0.903    0.041   22.084    0.000    0.823
##    .Stst37bjctnspc    0.824    0.035   23.602    0.000    0.756
##    .Stst28mchnclrs    0.343    0.015   22.328    0.000    0.313
##    .Stst29vslztn2D    0.720    0.027   26.702    0.000    0.667
##    .Stst30vslztn3D    0.465    0.018   25.536    0.000    0.429
##    .Stest1vocab       0.352    0.014   25.982    0.000    0.326
##    .Stst26rdngcmpr    0.231    0.011   20.564    0.000    0.209
##     english           1.000                               1.000
##     math              1.000                               1.000
##     speed             1.000                               1.000
##     spatial           1.000                               1.000
##     g                 1.000                               1.000
##  ci.upper   Std.lv  Std.all
##     0.415    0.388    0.503
##     0.546    0.509    0.498
##     0.411    0.380    0.388
##     0.372    0.348    0.322
##     0.682    0.636    0.451
##     0.903    0.854    0.641
##     0.614    0.570    0.423
##     0.656    0.596    0.446
##     0.605    0.564    0.536
##     0.417    0.393    0.589
##     0.338    0.317    0.478
##     0.206    0.178    0.302
##     1.650    1.517    0.533
##     0.983    0.903    0.539
##     0.893    0.824    0.537
##     0.373    0.343    0.426
##     0.772    0.720    0.598
##     0.501    0.465    0.546
##     0.379    0.352    0.323
##     0.253    0.231    0.200
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
## 
## 
## Group 2 [1]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english =~                                                   
##     Stst19d (.p1.)    0.111    0.013    8.468    0.000    0.085
##     Stst20s (.p2.)    0.336    0.021   16.186    0.000    0.295
##     Stst21c (.p3.)    0.261    0.015   17.603    0.000    0.232
##     Stst22p (.p4.)    0.296    0.016   18.131    0.000    0.264
##     Stst23n (.p5.)    0.308    0.019   16.020    0.000    0.271
##     Stst24x (.p6.)    0.224    0.018   12.420    0.000    0.188
##     Stst31b (.p7.)    0.112    0.018    6.059    0.000    0.076
##     Stst34r (.p8.)    0.184    0.023    8.160    0.000    0.140
##   math =~                                                      
##     Stst5mt (.p9.)    0.271    0.018   14.883    0.000    0.235
##     Stst25w (.10.)    0.138    0.015    9.078    0.000    0.108
##     Stst32r (.11.)    0.204    0.018   11.590    0.000    0.169
##     Stst33h (.12.)    0.349    0.023   15.239    0.000    0.304
##     Stst34r (.13.)    0.258    0.024   10.564    0.000    0.210
##   speed =~                                                     
##     Stst34r (.14.)    0.446    0.020   21.962    0.000    0.406
##     Stst35t (.15.)    0.953    0.032   30.185    0.000    0.891
##     Stst36c (.16.)    0.864    0.024   36.376    0.000    0.817
##     Stst37b (.17.)    0.737    0.022   32.833    0.000    0.693
##   spatial =~                                                   
##     Stst28m           0.720    0.051   14.017    0.000    0.619
##     Sts292D (.19.)    0.520    0.022   23.875    0.000    0.477
##     Sts303D (.20.)    0.469    0.020   23.993    0.000    0.430
##     Stst31b (.21.)    0.455    0.021   21.480    0.000    0.413
##     Stst37b (.22.)    0.286    0.022   12.862    0.000    0.243
##   g =~                                                         
##     Stst1vc (.23.)    0.859    0.016   53.059    0.000    0.827
##     Stst5mt (.24.)    0.644    0.016   41.038    0.000    0.613
##     Stst19d           0.751    0.018   41.621    0.000    0.716
##     Stst20s (.26.)    0.633    0.015   43.171    0.000    0.604
##     Stst21c (.27.)    0.729    0.014   53.361    0.000    0.703
##     Stst22p (.28.)    0.802    0.015   54.354    0.000    0.773
##     Stst23n (.29.)    0.823    0.017   48.604    0.000    0.790
##     Stst24x (.30.)    0.655    0.016   39.894    0.000    0.623
##     Stst25w (.31.)    0.505    0.013   39.277    0.000    0.480
##     Stst26r (.32.)    0.961    0.015   63.053    0.000    0.931
##     Stst28m           0.356    0.013   27.077    0.000    0.330
##     Sts292D (.34.)    0.462    0.015   30.230    0.000    0.432
##     Sts303D (.35.)    0.409    0.014   29.730    0.000    0.382
##     Stst31b (.36.)    0.748    0.016   47.681    0.000    0.717
##     Stst32r (.37.)    0.552    0.014   39.742    0.000    0.525
##     Stst33h (.38.)    0.539    0.013   41.550    0.000    0.514
##     Stst34r (.39.)    0.663    0.017   38.259    0.000    0.629
##     Stst35t (.40.)    0.649    0.023   28.091    0.000    0.603
##     Stst36c (.41.)    0.164    0.019    8.737    0.000    0.127
##     Stst37b (.42.)    0.292    0.018   16.392    0.000    0.257
##  ci.upper   Std.lv  Std.all
##                            
##     0.136    0.113    0.121
##     0.377    0.344    0.358
##     0.290    0.267    0.274
##     0.328    0.303    0.317
##     0.346    0.316    0.289
##     0.259    0.229    0.210
##     0.148    0.115    0.107
##     0.228    0.188    0.165
##                            
##     0.307    0.253    0.251
##     0.168    0.129    0.166
##     0.238    0.190    0.250
##     0.393    0.325    0.461
##     0.306    0.241    0.211
##                            
##     0.486    0.439    0.386
##     1.015    0.938    0.584
##     0.910    0.850    0.660
##     0.781    0.725    0.634
##                            
##     0.821    0.335    0.535
##     0.563    0.242    0.246
##     0.507    0.218    0.281
##     0.496    0.211    0.197
##     0.330    0.133    0.116
##                            
##     0.891    0.762    0.810
##     0.674    0.571    0.568
##     0.786    0.667    0.712
##     0.662    0.562    0.585
##     0.756    0.647    0.664
##     0.831    0.712    0.743
##     0.857    0.731    0.670
##     0.687    0.581    0.534
##     0.530    0.448    0.580
##     0.991    0.853    0.878
##     0.381    0.316    0.504
##     0.491    0.410    0.416
##     0.436    0.363    0.468
##     0.779    0.664    0.619
##     0.580    0.490    0.646
##     0.565    0.479    0.680
##     0.697    0.589    0.517
##     0.694    0.576    0.358
##     0.201    0.145    0.113
##     0.327    0.259    0.226
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english ~~                                                   
##     math              0.000                               0.000
##     speed             0.000                               0.000
##     spatial           0.000                               0.000
##     g                 0.000                               0.000
##   math ~~                                                      
##     speed             0.000                               0.000
##     spatial           0.000                               0.000
##     g                 0.000                               0.000
##   speed ~~                                                     
##     spatial           0.000                               0.000
##     g                 0.000                               0.000
##   spatial ~~                                                   
##     g                 0.000                               0.000
##  ci.upper   Std.lv  Std.all
##                            
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##                            
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##                            
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##                            
##     0.000    0.000    0.000
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stst19d (.78.)   -1.005    0.018  -57.043    0.000   -1.040
##    .Stst20s (.79.)   -0.838    0.021  -40.031    0.000   -0.879
##    .Stst21c (.80.)   -1.187    0.019  -61.403    0.000   -1.225
##    .Stst22p (.81.)   -1.253    0.022  -58.210    0.000   -1.295
##    .Stst23n (.82.)   -1.085    0.025  -43.483    0.000   -1.134
##    .Stst24x (.83.)   -0.964    0.023  -41.576    0.000   -1.009
##    .Stst31b (.84.)   -1.051    0.023  -45.255    0.000   -1.096
##    .Stst34r (.85.)   -1.232    0.023  -54.004    0.000   -1.277
##    .Stst5mt (.86.)   -0.868    0.020  -43.190    0.000   -0.908
##    .Stst25w (.87.)   -0.806    0.014  -56.442    0.000   -0.834
##    .Stst32r (.88.)   -1.107    0.016  -68.457    0.000   -1.139
##    .Stst33h (.89.)   -0.866    0.017  -51.552    0.000   -0.899
##    .Stst35t (.90.)   -0.790    0.033  -23.802    0.000   -0.855
##    .Stst36c (.91.)    0.002    0.026    0.081    0.935   -0.049
##    .Stst37b (.92.)   -0.259    0.025  -10.171    0.000   -0.309
##    .Stst28m (.93.)   -0.755    0.023  -32.428    0.000   -0.801
##    .Sts292D (.94.)   -0.511    0.022  -23.168    0.000   -0.554
##    .Sts303D (.95.)   -0.657    0.018  -35.709    0.000   -0.693
##    .Stst1vc (.96.)   -1.283    0.022  -58.394    0.000   -1.326
##    .Stst26r (.97.)   -1.265    0.023  -54.000    0.000   -1.311
##     english           1.090    0.079   13.775    0.000    0.935
##     math             -0.268    0.059   -4.510    0.000   -0.385
##     speed             0.313    0.038    8.316    0.000    0.239
##     spatial          -0.773    0.040  -19.150    0.000   -0.852
##     g                 0.007    0.030    0.235    0.814   -0.051
##  ci.upper   Std.lv  Std.all
##    -0.971   -1.005   -1.074
##    -0.797   -0.838   -0.873
##    -1.150   -1.187   -1.217
##    -1.211   -1.253   -1.309
##    -1.036   -1.085   -0.995
##    -0.918   -0.964   -0.885
##    -1.005   -1.051   -0.979
##    -1.188   -1.232   -1.083
##    -0.829   -0.868   -0.863
##    -0.778   -0.806   -1.042
##    -1.075   -1.107   -1.459
##    -0.834   -0.866   -1.230
##    -0.725   -0.790   -0.492
##     0.054    0.002    0.002
##    -0.209   -0.259   -0.227
##    -0.709   -0.755   -1.206
##    -0.468   -0.511   -0.519
##    -0.621   -0.657   -0.847
##    -1.240   -1.283   -1.363
##    -1.219   -1.265   -1.303
##     1.245    1.065    1.065
##    -0.152   -0.288   -0.288
##     0.387    0.318    0.318
##    -0.694   -1.662   -1.662
##     0.065    0.008    0.008
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stst19dsgsdwrd    0.419    0.012   35.147    0.000    0.396
##    .Stest20spellng    0.487    0.015   32.051    0.000    0.458
##    .Stest21cptlztn    0.462    0.013   34.457    0.000    0.435
##    .Stest22puncttn    0.318    0.011   28.516    0.000    0.296
##    .Stest23english    0.556    0.017   32.133    0.000    0.522
##    .Stest24exprssn    0.795    0.022   36.960    0.000    0.753
##    .Stst31bstrctrs    0.653    0.018   37.072    0.000    0.619
##    .Stst34rthcmptt    0.662    0.028   23.751    0.000    0.607
##    .Stest5math        0.622    0.017   35.692    0.000    0.588
##    .Stst25wrdfnctn    0.381    0.010   36.514    0.000    0.360
##    .Stst32rthrsnng    0.300    0.009   33.871    0.000    0.282
##    .Stst33hghschlm    0.161    0.012   13.984    0.000    0.138
##    .Stest35tblrdng    1.370    0.058   23.562    0.000    1.256
##    .Stst36clrclchc    0.915    0.032   28.512    0.000    0.852
##    .Stst37bjctnspc    0.697    0.027   25.534    0.000    0.644
##    .Stst28mchnclrs    0.180    0.009   20.742    0.000    0.163
##    .Stst29vslztn2D    0.743    0.020   36.585    0.000    0.703
##    .Stst30vslztn3D    0.423    0.012   35.119    0.000    0.400
##    .Stest1vocab       0.305    0.010   31.699    0.000    0.286
##    .Stst26rdngcmpr    0.215    0.008   26.673    0.000    0.199
##     english           1.048    0.116    9.026    0.000    0.821
##     math              0.868    0.098    8.847    0.000    0.676
##     speed             0.969    0.059   16.504    0.000    0.854
##     spatial           0.216    0.031    6.952    0.000    0.155
##     g                 0.788    0.032   24.517    0.000    0.725
##  ci.upper   Std.lv  Std.all
##     0.442    0.419    0.478
##     0.517    0.487    0.529
##     0.488    0.462    0.485
##     0.340    0.318    0.347
##     0.590    0.556    0.467
##     0.838    0.795    0.671
##     0.688    0.653    0.567
##     0.717    0.662    0.511
##     0.656    0.622    0.614
##     0.401    0.381    0.636
##     0.317    0.300    0.520
##     0.184    0.161    0.325
##     1.484    1.370    0.531
##     0.978    0.915    0.551
##     0.751    0.697    0.533
##     0.197    0.180    0.460
##     0.783    0.743    0.766
##     0.447    0.423    0.702
##     0.324    0.305    0.344
##     0.231    0.215    0.228
##     1.276    1.000    1.000
##     1.060    1.000    1.000
##     1.084    1.000    1.000
##     0.277    1.000    1.000
##     0.851    1.000    1.000
lavTestScore(scalar, release = 40:59) 
## Warning: lavaan->lavTestScore():  
##    se is not `standard'; not implemented yet; falling back to 
##    ordinary score test
## $test
## 
## total score test:
## 
##    test     X2 df p.value
## 1 score 824.01 20       0
## 
## $uni
## 
## univariate score tests:
## 
##      lhs op    rhs      X2 df p.value
## 1  .p78. == .p180.   0.090  1   0.765
## 2  .p79. == .p181.  14.903  1   0.000
## 3  .p80. == .p182.   0.082  1   0.774
## 4  .p81. == .p183.   1.277  1   0.259
## 5  .p82. == .p184.   0.020  1   0.888
## 6  .p83. == .p185.   2.823  1   0.093
## 7  .p84. == .p186.   8.307  1   0.004
## 8  .p85. == .p187.  68.845  1   0.000
## 9  .p86. == .p188.  13.284  1   0.000
## 10 .p87. == .p189.  70.243  1   0.000
## 11 .p88. == .p190.  26.319  1   0.000
## 12 .p89. == .p191.  38.868  1   0.000
## 13 .p90. == .p192.  15.050  1   0.000
## 14 .p91. == .p193.  11.780  1   0.001
## 15 .p92. == .p194.  31.956  1   0.000
## 16 .p93. == .p195. 419.771  1   0.000
## 17 .p94. == .p196.   0.946  1   0.331
## 18 .p95. == .p197.  73.010  1   0.000
## 19 .p96. == .p198. 177.689  1   0.000
## 20 .p97. == .p199. 106.080  1   0.000
scalar2<-cfa(chc.bifactor.model, data=dgroup, group="sex", meanstructure=TRUE, sampling.weights="BY_WTA", std.lv=T, orthogonal=T, group.equal=c("loadings", "intercepts"), group.partial=c("g=~Stest28mechanicalreasoning", "g=~Stest19disguisedwords", "spatial=~Stest28mechanicalreasoning", "Stest28mechanicalreasoning~1", "Stest1vocab~1"))
fitMeasures(scalar2, c("chisq", "df", "pvalue", "cfi", "rmsea", "srmr", "aic", "bic"))
##      chisq         df     pvalue        cfi      rmsea       srmr 
##   2833.057    343.000      0.000      0.956      0.049      0.042 
##        aic        bic 
## 290712.787 291498.277
Mc(scalar2)
## [1] 0.8149408
summary(scalar2, standardized=T, ci=T) # +.068
## lavaan 0.6-18 ended normally after 106 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                       174
##   Number of equality constraints                    57
## 
##   Number of observations per group:                   
##     0                                             2443
##     1                                             3642
##   Sampling weights variable                     BY_WTA
## 
## Model Test User Model:
##                                               Standard      Scaled
##   Test Statistic                              2833.057    2515.417
##   Degrees of freedom                               343         343
##   P-value (Chi-square)                           0.000       0.000
##   Scaling correction factor                                  1.126
##     Yuan-Bentler correction (Mplus variant)                       
##   Test statistic for each group:
##     0                                         1239.588    1100.607
##     1                                         1593.468    1414.810
## 
## Parameter Estimates:
## 
##   Standard errors                             Sandwich
##   Information bread                           Observed
##   Observed information based on                Hessian
## 
## 
## Group 1 [0]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english =~                                                   
##     Stst19d (.p1.)    0.100    0.014    6.960    0.000    0.072
##     Stst20s (.p2.)    0.342    0.021   15.912    0.000    0.300
##     Stst21c (.p3.)    0.260    0.016   16.639    0.000    0.229
##     Stst22p (.p4.)    0.298    0.017   17.373    0.000    0.264
##     Stst23n (.p5.)    0.307    0.020   15.307    0.000    0.268
##     Stst24x (.p6.)    0.217    0.019   11.188    0.000    0.179
##     Stst31b (.p7.)    0.092    0.018    5.071    0.000    0.056
##     Stst34r (.p8.)    0.224    0.025    9.065    0.000    0.175
##   math =~                                                      
##     Stst5mt (.p9.)    0.283    0.018   16.039    0.000    0.249
##     Stst25w (.10.)    0.136    0.015    9.093    0.000    0.106
##     Stst32r (.11.)    0.220    0.017   12.895    0.000    0.187
##     Stst33h (.12.)    0.327    0.021   15.627    0.000    0.286
##     Stst34r (.13.)    0.280    0.024   11.559    0.000    0.232
##   speed =~                                                     
##     Stst34r (.14.)    0.452    0.020   22.237    0.000    0.412
##     Stst35t (.15.)    0.951    0.032   30.015    0.000    0.889
##     Stst36c (.16.)    0.865    0.024   36.421    0.000    0.818
##     Stst37b (.17.)    0.733    0.022   32.649    0.000    0.689
##   spatial =~                                                   
##     Stst28m           0.385    0.020   19.729    0.000    0.347
##     Sts292D (.19.)    0.519    0.021   24.761    0.000    0.478
##     Sts303D (.20.)    0.472    0.019   24.573    0.000    0.434
##     Stst31b (.21.)    0.447    0.019   23.118    0.000    0.409
##     Stst37b (.22.)    0.280    0.020   14.228    0.000    0.242
##   g =~                                                         
##     Stst1vc (.23.)    0.861    0.016   55.250    0.000    0.830
##     Stst5mt (.24.)    0.641    0.016   41.052    0.000    0.611
##     Stst19d           0.609    0.018   33.974    0.000    0.574
##     Stst20s (.26.)    0.636    0.015   43.507    0.000    0.607
##     Stst21c (.27.)    0.729    0.014   53.314    0.000    0.703
##     Stst22p (.28.)    0.800    0.015   54.207    0.000    0.772
##     Stst23n (.29.)    0.824    0.017   48.617    0.000    0.790
##     Stst24x (.30.)    0.656    0.016   39.866    0.000    0.624
##     Stst25w (.31.)    0.507    0.013   39.540    0.000    0.482
##     Stst26r (.32.)    0.964    0.015   62.301    0.000    0.933
##     Stst28m           0.559    0.018   31.460    0.000    0.524
##     Sts292D (.34.)    0.452    0.015   29.925    0.000    0.423
##     Sts303D (.35.)    0.401    0.013   29.736    0.000    0.375
##     Stst31b (.36.)    0.747    0.016   48.056    0.000    0.716
##     Stst32r (.37.)    0.549    0.014   39.654    0.000    0.522
##     Stst33h (.38.)    0.540    0.013   41.668    0.000    0.515
##     Stst34r (.39.)    0.655    0.017   37.918    0.000    0.621
##     Stst35t (.40.)    0.643    0.023   27.874    0.000    0.598
##     Stst36c (.41.)    0.165    0.019    8.811    0.000    0.128
##     Stst37b (.42.)    0.289    0.018   16.352    0.000    0.255
##  ci.upper   Std.lv  Std.all
##                            
##     0.128    0.100    0.114
##     0.384    0.342    0.337
##     0.290    0.260    0.262
##     0.331    0.298    0.287
##     0.346    0.307    0.259
##     0.255    0.217    0.188
##     0.127    0.092    0.079
##     0.272    0.224    0.193
##                            
##     0.318    0.283    0.276
##     0.165    0.136    0.166
##     0.254    0.220    0.270
##     0.368    0.327    0.425
##     0.327    0.280    0.242
##                            
##     0.492    0.452    0.391
##     1.013    0.951    0.564
##     0.911    0.865    0.667
##     0.777    0.733    0.593
##                            
##     0.423    0.385    0.430
##     0.561    0.519    0.475
##     0.510    0.472    0.514
##     0.485    0.447    0.386
##     0.319    0.280    0.227
##                            
##     0.892    0.861    0.829
##     0.672    0.641    0.626
##     0.644    0.609    0.695
##     0.664    0.636    0.627
##     0.756    0.729    0.737
##     0.829    0.800    0.771
##     0.857    0.824    0.694
##     0.688    0.656    0.568
##     0.533    0.507    0.621
##     0.994    0.964    0.897
##     0.594    0.559    0.625
##     0.482    0.452    0.413
##     0.428    0.401    0.437
##     0.777    0.747    0.645
##     0.576    0.549    0.674
##     0.566    0.540    0.703
##     0.688    0.655    0.566
##     0.689    0.643    0.382
##     0.202    0.165    0.128
##     0.324    0.289    0.234
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english ~~                                                   
##     math              0.000                               0.000
##     speed             0.000                               0.000
##     spatial           0.000                               0.000
##     g                 0.000                               0.000
##   math ~~                                                      
##     speed             0.000                               0.000
##     spatial           0.000                               0.000
##     g                 0.000                               0.000
##   speed ~~                                                     
##     spatial           0.000                               0.000
##     g                 0.000                               0.000
##   spatial ~~                                                   
##     g                 0.000                               0.000
##  ci.upper   Std.lv  Std.all
##                            
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##                            
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##                            
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##                            
##     0.000    0.000    0.000
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stst19d (.78.)   -1.001    0.017  -58.132    0.000   -1.035
##    .Stst20s (.79.)   -0.807    0.021  -38.871    0.000   -0.848
##    .Stst21c (.80.)   -1.166    0.019  -62.854    0.000   -1.202
##    .Stst22p (.81.)   -1.230    0.021  -59.562    0.000   -1.270
##    .Stst23n (.82.)   -1.058    0.024  -44.105    0.000   -1.105
##    .Stst24x (.83.)   -0.943    0.022  -42.784    0.000   -0.986
##    .Stst31b (.84.)   -1.074    0.023  -46.398    0.000   -1.119
##    .Stst34r (.85.)   -1.199    0.023  -51.892    0.000   -1.244
##    .Stst5mt (.86.)   -0.848    0.020  -41.638    0.000   -0.888
##    .Stst25w (.87.)   -0.801    0.014  -56.258    0.000   -0.829
##    .Stst32r (.88.)   -1.091    0.017  -65.583    0.000   -1.124
##    .Stst33h (.89.)   -0.844    0.016  -51.460    0.000   -0.877
##    .Stst35t (.90.)   -0.784    0.033  -24.012    0.000   -0.848
##    .Stst36c (.91.)    0.016    0.026    0.621    0.535   -0.035
##    .Stst37b (.92.)   -0.272    0.025  -10.909    0.000   -0.321
##    .Stst28m          -0.712    0.019  -36.731    0.000   -0.750
##    .Sts292D (.94.)   -0.559    0.022  -25.384    0.000   -0.602
##    .Sts303D (.95.)   -0.696    0.018  -37.764    0.000   -0.732
##    .Stst1vc          -1.151    0.023  -50.235    0.000   -1.196
##    .Stst26r (.97.)   -1.286    0.023  -56.930    0.000   -1.330
##  ci.upper   Std.lv  Std.all
##    -0.967   -1.001   -1.142
##    -0.767   -0.807   -0.796
##    -1.129   -1.166   -1.177
##    -1.189   -1.230   -1.185
##    -1.011   -1.058   -0.891
##    -0.900   -0.943   -0.817
##    -1.029   -1.074   -0.928
##    -1.153   -1.199   -1.037
##    -0.808   -0.848   -0.827
##    -0.773   -0.801   -0.981
##    -1.059   -1.091   -1.340
##    -0.812   -0.844   -1.099
##    -0.720   -0.784   -0.465
##     0.067    0.016    0.013
##    -0.223   -0.272   -0.220
##    -0.674   -0.712   -0.796
##    -0.516   -0.559   -0.510
##    -0.660   -0.696   -0.758
##    -1.106   -1.151   -1.108
##    -1.242   -1.286   -1.197
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stst19dsgsdwrd    0.388    0.014   27.320    0.000    0.360
##    .Stest20spellng    0.507    0.019   26.652    0.000    0.470
##    .Stest21cptlztn    0.381    0.016   24.456    0.000    0.350
##    .Stest22puncttn    0.348    0.013   27.573    0.000    0.323
##    .Stest23english    0.637    0.024   27.000    0.000    0.591
##    .Stest24exprssn    0.854    0.025   33.644    0.000    0.805
##    .Stst31bstrctrs    0.574    0.022   26.424    0.000    0.532
##    .Stst34rthcmptt    0.574    0.030   18.887    0.000    0.515
##    .Stest5math        0.559    0.021   26.135    0.000    0.517
##    .Stst25wrdfnctn    0.391    0.012   31.997    0.000    0.367
##    .Stst32rthrsnng    0.313    0.011   28.427    0.000    0.292
##    .Stst33hghschlm    0.192    0.012   16.043    0.000    0.168
##    .Stest35tblrdng    1.521    0.068   22.440    0.000    1.388
##    .Stst36clrclchc    0.904    0.041   22.110    0.000    0.824
##    .Stst37bjctnspc    0.828    0.035   23.920    0.000    0.760
##    .Stst28mchnclrs    0.339    0.015   22.336    0.000    0.309
##    .Stst29vslztn2D    0.724    0.027   26.744    0.000    0.671
##    .Stst30vslztn3D    0.460    0.018   25.350    0.000    0.424
##    .Stest1vocab       0.337    0.013   26.601    0.000    0.312
##    .Stst26rdngcmpr    0.225    0.011   20.838    0.000    0.204
##     english           1.000                               1.000
##     math              1.000                               1.000
##     speed             1.000                               1.000
##     spatial           1.000                               1.000
##     g                 1.000                               1.000
##  ci.upper   Std.lv  Std.all
##     0.416    0.388    0.505
##     0.545    0.507    0.494
##     0.411    0.381    0.388
##     0.372    0.348    0.323
##     0.683    0.637    0.452
##     0.904    0.854    0.641
##     0.617    0.574    0.429
##     0.634    0.574    0.430
##     0.601    0.559    0.532
##     0.415    0.391    0.587
##     0.335    0.313    0.472
##     0.215    0.192    0.325
##     1.654    1.521    0.536
##     0.984    0.904    0.538
##     0.895    0.828    0.542
##     0.369    0.339    0.424
##     0.777    0.724    0.604
##     0.496    0.460    0.545
##     0.362    0.337    0.313
##     0.246    0.225    0.195
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
## 
## 
## Group 2 [1]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english =~                                                   
##     Stst19d (.p1.)    0.100    0.014    6.960    0.000    0.072
##     Stst20s (.p2.)    0.342    0.021   15.912    0.000    0.300
##     Stst21c (.p3.)    0.260    0.016   16.639    0.000    0.229
##     Stst22p (.p4.)    0.298    0.017   17.373    0.000    0.264
##     Stst23n (.p5.)    0.307    0.020   15.307    0.000    0.268
##     Stst24x (.p6.)    0.217    0.019   11.188    0.000    0.179
##     Stst31b (.p7.)    0.092    0.018    5.071    0.000    0.056
##     Stst34r (.p8.)    0.224    0.025    9.065    0.000    0.175
##   math =~                                                      
##     Stst5mt (.p9.)    0.283    0.018   16.039    0.000    0.249
##     Stst25w (.10.)    0.136    0.015    9.093    0.000    0.106
##     Stst32r (.11.)    0.220    0.017   12.895    0.000    0.187
##     Stst33h (.12.)    0.327    0.021   15.627    0.000    0.286
##     Stst34r (.13.)    0.280    0.024   11.559    0.000    0.232
##   speed =~                                                     
##     Stst34r (.14.)    0.452    0.020   22.237    0.000    0.412
##     Stst35t (.15.)    0.951    0.032   30.015    0.000    0.889
##     Stst36c (.16.)    0.865    0.024   36.421    0.000    0.818
##     Stst37b (.17.)    0.733    0.022   32.649    0.000    0.689
##   spatial =~                                                   
##     Stst28m           0.198    0.018   10.985    0.000    0.162
##     Sts292D (.19.)    0.519    0.021   24.761    0.000    0.478
##     Sts303D (.20.)    0.472    0.019   24.573    0.000    0.434
##     Stst31b (.21.)    0.447    0.019   23.118    0.000    0.409
##     Stst37b (.22.)    0.280    0.020   14.228    0.000    0.242
##   g =~                                                         
##     Stst1vc (.23.)    0.861    0.016   55.250    0.000    0.830
##     Stst5mt (.24.)    0.641    0.016   41.052    0.000    0.611
##     Stst19d           0.752    0.018   41.050    0.000    0.716
##     Stst20s (.26.)    0.636    0.015   43.507    0.000    0.607
##     Stst21c (.27.)    0.729    0.014   53.314    0.000    0.703
##     Stst22p (.28.)    0.800    0.015   54.207    0.000    0.772
##     Stst23n (.29.)    0.824    0.017   48.617    0.000    0.790
##     Stst24x (.30.)    0.656    0.016   39.866    0.000    0.624
##     Stst25w (.31.)    0.507    0.013   39.540    0.000    0.482
##     Stst26r (.32.)    0.964    0.015   62.301    0.000    0.933
##     Stst28m           0.359    0.013   27.497    0.000    0.334
##     Sts292D (.34.)    0.452    0.015   29.925    0.000    0.423
##     Sts303D (.35.)    0.401    0.013   29.736    0.000    0.375
##     Stst31b (.36.)    0.747    0.016   48.056    0.000    0.716
##     Stst32r (.37.)    0.549    0.014   39.654    0.000    0.522
##     Stst33h (.38.)    0.540    0.013   41.668    0.000    0.515
##     Stst34r (.39.)    0.655    0.017   37.918    0.000    0.621
##     Stst35t (.40.)    0.643    0.023   27.874    0.000    0.598
##     Stst36c (.41.)    0.165    0.019    8.811    0.000    0.128
##     Stst37b (.42.)    0.289    0.018   16.352    0.000    0.255
##  ci.upper   Std.lv  Std.all
##                            
##     0.128    0.102    0.109
##     0.384    0.349    0.363
##     0.290    0.265    0.272
##     0.331    0.304    0.317
##     0.346    0.314    0.287
##     0.255    0.222    0.204
##     0.127    0.094    0.087
##     0.272    0.228    0.200
##                            
##     0.318    0.264    0.262
##     0.165    0.126    0.163
##     0.254    0.205    0.270
##     0.368    0.304    0.432
##     0.327    0.260    0.229
##                            
##     0.492    0.445    0.391
##     1.013    0.936    0.583
##     0.911    0.851    0.661
##     0.777    0.721    0.631
##                            
##     0.233    0.163    0.266
##     0.561    0.428    0.430
##     0.510    0.389    0.496
##     0.485    0.368    0.341
##     0.319    0.231    0.202
##                            
##     0.892    0.764    0.814
##     0.672    0.569    0.566
##     0.788    0.668    0.714
##     0.664    0.564    0.587
##     0.756    0.647    0.664
##     0.829    0.710    0.742
##     0.857    0.731    0.670
##     0.688    0.582    0.535
##     0.533    0.450    0.582
##     0.994    0.855    0.881
##     0.385    0.319    0.520
##     0.482    0.401    0.403
##     0.428    0.356    0.453
##     0.777    0.663    0.613
##     0.576    0.487    0.642
##     0.566    0.479    0.681
##     0.688    0.581    0.510
##     0.689    0.571    0.356
##     0.202    0.147    0.114
##     0.324    0.257    0.224
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english ~~                                                   
##     math              0.000                               0.000
##     speed             0.000                               0.000
##     spatial           0.000                               0.000
##     g                 0.000                               0.000
##   math ~~                                                      
##     speed             0.000                               0.000
##     spatial           0.000                               0.000
##     g                 0.000                               0.000
##   speed ~~                                                     
##     spatial           0.000                               0.000
##     g                 0.000                               0.000
##   spatial ~~                                                   
##     g                 0.000                               0.000
##  ci.upper   Std.lv  Std.all
##                            
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##                            
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##                            
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##                            
##     0.000    0.000    0.000
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stst19d (.78.)   -1.001    0.017  -58.132    0.000   -1.035
##    .Stst20s (.79.)   -0.807    0.021  -38.871    0.000   -0.848
##    .Stst21c (.80.)   -1.166    0.019  -62.854    0.000   -1.202
##    .Stst22p (.81.)   -1.230    0.021  -59.562    0.000   -1.270
##    .Stst23n (.82.)   -1.058    0.024  -44.105    0.000   -1.105
##    .Stst24x (.83.)   -0.943    0.022  -42.784    0.000   -0.986
##    .Stst31b (.84.)   -1.074    0.023  -46.398    0.000   -1.119
##    .Stst34r (.85.)   -1.199    0.023  -51.892    0.000   -1.244
##    .Stst5mt (.86.)   -0.848    0.020  -41.638    0.000   -0.888
##    .Stst25w (.87.)   -0.801    0.014  -56.258    0.000   -0.829
##    .Stst32r (.88.)   -1.091    0.017  -65.583    0.000   -1.124
##    .Stst33h (.89.)   -0.844    0.016  -51.460    0.000   -0.877
##    .Stst35t (.90.)   -0.784    0.033  -24.012    0.000   -0.848
##    .Stst36c (.91.)    0.016    0.026    0.621    0.535   -0.035
##    .Stst37b (.92.)   -0.272    0.025  -10.909    0.000   -0.321
##    .Stst28m          -1.210    0.018  -66.111    0.000   -1.246
##    .Sts292D (.94.)   -0.559    0.022  -25.384    0.000   -0.602
##    .Sts303D (.95.)   -0.696    0.018  -37.764    0.000   -0.732
##    .Stst1vc          -1.391    0.023  -59.737    0.000   -1.436
##    .Stst26r (.97.)   -1.286    0.023  -56.930    0.000   -1.330
##     english           0.861    0.069   12.407    0.000    0.725
##     math             -0.453    0.064   -7.098    0.000   -0.578
##     speed             0.279    0.037    7.560    0.000    0.207
##     spatial          -0.683    0.041  -16.552    0.000   -0.764
##     g                 0.061    0.029    2.053    0.040    0.003
##  ci.upper   Std.lv  Std.all
##    -0.967   -1.001   -1.070
##    -0.767   -0.807   -0.840
##    -1.129   -1.166   -1.195
##    -1.189   -1.230   -1.284
##    -1.011   -1.058   -0.970
##    -0.900   -0.943   -0.866
##    -1.029   -1.074   -0.993
##    -1.153   -1.199   -1.052
##    -0.808   -0.848   -0.843
##    -0.773   -0.801   -1.036
##    -1.059   -1.091   -1.438
##    -0.812   -0.844   -1.200
##    -0.720   -0.784   -0.488
##     0.067    0.016    0.013
##    -0.223   -0.272   -0.238
##    -1.174   -1.210   -1.973
##    -0.516   -0.559   -0.561
##    -0.660   -0.696   -0.886
##    -1.345   -1.391   -1.481
##    -1.242   -1.286   -1.325
##     0.997    0.843    0.843
##    -0.328   -0.487   -0.487
##     0.352    0.284    0.284
##    -0.602   -0.828   -0.828
##     0.118    0.068    0.068
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stst19dsgsdwrd    0.419    0.012   35.095    0.000    0.395
##    .Stest20spellng    0.483    0.015   31.148    0.000    0.452
##    .Stest21cptlztn    0.462    0.013   34.337    0.000    0.436
##    .Stest22puncttn    0.320    0.012   27.764    0.000    0.297
##    .Stest23english    0.557    0.017   32.096    0.000    0.523
##    .Stest24exprssn    0.798    0.022   37.076    0.000    0.755
##    .Stst31bstrctrs    0.587    0.017   34.194    0.000    0.553
##    .Stst34rthcmptt    0.642    0.029   22.471    0.000    0.586
##    .Stest5math        0.618    0.017   35.706    0.000    0.585
##    .Stst25wrdfnctn    0.379    0.010   36.636    0.000    0.359
##    .Stst32rthrsnng    0.297    0.009   33.272    0.000    0.279
##    .Stst33hghschlm    0.173    0.010   17.416    0.000    0.154
##    .Stest35tblrdng    1.377    0.058   23.591    0.000    1.263
##    .Stst36clrclchc    0.914    0.032   28.463    0.000    0.851
##    .Stst37bjctnspc    0.669    0.027   24.646    0.000    0.616
##    .Stst28mchnclrs    0.248    0.007   37.673    0.000    0.235
##    .Stst29vslztn2D    0.647    0.021   31.489    0.000    0.607
##    .Stst30vslztn3D    0.339    0.012   28.098    0.000    0.315
##    .Stest1vocab       0.297    0.009   31.818    0.000    0.279
##    .Stst26rdngcmpr    0.211    0.008   26.476    0.000    0.195
##     english           1.043    0.114    9.148    0.000    0.820
##     math              0.865    0.098    8.872    0.000    0.674
##     speed             0.969    0.059   16.453    0.000    0.854
##     spatial           0.680    0.054   12.524    0.000    0.574
##     g                 0.788    0.032   24.571    0.000    0.725
##  ci.upper   Std.lv  Std.all
##     0.442    0.419    0.479
##     0.513    0.483    0.523
##     0.489    0.462    0.486
##     0.343    0.320    0.349
##     0.591    0.557    0.468
##     0.840    0.798    0.672
##     0.620    0.587    0.501
##     0.698    0.642    0.495
##     0.652    0.618    0.611
##     0.400    0.379    0.634
##     0.314    0.297    0.515
##     0.193    0.173    0.350
##     1.491    1.377    0.534
##     0.977    0.914    0.550
##     0.722    0.669    0.511
##     0.261    0.248    0.659
##     0.687    0.647    0.652
##     0.362    0.339    0.549
##     0.316    0.297    0.337
##     0.226    0.211    0.224
##     1.267    1.000    1.000
##     1.056    1.000    1.000
##     1.084    1.000    1.000
##     0.787    1.000    1.000
##     0.851    1.000    1.000
lavTestScore(scalar2, release = 40:57)
## Warning: lavaan->lavTestScore():  
##    se is not `standard'; not implemented yet; falling back to 
##    ordinary score test
## $test
## 
## total score test:
## 
##    test      X2 df p.value
## 1 score 233.876 18       0
## 
## $uni
## 
## univariate score tests:
## 
##      lhs op    rhs     X2 df p.value
## 1  .p78. == .p180.  2.632  1   0.105
## 2  .p79. == .p181. 24.664  1   0.000
## 3  .p80. == .p182.  0.083  1   0.774
## 4  .p81. == .p183.  1.167  1   0.280
## 5  .p82. == .p184.  0.004  1   0.952
## 6  .p83. == .p185.  2.570  1   0.109
## 7  .p84. == .p186.  0.892  1   0.345
## 8  .p85. == .p187. 42.218  1   0.000
## 9  .p86. == .p188. 14.315  1   0.000
## 10 .p87. == .p189. 57.219  1   0.000
## 11 .p88. == .p190. 31.727  1   0.000
## 12 .p89. == .p191. 52.936  1   0.000
## 13 .p90. == .p192. 21.710  1   0.000
## 14 .p91. == .p193. 17.275  1   0.000
## 15 .p92. == .p194. 17.915  1   0.000
## 16 .p94. == .p196. 25.673  1   0.000
## 17 .p95. == .p197. 12.250  1   0.000
## 18 .p97. == .p199.  0.416  1   0.519
strict<-cfa(chc.bifactor.model, data=dgroup, group="sex", meanstructure=TRUE, sampling.weights="BY_WTA", std.lv=T, orthogonal=T, group.equal=c("loadings", "intercepts", "residuals"), group.partial=c("g=~Stest28mechanicalreasoning", "g=~Stest19disguisedwords", "spatial=~Stest28mechanicalreasoning", "Stest28mechanicalreasoning~1", "Stest1vocab~1"))
fitMeasures(strict, c("chisq", "df", "pvalue", "cfi", "rmsea", "srmr", "aic", "bic"))
##      chisq         df     pvalue        cfi      rmsea       srmr 
##   3031.434    363.000      0.000      0.953      0.049      0.043 
##        aic        bic 
## 290871.165 291522.382
Mc(strict)
## [1] 0.8030813
chc.bifactor<-cfa(chc.bifactor.model, data=dgroup, group="sex", meanstructure=TRUE, sampling.weights="BY_WTA", std.lv=T, orthogonal=T, group.equal=c("loadings", "intercepts", "lv.variances"), group.partial=c("g=~Stest28mechanicalreasoning", "g=~Stest19disguisedwords", "spatial=~Stest28mechanicalreasoning", "Stest28mechanicalreasoning~1", "Stest1vocab~1"))
fitMeasures(chc.bifactor, c("chisq", "df", "pvalue", "cfi", "rmsea", "srmr", "aic", "bic"))
##      chisq         df     pvalue        cfi      rmsea       srmr 
##   2896.832    348.000      0.000      0.955      0.049      0.057 
##        aic        bic 
## 290766.563 291518.484
Mc(chc.bifactor)
## [1] 0.8110139
summary(chc.bifactor, standardized=T, ci=T) # +.066
## lavaan 0.6-18 ended normally after 55 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                       169
##   Number of equality constraints                    57
## 
##   Number of observations per group:                   
##     0                                             2443
##     1                                             3642
##   Sampling weights variable                     BY_WTA
## 
## Model Test User Model:
##                                               Standard      Scaled
##   Test Statistic                              2896.832    2569.672
##   Degrees of freedom                               348         348
##   P-value (Chi-square)                           0.000       0.000
##   Scaling correction factor                                  1.127
##     Yuan-Bentler correction (Mplus variant)                       
##   Test statistic for each group:
##     0                                         1281.577    1136.839
##     1                                         1615.256    1432.833
## 
## Parameter Estimates:
## 
##   Standard errors                             Sandwich
##   Information bread                           Observed
##   Observed information based on                Hessian
## 
## 
## Group 1 [0]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english =~                                                   
##     Stst19d (.p1.)    0.101    0.014    7.124    0.000    0.073
##     Stst20s (.p2.)    0.346    0.017   20.516    0.000    0.313
##     Stst21c (.p3.)    0.260    0.014   18.903    0.000    0.233
##     Stst22p (.p4.)    0.299    0.014   20.896    0.000    0.271
##     Stst23n (.p5.)    0.310    0.017   18.365    0.000    0.277
##     Stst24x (.p6.)    0.220    0.018   11.909    0.000    0.184
##     Stst31b (.p7.)    0.091    0.018    4.940    0.000    0.055
##     Stst34r (.p8.)    0.225    0.023    9.655    0.000    0.179
##   math =~                                                      
##     Stst5mt (.p9.)    0.274    0.016   17.091    0.000    0.242
##     Stst25w (.10.)    0.130    0.015    8.972    0.000    0.102
##     Stst32r (.11.)    0.210    0.014   15.539    0.000    0.183
##     Stst33h (.12.)    0.313    0.017   18.053    0.000    0.279
##     Stst34r (.13.)    0.268    0.022   12.340    0.000    0.225
##   speed =~                                                     
##     Stst34r (.14.)    0.448    0.019   23.885    0.000    0.411
##     Stst35t (.15.)    0.942    0.027   35.300    0.000    0.890
##     Stst36c (.16.)    0.856    0.018   48.927    0.000    0.822
##     Stst37b (.17.)    0.726    0.018   40.761    0.000    0.691
##   spatial =~                                                   
##     Stst28m           0.383    0.020   19.367    0.000    0.344
##     Sts292D (.19.)    0.465    0.017   28.146    0.000    0.433
##     Sts303D (.20.)    0.418    0.014   29.607    0.000    0.390
##     Stst31b (.21.)    0.399    0.016   25.532    0.000    0.369
##     Stst37b (.22.)    0.249    0.017   14.799    0.000    0.216
##   g =~                                                         
##     Stst1vc (.23.)    0.803    0.011   73.616    0.000    0.782
##     Stst5mt (.24.)    0.599    0.013   47.210    0.000    0.574
##     Stst19d           0.574    0.016   36.394    0.000    0.543
##     Stst20s (.26.)    0.594    0.012   49.480    0.000    0.571
##     Stst21c (.27.)    0.683    0.011   62.029    0.000    0.662
##     Stst22p (.28.)    0.749    0.011   65.764    0.000    0.726
##     Stst23n (.29.)    0.770    0.013   59.253    0.000    0.744
##     Stst24x (.30.)    0.613    0.013   46.093    0.000    0.587
##     Stst25w (.31.)    0.475    0.011   41.761    0.000    0.452
##     Stst26r (.32.)    0.900    0.010   90.292    0.000    0.880
##     Stst28m           0.527    0.016   33.859    0.000    0.497
##     Sts292D (.34.)    0.424    0.013   31.903    0.000    0.398
##     Sts303D (.35.)    0.375    0.012   32.015    0.000    0.352
##     Stst31b (.36.)    0.700    0.012   56.013    0.000    0.676
##     Stst32r (.37.)    0.513    0.011   45.069    0.000    0.491
##     Stst33h (.38.)    0.505    0.011   47.482    0.000    0.484
##     Stst34r (.39.)    0.613    0.015   42.249    0.000    0.585
##     Stst35t (.40.)    0.602    0.020   29.404    0.000    0.562
##     Stst36c (.41.)    0.154    0.017    8.849    0.000    0.120
##     Stst37b (.42.)    0.272    0.016   16.536    0.000    0.239
##  ci.upper   Std.lv  Std.all
##                            
##     0.128    0.101    0.118
##     0.379    0.346    0.350
##     0.287    0.260    0.272
##     0.328    0.299    0.300
##     0.343    0.310    0.269
##     0.256    0.220    0.194
##     0.127    0.091    0.082
##     0.271    0.225    0.199
##                            
##     0.305    0.274    0.275
##     0.159    0.130    0.164
##     0.236    0.210    0.266
##     0.347    0.313    0.423
##     0.310    0.268    0.237
##                            
##     0.485    0.448    0.397
##     0.994    0.942    0.566
##     0.891    0.856    0.664
##     0.761    0.726    0.593
##                            
##     0.422    0.383    0.441
##     0.497    0.465    0.437
##     0.445    0.418    0.469
##     0.430    0.399    0.358
##     0.282    0.249    0.204
##                            
##     0.825    0.803    0.809
##     0.624    0.599    0.601
##     0.605    0.574    0.673
##     0.618    0.594    0.600
##     0.705    0.683    0.714
##     0.771    0.749    0.750
##     0.795    0.770    0.668
##     0.639    0.613    0.542
##     0.497    0.475    0.597
##     0.919    0.900    0.883
##     0.558    0.527    0.607
##     0.450    0.424    0.398
##     0.398    0.375    0.421
##     0.725    0.700    0.628
##     0.535    0.513    0.651
##     0.526    0.505    0.682
##     0.642    0.613    0.543
##     0.642    0.602    0.362
##     0.188    0.154    0.119
##     0.304    0.272    0.222
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english ~~                                                   
##     math              0.000                               0.000
##     speed             0.000                               0.000
##     spatial           0.000                               0.000
##     g                 0.000                               0.000
##   math ~~                                                      
##     speed             0.000                               0.000
##     spatial           0.000                               0.000
##     g                 0.000                               0.000
##   speed ~~                                                     
##     spatial           0.000                               0.000
##     g                 0.000                               0.000
##   spatial ~~                                                   
##     g                 0.000                               0.000
##  ci.upper   Std.lv  Std.all
##                            
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##                            
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##                            
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##                            
##     0.000    0.000    0.000
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stst19d (.78.)   -1.002    0.017  -58.289    0.000   -1.035
##    .Stst20s (.79.)   -0.809    0.021  -38.981    0.000   -0.849
##    .Stst21c (.80.)   -1.166    0.019  -62.988    0.000   -1.202
##    .Stst22p (.81.)   -1.230    0.021  -59.686    0.000   -1.270
##    .Stst23n (.82.)   -1.059    0.024  -44.206    0.000   -1.106
##    .Stst24x (.83.)   -0.944    0.022  -42.833    0.000   -0.987
##    .Stst31b (.84.)   -1.073    0.023  -46.306    0.000   -1.119
##    .Stst34r (.85.)   -1.199    0.023  -52.114    0.000   -1.244
##    .Stst5mt (.86.)   -0.848    0.020  -41.543    0.000   -0.888
##    .Stst25w (.87.)   -0.802    0.014  -56.284    0.000   -0.830
##    .Stst32r (.88.)   -1.092    0.017  -66.162    0.000   -1.124
##    .Stst33h (.89.)   -0.845    0.016  -51.431    0.000   -0.877
##    .Stst35t (.90.)   -0.784    0.033  -24.055    0.000   -0.848
##    .Stst36c (.91.)    0.016    0.026    0.629    0.529   -0.035
##    .Stst37b (.92.)   -0.272    0.025  -10.895    0.000   -0.321
##    .Stst28m          -0.713    0.019  -36.804    0.000   -0.751
##    .Sts292D (.94.)   -0.558    0.022  -25.348    0.000   -0.602
##    .Sts303D (.95.)   -0.697    0.018  -37.941    0.000   -0.733
##    .Stst1vc          -1.152    0.023  -50.350    0.000   -1.196
##    .Stst26r (.97.)   -1.287    0.023  -57.038    0.000   -1.331
##  ci.upper   Std.lv  Std.all
##    -0.968   -1.002   -1.174
##    -0.768   -0.809   -0.817
##    -1.130   -1.166   -1.219
##    -1.190   -1.230   -1.232
##    -1.012   -1.059   -0.920
##    -0.901   -0.944   -0.835
##    -1.028   -1.073   -0.963
##    -1.154   -1.199   -1.062
##    -0.808   -0.848   -0.850
##    -0.774   -0.802   -1.007
##    -1.060   -1.092   -1.385
##    -0.812   -0.845   -1.140
##    -0.720   -0.784   -0.471
##     0.068    0.016    0.013
##    -0.223   -0.272   -0.222
##    -0.675   -0.713   -0.821
##    -0.515   -0.558   -0.525
##    -0.661   -0.697   -0.783
##    -1.107   -1.152   -1.160
##    -1.243   -1.287   -1.263
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stst19dsgsdwrd    0.388    0.014   27.275    0.000    0.360
##    .Stest20spellng    0.507    0.019   26.876    0.000    0.470
##    .Stest21cptlztn    0.381    0.016   24.461    0.000    0.350
##    .Stest22puncttn    0.347    0.013   27.650    0.000    0.322
##    .Stest23english    0.637    0.024   26.939    0.000    0.591
##    .Stest24exprssn    0.855    0.025   33.654    0.000    0.805
##    .Stst31bstrctrs    0.585    0.022   27.103    0.000    0.542
##    .Stst34rthcmptt    0.576    0.031   18.859    0.000    0.516
##    .Stest5math        0.560    0.021   26.119    0.000    0.518
##    .Stst25wrdfnctn    0.391    0.012   32.022    0.000    0.367
##    .Stst32rthrsnng    0.315    0.011   28.579    0.000    0.293
##    .Stst33hghschlm    0.196    0.012   16.965    0.000    0.173
##    .Stest35tblrdng    1.518    0.068   22.437    0.000    1.386
##    .Stst36clrclchc    0.907    0.040   22.722    0.000    0.829
##    .Stst37bjctnspc    0.835    0.034   24.412    0.000    0.768
##    .Stst28mchnclrs    0.330    0.016   21.155    0.000    0.300
##    .Stst29vslztn2D    0.737    0.026   27.999    0.000    0.685
##    .Stst30vslztn3D    0.478    0.017   27.489    0.000    0.444
##    .Stest1vocab       0.340    0.013   26.798    0.000    0.316
##    .Stst26rdngcmpr    0.229    0.011   21.178    0.000    0.208
##     english           1.000                               1.000
##     math              1.000                               1.000
##     speed             1.000                               1.000
##     spatial           1.000                               1.000
##     g                 1.000                               1.000
##  ci.upper   Std.lv  Std.all
##     0.416    0.388    0.534
##     0.544    0.507    0.517
##     0.411    0.381    0.416
##     0.371    0.347    0.348
##     0.684    0.637    0.481
##     0.905    0.855    0.668
##     0.627    0.585    0.470
##     0.636    0.576    0.452
##     0.602    0.560    0.563
##     0.415    0.391    0.617
##     0.336    0.315    0.506
##     0.218    0.196    0.357
##     1.651    1.518    0.549
##     0.986    0.907    0.545
##     0.902    0.835    0.558
##     0.361    0.330    0.438
##     0.788    0.737    0.650
##     0.513    0.478    0.603
##     0.365    0.340    0.345
##     0.250    0.229    0.221
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
## 
## 
## Group 2 [1]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english =~                                                   
##     Stst19d (.p1.)    0.101    0.014    7.124    0.000    0.073
##     Stst20s (.p2.)    0.346    0.017   20.516    0.000    0.313
##     Stst21c (.p3.)    0.260    0.014   18.903    0.000    0.233
##     Stst22p (.p4.)    0.299    0.014   20.896    0.000    0.271
##     Stst23n (.p5.)    0.310    0.017   18.365    0.000    0.277
##     Stst24x (.p6.)    0.220    0.018   11.909    0.000    0.184
##     Stst31b (.p7.)    0.091    0.018    4.940    0.000    0.055
##     Stst34r (.p8.)    0.225    0.023    9.655    0.000    0.179
##   math =~                                                      
##     Stst5mt (.p9.)    0.274    0.016   17.091    0.000    0.242
##     Stst25w (.10.)    0.130    0.015    8.972    0.000    0.102
##     Stst32r (.11.)    0.210    0.014   15.539    0.000    0.183
##     Stst33h (.12.)    0.313    0.017   18.053    0.000    0.279
##     Stst34r (.13.)    0.268    0.022   12.340    0.000    0.225
##   speed =~                                                     
##     Stst34r (.14.)    0.448    0.019   23.885    0.000    0.411
##     Stst35t (.15.)    0.942    0.027   35.300    0.000    0.890
##     Stst36c (.16.)    0.856    0.018   48.927    0.000    0.822
##     Stst37b (.17.)    0.726    0.018   40.761    0.000    0.691
##   spatial =~                                                   
##     Stst28m           0.164    0.013   12.290    0.000    0.138
##     Sts292D (.19.)    0.465    0.017   28.146    0.000    0.433
##     Sts303D (.20.)    0.418    0.014   29.607    0.000    0.390
##     Stst31b (.21.)    0.399    0.016   25.532    0.000    0.369
##     Stst37b (.22.)    0.249    0.017   14.799    0.000    0.216
##   g =~                                                         
##     Stst1vc (.23.)    0.803    0.011   73.616    0.000    0.782
##     Stst5mt (.24.)    0.599    0.013   47.210    0.000    0.574
##     Stst19d           0.698    0.014   48.918    0.000    0.670
##     Stst20s (.26.)    0.594    0.012   49.480    0.000    0.571
##     Stst21c (.27.)    0.683    0.011   62.029    0.000    0.662
##     Stst22p (.28.)    0.749    0.011   65.764    0.000    0.726
##     Stst23n (.29.)    0.770    0.013   59.253    0.000    0.744
##     Stst24x (.30.)    0.613    0.013   46.093    0.000    0.587
##     Stst25w (.31.)    0.475    0.011   41.761    0.000    0.452
##     Stst26r (.32.)    0.900    0.010   90.292    0.000    0.880
##     Stst28m           0.334    0.012   28.548    0.000    0.311
##     Sts292D (.34.)    0.424    0.013   31.903    0.000    0.398
##     Sts303D (.35.)    0.375    0.012   32.015    0.000    0.352
##     Stst31b (.36.)    0.700    0.012   56.013    0.000    0.676
##     Stst32r (.37.)    0.513    0.011   45.069    0.000    0.491
##     Stst33h (.38.)    0.505    0.011   47.482    0.000    0.484
##     Stst34r (.39.)    0.613    0.015   42.249    0.000    0.585
##     Stst35t (.40.)    0.602    0.020   29.404    0.000    0.562
##     Stst36c (.41.)    0.154    0.017    8.849    0.000    0.120
##     Stst37b (.42.)    0.272    0.016   16.536    0.000    0.239
##  ci.upper   Std.lv  Std.all
##                            
##     0.128    0.101    0.105
##     0.379    0.346    0.354
##     0.287    0.260    0.261
##     0.328    0.299    0.304
##     0.343    0.310    0.278
##     0.256    0.220    0.199
##     0.127    0.091    0.082
##     0.271    0.225    0.194
##                            
##     0.305    0.274    0.267
##     0.159    0.130    0.166
##     0.236    0.210    0.270
##     0.347    0.313    0.433
##     0.310    0.268    0.231
##                            
##     0.485    0.448    0.387
##     0.994    0.942    0.581
##     0.891    0.856    0.663
##     0.761    0.726    0.630
##                            
##     0.190    0.164    0.264
##     0.497    0.465    0.457
##     0.445    0.418    0.519
##     0.430    0.399    0.359
##     0.282    0.249    0.216
##                            
##     0.825    0.803    0.828
##     0.624    0.599    0.584
##     0.726    0.698    0.729
##     0.618    0.594    0.608
##     0.705    0.683    0.684
##     0.771    0.749    0.760
##     0.795    0.770    0.690
##     0.639    0.613    0.555
##     0.497    0.475    0.602
##     0.919    0.900    0.892
##     0.357    0.334    0.536
##     0.450    0.424    0.417
##     0.398    0.375    0.466
##     0.725    0.700    0.629
##     0.535    0.513    0.660
##     0.526    0.505    0.698
##     0.642    0.613    0.530
##     0.642    0.602    0.371
##     0.188    0.154    0.119
##     0.304    0.272    0.236
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english ~~                                                   
##     math              0.000                               0.000
##     speed             0.000                               0.000
##     spatial           0.000                               0.000
##     g                 0.000                               0.000
##   math ~~                                                      
##     speed             0.000                               0.000
##     spatial           0.000                               0.000
##     g                 0.000                               0.000
##   speed ~~                                                     
##     spatial           0.000                               0.000
##     g                 0.000                               0.000
##   spatial ~~                                                   
##     g                 0.000                               0.000
##  ci.upper   Std.lv  Std.all
##                            
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##                            
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##                            
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##                            
##     0.000    0.000    0.000
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stst19d (.78.)   -1.002    0.017  -58.289    0.000   -1.035
##    .Stst20s (.79.)   -0.809    0.021  -38.981    0.000   -0.849
##    .Stst21c (.80.)   -1.166    0.019  -62.988    0.000   -1.202
##    .Stst22p (.81.)   -1.230    0.021  -59.686    0.000   -1.270
##    .Stst23n (.82.)   -1.059    0.024  -44.206    0.000   -1.106
##    .Stst24x (.83.)   -0.944    0.022  -42.833    0.000   -0.987
##    .Stst31b (.84.)   -1.073    0.023  -46.306    0.000   -1.119
##    .Stst34r (.85.)   -1.199    0.023  -52.114    0.000   -1.244
##    .Stst5mt (.86.)   -0.848    0.020  -41.543    0.000   -0.888
##    .Stst25w (.87.)   -0.802    0.014  -56.284    0.000   -0.830
##    .Stst32r (.88.)   -1.092    0.017  -66.162    0.000   -1.124
##    .Stst33h (.89.)   -0.845    0.016  -51.431    0.000   -0.877
##    .Stst35t (.90.)   -0.784    0.033  -24.055    0.000   -0.848
##    .Stst36c (.91.)    0.016    0.026    0.629    0.529   -0.035
##    .Stst37b (.92.)   -0.272    0.025  -10.895    0.000   -0.321
##    .Stst28m          -1.219    0.017  -70.441    0.000   -1.253
##    .Sts292D (.94.)   -0.558    0.022  -25.348    0.000   -0.602
##    .Sts303D (.95.)   -0.697    0.018  -37.941    0.000   -0.733
##    .Stst1vc          -1.392    0.023  -59.831    0.000   -1.437
##    .Stst26r (.97.)   -1.287    0.023  -57.038    0.000   -1.331
##     english           0.854    0.060   14.120    0.000    0.736
##     math             -0.473    0.066   -7.130    0.000   -0.603
##     speed             0.282    0.036    7.890    0.000    0.212
##     spatial          -0.768    0.046  -16.632    0.000   -0.858
##     g                 0.066    0.031    2.114    0.034    0.005
##  ci.upper   Std.lv  Std.all
##    -0.968   -1.002   -1.046
##    -0.768   -0.809   -0.827
##    -1.130   -1.166   -1.168
##    -1.190   -1.230   -1.248
##    -1.012   -1.059   -0.949
##    -0.901   -0.944   -0.854
##    -1.028   -1.073   -0.964
##    -1.154   -1.199   -1.036
##    -0.808   -0.848   -0.827
##    -0.774   -0.802   -1.017
##    -1.060   -1.092   -1.405
##    -0.812   -0.845   -1.167
##    -0.720   -0.784   -0.484
##     0.068    0.016    0.013
##    -0.223   -0.272   -0.236
##    -1.185   -1.219   -1.960
##    -0.515   -0.558   -0.549
##    -0.661   -0.697   -0.866
##    -1.346   -1.392   -1.434
##    -1.243   -1.287   -1.275
##     0.973    0.854    0.854
##    -0.343   -0.473   -0.473
##     0.351    0.282    0.282
##    -0.677   -0.768   -0.768
##     0.127    0.066    0.066
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stst19dsgsdwrd    0.419    0.012   35.135    0.000    0.395
##    .Stest20spellng    0.482    0.015   31.207    0.000    0.452
##    .Stest21cptlztn    0.462    0.013   34.512    0.000    0.436
##    .Stest22puncttn    0.321    0.011   28.055    0.000    0.298
##    .Stest23english    0.557    0.017   32.051    0.000    0.523
##    .Stest24exprssn    0.798    0.022   37.092    0.000    0.755
##    .Stst31bstrctrs    0.581    0.017   33.804    0.000    0.547
##    .Stst34rthcmptt    0.641    0.029   22.383    0.000    0.585
##    .Stest5math        0.617    0.017   35.729    0.000    0.584
##    .Stst25wrdfnctn    0.379    0.010   36.627    0.000    0.359
##    .Stst32rthrsnng    0.297    0.009   33.227    0.000    0.279
##    .Stst33hghschlm    0.171    0.010   17.166    0.000    0.151
##    .Stest35tblrdng    1.376    0.058   23.573    0.000    1.261
##    .Stst36clrclchc    0.913    0.032   28.741    0.000    0.851
##    .Stst37bjctnspc    0.666    0.027   24.600    0.000    0.613
##    .Stst28mchnclrs    0.249    0.007   38.113    0.000    0.236
##    .Stst29vslztn2D    0.639    0.021   30.778    0.000    0.598
##    .Stst30vslztn3D    0.333    0.012   27.185    0.000    0.309
##    .Stest1vocab       0.297    0.009   31.871    0.000    0.278
##    .Stst26rdngcmpr    0.209    0.008   26.374    0.000    0.193
##     english           1.000                               1.000
##     math              1.000                               1.000
##     speed             1.000                               1.000
##     spatial           1.000                               1.000
##     g                 1.000                               1.000
##  ci.upper   Std.lv  Std.all
##     0.442    0.419    0.457
##     0.513    0.482    0.505
##     0.489    0.462    0.464
##     0.343    0.321    0.330
##     0.591    0.557    0.447
##     0.840    0.798    0.653
##     0.615    0.581    0.469
##     0.698    0.641    0.478
##     0.651    0.617    0.587
##     0.399    0.379    0.610
##     0.314    0.297    0.491
##     0.190    0.171    0.326
##     1.490    1.376    0.524
##     0.975    0.913    0.547
##     0.719    0.666    0.501
##     0.262    0.249    0.643
##     0.679    0.639    0.617
##     0.357    0.333    0.514
##     0.315    0.297    0.315
##     0.224    0.209    0.205
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
standardizedSolution(chc.bifactor) # get the correct SEs for standardized solution
##                            lhs op                         rhs group
## 1                      english =~       Stest19disguisedwords     1
## 2                      english =~             Stest20spelling     1
## 3                      english =~       Stest21capitalization     1
## 4                      english =~          Stest22punctuation     1
## 5                      english =~              Stest23english     1
## 6                      english =~           Stest24expression     1
## 7                      english =~    Stest31abstractreasoning     1
## 8                      english =~     Stest34arithcomputation     1
## 9                         math =~                  Stest5math     1
## 10                        math =~        Stest25wordfunctions     1
## 11                        math =~       Stest32arithreasoning     1
## 12                        math =~       Stest33highschoolmath     1
## 13                        math =~     Stest34arithcomputation     1
## 14                       speed =~     Stest34arithcomputation     1
## 15                       speed =~         Stest35tablereading     1
## 16                       speed =~     Stest36clericalchecking     1
## 17                       speed =~     Stest37objectinspection     1
## 18                     spatial =~  Stest28mechanicalreasoning     1
## 19                     spatial =~      Stest29visualization2D     1
## 20                     spatial =~      Stest30visualization3D     1
## 21                     spatial =~    Stest31abstractreasoning     1
## 22                     spatial =~     Stest37objectinspection     1
## 23                           g =~                 Stest1vocab     1
## 24                           g =~                  Stest5math     1
## 25                           g =~       Stest19disguisedwords     1
## 26                           g =~             Stest20spelling     1
## 27                           g =~       Stest21capitalization     1
## 28                           g =~          Stest22punctuation     1
## 29                           g =~              Stest23english     1
## 30                           g =~           Stest24expression     1
## 31                           g =~        Stest25wordfunctions     1
## 32                           g =~ Stest26readingcomprehension     1
## 33                           g =~  Stest28mechanicalreasoning     1
## 34                           g =~      Stest29visualization2D     1
## 35                           g =~      Stest30visualization3D     1
## 36                           g =~    Stest31abstractreasoning     1
## 37                           g =~       Stest32arithreasoning     1
## 38                           g =~       Stest33highschoolmath     1
## 39                           g =~     Stest34arithcomputation     1
## 40                           g =~         Stest35tablereading     1
## 41                           g =~     Stest36clericalchecking     1
## 42                           g =~     Stest37objectinspection     1
## 43       Stest19disguisedwords ~~       Stest19disguisedwords     1
## 44             Stest20spelling ~~             Stest20spelling     1
## 45       Stest21capitalization ~~       Stest21capitalization     1
## 46          Stest22punctuation ~~          Stest22punctuation     1
## 47              Stest23english ~~              Stest23english     1
## 48           Stest24expression ~~           Stest24expression     1
## 49    Stest31abstractreasoning ~~    Stest31abstractreasoning     1
## 50     Stest34arithcomputation ~~     Stest34arithcomputation     1
## 51                  Stest5math ~~                  Stest5math     1
## 52        Stest25wordfunctions ~~        Stest25wordfunctions     1
## 53       Stest32arithreasoning ~~       Stest32arithreasoning     1
## 54       Stest33highschoolmath ~~       Stest33highschoolmath     1
## 55         Stest35tablereading ~~         Stest35tablereading     1
## 56     Stest36clericalchecking ~~     Stest36clericalchecking     1
## 57     Stest37objectinspection ~~     Stest37objectinspection     1
## 58  Stest28mechanicalreasoning ~~  Stest28mechanicalreasoning     1
## 59      Stest29visualization2D ~~      Stest29visualization2D     1
## 60      Stest30visualization3D ~~      Stest30visualization3D     1
## 61                 Stest1vocab ~~                 Stest1vocab     1
## 62 Stest26readingcomprehension ~~ Stest26readingcomprehension     1
## 63                     english ~~                     english     1
## 64                        math ~~                        math     1
## 65                       speed ~~                       speed     1
## 66                     spatial ~~                     spatial     1
## 67                           g ~~                           g     1
## 68                     english ~~                        math     1
## 69                     english ~~                       speed     1
## 70                     english ~~                     spatial     1
## 71                     english ~~                           g     1
## 72                        math ~~                       speed     1
## 73                        math ~~                     spatial     1
## 74                        math ~~                           g     1
## 75                       speed ~~                     spatial     1
## 76                       speed ~~                           g     1
## 77                     spatial ~~                           g     1
## 78       Stest19disguisedwords ~1                                 1
## 79             Stest20spelling ~1                                 1
## 80       Stest21capitalization ~1                                 1
## 81          Stest22punctuation ~1                                 1
## 82              Stest23english ~1                                 1
## 83           Stest24expression ~1                                 1
## 84    Stest31abstractreasoning ~1                                 1
## 85     Stest34arithcomputation ~1                                 1
## 86                  Stest5math ~1                                 1
## 87        Stest25wordfunctions ~1                                 1
## 88       Stest32arithreasoning ~1                                 1
## 89       Stest33highschoolmath ~1                                 1
## 90         Stest35tablereading ~1                                 1
##    label est.std    se       z pvalue ci.lower ci.upper
## 1   .p1.   0.118 0.017   7.033      0    0.085    0.151
## 2   .p2.   0.350 0.017  20.237      0    0.316    0.383
## 3   .p3.   0.272 0.015  18.438      0    0.243    0.301
## 4   .p4.   0.300 0.014  20.927      0    0.272    0.328
## 5   .p5.   0.269 0.014  18.791      0    0.241    0.297
## 6   .p6.   0.194 0.016  11.995      0    0.163    0.226
## 7   .p7.   0.082 0.017   4.946      0    0.049    0.114
## 8   .p8.   0.199 0.021   9.700      0    0.159    0.240
## 9   .p9.   0.275 0.016  16.763      0    0.242    0.307
## 10 .p10.   0.164 0.018   9.063      0    0.128    0.199
## 11 .p11.   0.266 0.017  15.920      0    0.233    0.299
## 12 .p12.   0.423 0.023  18.633      0    0.378    0.467
## 13 .p13.   0.237 0.019  12.388      0    0.200    0.275
## 14 .p14.   0.397 0.015  26.885      0    0.368    0.426
## 15 .p15.   0.566 0.014  39.156      0    0.538    0.595
## 16 .p16.   0.664 0.014  48.467      0    0.637    0.691
## 17 .p17.   0.593 0.014  43.236      0    0.566    0.620
## 18         0.441 0.022  20.027      0    0.398    0.484
## 19 .p19.   0.437 0.016  28.007      0    0.406    0.468
## 20 .p20.   0.469 0.015  30.342      0    0.439    0.499
## 21 .p21.   0.358 0.014  25.427      0    0.331    0.386
## 22 .p22.   0.204 0.014  14.794      0    0.177    0.231
## 23 .p23.   0.809 0.007 110.412      0    0.795    0.823
## 24 .p24.   0.601 0.011  54.158      0    0.579    0.623
## 25         0.673 0.012  54.850      0    0.649    0.697
## 26 .p26.   0.600 0.010  59.735      0    0.581    0.620
## 27 .p27.   0.714 0.009  82.540      0    0.697    0.731
## 28 .p28.   0.750 0.007 101.904      0    0.735    0.764
## 29 .p29.   0.668 0.009  74.511      0    0.651    0.686
## 30 .p30.   0.542 0.011  49.705      0    0.521    0.563
## 31 .p31.   0.597 0.011  55.289      0    0.575    0.618
## 32 .p32.   0.883 0.006 159.300      0    0.872    0.894
## 33         0.607 0.014  43.228      0    0.579    0.634
## 34 .p34.   0.398 0.012  32.263      0    0.374    0.422
## 35 .p35.   0.421 0.012  34.006      0    0.397    0.445
## 36 .p36.   0.628 0.010  63.399      0    0.609    0.648
## 37 .p37.   0.651 0.010  62.031      0    0.630    0.671
## 38 .p38.   0.682 0.009  72.553      0    0.663    0.700
## 39 .p39.   0.543 0.013  43.337      0    0.518    0.568
## 40 .p40.   0.362 0.011  31.776      0    0.339    0.384
## 41 .p41.   0.119 0.013   8.858      0    0.093    0.146
## 42 .p42.   0.222 0.013  16.905      0    0.196    0.248
## 43         0.534 0.016  33.890      0    0.503    0.564
## 44         0.517 0.015  35.543      0    0.489    0.546
## 45         0.416 0.012  33.869      0    0.392    0.440
## 46         0.348 0.011  32.189      0    0.327    0.369
## 47         0.481 0.012  38.977      0    0.456    0.505
## 48         0.668 0.012  54.199      0    0.644    0.693
## 49         0.470 0.013  34.975      0    0.444    0.497
## 50         0.452 0.017  26.349      0    0.418    0.485
## 51         0.563 0.014  39.194      0    0.535    0.592
## 52         0.617 0.013  47.224      0    0.592    0.643
## 53         0.506 0.015  33.700      0    0.476    0.535
## 54         0.357 0.020  17.756      0    0.317    0.396
## 55         0.549 0.017  32.062      0    0.515    0.582
## 56         0.545 0.018  29.624      0    0.509    0.581
## 57         0.558 0.017  32.244      0    0.524    0.591
## 58         0.438 0.019  22.881      0    0.400    0.475
## 59         0.650 0.016  41.263      0    0.619    0.681
## 60         0.603 0.017  36.484      0    0.571    0.635
## 61         0.345 0.012  29.129      0    0.322    0.369
## 62         0.221 0.010  22.549      0    0.201    0.240
## 63         1.000 0.000      NA     NA    1.000    1.000
## 64         1.000 0.000      NA     NA    1.000    1.000
## 65         1.000 0.000      NA     NA    1.000    1.000
## 66         1.000 0.000      NA     NA    1.000    1.000
## 67         1.000 0.000      NA     NA    1.000    1.000
## 68         0.000 0.000      NA     NA    0.000    0.000
## 69         0.000 0.000      NA     NA    0.000    0.000
## 70         0.000 0.000      NA     NA    0.000    0.000
## 71         0.000 0.000      NA     NA    0.000    0.000
## 72         0.000 0.000      NA     NA    0.000    0.000
## 73         0.000 0.000      NA     NA    0.000    0.000
## 74         0.000 0.000      NA     NA    0.000    0.000
## 75         0.000 0.000      NA     NA    0.000    0.000
## 76         0.000 0.000      NA     NA    0.000    0.000
## 77         0.000 0.000      NA     NA    0.000    0.000
## 78 .p78.  -1.174 0.034 -34.763      0   -1.241   -1.108
## 79 .p79.  -0.817 0.024 -34.708      0   -0.863   -0.771
## 80 .p80.  -1.219 0.029 -42.435      0   -1.275   -1.162
## 81 .p81.  -1.232 0.025 -49.133      0   -1.281   -1.183
## 82 .p82.  -0.920 0.022 -42.656      0   -0.962   -0.878
## 83 .p83.  -0.835 0.020 -41.603      0   -0.874   -0.796
## 84 .p84.  -0.963 0.024 -40.625      0   -1.009   -0.916
## 85 .p85.  -1.062 0.029 -36.449      0   -1.119   -1.005
## 86 .p86.  -0.850 0.020 -42.299      0   -0.890   -0.811
## 87 .p87.  -1.007 0.025 -40.427      0   -1.056   -0.959
## 88 .p88.  -1.385 0.032 -43.176      0   -1.447   -1.322
## 89 .p89.  -1.140 0.032 -35.487      0   -1.203   -1.077
## 90 .p90.  -0.471 0.019 -25.165      0   -0.508   -0.435
##  [ reached 'max' / getOption("max.print") -- omitted 114 rows ]
tests<-lavTestLRT(configural, metric2, scalar2, chc.bifactor)
Td=tests[2:4,"Chisq diff"]
Td
## [1] 180.83120 204.16843  53.20924
dfd=tests[2:4,"Df diff"]
dfd
## [1] 34 13  5
lambda<-Td-dfd
ld<-lambda/dfd
G<-2 # number of groups
N<- 2443 + 3642 # sample size
RMSEAD<-sqrt((ld)*G/(N-G))
RMSEAD
## [1] 0.03768129 0.06953324 0.05630361
RMSEA.CI(T=Td[1],df=dfd[1],N=N,G=2)
## [1] 0.03237787 0.04317091
RMSEA.CI(T=Td[2],df=dfd[2],N=N,G=2)
## [1] 0.06129601 0.07809757
RMSEA.CI(T=Td[3],df=dfd[3],N=N,G=2)
## [1] 0.04320978 0.07044331
round(pvals(T=Td[1],df=dfd[1],N=N,G=2),3)
##   RMSEA>0 RMSEA>.01 RMSEA>.05 RMSEA>.06 RMSEA>.08 RMSEA>.10 
##         1         1         0         0         0         0
round(pvals(T=Td[2],df=dfd[2],N=N,G=2),3)
##   RMSEA>0 RMSEA>.01 RMSEA>.05 RMSEA>.06 RMSEA>.08 RMSEA>.10 
##     1.000     1.000     1.000     0.971     0.022     0.000
round(pvals(T=Td[3],df=dfd[3],N=N,G=2),3)
##   RMSEA>0 RMSEA>.01 RMSEA>.05 RMSEA>.06 RMSEA>.08 RMSEA>.10 
##     1.000     1.000     0.797     0.353     0.003     0.000
tests<-lavTestLRT(configural, metric2, scalar)
Td=tests[2:3,"Chisq diff"]
Td
## [1] 180.8312 706.3221
dfd=tests[2:3,"Df diff"]
dfd
## [1] 34 15
lambda<-Td-dfd
ld<-lambda/dfd
G<-2 # number of groups
N<- 2443 + 3642 # sample size
RMSEAD<-sqrt((ld)*G/(N-G))
RMSEAD
## [1] 0.03768129 0.12309791
RMSEA.CI(T=Td[1],df=dfd[1],N=N,G=2)
## [1] 0.03237787 0.04317091
RMSEA.CI(T=Td[2],df=dfd[2],N=N,G=2)
## [1] 0.1154357 0.1309140
round(pvals(T=Td[1],df=dfd[1],N=N,G=2),3)
##   RMSEA>0 RMSEA>.01 RMSEA>.05 RMSEA>.06 RMSEA>.08 RMSEA>.10 
##         1         1         0         0         0         0
round(pvals(T=Td[2],df=dfd[2],N=N,G=2),3)
##   RMSEA>0 RMSEA>.01 RMSEA>.05 RMSEA>.06 RMSEA>.08 RMSEA>.10 
##         1         1         1         1         1         1
tests<-lavTestLRT(configural, metric2, scalar2, strict)
Td=tests[2:4,"Chisq diff"]
Td
## [1] 180.8312 204.1684 165.0430
dfd=tests[2:4,"Df diff"]
dfd
## [1] 34 13 20
lambda<-Td-dfd
ld<-lambda/dfd
G<-2 # number of groups
N<- 2443 + 3642 # sample size
RMSEAD<-sqrt((ld)*G/(N-G))
RMSEAD
## [1] 0.03768129 0.06953324 0.04883031
RMSEA.CI(T=Td[1],df=dfd[1],N=N,G=2)
## [1] 0.03237787 0.04317091
RMSEA.CI(T=Td[2],df=dfd[2],N=N,G=2)
## [1] 0.06129601 0.07809757
RMSEA.CI(T=Td[3],df=dfd[3],N=N,G=2)
## [1] 0.04208516 0.05585526
round(pvals(T=Td[1],df=dfd[1],N=N,G=2),3)
##   RMSEA>0 RMSEA>.01 RMSEA>.05 RMSEA>.06 RMSEA>.08 RMSEA>.10 
##         1         1         0         0         0         0
round(pvals(T=Td[2],df=dfd[2],N=N,G=2),3)
##   RMSEA>0 RMSEA>.01 RMSEA>.05 RMSEA>.06 RMSEA>.08 RMSEA>.10 
##     1.000     1.000     1.000     0.971     0.022     0.000
round(pvals(T=Td[3],df=dfd[3],N=N,G=2),3)
##   RMSEA>0 RMSEA>.01 RMSEA>.05 RMSEA>.06 RMSEA>.08 RMSEA>.10 
##     1.000     1.000     0.405     0.004     0.000     0.000
bf.age <-'
english =~ Stest19disguisedwords + Stest20spelling + Stest21capitalization + Stest22punctuation + Stest23english + Stest24expression + Stest31abstractreasoning + Stest34arithcomputation
math =~ Stest5math + Stest25wordfunctions + Stest32arithreasoning + Stest33highschoolmath + Stest34arithcomputation
speed =~ Stest34arithcomputation + Stest35tablereading + Stest36clericalchecking + Stest37objectinspection
spatial =~ Stest28mechanicalreasoning + Stest29visualization2D + Stest30visualization3D + Stest31abstractreasoning + Stest37objectinspection
g=~ Stest1vocab + Stest5math + Stest19disguisedwords + Stest20spelling + Stest21capitalization + Stest22punctuation + Stest23english + Stest24expression + Stest25wordfunctions + Stest26readingcomprehension + Stest28mechanicalreasoning + Stest29visualization2D + Stest30visualization3D + Stest31abstractreasoning + Stest32arithreasoning + Stest33highschoolmath + Stest34arithcomputation + Stest35tablereading + Stest36clericalchecking + Stest37objectinspection
g ~ age
'

bf.age2 <-'
english =~ Stest19disguisedwords + Stest20spelling + Stest21capitalization + Stest22punctuation + Stest23english + Stest24expression + Stest31abstractreasoning + Stest34arithcomputation
math =~ Stest5math + Stest25wordfunctions + Stest32arithreasoning + Stest33highschoolmath + Stest34arithcomputation
speed =~ Stest34arithcomputation + Stest35tablereading + Stest36clericalchecking + Stest37objectinspection
spatial =~ Stest28mechanicalreasoning + Stest29visualization2D + Stest30visualization3D + Stest31abstractreasoning + Stest37objectinspection
g=~ Stest1vocab + Stest5math + Stest19disguisedwords + Stest20spelling + Stest21capitalization + Stest22punctuation + Stest23english + Stest24expression + Stest25wordfunctions + Stest26readingcomprehension + Stest28mechanicalreasoning + Stest29visualization2D + Stest30visualization3D + Stest31abstractreasoning + Stest32arithreasoning + Stest33highschoolmath + Stest34arithcomputation + Stest35tablereading + Stest36clericalchecking + Stest37objectinspection
g ~ age + age2 
'

sem.age<-sem(bf.age, data=dgroup, group="sex", meanstructure=TRUE, sampling.weights="BY_WTA", std.lv=T, orthogonal=T, group.equal=c("loadings", "intercepts", "lv.variances"), group.partial=c("g=~Stest28mechanicalreasoning", "g=~Stest19disguisedwords", "spatial=~Stest28mechanicalreasoning", "Stest28mechanicalreasoning~1", "Stest1vocab~1"))
fitMeasures(sem.age, c("chisq", "df", "pvalue", "cfi", "rmsea", "srmr", "ecvi", "aic", "bic"))
##      chisq         df     pvalue        cfi      rmsea       srmr 
##   3099.933    386.000      0.000      0.952      0.048      0.055 
##       ecvi        aic        bic 
##      0.547 290766.407 291531.756
Mc(sem.age)
## [1] 0.800084
summary(sem.age, standardized=T, ci=T) 
## lavaan 0.6-18 ended normally after 56 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                       171
##   Number of equality constraints                    57
## 
##   Number of observations per group:                   
##     0                                             2443
##     1                                             3642
##   Sampling weights variable                     BY_WTA
## 
## Model Test User Model:
##                                               Standard      Scaled
##   Test Statistic                              3099.933    2749.649
##   Degrees of freedom                               386         386
##   P-value (Chi-square)                           0.000       0.000
##   Scaling correction factor                                  1.127
##     Yuan-Bentler correction (Mplus variant)                       
##   Test statistic for each group:
##     0                                         1348.770    1196.362
##     1                                         1751.164    1553.287
## 
## Parameter Estimates:
## 
##   Standard errors                             Sandwich
##   Information bread                           Observed
##   Observed information based on                Hessian
## 
## 
## Group 1 [0]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english =~                                                   
##     Stst19d (.p1.)    0.100    0.014    7.120    0.000    0.073
##     Stst20s (.p2.)    0.346    0.017   20.506    0.000    0.313
##     Stst21c (.p3.)    0.260    0.014   18.894    0.000    0.233
##     Stst22p (.p4.)    0.300    0.014   20.889    0.000    0.271
##     Stst23n (.p5.)    0.310    0.017   18.353    0.000    0.277
##     Stst24x (.p6.)    0.220    0.018   11.903    0.000    0.184
##     Stst31b (.p7.)    0.091    0.018    4.934    0.000    0.055
##     Stst34r (.p8.)    0.225    0.023    9.655    0.000    0.179
##   math =~                                                      
##     Stst5mt (.p9.)    0.274    0.016   17.100    0.000    0.243
##     Stst25w (.10.)    0.131    0.015    8.982    0.000    0.102
##     Stst32r (.11.)    0.210    0.014   15.545    0.000    0.184
##     Stst33h (.12.)    0.313    0.017   18.066    0.000    0.279
##     Stst34r (.13.)    0.268    0.022   12.344    0.000    0.225
##   speed =~                                                     
##     Stst34r (.14.)    0.448    0.019   23.885    0.000    0.411
##     Stst35t (.15.)    0.942    0.027   35.299    0.000    0.890
##     Stst36c (.16.)    0.856    0.018   48.925    0.000    0.822
##     Stst37b (.17.)    0.726    0.018   40.762    0.000    0.691
##   spatial =~                                                   
##     Stst28m           0.383    0.020   19.361    0.000    0.344
##     Sts292D (.19.)    0.465    0.017   28.150    0.000    0.433
##     Sts303D (.20.)    0.418    0.014   29.613    0.000    0.390
##     Stst31b (.21.)    0.399    0.016   25.533    0.000    0.369
##     Stst37b (.22.)    0.249    0.017   14.801    0.000    0.216
##   g =~                                                         
##     Stst1vc (.23.)    0.803    0.011   73.502    0.000    0.782
##     Stst5mt (.24.)    0.599    0.013   47.130    0.000    0.574
##     Stst19d           0.574    0.016   36.428    0.000    0.543
##     Stst20s (.26.)    0.594    0.012   49.462    0.000    0.571
##     Stst21c (.27.)    0.683    0.011   62.085    0.000    0.661
##     Stst22p (.28.)    0.748    0.011   65.697    0.000    0.726
##     Stst23n (.29.)    0.769    0.013   59.210    0.000    0.744
##     Stst24x (.30.)    0.613    0.013   46.055    0.000    0.587
##     Stst25w (.31.)    0.475    0.011   41.764    0.000    0.452
##     Stst26r (.32.)    0.899    0.010   90.227    0.000    0.880
##     Stst28m           0.527    0.016   33.832    0.000    0.496
##     Sts292D (.34.)    0.424    0.013   31.865    0.000    0.398
##     Sts303D (.35.)    0.375    0.012   31.989    0.000    0.352
##     Stst31b (.36.)    0.700    0.013   55.965    0.000    0.675
##     Stst32r (.37.)    0.513    0.011   45.038    0.000    0.491
##     Stst33h (.38.)    0.505    0.011   47.401    0.000    0.484
##     Stst34r (.39.)    0.613    0.015   42.233    0.000    0.584
##     Stst35t (.40.)    0.602    0.020   29.403    0.000    0.561
##     Stst36c (.41.)    0.154    0.017    8.854    0.000    0.120
##     Stst37b (.42.)    0.272    0.016   16.532    0.000    0.239
##  ci.upper   Std.lv  Std.all
##                            
##     0.128    0.100    0.118
##     0.379    0.346    0.349
##     0.287    0.260    0.272
##     0.328    0.300    0.300
##     0.343    0.310    0.269
##     0.256    0.220    0.194
##     0.127    0.091    0.082
##     0.271    0.225    0.199
##                            
##     0.305    0.274    0.275
##     0.159    0.131    0.164
##     0.237    0.210    0.266
##     0.347    0.313    0.423
##     0.310    0.268    0.237
##                            
##     0.485    0.448    0.397
##     0.994    0.942    0.566
##     0.891    0.856    0.664
##     0.761    0.726    0.593
##                            
##     0.422    0.383    0.441
##     0.498    0.465    0.437
##     0.445    0.418    0.469
##     0.430    0.399    0.358
##     0.282    0.249    0.204
##                            
##     0.824    0.803    0.809
##     0.624    0.599    0.601
##     0.605    0.574    0.673
##     0.618    0.595    0.601
##     0.705    0.683    0.714
##     0.771    0.749    0.750
##     0.795    0.770    0.669
##     0.639    0.613    0.542
##     0.497    0.475    0.597
##     0.919    0.900    0.883
##     0.557    0.527    0.607
##     0.450    0.424    0.398
##     0.398    0.375    0.421
##     0.724    0.700    0.628
##     0.535    0.513    0.651
##     0.525    0.505    0.682
##     0.641    0.613    0.543
##     0.642    0.602    0.362
##     0.188    0.154    0.119
##     0.304    0.272    0.222
## 
## Regressions:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   g ~                                                          
##     age              -0.024    0.015   -1.579    0.114   -0.054
##  ci.upper   Std.lv  Std.all
##                            
##     0.006   -0.024   -0.035
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english ~~                                                   
##     math              0.000                               0.000
##     speed             0.000                               0.000
##     spatial           0.000                               0.000
##   math ~~                                                      
##     speed             0.000                               0.000
##     spatial           0.000                               0.000
##   speed ~~                                                     
##     spatial           0.000                               0.000
##  ci.upper   Std.lv  Std.all
##                            
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##                            
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##                            
##     0.000    0.000    0.000
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stst19d (.76.)   -1.001    0.017  -58.350    0.000   -1.034
##    .Stst20s (.77.)   -0.808    0.021  -38.964    0.000   -0.849
##    .Stst21c (.78.)   -1.165    0.018  -62.994    0.000   -1.201
##    .Stst22p (.79.)   -1.229    0.021  -59.715    0.000   -1.270
##    .Stst23n (.80.)   -1.059    0.024  -44.200    0.000   -1.106
##    .Stst24x (.81.)   -0.944    0.022  -42.836    0.000   -0.987
##    .Stst31b (.82.)   -1.073    0.023  -46.363    0.000   -1.118
##    .Stst34r (.83.)   -1.199    0.023  -52.172    0.000   -1.244
##    .Stst5mt (.84.)   -0.847    0.020  -41.512    0.000   -0.887
##    .Stst25w (.85.)   -0.801    0.014  -56.288    0.000   -0.829
##    .Stst32r (.86.)   -1.092    0.016  -66.207    0.000   -1.124
##    .Stst33h (.87.)   -0.844    0.016  -51.454    0.000   -0.876
##    .Stst35t (.88.)   -0.783    0.033  -24.054    0.000   -0.847
##    .Stst36c (.89.)    0.017    0.026    0.636    0.525   -0.035
##    .Stst37b (.90.)   -0.272    0.025  -10.889    0.000   -0.320
##    .Stst28m          -0.712    0.019  -36.815    0.000   -0.750
##    .Sts292D (.92.)   -0.558    0.022  -25.340    0.000   -0.601
##    .Sts303D (.93.)   -0.697    0.018  -37.958    0.000   -0.733
##    .Stst1vc          -1.151    0.023  -50.325    0.000   -1.196
##    .Stst26r (.95.)   -1.286    0.023  -57.083    0.000   -1.330
##  ci.upper   Std.lv  Std.all
##    -0.967   -1.001   -1.173
##    -0.767   -0.808   -0.816
##    -1.129   -1.165   -1.218
##    -1.189   -1.229   -1.231
##    -1.012   -1.059   -0.919
##    -0.900   -0.944   -0.834
##    -1.027   -1.073   -0.962
##    -1.154   -1.199   -1.062
##    -0.807   -0.847   -0.850
##    -0.773   -0.801   -1.007
##    -1.059   -1.092   -1.384
##    -0.812   -0.844   -1.139
##    -0.720   -0.783   -0.471
##     0.068    0.017    0.013
##    -0.223   -0.272   -0.222
##    -0.674   -0.712   -0.820
##    -0.515   -0.558   -0.524
##    -0.661   -0.697   -0.782
##    -1.106   -1.151   -1.159
##    -1.242   -1.286   -1.262
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stst19dsgsdwrd    0.388    0.014   27.262    0.000    0.360
##    .Stest20spellng    0.507    0.019   26.873    0.000    0.470
##    .Stest21cptlztn    0.380    0.016   24.464    0.000    0.350
##    .Stest22puncttn    0.347    0.013   27.648    0.000    0.322
##    .Stest23english    0.637    0.024   26.940    0.000    0.591
##    .Stest24exprssn    0.855    0.025   33.654    0.000    0.805
##    .Stst31bstrctrs    0.584    0.022   27.102    0.000    0.542
##    .Stst34rthcmptt    0.576    0.031   18.863    0.000    0.516
##    .Stest5math        0.560    0.021   26.118    0.000    0.518
##    .Stst25wrdfnctn    0.391    0.012   32.024    0.000    0.367
##    .Stst32rthrsnng    0.315    0.011   28.580    0.000    0.293
##    .Stst33hghschlm    0.196    0.012   16.959    0.000    0.173
##    .Stest35tblrdng    1.519    0.068   22.437    0.000    1.386
##    .Stst36clrclchc    0.907    0.040   22.722    0.000    0.829
##    .Stst37bjctnspc    0.835    0.034   24.411    0.000    0.768
##    .Stst28mchnclrs    0.330    0.016   21.156    0.000    0.300
##    .Stst29vslztn2D    0.737    0.026   27.997    0.000    0.685
##    .Stst30vslztn3D    0.478    0.017   27.489    0.000    0.444
##    .Stest1vocab       0.341    0.013   26.804    0.000    0.316
##    .Stst26rdngcmpr    0.229    0.011   21.171    0.000    0.208
##     english           1.000                               1.000
##     math              1.000                               1.000
##     speed             1.000                               1.000
##     spatial           1.000                               1.000
##    .g                 1.000                               1.000
##  ci.upper   Std.lv  Std.all
##     0.416    0.388    0.533
##     0.544    0.507    0.517
##     0.411    0.380    0.416
##     0.371    0.347    0.348
##     0.684    0.637    0.481
##     0.905    0.855    0.668
##     0.627    0.584    0.470
##     0.636    0.576    0.452
##     0.602    0.560    0.563
##     0.415    0.391    0.617
##     0.336    0.315    0.506
##     0.218    0.196    0.356
##     1.651    1.519    0.549
##     0.986    0.907    0.545
##     0.902    0.835    0.558
##     0.361    0.330    0.438
##     0.788    0.737    0.650
##     0.513    0.478    0.603
##     0.365    0.341    0.345
##     0.250    0.229    0.220
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    0.999    0.999
## 
## 
## Group 2 [1]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english =~                                                   
##     Stst19d (.p1.)    0.100    0.014    7.120    0.000    0.073
##     Stst20s (.p2.)    0.346    0.017   20.506    0.000    0.313
##     Stst21c (.p3.)    0.260    0.014   18.894    0.000    0.233
##     Stst22p (.p4.)    0.300    0.014   20.889    0.000    0.271
##     Stst23n (.p5.)    0.310    0.017   18.353    0.000    0.277
##     Stst24x (.p6.)    0.220    0.018   11.903    0.000    0.184
##     Stst31b (.p7.)    0.091    0.018    4.934    0.000    0.055
##     Stst34r (.p8.)    0.225    0.023    9.655    0.000    0.179
##   math =~                                                      
##     Stst5mt (.p9.)    0.274    0.016   17.100    0.000    0.243
##     Stst25w (.10.)    0.131    0.015    8.982    0.000    0.102
##     Stst32r (.11.)    0.210    0.014   15.545    0.000    0.184
##     Stst33h (.12.)    0.313    0.017   18.066    0.000    0.279
##     Stst34r (.13.)    0.268    0.022   12.344    0.000    0.225
##   speed =~                                                     
##     Stst34r (.14.)    0.448    0.019   23.885    0.000    0.411
##     Stst35t (.15.)    0.942    0.027   35.299    0.000    0.890
##     Stst36c (.16.)    0.856    0.018   48.925    0.000    0.822
##     Stst37b (.17.)    0.726    0.018   40.762    0.000    0.691
##   spatial =~                                                   
##     Stst28m           0.164    0.013   12.298    0.000    0.138
##     Sts292D (.19.)    0.465    0.017   28.150    0.000    0.433
##     Sts303D (.20.)    0.418    0.014   29.613    0.000    0.390
##     Stst31b (.21.)    0.399    0.016   25.533    0.000    0.369
##     Stst37b (.22.)    0.249    0.017   14.801    0.000    0.216
##   g =~                                                         
##     Stst1vc (.23.)    0.803    0.011   73.502    0.000    0.782
##     Stst5mt (.24.)    0.599    0.013   47.130    0.000    0.574
##     Stst19d           0.698    0.014   48.889    0.000    0.670
##     Stst20s (.26.)    0.594    0.012   49.462    0.000    0.571
##     Stst21c (.27.)    0.683    0.011   62.085    0.000    0.661
##     Stst22p (.28.)    0.748    0.011   65.697    0.000    0.726
##     Stst23n (.29.)    0.769    0.013   59.210    0.000    0.744
##     Stst24x (.30.)    0.613    0.013   46.055    0.000    0.587
##     Stst25w (.31.)    0.475    0.011   41.764    0.000    0.452
##     Stst26r (.32.)    0.899    0.010   90.227    0.000    0.880
##     Stst28m           0.334    0.012   28.529    0.000    0.311
##     Sts292D (.34.)    0.424    0.013   31.865    0.000    0.398
##     Sts303D (.35.)    0.375    0.012   31.989    0.000    0.352
##     Stst31b (.36.)    0.700    0.013   55.965    0.000    0.675
##     Stst32r (.37.)    0.513    0.011   45.038    0.000    0.491
##     Stst33h (.38.)    0.505    0.011   47.401    0.000    0.484
##     Stst34r (.39.)    0.613    0.015   42.233    0.000    0.584
##     Stst35t (.40.)    0.602    0.020   29.403    0.000    0.561
##     Stst36c (.41.)    0.154    0.017    8.854    0.000    0.120
##     Stst37b (.42.)    0.272    0.016   16.532    0.000    0.239
##  ci.upper   Std.lv  Std.all
##                            
##     0.128    0.100    0.105
##     0.379    0.346    0.354
##     0.287    0.260    0.261
##     0.328    0.300    0.304
##     0.343    0.310    0.278
##     0.256    0.220    0.199
##     0.127    0.091    0.082
##     0.271    0.225    0.194
##                            
##     0.305    0.274    0.267
##     0.159    0.131    0.166
##     0.237    0.210    0.270
##     0.347    0.313    0.433
##     0.310    0.268    0.231
##                            
##     0.485    0.448    0.387
##     0.994    0.942    0.581
##     0.891    0.856    0.663
##     0.761    0.726    0.630
##                            
##     0.191    0.164    0.264
##     0.498    0.465    0.457
##     0.445    0.418    0.519
##     0.430    0.399    0.359
##     0.282    0.249    0.216
##                            
##     0.824    0.803    0.828
##     0.624    0.599    0.584
##     0.726    0.698    0.729
##     0.618    0.594    0.608
##     0.705    0.683    0.684
##     0.771    0.749    0.760
##     0.795    0.770    0.690
##     0.639    0.613    0.555
##     0.497    0.475    0.602
##     0.919    0.900    0.892
##     0.356    0.334    0.536
##     0.450    0.424    0.417
##     0.398    0.375    0.466
##     0.724    0.700    0.629
##     0.535    0.513    0.660
##     0.525    0.505    0.698
##     0.641    0.613    0.529
##     0.642    0.602    0.371
##     0.188    0.154    0.119
##     0.304    0.272    0.236
## 
## Regressions:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   g ~                                                          
##     age               0.016    0.013    1.266    0.206   -0.009
##  ci.upper   Std.lv  Std.all
##                            
##     0.040    0.016    0.021
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english ~~                                                   
##     math              0.000                               0.000
##     speed             0.000                               0.000
##     spatial           0.000                               0.000
##   math ~~                                                      
##     speed             0.000                               0.000
##     spatial           0.000                               0.000
##   speed ~~                                                     
##     spatial           0.000                               0.000
##  ci.upper   Std.lv  Std.all
##                            
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##                            
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##                            
##     0.000    0.000    0.000
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stst19d (.76.)   -1.001    0.017  -58.350    0.000   -1.034
##    .Stst20s (.77.)   -0.808    0.021  -38.964    0.000   -0.849
##    .Stst21c (.78.)   -1.165    0.018  -62.994    0.000   -1.201
##    .Stst22p (.79.)   -1.229    0.021  -59.715    0.000   -1.270
##    .Stst23n (.80.)   -1.059    0.024  -44.200    0.000   -1.106
##    .Stst24x (.81.)   -0.944    0.022  -42.836    0.000   -0.987
##    .Stst31b (.82.)   -1.073    0.023  -46.363    0.000   -1.118
##    .Stst34r (.83.)   -1.199    0.023  -52.172    0.000   -1.244
##    .Stst5mt (.84.)   -0.847    0.020  -41.512    0.000   -0.887
##    .Stst25w (.85.)   -0.801    0.014  -56.288    0.000   -0.829
##    .Stst32r (.86.)   -1.092    0.016  -66.207    0.000   -1.124
##    .Stst33h (.87.)   -0.844    0.016  -51.454    0.000   -0.876
##    .Stst35t (.88.)   -0.783    0.033  -24.054    0.000   -0.847
##    .Stst36c (.89.)    0.017    0.026    0.636    0.525   -0.035
##    .Stst37b (.90.)   -0.272    0.025  -10.889    0.000   -0.320
##    .Stst28m          -1.219    0.017  -70.460    0.000   -1.253
##    .Sts292D (.92.)   -0.558    0.022  -25.340    0.000   -0.601
##    .Sts303D (.93.)   -0.697    0.018  -37.958    0.000   -0.733
##    .Stst1vc          -1.391    0.023  -59.864    0.000   -1.436
##    .Stst26r (.95.)   -1.286    0.023  -57.083    0.000   -1.330
##     english           0.854    0.061   14.117    0.000    0.736
##     math             -0.473    0.066   -7.132    0.000   -0.602
##     speed             0.281    0.036    7.889    0.000    0.212
##     spatial          -0.768    0.046  -16.633    0.000   -0.858
##    .g                 0.069    0.031    2.190    0.029    0.007
##  ci.upper   Std.lv  Std.all
##    -0.967   -1.001   -1.046
##    -0.767   -0.808   -0.827
##    -1.129   -1.165   -1.167
##    -1.189   -1.229   -1.248
##    -1.012   -1.059   -0.948
##    -0.900   -0.944   -0.854
##    -1.027   -1.073   -0.964
##    -1.154   -1.199   -1.035
##    -0.807   -0.847   -0.826
##    -0.773   -0.801   -1.017
##    -1.059   -1.092   -1.404
##    -0.812   -0.844   -1.167
##    -0.720   -0.783   -0.484
##     0.068    0.017    0.013
##    -0.223   -0.272   -0.236
##    -1.185   -1.219   -1.959
##    -0.515   -0.558   -0.548
##    -0.661   -0.697   -0.866
##    -1.345   -1.391   -1.433
##    -1.242   -1.286   -1.275
##     0.973    0.854    0.854
##    -0.343   -0.473   -0.473
##     0.351    0.281    0.281
##    -0.677   -0.768   -0.768
##     0.130    0.069    0.069
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stst19dsgsdwrd    0.419    0.012   35.138    0.000    0.395
##    .Stest20spellng    0.482    0.015   31.208    0.000    0.452
##    .Stest21cptlztn    0.462    0.013   34.514    0.000    0.436
##    .Stest22puncttn    0.321    0.011   28.052    0.000    0.298
##    .Stest23english    0.557    0.017   32.050    0.000    0.523
##    .Stest24exprssn    0.798    0.022   37.092    0.000    0.755
##    .Stst31bstrctrs    0.581    0.017   33.805    0.000    0.547
##    .Stst34rthcmptt    0.641    0.029   22.388    0.000    0.585
##    .Stest5math        0.617    0.017   35.729    0.000    0.583
##    .Stst25wrdfnctn    0.379    0.010   36.627    0.000    0.359
##    .Stst32rthrsnng    0.297    0.009   33.228    0.000    0.279
##    .Stst33hghschlm    0.171    0.010   17.163    0.000    0.151
##    .Stest35tblrdng    1.376    0.058   23.572    0.000    1.261
##    .Stst36clrclchc    0.913    0.032   28.741    0.000    0.851
##    .Stst37bjctnspc    0.666    0.027   24.600    0.000    0.613
##    .Stst28mchnclrs    0.249    0.007   38.111    0.000    0.236
##    .Stst29vslztn2D    0.639    0.021   30.776    0.000    0.598
##    .Stst30vslztn3D    0.333    0.012   27.185    0.000    0.309
##    .Stest1vocab       0.297    0.009   31.878    0.000    0.278
##    .Stst26rdngcmpr    0.209    0.008   26.361    0.000    0.193
##     english           1.000                               1.000
##     math              1.000                               1.000
##     speed             1.000                               1.000
##     spatial           1.000                               1.000
##    .g                 1.000                               1.000
##  ci.upper   Std.lv  Std.all
##     0.442    0.419    0.457
##     0.513    0.482    0.505
##     0.489    0.462    0.464
##     0.343    0.321    0.330
##     0.591    0.557    0.447
##     0.840    0.798    0.653
##     0.615    0.581    0.469
##     0.698    0.641    0.479
##     0.651    0.617    0.587
##     0.399    0.379    0.610
##     0.314    0.297    0.491
##     0.190    0.171    0.326
##     1.490    1.376    0.524
##     0.975    0.913    0.547
##     0.719    0.666    0.501
##     0.262    0.249    0.643
##     0.679    0.639    0.617
##     0.357    0.333    0.514
##     0.315    0.297    0.315
##     0.224    0.209    0.205
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
sem.age2<-sem(bf.age2, data=dgroup, group="sex", meanstructure=TRUE, sampling.weights="BY_WTA", std.lv=T, orthogonal=T, group.equal=c("loadings", "intercepts", "lv.variances"), group.partial=c("g=~Stest28mechanicalreasoning", "g=~Stest19disguisedwords", "spatial=~Stest28mechanicalreasoning", "Stest28mechanicalreasoning~1", "Stest1vocab~1"))
fitMeasures(sem.age2, c("chisq", "df", "pvalue", "cfi", "rmsea", "srmr", "ecvi", "aic", "bic"))
##      chisq         df     pvalue        cfi      rmsea       srmr 
##   3190.849    424.000      0.000      0.952      0.046      0.052 
##       ecvi        aic        bic 
##      0.563 290716.957 291495.733
Mc(sem.age2)
## [1] 0.7966122
summary(sem.age2, standardized=T, ci=T) 
## lavaan 0.6-18 ended normally after 60 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                       173
##   Number of equality constraints                    57
## 
##   Number of observations per group:                   
##     0                                             2443
##     1                                             3642
##   Sampling weights variable                     BY_WTA
## 
## Model Test User Model:
##                                               Standard      Scaled
##   Test Statistic                              3190.849    2834.475
##   Degrees of freedom                               424         424
##   P-value (Chi-square)                           0.000       0.000
##   Scaling correction factor                                  1.126
##     Yuan-Bentler correction (Mplus variant)                       
##   Test statistic for each group:
##     0                                         1396.433    1240.471
##     1                                         1794.416    1594.004
## 
## Parameter Estimates:
## 
##   Standard errors                             Sandwich
##   Information bread                           Observed
##   Observed information based on                Hessian
## 
## 
## Group 1 [0]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english =~                                                   
##     Stst19d (.p1.)    0.105    0.014    7.422    0.000    0.077
##     Stst20s (.p2.)    0.346    0.017   20.590    0.000    0.313
##     Stst21c (.p3.)    0.260    0.014   18.849    0.000    0.233
##     Stst22p (.p4.)    0.299    0.014   20.785    0.000    0.271
##     Stst23n (.p5.)    0.311    0.017   18.374    0.000    0.278
##     Stst24x (.p6.)    0.220    0.019   11.862    0.000    0.183
##     Stst31b (.p7.)    0.091    0.019    4.904    0.000    0.055
##     Stst34r (.p8.)    0.226    0.023    9.689    0.000    0.180
##   math =~                                                      
##     Stst5mt (.p9.)    0.274    0.016   17.083    0.000    0.242
##     Stst25w (.10.)    0.130    0.015    8.952    0.000    0.102
##     Stst32r (.11.)    0.210    0.013   15.578    0.000    0.184
##     Stst33h (.12.)    0.312    0.017   18.022    0.000    0.278
##     Stst34r (.13.)    0.268    0.022   12.362    0.000    0.226
##   speed =~                                                     
##     Stst34r (.14.)    0.448    0.019   23.877    0.000    0.411
##     Stst35t (.15.)    0.942    0.027   35.276    0.000    0.890
##     Stst36c (.16.)    0.856    0.018   48.914    0.000    0.822
##     Stst37b (.17.)    0.726    0.018   40.753    0.000    0.691
##   spatial =~                                                   
##     Stst28m           0.382    0.020   19.320    0.000    0.343
##     Sts292D (.19.)    0.465    0.017   28.161    0.000    0.433
##     Sts303D (.20.)    0.417    0.014   29.614    0.000    0.390
##     Stst31b (.21.)    0.399    0.016   25.526    0.000    0.369
##     Stst37b (.22.)    0.249    0.017   14.788    0.000    0.216
##   g =~                                                         
##     Stst1vc (.23.)    0.799    0.011   73.804    0.000    0.778
##     Stst5mt (.24.)    0.596    0.013   47.356    0.000    0.572
##     Stst19d           0.570    0.016   36.620    0.000    0.539
##     Stst20s (.26.)    0.591    0.012   49.617    0.000    0.568
##     Stst21c (.27.)    0.680    0.011   61.813    0.000    0.658
##     Stst22p (.28.)    0.745    0.011   65.673    0.000    0.722
##     Stst23n (.29.)    0.766    0.013   59.037    0.000    0.740
##     Stst24x (.30.)    0.610    0.013   46.099    0.000    0.584
##     Stst25w (.31.)    0.472    0.011   41.859    0.000    0.450
##     Stst26r (.32.)    0.895    0.010   90.403    0.000    0.876
##     Stst28m           0.525    0.015   34.018    0.000    0.494
##     Sts292D (.34.)    0.422    0.013   31.891    0.000    0.396
##     Sts303D (.35.)    0.373    0.012   31.999    0.000    0.350
##     Stst31b (.36.)    0.697    0.012   56.015    0.000    0.672
##     Stst32r (.37.)    0.511    0.011   45.189    0.000    0.488
##     Stst33h (.38.)    0.502    0.011   47.640    0.000    0.482
##     Stst34r (.39.)    0.610    0.014   42.294    0.000    0.582
##     Stst35t (.40.)    0.599    0.020   29.417    0.000    0.559
##     Stst36c (.41.)    0.153    0.017    8.860    0.000    0.119
##     Stst37b (.42.)    0.271    0.016   16.552    0.000    0.238
##  ci.upper   Std.lv  Std.all
##                            
##     0.133    0.105    0.123
##     0.379    0.346    0.349
##     0.288    0.260    0.272
##     0.327    0.299    0.299
##     0.344    0.311    0.269
##     0.256    0.220    0.194
##     0.127    0.091    0.081
##     0.272    0.226    0.200
##                            
##     0.305    0.274    0.274
##     0.159    0.130    0.163
##     0.237    0.210    0.266
##     0.346    0.312    0.421
##     0.311    0.268    0.237
##                            
##     0.485    0.448    0.396
##     0.994    0.942    0.566
##     0.890    0.856    0.664
##     0.761    0.726    0.593
##                            
##     0.421    0.382    0.439
##     0.497    0.465    0.437
##     0.445    0.417    0.468
##     0.430    0.399    0.358
##     0.282    0.249    0.203
##                            
##     0.821    0.807    0.810
##     0.621    0.602    0.603
##     0.600    0.575    0.673
##     0.615    0.597    0.602
##     0.701    0.686    0.716
##     0.767    0.752    0.751
##     0.791    0.773    0.670
##     0.636    0.616    0.544
##     0.495    0.477    0.598
##     0.915    0.904    0.884
##     0.555    0.530    0.609
##     0.448    0.426    0.400
##     0.396    0.377    0.423
##     0.721    0.703    0.630
##     0.533    0.515    0.652
##     0.523    0.507    0.683
##     0.638    0.616    0.544
##     0.639    0.604    0.363
##     0.187    0.155    0.120
##     0.303    0.273    0.223
## 
## Regressions:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   g ~                                                          
##     age               0.004    0.017    0.269    0.788   -0.028
##     age2             -0.049    0.008   -6.537    0.000   -0.064
##  ci.upper   Std.lv  Std.all
##                            
##     0.037    0.004    0.006
##    -0.035   -0.049   -0.138
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english ~~                                                   
##     math              0.000                               0.000
##     speed             0.000                               0.000
##     spatial           0.000                               0.000
##   math ~~                                                      
##     speed             0.000                               0.000
##     spatial           0.000                               0.000
##   speed ~~                                                     
##     spatial           0.000                               0.000
##  ci.upper   Std.lv  Std.all
##                            
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##                            
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##                            
##     0.000    0.000    0.000
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stst19d (.79.)   -0.940    0.021  -45.446    0.000   -0.980
##    .Stst20s (.80.)   -0.749    0.023  -32.137    0.000   -0.795
##    .Stst21c (.81.)   -1.097    0.022  -49.578    0.000   -1.141
##    .Stst22p (.82.)   -1.155    0.025  -46.471    0.000   -1.204
##    .Stst23n (.83.)   -0.983    0.028  -35.148    0.000   -1.037
##    .Stst24x (.84.)   -0.883    0.025  -35.697    0.000   -0.931
##    .Stst31b (.85.)   -1.003    0.026  -37.859    0.000   -1.055
##    .Stst34r (.86.)   -1.137    0.026  -43.901    0.000   -1.188
##    .Stst5mt (.87.)   -0.787    0.023  -33.562    0.000   -0.833
##    .Stst25w (.88.)   -0.754    0.017  -44.569    0.000   -0.787
##    .Stst32r (.89.)   -1.040    0.020  -53.092    0.000   -1.079
##    .Stst33h (.90.)   -0.794    0.019  -40.702    0.000   -0.832
##    .Stst35t (.91.)   -0.724    0.034  -21.355    0.000   -0.790
##    .Stst36c (.92.)    0.032    0.026    1.222    0.222   -0.019
##    .Stst37b (.93.)   -0.244    0.025   -9.597    0.000   -0.294
##    .Stst28m          -0.660    0.022  -29.817    0.000   -0.703
##    .Sts292D (.95.)   -0.516    0.023  -22.103    0.000   -0.561
##    .Sts303D (.96.)   -0.659    0.020  -33.420    0.000   -0.698
##    .Stst1vc          -1.071    0.027  -39.480    0.000   -1.124
##    .Stst26r (.98.)   -1.198    0.028  -43.181    0.000   -1.252
##  ci.upper   Std.lv  Std.all
##    -0.899   -0.940   -1.100
##    -0.703   -0.749   -0.756
##    -1.054   -1.097   -1.145
##    -1.106   -1.155   -1.154
##    -0.928   -0.983   -0.852
##    -0.834   -0.883   -0.779
##    -0.951   -1.003   -0.898
##    -1.087   -1.137   -1.006
##    -0.741   -0.787   -0.789
##    -0.721   -0.754   -0.946
##    -1.002   -1.040   -1.316
##    -0.755   -0.794   -1.069
##    -0.658   -0.724   -0.435
##     0.083    0.032    0.025
##    -0.194   -0.244   -0.200
##    -0.616   -0.660   -0.758
##    -0.470   -0.516   -0.484
##    -0.621   -0.659   -0.740
##    -1.017   -1.071   -1.075
##    -1.143   -1.198   -1.171
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stst19dsgsdwrd    0.388    0.014   27.282    0.000    0.360
##    .Stest20spellng    0.507    0.019   26.853    0.000    0.470
##    .Stest21cptlztn    0.381    0.016   24.465    0.000    0.350
##    .Stest22puncttn    0.347    0.013   27.663    0.000    0.323
##    .Stest23english    0.638    0.024   26.939    0.000    0.591
##    .Stest24exprssn    0.855    0.025   33.672    0.000    0.805
##    .Stst31bstrctrs    0.585    0.022   27.108    0.000    0.542
##    .Stst34rthcmptt    0.575    0.031   18.848    0.000    0.515
##    .Stest5math        0.560    0.021   26.106    0.000    0.518
##    .Stst25wrdfnctn    0.391    0.012   32.021    0.000    0.367
##    .Stst32rthrsnng    0.315    0.011   28.544    0.000    0.293
##    .Stst33hghschlm    0.196    0.011   17.034    0.000    0.173
##    .Stest35tblrdng    1.518    0.068   22.438    0.000    1.386
##    .Stst36clrclchc    0.907    0.040   22.724    0.000    0.829
##    .Stst37bjctnspc    0.835    0.034   24.412    0.000    0.768
##    .Stst28mchnclrs    0.330    0.016   21.167    0.000    0.300
##    .Stst29vslztn2D    0.736    0.026   27.997    0.000    0.685
##    .Stst30vslztn3D    0.478    0.017   27.490    0.000    0.444
##    .Stest1vocab       0.340    0.013   26.768    0.000    0.315
##    .Stst26rdngcmpr    0.229    0.011   21.214    0.000    0.208
##     english           1.000                               1.000
##     math              1.000                               1.000
##     speed             1.000                               1.000
##     spatial           1.000                               1.000
##    .g                 1.000                               1.000
##  ci.upper   Std.lv  Std.all
##     0.416    0.388    0.532
##     0.544    0.507    0.515
##     0.411    0.381    0.414
##     0.372    0.347    0.347
##     0.684    0.638    0.479
##     0.905    0.855    0.667
##     0.627    0.585    0.469
##     0.635    0.575    0.450
##     0.602    0.560    0.561
##     0.415    0.391    0.615
##     0.336    0.315    0.504
##     0.218    0.196    0.356
##     1.651    1.518    0.548
##     0.986    0.907    0.545
##     0.902    0.835    0.557
##     0.361    0.330    0.436
##     0.788    0.736    0.649
##     0.513    0.478    0.602
##     0.365    0.340    0.343
##     0.251    0.229    0.219
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    0.981    0.981
## 
## 
## Group 2 [1]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english =~                                                   
##     Stst19d (.p1.)    0.105    0.014    7.422    0.000    0.077
##     Stst20s (.p2.)    0.346    0.017   20.590    0.000    0.313
##     Stst21c (.p3.)    0.260    0.014   18.849    0.000    0.233
##     Stst22p (.p4.)    0.299    0.014   20.785    0.000    0.271
##     Stst23n (.p5.)    0.311    0.017   18.374    0.000    0.278
##     Stst24x (.p6.)    0.220    0.019   11.862    0.000    0.183
##     Stst31b (.p7.)    0.091    0.019    4.904    0.000    0.055
##     Stst34r (.p8.)    0.226    0.023    9.689    0.000    0.180
##   math =~                                                      
##     Stst5mt (.p9.)    0.274    0.016   17.083    0.000    0.242
##     Stst25w (.10.)    0.130    0.015    8.952    0.000    0.102
##     Stst32r (.11.)    0.210    0.013   15.578    0.000    0.184
##     Stst33h (.12.)    0.312    0.017   18.022    0.000    0.278
##     Stst34r (.13.)    0.268    0.022   12.362    0.000    0.226
##   speed =~                                                     
##     Stst34r (.14.)    0.448    0.019   23.877    0.000    0.411
##     Stst35t (.15.)    0.942    0.027   35.276    0.000    0.890
##     Stst36c (.16.)    0.856    0.018   48.914    0.000    0.822
##     Stst37b (.17.)    0.726    0.018   40.753    0.000    0.691
##   spatial =~                                                   
##     Stst28m           0.164    0.013   12.299    0.000    0.138
##     Sts292D (.19.)    0.465    0.017   28.161    0.000    0.433
##     Sts303D (.20.)    0.417    0.014   29.614    0.000    0.390
##     Stst31b (.21.)    0.399    0.016   25.526    0.000    0.369
##     Stst37b (.22.)    0.249    0.017   14.788    0.000    0.216
##   g =~                                                         
##     Stst1vc (.23.)    0.799    0.011   73.804    0.000    0.778
##     Stst5mt (.24.)    0.596    0.013   47.356    0.000    0.572
##     Stst19d           0.695    0.014   49.722    0.000    0.668
##     Stst20s (.26.)    0.591    0.012   49.617    0.000    0.568
##     Stst21c (.27.)    0.680    0.011   61.813    0.000    0.658
##     Stst22p (.28.)    0.745    0.011   65.673    0.000    0.722
##     Stst23n (.29.)    0.766    0.013   59.037    0.000    0.740
##     Stst24x (.30.)    0.610    0.013   46.099    0.000    0.584
##     Stst25w (.31.)    0.472    0.011   41.859    0.000    0.450
##     Stst26r (.32.)    0.895    0.010   90.403    0.000    0.876
##     Stst28m           0.332    0.012   28.502    0.000    0.309
##     Sts292D (.34.)    0.422    0.013   31.891    0.000    0.396
##     Sts303D (.35.)    0.373    0.012   31.999    0.000    0.350
##     Stst31b (.36.)    0.697    0.012   56.015    0.000    0.672
##     Stst32r (.37.)    0.511    0.011   45.189    0.000    0.488
##     Stst33h (.38.)    0.502    0.011   47.640    0.000    0.482
##     Stst34r (.39.)    0.610    0.014   42.294    0.000    0.582
##     Stst35t (.40.)    0.599    0.020   29.417    0.000    0.559
##     Stst36c (.41.)    0.153    0.017    8.860    0.000    0.119
##     Stst37b (.42.)    0.271    0.016   16.552    0.000    0.238
##  ci.upper   Std.lv  Std.all
##                            
##     0.133    0.105    0.110
##     0.379    0.346    0.355
##     0.288    0.260    0.261
##     0.327    0.299    0.304
##     0.344    0.311    0.279
##     0.256    0.220    0.199
##     0.127    0.091    0.082
##     0.272    0.226    0.195
##                            
##     0.305    0.274    0.267
##     0.159    0.130    0.165
##     0.237    0.210    0.271
##     0.346    0.312    0.432
##     0.311    0.268    0.232
##                            
##     0.485    0.448    0.387
##     0.994    0.942    0.582
##     0.890    0.856    0.663
##     0.761    0.726    0.630
##                            
##     0.191    0.164    0.264
##     0.497    0.465    0.457
##     0.445    0.417    0.519
##     0.430    0.399    0.359
##     0.282    0.249    0.216
##                            
##     0.821    0.801    0.827
##     0.621    0.598    0.584
##     0.722    0.697    0.728
##     0.615    0.593    0.607
##     0.701    0.681    0.683
##     0.767    0.746    0.759
##     0.791    0.767    0.688
##     0.636    0.611    0.554
##     0.495    0.474    0.601
##     0.915    0.897    0.891
##     0.355    0.333    0.535
##     0.448    0.423    0.416
##     0.396    0.374    0.465
##     0.721    0.698    0.628
##     0.533    0.512    0.659
##     0.523    0.504    0.697
##     0.638    0.611    0.528
##     0.639    0.600    0.371
##     0.187    0.154    0.119
##     0.303    0.271    0.235
## 
## Regressions:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   g ~                                                          
##     age               0.011    0.012    0.878    0.380   -0.013
##     age2             -0.028    0.007   -4.156    0.000   -0.042
##  ci.upper   Std.lv  Std.all
##                            
##     0.035    0.011    0.014
##    -0.015   -0.028   -0.064
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##   english ~~                                                   
##     math              0.000                               0.000
##     speed             0.000                               0.000
##     spatial           0.000                               0.000
##   math ~~                                                      
##     speed             0.000                               0.000
##     spatial           0.000                               0.000
##   speed ~~                                                     
##     spatial           0.000                               0.000
##  ci.upper   Std.lv  Std.all
##                            
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##                            
##     0.000    0.000    0.000
##     0.000    0.000    0.000
##                            
##     0.000    0.000    0.000
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stst19d (.79.)   -0.940    0.021  -45.446    0.000   -0.980
##    .Stst20s (.80.)   -0.749    0.023  -32.137    0.000   -0.795
##    .Stst21c (.81.)   -1.097    0.022  -49.578    0.000   -1.141
##    .Stst22p (.82.)   -1.155    0.025  -46.471    0.000   -1.204
##    .Stst23n (.83.)   -0.983    0.028  -35.148    0.000   -1.037
##    .Stst24x (.84.)   -0.883    0.025  -35.697    0.000   -0.931
##    .Stst31b (.85.)   -1.003    0.026  -37.859    0.000   -1.055
##    .Stst34r (.86.)   -1.137    0.026  -43.901    0.000   -1.188
##    .Stst5mt (.87.)   -0.787    0.023  -33.562    0.000   -0.833
##    .Stst25w (.88.)   -0.754    0.017  -44.569    0.000   -0.787
##    .Stst32r (.89.)   -1.040    0.020  -53.092    0.000   -1.079
##    .Stst33h (.90.)   -0.794    0.019  -40.702    0.000   -0.832
##    .Stst35t (.91.)   -0.724    0.034  -21.355    0.000   -0.790
##    .Stst36c (.92.)    0.032    0.026    1.222    0.222   -0.019
##    .Stst37b (.93.)   -0.244    0.025   -9.597    0.000   -0.294
##    .Stst28m          -1.186    0.018  -64.354    0.000   -1.222
##    .Sts292D (.95.)   -0.516    0.023  -22.103    0.000   -0.561
##    .Sts303D (.96.)   -0.659    0.020  -33.420    0.000   -0.698
##    .Stst1vc          -1.313    0.027  -48.110    0.000   -1.366
##    .Stst26r (.98.)   -1.198    0.028  -43.181    0.000   -1.252
##     english           0.851    0.060   14.079    0.000    0.732
##     math             -0.479    0.067   -7.175    0.000   -0.609
##     speed             0.281    0.036    7.874    0.000    0.211
##     spatial          -0.770    0.046  -16.660    0.000   -0.861
##    .g                 0.021    0.039    0.528    0.597   -0.056
##  ci.upper   Std.lv  Std.all
##    -0.899   -0.940   -0.982
##    -0.703   -0.749   -0.767
##    -1.054   -1.097   -1.101
##    -1.106   -1.155   -1.174
##    -0.928   -0.983   -0.881
##    -0.834   -0.883   -0.799
##    -0.951   -1.003   -0.902
##    -1.087   -1.137   -0.983
##    -0.741   -0.787   -0.769
##    -0.721   -0.754   -0.958
##    -1.002   -1.040   -1.340
##    -0.755   -0.794   -1.098
##    -0.658   -0.724   -0.447
##     0.083    0.032    0.025
##    -0.194   -0.244   -0.212
##    -1.150   -1.186   -1.907
##    -0.470   -0.516   -0.507
##    -0.621   -0.659   -0.820
##    -1.259   -1.313   -1.355
##    -1.143   -1.198   -1.190
##     0.969    0.851    0.851
##    -0.348   -0.479   -0.479
##     0.351    0.281    0.281
##    -0.680   -0.770   -0.770
##     0.097    0.020    0.020
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower
##    .Stst19dsgsdwrd    0.419    0.012   35.157    0.000    0.395
##    .Stest20spellng    0.482    0.015   31.180    0.000    0.452
##    .Stest21cptlztn    0.462    0.013   34.507    0.000    0.436
##    .Stest22puncttn    0.321    0.011   28.072    0.000    0.299
##    .Stest23english    0.557    0.017   32.050    0.000    0.523
##    .Stest24exprssn    0.798    0.022   37.104    0.000    0.756
##    .Stst31bstrctrs    0.581    0.017   33.807    0.000    0.547
##    .Stst34rthcmptt    0.641    0.029   22.336    0.000    0.585
##    .Stest5math        0.617    0.017   35.736    0.000    0.583
##    .Stst25wrdfnctn    0.379    0.010   36.628    0.000    0.359
##    .Stst32rthrsnng    0.297    0.009   33.211    0.000    0.279
##    .Stst33hghschlm    0.171    0.010   17.254    0.000    0.152
##    .Stest35tblrdng    1.376    0.058   23.570    0.000    1.261
##    .Stst36clrclchc    0.913    0.032   28.742    0.000    0.851
##    .Stst37bjctnspc    0.666    0.027   24.596    0.000    0.613
##    .Stst28mchnclrs    0.249    0.007   38.103    0.000    0.236
##    .Stst29vslztn2D    0.639    0.021   30.778    0.000    0.598
##    .Stst30vslztn3D    0.333    0.012   27.195    0.000    0.309
##    .Stest1vocab       0.297    0.009   31.852    0.000    0.278
##    .Stst26rdngcmpr    0.209    0.008   26.343    0.000    0.193
##     english           1.000                               1.000
##     math              1.000                               1.000
##     speed             1.000                               1.000
##     spatial           1.000                               1.000
##    .g                 1.000                               1.000
##  ci.upper   Std.lv  Std.all
##     0.442    0.419    0.457
##     0.512    0.482    0.506
##     0.489    0.462    0.465
##     0.344    0.321    0.332
##     0.591    0.557    0.449
##     0.840    0.798    0.654
##     0.615    0.581    0.470
##     0.697    0.641    0.479
##     0.651    0.617    0.588
##     0.399    0.379    0.611
##     0.314    0.297    0.492
##     0.190    0.171    0.327
##     1.490    1.376    0.524
##     0.975    0.913    0.547
##     0.719    0.666    0.502
##     0.262    0.249    0.644
##     0.679    0.639    0.618
##     0.357    0.333    0.514
##     0.315    0.297    0.316
##     0.224    0.209    0.206
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    1.000    1.000
##     1.000    0.996    0.996