#Reading in the data
library(haven)
## Warning: package 'haven' was built under R version 4.3.3
csek12 <- as.data.frame(read_sav("RegRep_K12 Sex Ed_De-Id Data_Clean_11-24-23.sav"))
#Making variables nominal
csek12$Vote <- factor(csek12$Vote, levels = c(1:3))
csek12$Gender_3cat <- factor(csek12$Gender_3cat, levels = c(1:3))
csek12$Gender_5cat <- factor(csek12$Gender_5cat, levels = c(1:5))
csek12$Race_cat <- factor(csek12$Race_cat, levels = c(1:7))
csek12$SO <- factor(csek12$SO, levels = c(1:6))
csek12$Geo <- factor(csek12$Geo, levels = c(1:4))
csek12$Parent <- factor(csek12$Parent, levels = c(1:3))
#setting "I don't know" responses to NA
csek12$PolAff <- ifelse(csek12$Politic == 8, NA, csek12$Politic)
#setting "I would abstain (not vote)" responses to NA
csek12$Vote1 <- ifelse(csek12$Vote == 3, NA, csek12$Vote)
csek12one.mod4 <- '
CSE =~ Q2_1 + Q2_2 + Q2_3 + Q2_4 + Q2_5 + Q2_6 + Q2_7 + Q2_8 + Q2_9 + Q3_1 + Q3_2 + Q3_3 + Q3_4 + Q3_5 + Q3_6 + Q3_7 + Q3_8 + Q3_9 + Q3_10 + Q4_1 + Q4_2 + Q4_3 + Q4_4 + Q4_5 + Q4_6 + Q4_7 + Q4_8 + Q4_9 + Q4_10 + Q5_1 + Q5_2 + Q5_4 + Q5_5 + Q5_6 + Q5_7 + Q5_8 + Q5_9 + Q5_10 + Q5_11
#covariances
Q2_3 ~~ Q2_4
Q2_3 ~~ Q2_5
Q2_3 ~~ Q5_5
Q2_3 ~~ Q5_6
Q2_4 ~~ Q2_5
Q2_4 ~~ Q5_5
Q2_4 ~~ Q5_6
Q2_5 ~~ Q5_5
Q2_5 ~~ Q5_6
Q5_5 ~~ Q5_6
Q4_4 ~~ Q4_5
Q4_4 ~~ Q4_6
Q4_5 ~~ Q4_6
Q4_7 ~~ Q4_8
Q2_8 ~~ Q2_9
'
csek12one.mod4.fit <- lavaan::cfa(csek12one.mod4, data = csek12, std.lv = TRUE, missing = "FIML", estimator = "MLR")
#invariance testing
##school aged children or not
library(lavaan)
## Warning: package 'lavaan' was built under R version 4.3.3
## This is lavaan 0.6-18
## lavaan is FREE software! Please report any bugs.
library(dplyr)
## Warning: package 'dplyr' was built under R version 4.3.3
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(semTools)
## Warning: package 'semTools' was built under R version 4.3.2
##
## ###############################################################################
## This is semTools 0.5-6
## All users of R (or SEM) are invited to submit functions or ideas for functions.
## ###############################################################################
summarytools::freq(csek12$Parent)
## Frequencies
## csek12$Parent
## Type: Factor
##
## Freq % Valid % Valid Cum. % Total % Total Cum.
## ----------- ------ --------- -------------- --------- --------------
## 1 75 25.17 25.17 25.17 25.17
## 2 66 22.15 47.32 22.15 47.32
## 3 157 52.68 100.00 52.68 100.00
## <NA> 0 0.00 100.00
## Total 298 100.00 100.00 100.00 100.00
csek12.schoolage <- subset(csek12, Parent != 3) #sub-setting to remove participants who do not have children
csek12one.config <- cfa(csek12one.mod4, data = csek12.schoolage, std.lv = TRUE, missing = "FIML", estimator = "MLR", group = "Parent") #configural model
## 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.913808e-14)
## is smaller than zero. This may be a symptom that the model is not
## identified.
summary(csek12one.config, fit.measures = TRUE)
## lavaan 0.6-18 ended normally after 91 iterations
##
## Estimator ML
## Optimization method NLMINB
## Number of model parameters 264
##
## Number of observations per group:
## 1 75
## 2 66
## Number of missing patterns per group:
## 1 1
## 2 1
##
## Model Test User Model:
## Standard Scaled
## Test Statistic 4187.373 3814.119
## Degrees of freedom 1374 1374
## P-value (Chi-square) 0.000 0.000
## Scaling correction factor 1.098
## Yuan-Bentler correction (Mplus variant)
## Test statistic for each group:
## 1 1974.305 1798.320
## 2 2213.068 2015.799
##
## Model Test Baseline Model:
##
## Test statistic 11398.347 9474.474
## Degrees of freedom 1482 1482
## P-value 0.000 0.000
## Scaling correction factor 1.203
##
## User Model versus Baseline Model:
##
## Comparative Fit Index (CFI) 0.716 0.695
## Tucker-Lewis Index (TLI) 0.694 0.671
##
## Robust Comparative Fit Index (CFI) 0.735
## Robust Tucker-Lewis Index (TLI) 0.714
##
## Loglikelihood and Information Criteria:
##
## Loglikelihood user model (H0) -4730.580 -4730.580
## Scaling correction factor 1.911
## for the MLR correction
## Loglikelihood unrestricted model (H1) NA NA
## Scaling correction factor 1.229
## for the MLR correction
##
## Akaike (AIC) 9989.159 9989.159
## Bayesian (BIC) 10767.632 10767.632
## Sample-size adjusted Bayesian (SABIC) 9932.344 9932.344
##
## Root Mean Square Error of Approximation:
##
## RMSEA 0.170 0.159
## 90 Percent confidence interval - lower 0.165 0.153
## 90 Percent confidence interval - upper 0.176 0.164
## P-value H_0: RMSEA <= 0.050 0.000 0.000
## P-value H_0: RMSEA >= 0.080 1.000 1.000
##
## Robust RMSEA 0.163
## 90 Percent confidence interval - lower 0.156
## 90 Percent confidence interval - upper 0.169
## P-value H_0: Robust RMSEA <= 0.050 0.000
## P-value H_0: Robust RMSEA >= 0.080 1.000
##
## Standardized Root Mean Square Residual:
##
## SRMR 0.048 0.048
##
## Parameter Estimates:
##
## Standard errors Sandwich
## Information bread Observed
## Observed information based on Hessian
##
##
## Group 1 [1]:
##
## Latent Variables:
## Estimate Std.Err z-value P(>|z|)
## CSE =~
## Q2_1 0.872 0.129 6.758 0.000
## Q2_2 0.821 0.157 5.237 0.000
## Q2_3 0.977 0.144 6.781 0.000
## Q2_4 0.943 0.137 6.880 0.000
## Q2_5 0.934 0.139 6.697 0.000
## Q2_6 0.929 0.148 6.275 0.000
## Q2_7 0.885 0.144 6.128 0.000
## Q2_8 0.886 0.155 5.707 0.000
## Q2_9 0.781 0.167 4.685 0.000
## Q3_1 0.941 0.139 6.768 0.000
## Q3_2 0.946 0.146 6.490 0.000
## Q3_3 0.823 0.183 4.495 0.000
## Q3_4 0.962 0.139 6.941 0.000
## Q3_5 0.891 0.170 5.233 0.000
## Q3_6 0.910 0.159 5.717 0.000
## Q3_7 0.889 0.141 6.316 0.000
## Q3_8 0.792 0.145 5.480 0.000
## Q3_9 0.876 0.109 8.016 0.000
## Q3_10 0.948 0.139 6.807 0.000
## Q4_1 0.903 0.159 5.691 0.000
## Q4_2 0.972 0.137 7.101 0.000
## Q4_3 0.987 0.150 6.591 0.000
## Q4_4 0.958 0.159 6.022 0.000
## Q4_5 0.976 0.155 6.296 0.000
## Q4_6 1.027 0.137 7.523 0.000
## Q4_7 1.050 0.115 9.136 0.000
## Q4_8 0.902 0.172 5.243 0.000
## Q4_9 0.804 0.170 4.741 0.000
## Q4_10 0.974 0.145 6.725 0.000
## Q5_1 0.990 0.140 7.090 0.000
## Q5_2 1.044 0.138 7.572 0.000
## Q5_4 0.974 0.152 6.398 0.000
## Q5_5 1.005 0.140 7.190 0.000
## Q5_6 0.928 0.168 5.534 0.000
## Q5_7 1.032 0.149 6.943 0.000
## Q5_8 0.879 0.174 5.052 0.000
## Q5_9 0.939 0.169 5.545 0.000
## Q5_10 0.921 0.160 5.758 0.000
## Q5_11 1.023 0.151 6.796 0.000
##
## Covariances:
## Estimate Std.Err z-value P(>|z|)
## .Q2_3 ~~
## .Q2_4 0.009 0.036 0.258 0.796
## .Q2_5 0.049 0.046 1.064 0.287
## .Q5_5 -0.032 0.040 -0.808 0.419
## .Q5_6 0.016 0.029 0.550 0.583
## .Q2_4 ~~
## .Q2_5 0.162 0.066 2.460 0.014
## .Q5_5 -0.053 0.043 -1.230 0.219
## .Q5_6 -0.053 0.028 -1.900 0.057
## .Q2_5 ~~
## .Q5_5 0.133 0.061 2.187 0.029
## .Q5_6 -0.065 0.036 -1.825 0.068
## .Q5_5 ~~
## .Q5_6 -0.038 0.036 -1.067 0.286
## .Q4_4 ~~
## .Q4_5 0.092 0.053 1.724 0.085
## .Q4_6 -0.035 0.039 -0.899 0.369
## .Q4_5 ~~
## .Q4_6 0.067 0.049 1.366 0.172
## .Q4_7 ~~
## .Q4_8 0.000 0.069 0.001 0.999
## .Q2_8 ~~
## .Q2_9 0.114 0.057 2.010 0.044
##
## Intercepts:
## Estimate Std.Err z-value P(>|z|)
## .Q2_1 4.120 0.119 34.565 0.000
## .Q2_2 4.080 0.138 29.511 0.000
## .Q2_3 4.267 0.126 33.984 0.000
## .Q2_4 4.160 0.127 32.873 0.000
## .Q2_5 4.147 0.132 31.515 0.000
## .Q2_6 4.227 0.130 32.498 0.000
## .Q2_7 4.307 0.122 35.253 0.000
## .Q2_8 4.253 0.118 36.076 0.000
## .Q2_9 4.400 0.110 40.018 0.000
## .Q3_1 4.173 0.128 32.501 0.000
## .Q3_2 4.280 0.123 34.793 0.000
## .Q3_3 4.360 0.114 38.199 0.000
## .Q3_4 4.240 0.129 32.855 0.000
## .Q3_5 4.360 0.120 36.271 0.000
## .Q3_6 4.333 0.127 34.132 0.000
## .Q3_7 3.960 0.145 27.240 0.000
## .Q3_8 3.773 0.157 23.991 0.000
## .Q3_9 3.480 0.175 19.860 0.000
## .Q3_10 4.120 0.132 31.226 0.000
## .Q4_1 4.333 0.121 35.745 0.000
## .Q4_2 4.200 0.126 33.204 0.000
## .Q4_3 4.373 0.122 35.885 0.000
## .Q4_4 4.400 0.124 35.585 0.000
## .Q4_5 4.400 0.129 34.037 0.000
## .Q4_6 4.293 0.130 32.942 0.000
## .Q4_7 4.000 0.152 26.312 0.000
## .Q4_8 4.427 0.128 34.548 0.000
## .Q4_9 4.187 0.130 32.150 0.000
## .Q4_10 4.293 0.125 34.414 0.000
## .Q5_1 4.227 0.133 31.836 0.000
## .Q5_2 4.240 0.140 30.364 0.000
## .Q5_4 4.387 0.122 35.943 0.000
## .Q5_5 4.240 0.138 30.645 0.000
## .Q5_6 4.440 0.117 38.078 0.000
## .Q5_7 4.347 0.130 33.449 0.000
## .Q5_8 4.373 0.128 34.281 0.000
## .Q5_9 4.467 0.121 36.845 0.000
## .Q5_10 4.320 0.124 34.873 0.000
## .Q5_11 4.347 0.134 32.440 0.000
##
## Variances:
## Estimate Std.Err z-value P(>|z|)
## .Q2_1 0.305 0.073 4.158 0.000
## .Q2_2 0.760 0.232 3.271 0.001
## .Q2_3 0.228 0.051 4.452 0.000
## .Q2_4 0.311 0.069 4.477 0.000
## .Q2_5 0.426 0.095 4.477 0.000
## .Q2_6 0.405 0.105 3.861 0.000
## .Q2_7 0.336 0.082 4.070 0.000
## .Q2_8 0.258 0.060 4.332 0.000
## .Q2_9 0.297 0.071 4.204 0.000
## .Q3_1 0.352 0.194 1.812 0.070
## .Q3_2 0.240 0.082 2.922 0.003
## .Q3_3 0.299 0.165 1.820 0.069
## .Q3_4 0.323 0.103 3.143 0.002
## .Q3_5 0.291 0.104 2.792 0.005
## .Q3_6 0.382 0.132 2.899 0.004
## .Q3_7 0.794 0.226 3.518 0.000
## .Q3_8 1.228 0.243 5.045 0.000
## .Q3_9 1.536 0.251 6.121 0.000
## .Q3_10 0.408 0.189 2.151 0.032
## .Q4_1 0.287 0.125 2.303 0.021
## .Q4_2 0.255 0.072 3.547 0.000
## .Q4_3 0.139 0.037 3.812 0.000
## .Q4_4 0.228 0.066 3.459 0.001
## .Q4_5 0.302 0.082 3.663 0.000
## .Q4_6 0.219 0.066 3.326 0.001
## .Q4_7 0.631 0.179 3.519 0.000
## .Q4_8 0.418 0.097 4.323 0.000
## .Q4_9 0.626 0.194 3.225 0.001
## .Q4_10 0.219 0.115 1.901 0.057
## .Q5_1 0.342 0.122 2.810 0.005
## .Q5_2 0.373 0.152 2.460 0.014
## .Q5_4 0.168 0.047 3.582 0.000
## .Q5_5 0.426 0.196 2.177 0.030
## .Q5_6 0.158 0.032 4.934 0.000
## .Q5_7 0.201 0.051 3.957 0.000
## .Q5_8 0.448 0.199 2.249 0.024
## .Q5_9 0.220 0.043 5.110 0.000
## .Q5_10 0.302 0.088 3.415 0.001
## .Q5_11 0.300 0.129 2.323 0.020
## CSE 1.000
##
##
## Group 2 [2]:
##
## Latent Variables:
## Estimate Std.Err z-value P(>|z|)
## CSE =~
## Q2_1 0.985 0.124 7.939 0.000
## Q2_2 0.886 0.132 6.734 0.000
## Q2_3 0.819 0.119 6.882 0.000
## Q2_4 1.014 0.122 8.302 0.000
## Q2_5 0.898 0.154 5.850 0.000
## Q2_6 1.018 0.142 7.173 0.000
## Q2_7 0.742 0.147 5.035 0.000
## Q2_8 0.883 0.138 6.404 0.000
## Q2_9 0.765 0.134 5.691 0.000
## Q3_1 1.087 0.121 8.993 0.000
## Q3_2 1.065 0.132 8.064 0.000
## Q3_3 0.819 0.155 5.298 0.000
## Q3_4 1.099 0.134 8.232 0.000
## Q3_5 0.907 0.146 6.223 0.000
## Q3_6 0.926 0.137 6.770 0.000
## Q3_7 1.100 0.122 8.978 0.000
## Q3_8 1.122 0.120 9.316 0.000
## Q3_9 1.103 0.111 9.896 0.000
## Q3_10 1.025 0.108 9.492 0.000
## Q4_1 1.050 0.132 7.946 0.000
## Q4_2 1.088 0.124 8.745 0.000
## Q4_3 1.041 0.118 8.796 0.000
## Q4_4 0.972 0.149 6.499 0.000
## Q4_5 0.852 0.154 5.518 0.000
## Q4_6 1.008 0.145 6.938 0.000
## Q4_7 1.058 0.123 8.582 0.000
## Q4_8 0.994 0.160 6.205 0.000
## Q4_9 0.566 0.157 3.600 0.000
## Q4_10 0.923 0.147 6.264 0.000
## Q5_1 0.971 0.130 7.454 0.000
## Q5_2 0.974 0.136 7.180 0.000
## Q5_4 0.994 0.141 7.064 0.000
## Q5_5 0.824 0.159 5.171 0.000
## Q5_6 0.782 0.143 5.468 0.000
## Q5_7 1.077 0.138 7.805 0.000
## Q5_8 0.721 0.188 3.826 0.000
## Q5_9 0.811 0.130 6.235 0.000
## Q5_10 0.726 0.140 5.177 0.000
## Q5_11 1.023 0.148 6.904 0.000
##
## Covariances:
## Estimate Std.Err z-value P(>|z|)
## .Q2_3 ~~
## .Q2_4 0.170 0.124 1.368 0.171
## .Q2_5 0.052 0.063 0.825 0.409
## .Q5_5 -0.028 0.040 -0.717 0.473
## .Q5_6 -0.019 0.046 -0.415 0.678
## .Q2_4 ~~
## .Q2_5 0.170 0.073 2.334 0.020
## .Q5_5 -0.030 0.032 -0.932 0.351
## .Q5_6 -0.039 0.037 -1.076 0.282
## .Q2_5 ~~
## .Q5_5 -0.045 0.063 -0.712 0.477
## .Q5_6 -0.072 0.042 -1.723 0.085
## .Q5_5 ~~
## .Q5_6 0.019 0.051 0.380 0.704
## .Q4_4 ~~
## .Q4_5 0.073 0.052 1.401 0.161
## .Q4_6 0.106 0.048 2.228 0.026
## .Q4_5 ~~
## .Q4_6 0.079 0.052 1.525 0.127
## .Q4_7 ~~
## .Q4_8 0.049 0.070 0.698 0.485
## .Q2_8 ~~
## .Q2_9 0.089 0.057 1.561 0.119
##
## Intercepts:
## Estimate Std.Err z-value P(>|z|)
## .Q2_1 4.076 0.146 27.951 0.000
## .Q2_2 3.985 0.145 27.572 0.000
## .Q2_3 4.333 0.124 35.028 0.000
## .Q2_4 4.136 0.142 29.140 0.000
## .Q2_5 4.182 0.135 30.893 0.000
## .Q2_6 4.258 0.136 31.295 0.000
## .Q2_7 4.424 0.109 40.446 0.000
## .Q2_8 4.197 0.125 33.483 0.000
## .Q2_9 4.348 0.112 38.704 0.000
## .Q3_1 4.167 0.143 29.123 0.000
## .Q3_2 4.227 0.142 29.811 0.000
## .Q3_3 4.409 0.115 38.225 0.000
## .Q3_4 4.258 0.141 30.192 0.000
## .Q3_5 4.394 0.121 36.319 0.000
## .Q3_6 4.288 0.130 33.003 0.000
## .Q3_7 4.106 0.156 26.290 0.000
## .Q3_8 3.924 0.178 21.998 0.000
## .Q3_9 3.576 0.181 19.796 0.000
## .Q3_10 4.061 0.144 28.288 0.000
## .Q4_1 4.242 0.136 31.281 0.000
## .Q4_2 4.197 0.142 29.455 0.000
## .Q4_3 4.273 0.133 32.118 0.000
## .Q4_4 4.318 0.131 33.060 0.000
## .Q4_5 4.455 0.122 36.646 0.000
## .Q4_6 4.303 0.135 31.764 0.000
## .Q4_7 4.015 0.151 26.636 0.000
## .Q4_8 4.394 0.139 31.687 0.000
## .Q4_9 4.167 0.126 33.066 0.000
## .Q4_10 4.379 0.123 35.701 0.000
## .Q5_1 4.212 0.131 32.094 0.000
## .Q5_2 4.212 0.145 29.137 0.000
## .Q5_4 4.379 0.128 34.171 0.000
## .Q5_5 4.424 0.116 38.301 0.000
## .Q5_6 4.364 0.119 36.792 0.000
## .Q5_7 4.288 0.143 29.909 0.000
## .Q5_8 4.394 0.134 32.887 0.000
## .Q5_9 4.439 0.112 39.777 0.000
## .Q5_10 4.273 0.120 35.503 0.000
## .Q5_11 4.364 0.135 32.347 0.000
##
## Variances:
## Estimate Std.Err z-value P(>|z|)
## .Q2_1 0.432 0.118 3.666 0.000
## .Q2_2 0.593 0.114 5.189 0.000
## .Q2_3 0.339 0.135 2.512 0.012
## .Q2_4 0.302 0.125 2.424 0.015
## .Q2_5 0.402 0.109 3.684 0.000
## .Q2_6 0.184 0.049 3.798 0.000
## .Q2_7 0.240 0.076 3.173 0.002
## .Q2_8 0.258 0.069 3.746 0.000
## .Q2_9 0.247 0.068 3.648 0.000
## .Q3_1 0.169 0.051 3.299 0.001
## .Q3_2 0.193 0.074 2.592 0.010
## .Q3_3 0.207 0.076 2.734 0.006
## .Q3_4 0.104 0.051 2.029 0.042
## .Q3_5 0.143 0.058 2.459 0.014
## .Q3_6 0.256 0.076 3.354 0.001
## .Q3_7 0.400 0.136 2.954 0.003
## .Q3_8 0.841 0.246 3.415 0.001
## .Q3_9 0.937 0.183 5.118 0.000
## .Q3_10 0.310 0.091 3.389 0.001
## .Q4_1 0.111 0.058 1.933 0.053
## .Q4_2 0.157 0.044 3.588 0.000
## .Q4_3 0.083 0.038 2.210 0.027
## .Q4_4 0.182 0.076 2.400 0.016
## .Q4_5 0.249 0.065 3.804 0.000
## .Q4_6 0.196 0.068 2.875 0.004
## .Q4_7 0.380 0.089 4.252 0.000
## .Q4_8 0.282 0.094 3.006 0.003
## .Q4_9 0.728 0.132 5.504 0.000
## .Q4_10 0.141 0.059 2.407 0.016
## .Q5_1 0.193 0.072 2.698 0.007
## .Q5_2 0.431 0.117 3.670 0.000
## .Q5_4 0.097 0.033 2.967 0.003
## .Q5_5 0.201 0.061 3.296 0.001
## .Q5_6 0.317 0.114 2.792 0.005
## .Q5_7 0.196 0.064 3.046 0.002
## .Q5_8 0.659 0.241 2.733 0.006
## .Q5_9 0.164 0.050 3.290 0.001
## .Q5_10 0.429 0.107 3.995 0.000
## .Q5_11 0.156 0.051 3.065 0.002
## CSE 1.000
csek12one.metric <- cfa(csek12one.mod4, data = csek12.schoolage, std.lv = TRUE, missing = "FIML", estimator = "MLR", group = "Parent", group.equal = "loadings") #metric model
## 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.243378e-17)
## is smaller than zero. This may be a symptom that the model is not
## identified.
summary(compareFit(csek12one.config, csek12one.metric))
## ################### Nested Model Comparison #########################
##
## Scaled Chi-Squared Difference Test (method = "satorra.bentler.2001")
##
## lavaan->unknown():
## lavaan NOTE: The "Chisq" column contains standard test statistics, not the
## robust test that should be reported per model. A robust difference test is
## a function of two standard (not robust) statistics.
## Df AIC BIC Chisq Chisq diff Df diff Pr(>Chisq)
## csek12one.config 1374 9989.2 10768 4187.4
## csek12one.metric 1412 9966.7 10633 4240.9 48.451 38 0.1193
##
## ####################### Model Fit Indices ###########################
## chisq.scaled df.scaled pvalue.scaled rmsea.robust cfi.robust
## csek12one.config 3814.119† 1374 .000 .163 .735†
## csek12one.metric 3862.242 1412 .000 .161† .733
## tli.robust srmr aic bic
## csek12one.config .714 .048† 9989.159 10767.632
## csek12one.metric .720† .081 9966.667† 10633.086†
##
## ################## Differences in Fit Indices #######################
## df.scaled rmsea.robust cfi.robust
## csek12one.metric - csek12one.config 38 -0.002 -0.002
## tli.robust srmr aic bic
## csek12one.metric - csek12one.config 0.006 0.033 -22.492 -134.545
csek12one.scalar <- cfa(csek12one.mod4, data = csek12.schoolage, std.lv = TRUE, missing = "FIML", estimator = "MLR", group = "Parent", group.equal = c("loadings", "intercepts")) #scalar model
## Warning: lavaan->lav_model_vcov():
## The variance-covariance matrix of the estimated parameters (vcov) does not
## appear to be positive definite! The smallest eigenvalue (= 7.851874e-18)
## is close to zero. This may be a symptom that the model is not identified.
summary(compareFit(csek12one.metric, csek12one.scalar))
## ################### Nested Model Comparison #########################
##
## Scaled Chi-Squared Difference Test (method = "satorra.bentler.2001")
##
## lavaan->unknown():
## lavaan NOTE: The "Chisq" column contains standard test statistics, not the
## robust test that should be reported per model. A robust difference test is
## a function of two standard (not robust) statistics.
## Df AIC BIC Chisq Chisq diff Df diff Pr(>Chisq)
## csek12one.metric 1412 9966.7 10633 4240.9
## csek12one.scalar 1450 9912.1 10466 4262.4 22.012 38 0.9822
##
## ####################### Model Fit Indices ###########################
## chisq.scaled df.scaled pvalue.scaled rmsea.robust cfi.robust
## csek12one.metric 3862.242† 1412 .000 .161 .733
## csek12one.scalar 3893.174 1450 .000 .158† .735†
## tli.robust srmr aic bic
## csek12one.metric .720 .081† 9966.667 10633.086
## csek12one.scalar .729† .081 9912.143† 10466.509†
##
## ################## Differences in Fit Indices #######################
## df.scaled rmsea.robust cfi.robust
## csek12one.scalar - csek12one.metric 38 -0.003 0.002
## tli.robust srmr aic bic
## csek12one.scalar - csek12one.metric 0.009 0 -54.524 -166.577
##gender
summarytools::freq(csek12$Gender_3cat)
## Frequencies
## csek12$Gender_3cat
## Type: Factor
##
## Freq % Valid % Valid Cum. % Total % Total Cum.
## ----------- ------ --------- -------------- --------- --------------
## 1 145 50.00 50.00 48.66 48.66
## 2 137 47.24 97.24 45.97 94.63
## 3 8 2.76 100.00 2.68 97.32
## <NA> 8 2.68 100.00
## Total 298 100.00 100.00 100.00 100.00
csek12.gender <- subset(csek12, Gender_3cat != 3) #removal of participants who did not identify as either male or female
csek12one.config1 <- cfa(csek12one.mod4, data = csek12.gender, std.lv = TRUE, missing = "FIML", estimator = "MLR", group = "Gender_3cat") #configural model
## 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.277019e-15)
## is smaller than zero. This may be a symptom that the model is not
## identified.
summary(csek12one.config1, fit.measures = TRUE)
## lavaan 0.6-18 ended normally after 159 iterations
##
## Estimator ML
## Optimization method NLMINB
## Number of model parameters 264
##
## Number of observations per group:
## 2 137
## 1 145
## Number of missing patterns per group:
## 2 1
## 1 2
##
## Model Test User Model:
## Standard Scaled
## Test Statistic 4054.198 2795.809
## Degrees of freedom 1374 1374
## P-value (Chi-square) 0.000 0.000
## Scaling correction factor 1.450
## Yuan-Bentler correction (Mplus variant)
## Test statistic for each group:
## 2 1658.539 1143.743
## 1 2395.658 1652.066
##
## Model Test Baseline Model:
##
## Test statistic 18039.342 11661.985
## Degrees of freedom 1482 1482
## P-value 0.000 0.000
## Scaling correction factor 1.547
##
## User Model versus Baseline Model:
##
## Comparative Fit Index (CFI) 0.838 0.860
## Tucker-Lewis Index (TLI) 0.825 0.849
##
## Robust Comparative Fit Index (CFI) 0.875
## Robust Tucker-Lewis Index (TLI) 0.866
##
## Loglikelihood and Information Criteria:
##
## Loglikelihood user model (H0) -8488.814 -8488.814
## Scaling correction factor 2.190
## for the MLR correction
## Loglikelihood unrestricted model (H1) NA NA
## Scaling correction factor 1.569
## for the MLR correction
##
## Akaike (AIC) 17505.628 17505.628
## Bayesian (BIC) 18467.091 18467.091
## Sample-size adjusted Bayesian (SABIC) 17629.951 17629.951
##
## Root Mean Square Error of Approximation:
##
## RMSEA 0.118 0.086
## 90 Percent confidence interval - lower 0.113 0.082
## 90 Percent confidence interval - upper 0.122 0.089
## P-value H_0: RMSEA <= 0.050 0.000 0.000
## P-value H_0: RMSEA >= 0.080 1.000 0.993
##
## Robust RMSEA 0.101
## 90 Percent confidence interval - lower 0.095
## 90 Percent confidence interval - upper 0.107
## P-value H_0: Robust RMSEA <= 0.050 0.000
## P-value H_0: Robust RMSEA >= 0.080 1.000
##
## Standardized Root Mean Square Residual:
##
## SRMR 0.041 0.041
##
## Parameter Estimates:
##
## Standard errors Sandwich
## Information bread Observed
## Observed information based on Hessian
##
##
## Group 1 [2]:
##
## Latent Variables:
## Estimate Std.Err z-value P(>|z|)
## CSE =~
## Q2_1 0.971 0.098 9.921 0.000
## Q2_2 0.861 0.102 8.465 0.000
## Q2_3 0.883 0.094 9.408 0.000
## Q2_4 0.973 0.093 10.413 0.000
## Q2_5 0.988 0.099 9.933 0.000
## Q2_6 0.965 0.103 9.399 0.000
## Q2_7 0.883 0.108 8.214 0.000
## Q2_8 0.878 0.105 8.345 0.000
## Q2_9 0.744 0.112 6.671 0.000
## Q3_1 1.023 0.090 11.303 0.000
## Q3_2 1.022 0.092 11.072 0.000
## Q3_3 0.976 0.097 10.036 0.000
## Q3_4 1.082 0.095 11.400 0.000
## Q3_5 0.958 0.110 8.728 0.000
## Q3_6 0.877 0.110 7.972 0.000
## Q3_7 1.044 0.095 11.001 0.000
## Q3_8 1.050 0.098 10.738 0.000
## Q3_9 1.078 0.082 13.102 0.000
## Q3_10 0.869 0.102 8.541 0.000
## Q4_1 1.032 0.100 10.323 0.000
## Q4_2 1.067 0.092 11.548 0.000
## Q4_3 1.021 0.096 10.598 0.000
## Q4_4 1.049 0.104 10.122 0.000
## Q4_5 0.973 0.098 9.893 0.000
## Q4_6 1.072 0.097 11.052 0.000
## Q4_7 1.150 0.082 13.955 0.000
## Q4_8 0.955 0.115 8.315 0.000
## Q4_9 0.727 0.104 7.013 0.000
## Q4_10 0.986 0.101 9.719 0.000
## Q5_1 0.955 0.098 9.757 0.000
## Q5_2 1.071 0.095 11.310 0.000
## Q5_4 0.950 0.108 8.825 0.000
## Q5_5 0.838 0.110 7.603 0.000
## Q5_6 0.850 0.105 8.126 0.000
## Q5_7 1.093 0.098 11.134 0.000
## Q5_8 0.789 0.115 6.890 0.000
## Q5_9 0.859 0.104 8.236 0.000
## Q5_10 0.771 0.116 6.659 0.000
## Q5_11 1.009 0.101 10.009 0.000
##
## Covariances:
## Estimate Std.Err z-value P(>|z|)
## .Q2_3 ~~
## .Q2_4 0.063 0.042 1.524 0.127
## .Q2_5 0.027 0.035 0.769 0.442
## .Q5_5 0.012 0.035 0.358 0.720
## .Q5_6 0.018 0.029 0.625 0.532
## .Q2_4 ~~
## .Q2_5 0.109 0.040 2.705 0.007
## .Q5_5 0.004 0.036 0.120 0.904
## .Q5_6 -0.051 0.023 -2.219 0.026
## .Q2_5 ~~
## .Q5_5 0.087 0.051 1.701 0.089
## .Q5_6 -0.067 0.028 -2.356 0.018
## .Q5_5 ~~
## .Q5_6 -0.019 0.035 -0.527 0.598
## .Q4_4 ~~
## .Q4_5 0.097 0.034 2.836 0.005
## .Q4_6 0.027 0.029 0.933 0.351
## .Q4_5 ~~
## .Q4_6 0.085 0.032 2.665 0.008
## .Q4_7 ~~
## .Q4_8 0.060 0.044 1.360 0.174
## .Q2_8 ~~
## .Q2_9 0.122 0.045 2.717 0.007
##
## Intercepts:
## Estimate Std.Err z-value P(>|z|)
## .Q2_1 4.146 0.095 43.682 0.000
## .Q2_2 4.051 0.101 39.987 0.000
## .Q2_3 4.285 0.087 49.278 0.000
## .Q2_4 4.117 0.096 42.741 0.000
## .Q2_5 4.146 0.098 42.445 0.000
## .Q2_6 4.131 0.104 39.663 0.000
## .Q2_7 4.270 0.093 46.103 0.000
## .Q2_8 4.255 0.088 48.573 0.000
## .Q2_9 4.336 0.083 52.389 0.000
## .Q3_1 4.219 0.093 45.492 0.000
## .Q3_2 4.248 0.094 44.961 0.000
## .Q3_3 4.307 0.090 47.679 0.000
## .Q3_4 4.197 0.099 42.427 0.000
## .Q3_5 4.336 0.091 47.474 0.000
## .Q3_6 4.365 0.091 47.916 0.000
## .Q3_7 4.051 0.106 38.240 0.000
## .Q3_8 3.942 0.115 34.322 0.000
## .Q3_9 3.686 0.123 29.992 0.000
## .Q3_10 4.036 0.096 42.066 0.000
## .Q4_1 4.277 0.093 46.117 0.000
## .Q4_2 4.139 0.100 41.313 0.000
## .Q4_3 4.307 0.091 47.069 0.000
## .Q4_4 4.307 0.096 44.841 0.000
## .Q4_5 4.285 0.095 45.034 0.000
## .Q4_6 4.219 0.099 42.446 0.000
## .Q4_7 4.007 0.110 36.439 0.000
## .Q4_8 4.380 0.096 45.452 0.000
## .Q4_9 4.117 0.088 46.979 0.000
## .Q4_10 4.285 0.092 46.714 0.000
## .Q5_1 4.168 0.093 44.982 0.000
## .Q5_2 4.190 0.100 41.745 0.000
## .Q5_4 4.358 0.090 48.507 0.000
## .Q5_5 4.226 0.091 46.359 0.000
## .Q5_6 4.350 0.085 51.261 0.000
## .Q5_7 4.204 0.102 41.325 0.000
## .Q5_8 4.146 0.099 41.979 0.000
## .Q5_9 4.438 0.082 53.798 0.000
## .Q5_10 4.321 0.085 50.788 0.000
## .Q5_11 4.314 0.093 46.505 0.000
##
## Variances:
## Estimate Std.Err z-value P(>|z|)
## .Q2_1 0.291 0.067 4.363 0.000
## .Q2_2 0.665 0.110 6.037 0.000
## .Q2_3 0.256 0.047 5.493 0.000
## .Q2_4 0.324 0.067 4.856 0.000
## .Q2_5 0.331 0.061 5.414 0.000
## .Q2_6 0.556 0.157 3.537 0.000
## .Q2_7 0.395 0.082 4.833 0.000
## .Q2_8 0.281 0.057 4.955 0.000
## .Q2_9 0.385 0.064 5.995 0.000
## .Q3_1 0.132 0.023 5.816 0.000
## .Q3_2 0.178 0.041 4.339 0.000
## .Q3_3 0.165 0.042 3.901 0.000
## .Q3_4 0.170 0.041 4.127 0.000
## .Q3_5 0.225 0.054 4.168 0.000
## .Q3_6 0.367 0.083 4.436 0.000
## .Q3_7 0.447 0.118 3.789 0.000
## .Q3_8 0.704 0.136 5.157 0.000
## .Q3_9 0.907 0.151 6.028 0.000
## .Q3_10 0.506 0.125 4.031 0.000
## .Q4_1 0.114 0.032 3.571 0.000
## .Q4_2 0.237 0.049 4.875 0.000
## .Q4_3 0.104 0.020 5.112 0.000
## .Q4_4 0.164 0.037 4.366 0.000
## .Q4_5 0.294 0.058 5.066 0.000
## .Q4_6 0.204 0.039 5.283 0.000
## .Q4_7 0.335 0.057 5.928 0.000
## .Q4_8 0.360 0.067 5.415 0.000
## .Q4_9 0.524 0.068 7.700 0.000
## .Q4_10 0.180 0.039 4.567 0.000
## .Q5_1 0.263 0.049 5.409 0.000
## .Q5_2 0.233 0.050 4.618 0.000
## .Q5_4 0.202 0.047 4.311 0.000
## .Q5_5 0.436 0.111 3.912 0.000
## .Q5_6 0.264 0.055 4.791 0.000
## .Q5_7 0.224 0.045 4.972 0.000
## .Q5_8 0.713 0.159 4.499 0.000
## .Q5_9 0.194 0.033 5.953 0.000
## .Q5_10 0.397 0.083 4.809 0.000
## .Q5_11 0.160 0.037 4.340 0.000
## CSE 1.000
##
##
## Group 2 [1]:
##
## Latent Variables:
## Estimate Std.Err z-value P(>|z|)
## CSE =~
## Q2_1 0.773 0.079 9.835 0.000
## Q2_2 0.717 0.095 7.581 0.000
## Q2_3 0.708 0.103 6.891 0.000
## Q2_4 0.740 0.101 7.356 0.000
## Q2_5 0.770 0.099 7.809 0.000
## Q2_6 0.682 0.105 6.468 0.000
## Q2_7 0.664 0.109 6.096 0.000
## Q2_8 0.690 0.098 7.009 0.000
## Q2_9 0.643 0.109 5.877 0.000
## Q3_1 0.763 0.102 7.495 0.000
## Q3_2 0.768 0.101 7.606 0.000
## Q3_3 0.713 0.104 6.848 0.000
## Q3_4 0.803 0.089 9.007 0.000
## Q3_5 0.737 0.103 7.138 0.000
## Q3_6 0.696 0.108 6.452 0.000
## Q3_7 0.845 0.092 9.210 0.000
## Q3_8 0.831 0.094 8.882 0.000
## Q3_9 0.866 0.079 10.994 0.000
## Q3_10 0.797 0.095 8.401 0.000
## Q4_1 0.773 0.098 7.881 0.000
## Q4_2 0.738 0.096 7.669 0.000
## Q4_3 0.772 0.098 7.896 0.000
## Q4_4 0.731 0.104 7.030 0.000
## Q4_5 0.637 0.116 5.503 0.000
## Q4_6 0.757 0.098 7.744 0.000
## Q4_7 0.814 0.089 9.168 0.000
## Q4_8 0.681 0.115 5.944 0.000
## Q4_9 0.474 0.126 3.771 0.000
## Q4_10 0.802 0.094 8.563 0.000
## Q5_1 0.812 0.092 8.818 0.000
## Q5_2 0.687 0.101 6.825 0.000
## Q5_4 0.744 0.102 7.274 0.000
## Q5_5 0.671 0.110 6.117 0.000
## Q5_6 0.675 0.110 6.153 0.000
## Q5_7 0.710 0.107 6.665 0.000
## Q5_8 0.541 0.128 4.221 0.000
## Q5_9 0.650 0.110 5.930 0.000
## Q5_10 0.669 0.106 6.332 0.000
## Q5_11 0.735 0.106 6.958 0.000
##
## Covariances:
## Estimate Std.Err z-value P(>|z|)
## .Q2_3 ~~
## .Q2_4 0.088 0.059 1.479 0.139
## .Q2_5 0.029 0.034 0.836 0.403
## .Q5_5 -0.004 0.022 -0.201 0.841
## .Q5_6 -0.018 0.016 -1.113 0.266
## .Q2_4 ~~
## .Q2_5 0.188 0.055 3.394 0.001
## .Q5_5 0.031 0.032 0.989 0.323
## .Q5_6 -0.017 0.023 -0.725 0.468
## .Q2_5 ~~
## .Q5_5 0.029 0.029 1.009 0.313
## .Q5_6 -0.047 0.022 -2.111 0.035
## .Q5_5 ~~
## .Q5_6 0.012 0.020 0.586 0.558
## .Q4_4 ~~
## .Q4_5 0.024 0.027 0.906 0.365
## .Q4_6 0.051 0.023 2.263 0.024
## .Q4_5 ~~
## .Q4_6 0.045 0.026 1.706 0.088
## .Q4_7 ~~
## .Q4_8 -0.015 0.024 -0.618 0.536
## .Q2_8 ~~
## .Q2_9 0.179 0.048 3.706 0.000
##
## Intercepts:
## Estimate Std.Err z-value P(>|z|)
## .Q2_1 4.393 0.079 55.320 0.000
## .Q2_2 4.317 0.084 51.214 0.000
## .Q2_3 4.586 0.069 66.777 0.000
## .Q2_4 4.428 0.080 55.566 0.000
## .Q2_5 4.421 0.079 55.932 0.000
## .Q2_6 4.586 0.067 68.166 0.000
## .Q2_7 4.628 0.062 74.150 0.000
## .Q2_8 4.428 0.074 59.740 0.000
## .Q2_9 4.545 0.068 66.584 0.000
## .Q3_1 4.531 0.074 60.972 0.000
## .Q3_2 4.545 0.071 64.020 0.000
## .Q3_3 4.607 0.065 70.970 0.000
## .Q3_4 4.538 0.072 62.726 0.000
## .Q3_5 4.566 0.070 65.031 0.000
## .Q3_6 4.613 0.068 67.895 0.000
## .Q3_7 4.372 0.092 47.535 0.000
## .Q3_8 4.200 0.107 39.213 0.000
## .Q3_9 3.938 0.117 33.738 0.000
## .Q3_10 4.448 0.076 58.429 0.000
## .Q4_1 4.545 0.072 62.845 0.000
## .Q4_2 4.517 0.070 64.789 0.000
## .Q4_3 4.614 0.067 68.866 0.000
## .Q4_4 4.607 0.068 67.275 0.000
## .Q4_5 4.683 0.063 74.348 0.000
## .Q4_6 4.572 0.069 65.812 0.000
## .Q4_7 4.414 0.084 52.755 0.000
## .Q4_8 4.697 0.062 75.831 0.000
## .Q4_9 4.269 0.092 46.591 0.000
## .Q4_10 4.524 0.075 60.347 0.000
## .Q5_1 4.462 0.079 56.737 0.000
## .Q5_2 4.531 0.074 60.972 0.000
## .Q5_4 4.634 0.065 70.982 0.000
## .Q5_5 4.621 0.065 70.570 0.000
## .Q5_6 4.662 0.063 73.564 0.000
## .Q5_7 4.628 0.066 69.999 0.000
## .Q5_8 4.545 0.076 59.673 0.000
## .Q5_9 4.676 0.062 75.914 0.000
## .Q5_10 4.414 0.076 58.140 0.000
## .Q5_11 4.634 0.068 68.011 0.000
##
## Variances:
## Estimate Std.Err z-value P(>|z|)
## .Q2_1 0.317 0.070 4.541 0.000
## .Q2_2 0.516 0.115 4.468 0.000
## .Q2_3 0.183 0.063 2.898 0.004
## .Q2_4 0.374 0.086 4.332 0.000
## .Q2_5 0.312 0.063 4.969 0.000
## .Q2_6 0.191 0.052 3.701 0.000
## .Q2_7 0.124 0.027 4.526 0.000
## .Q2_8 0.321 0.059 5.413 0.000
## .Q2_9 0.262 0.052 5.037 0.000
## .Q3_1 0.219 0.111 1.968 0.049
## .Q3_2 0.140 0.049 2.859 0.004
## .Q3_3 0.103 0.035 2.953 0.003
## .Q3_4 0.115 0.042 2.732 0.006
## .Q3_5 0.172 0.070 2.448 0.014
## .Q3_6 0.182 0.048 3.764 0.000
## .Q3_7 0.513 0.119 4.322 0.000
## .Q3_8 0.972 0.198 4.915 0.000
## .Q3_9 1.225 0.186 6.604 0.000
## .Q3_10 0.204 0.052 3.928 0.000
## .Q4_1 0.161 0.064 2.526 0.012
## .Q4_2 0.160 0.046 3.468 0.001
## .Q4_3 0.055 0.015 3.761 0.000
## .Q4_4 0.146 0.042 3.501 0.000
## .Q4_5 0.170 0.044 3.834 0.000
## .Q4_6 0.127 0.036 3.570 0.000
## .Q4_7 0.353 0.106 3.342 0.001
## .Q4_8 0.093 0.020 4.752 0.000
## .Q4_9 0.993 0.168 5.897 0.000
## .Q4_10 0.172 0.065 2.652 0.008
## .Q5_1 0.238 0.067 3.528 0.000
## .Q5_2 0.329 0.105 3.140 0.002
## .Q5_4 0.065 0.016 4.189 0.000
## .Q5_5 0.171 0.041 4.199 0.000
## .Q5_6 0.127 0.034 3.686 0.000
## .Q5_7 0.129 0.036 3.600 0.000
## .Q5_8 0.549 0.153 3.597 0.000
## .Q5_9 0.127 0.027 4.738 0.000
## .Q5_10 0.388 0.068 5.664 0.000
## .Q5_11 0.133 0.061 2.169 0.030
## CSE 1.000
csek12one.metric1 <- cfa(csek12one.mod4, data = csek12.gender, std.lv = TRUE, missing = "FIML", estimator = "MLR", group = "Gender_3cat", group.equal = "loadings") #metric model
## 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.316154e-16)
## is close to zero. This may be a symptom that the model is not identified.
summary(compareFit(csek12one.metric1, csek12one.config1))
## ################### Nested Model Comparison #########################
##
## Scaled Chi-Squared Difference Test (method = "satorra.bentler.2001")
##
## lavaan->unknown():
## lavaan NOTE: The "Chisq" column contains standard test statistics, not the
## robust test that should be reported per model. A robust difference test is
## a function of two standard (not robust) statistics.
## Df AIC BIC Chisq Chisq diff Df diff Pr(>Chisq)
## csek12one.config1 1374 17506 18467 4054.2
## csek12one.metric1 1412 17471 18294 4095.9 32.412 38 0.725
##
## ####################### Model Fit Indices ###########################
## chisq.scaled df.scaled pvalue.scaled rmsea.robust cfi.robust
## csek12one.config1 2795.809† 1374 .000 .101 .875
## csek12one.metric1 2833.133 1412 .000 .099† .876†
## tli.robust srmr aic bic
## csek12one.config1 .866 .041† 17505.628 18467.091
## csek12one.metric1 .869† .058 17471.361† 18294.432†
##
## ################## Differences in Fit Indices #######################
## df.scaled rmsea.robust cfi.robust
## csek12one.metric1 - csek12one.config1 38 -0.001 0
## tli.robust srmr aic bic
## csek12one.metric1 - csek12one.config1 0.004 0.017 -34.266 -172.659
csek12one.scalar1 <- cfa(csek12one.mod4, data = csek12.gender, std.lv = TRUE, missing = "FIML", estimator = "MLR", group = "Gender_3cat", group.equal = c("loadings", "intercepts")) #scalar model
summary(compareFit(csek12one.scalar1, csek12one.metric1))
## ################### Nested Model Comparison #########################
##
## Scaled Chi-Squared Difference Test (method = "satorra.bentler.2001")
##
## lavaan->unknown():
## lavaan NOTE: The "Chisq" column contains standard test statistics, not the
## robust test that should be reported per model. A robust difference test is
## a function of two standard (not robust) statistics.
## Df AIC BIC Chisq Chisq diff Df diff Pr(>Chisq)
## csek12one.metric1 1412 17471 18294 4095.9
## csek12one.scalar1 1450 17439 18124 4139.8 46.113 38 0.1719
##
## ####################### Model Fit Indices ###########################
## chisq.scaled df.scaled pvalue.scaled rmsea.robust cfi.robust
## csek12one.metric1 2833.133† 1412 .000 .099 .876†
## csek12one.scalar1 2889.385 1450 .000 .098† .875
## tli.robust srmr aic bic
## csek12one.metric1 .869 .058† 17471.361 18294.432
## csek12one.scalar1 .872† .059 17439.199† 18123.878†
##
## ################## Differences in Fit Indices #######################
## df.scaled rmsea.robust cfi.robust
## csek12one.scalar1 - csek12one.metric1 38 -0.001 0
## tli.robust srmr aic bic
## csek12one.scalar1 - csek12one.metric1 0.003 0.001 -32.162 -170.555
##higher ed
csek12$highered <- ifelse(csek12$Edu > 5, 1, 0) #creating two groups to compare
summarytools::freq(csek12$highered)
## Frequencies
## csek12$highered
## Type: Numeric
##
## Freq % Valid % Valid Cum. % Total % Total Cum.
## ----------- ------ --------- -------------- --------- --------------
## 0 102 34.23 34.23 34.23 34.23
## 1 196 65.77 100.00 65.77 100.00
## <NA> 0 0.00 100.00
## Total 298 100.00 100.00 100.00 100.00
csek12one.config2 <- cfa(csek12one.mod4, data = csek12, std.lv = TRUE, missing = "FIML", estimator = "MLR", group = "highered") #configural model
## 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.456772e-15)
## is smaller than zero. This may be a symptom that the model is not
## identified.
summary(csek12one.config2, fit.measures = TRUE)
## lavaan 0.6-18 ended normally after 155 iterations
##
## Estimator ML
## Optimization method NLMINB
## Number of model parameters 264
##
## Number of observations per group:
## 1 196
## 0 102
## Number of missing patterns per group:
## 1 1
## 0 2
##
## Model Test User Model:
## Standard Scaled
## Test Statistic 4033.823 2733.806
## Degrees of freedom 1374 1374
## P-value (Chi-square) 0.000 0.000
## Scaling correction factor 1.476
## Yuan-Bentler correction (Mplus variant)
## Test statistic for each group:
## 1 2159.639 1463.632
## 0 1874.184 1270.173
##
## Model Test Baseline Model:
##
## Test statistic 19194.384 12267.739
## Degrees of freedom 1482 1482
## P-value 0.000 0.000
## Scaling correction factor 1.565
##
## User Model versus Baseline Model:
##
## Comparative Fit Index (CFI) 0.850 0.874
## Tucker-Lewis Index (TLI) 0.838 0.864
##
## Robust Comparative Fit Index (CFI) 0.886
## Robust Tucker-Lewis Index (TLI) 0.877
##
## Loglikelihood and Information Criteria:
##
## Loglikelihood user model (H0) -9094.881 -9094.881
## Scaling correction factor 2.164
## for the MLR correction
## Loglikelihood unrestricted model (H1) NA NA
## Scaling correction factor 1.587
## for the MLR correction
##
## Akaike (AIC) 18717.762 18717.762
## Bayesian (BIC) 19693.795 19693.795
## Sample-size adjusted Bayesian (SABIC) 18856.555 18856.555
##
## Root Mean Square Error of Approximation:
##
## RMSEA 0.114 0.081
## 90 Percent confidence interval - lower 0.110 0.078
## 90 Percent confidence interval - upper 0.118 0.085
## P-value H_0: RMSEA <= 0.050 0.000 0.000
## P-value H_0: RMSEA >= 0.080 1.000 0.751
##
## Robust RMSEA 0.097
## 90 Percent confidence interval - lower 0.091
## 90 Percent confidence interval - upper 0.103
## P-value H_0: Robust RMSEA <= 0.050 0.000
## P-value H_0: Robust RMSEA >= 0.080 1.000
##
## Standardized Root Mean Square Residual:
##
## SRMR 0.037 0.037
##
## Parameter Estimates:
##
## Standard errors Sandwich
## Information bread Observed
## Observed information based on Hessian
##
##
## Group 1 [1]:
##
## Latent Variables:
## Estimate Std.Err z-value P(>|z|)
## CSE =~
## Q2_1 0.898 0.080 11.185 0.000
## Q2_2 0.870 0.088 9.846 0.000
## Q2_3 0.837 0.084 9.980 0.000
## Q2_4 0.925 0.083 11.106 0.000
## Q2_5 0.926 0.087 10.657 0.000
## Q2_6 0.935 0.088 10.591 0.000
## Q2_7 0.848 0.091 9.310 0.000
## Q2_8 0.810 0.090 8.954 0.000
## Q2_9 0.708 0.090 7.849 0.000
## Q3_1 0.973 0.078 12.502 0.000
## Q3_2 0.950 0.082 11.606 0.000
## Q3_3 0.829 0.096 8.600 0.000
## Q3_4 1.022 0.082 12.396 0.000
## Q3_5 0.910 0.094 9.668 0.000
## Q3_6 0.853 0.093 9.191 0.000
## Q3_7 1.009 0.080 12.691 0.000
## Q3_8 1.008 0.083 12.159 0.000
## Q3_9 1.015 0.069 14.778 0.000
## Q3_10 0.895 0.085 10.479 0.000
## Q4_1 0.966 0.086 11.277 0.000
## Q4_2 0.984 0.082 12.061 0.000
## Q4_3 0.975 0.082 11.949 0.000
## Q4_4 0.966 0.091 10.605 0.000
## Q4_5 0.862 0.094 9.201 0.000
## Q4_6 0.999 0.086 11.610 0.000
## Q4_7 1.092 0.074 14.697 0.000
## Q4_8 0.891 0.100 8.923 0.000
## Q4_9 0.618 0.095 6.483 0.000
## Q4_10 0.943 0.085 11.070 0.000
## Q5_1 0.940 0.083 11.343 0.000
## Q5_2 1.008 0.084 11.938 0.000
## Q5_4 0.918 0.091 10.055 0.000
## Q5_5 0.856 0.093 9.241 0.000
## Q5_6 0.833 0.089 9.321 0.000
## Q5_7 1.024 0.088 11.637 0.000
## Q5_8 0.769 0.101 7.605 0.000
## Q5_9 0.821 0.091 9.034 0.000
## Q5_10 0.723 0.098 7.403 0.000
## Q5_11 0.955 0.087 10.929 0.000
##
## Covariances:
## Estimate Std.Err z-value P(>|z|)
## .Q2_3 ~~
## .Q2_4 0.074 0.047 1.572 0.116
## .Q2_5 0.042 0.031 1.354 0.176
## .Q5_5 -0.002 0.027 -0.093 0.926
## .Q5_6 0.015 0.021 0.745 0.456
## .Q2_4 ~~
## .Q2_5 0.136 0.041 3.326 0.001
## .Q5_5 0.028 0.030 0.954 0.340
## .Q5_6 -0.028 0.019 -1.475 0.140
## .Q2_5 ~~
## .Q5_5 0.092 0.042 2.188 0.029
## .Q5_6 -0.060 0.022 -2.777 0.005
## .Q5_5 ~~
## .Q5_6 -0.009 0.026 -0.356 0.722
## .Q4_4 ~~
## .Q4_5 0.056 0.027 2.125 0.034
## .Q4_6 0.024 0.022 1.080 0.280
## .Q4_5 ~~
## .Q4_6 0.072 0.027 2.729 0.006
## .Q4_7 ~~
## .Q4_8 0.040 0.032 1.272 0.203
## .Q2_8 ~~
## .Q2_9 0.163 0.043 3.803 0.000
##
## Intercepts:
## Estimate Std.Err z-value P(>|z|)
## .Q2_1 4.265 0.074 57.389 0.000
## .Q2_2 4.209 0.081 51.722 0.000
## .Q2_3 4.423 0.069 64.292 0.000
## .Q2_4 4.286 0.077 55.630 0.000
## .Q2_5 4.276 0.077 55.362 0.000
## .Q2_6 4.337 0.078 55.593 0.000
## .Q2_7 4.383 0.071 61.310 0.000
## .Q2_8 4.306 0.071 60.653 0.000
## .Q2_9 4.429 0.065 67.779 0.000
## .Q3_1 4.311 0.076 56.457 0.000
## .Q3_2 4.357 0.074 58.792 0.000
## .Q3_3 4.454 0.068 65.695 0.000
## .Q3_4 4.332 0.079 55.097 0.000
## .Q3_5 4.403 0.073 60.547 0.000
## .Q3_6 4.418 0.073 60.382 0.000
## .Q3_7 4.189 0.086 48.716 0.000
## .Q3_8 4.071 0.094 43.214 0.000
## .Q3_9 3.745 0.102 36.735 0.000
## .Q3_10 4.250 0.076 56.065 0.000
## .Q4_1 4.357 0.074 58.515 0.000
## .Q4_2 4.230 0.080 52.999 0.000
## .Q4_3 4.393 0.073 60.172 0.000
## .Q4_4 4.413 0.075 59.196 0.000
## .Q4_5 4.480 0.071 63.213 0.000
## .Q4_6 4.362 0.077 56.465 0.000
## .Q4_7 4.153 0.088 47.043 0.000
## .Q4_8 4.480 0.074 60.171 0.000
## .Q4_9 4.133 0.078 52.889 0.000
## .Q4_10 4.347 0.076 57.389 0.000
## .Q5_1 4.321 0.075 57.799 0.000
## .Q5_2 4.347 0.079 54.950 0.000
## .Q5_4 4.459 0.070 63.295 0.000
## .Q5_5 4.362 0.075 58.545 0.000
## .Q5_6 4.439 0.068 65.161 0.000
## .Q5_7 4.372 0.079 55.573 0.000
## .Q5_8 4.337 0.077 56.569 0.000
## .Q5_9 4.510 0.066 68.004 0.000
## .Q5_10 4.362 0.069 63.502 0.000
## .Q5_11 4.418 0.075 58.966 0.000
##
## Variances:
## Estimate Std.Err z-value P(>|z|)
## .Q2_1 0.277 0.055 5.070 0.000
## .Q2_2 0.541 0.103 5.232 0.000
## .Q2_3 0.227 0.053 4.291 0.000
## .Q2_4 0.308 0.066 4.694 0.000
## .Q2_5 0.311 0.053 5.896 0.000
## .Q2_6 0.318 0.082 3.885 0.000
## .Q2_7 0.283 0.058 4.898 0.000
## .Q2_8 0.332 0.053 6.211 0.000
## .Q2_9 0.335 0.051 6.549 0.000
## .Q3_1 0.195 0.080 2.436 0.015
## .Q3_2 0.174 0.042 4.144 0.000
## .Q3_3 0.214 0.070 3.047 0.002
## .Q3_4 0.168 0.042 4.021 0.000
## .Q3_5 0.208 0.048 4.318 0.000
## .Q3_6 0.322 0.063 5.103 0.000
## .Q3_7 0.431 0.105 4.088 0.000
## .Q3_8 0.724 0.134 5.413 0.000
## .Q3_9 1.006 0.136 7.409 0.000
## .Q3_10 0.325 0.068 4.812 0.000
## .Q4_1 0.153 0.049 3.125 0.002
## .Q4_2 0.280 0.057 4.887 0.000
## .Q4_3 0.095 0.021 4.472 0.000
## .Q4_4 0.157 0.033 4.723 0.000
## .Q4_5 0.241 0.045 5.416 0.000
## .Q4_6 0.172 0.032 5.416 0.000
## .Q4_7 0.336 0.075 4.455 0.000
## .Q4_8 0.292 0.051 5.713 0.000
## .Q4_9 0.815 0.121 6.713 0.000
## .Q4_10 0.235 0.059 3.979 0.000
## .Q5_1 0.212 0.052 4.115 0.000
## .Q5_2 0.210 0.062 3.385 0.001
## .Q5_4 0.130 0.029 4.471 0.000
## .Q5_5 0.355 0.084 4.210 0.000
## .Q5_6 0.216 0.044 4.897 0.000
## .Q5_7 0.164 0.031 5.222 0.000
## .Q5_8 0.560 0.117 4.785 0.000
## .Q5_9 0.188 0.029 6.513 0.000
## .Q5_10 0.402 0.068 5.865 0.000
## .Q5_11 0.189 0.052 3.662 0.000
## CSE 1.000
##
##
## Group 2 [0]:
##
## Latent Variables:
## Estimate Std.Err z-value P(>|z|)
## CSE =~
## Q2_1 0.896 0.106 8.458 0.000
## Q2_2 0.683 0.111 6.124 0.000
## Q2_3 0.799 0.116 6.889 0.000
## Q2_4 0.830 0.114 7.313 0.000
## Q2_5 0.876 0.112 7.845 0.000
## Q2_6 0.716 0.128 5.576 0.000
## Q2_7 0.719 0.139 5.178 0.000
## Q2_8 0.784 0.120 6.541 0.000
## Q2_9 0.680 0.131 5.182 0.000
## Q3_1 0.836 0.127 6.601 0.000
## Q3_2 0.854 0.124 6.904 0.000
## Q3_3 0.794 0.124 6.398 0.000
## Q3_4 0.828 0.116 7.148 0.000
## Q3_5 0.759 0.128 5.917 0.000
## Q3_6 0.721 0.133 5.416 0.000
## Q3_7 0.883 0.114 7.728 0.000
## Q3_8 0.865 0.118 7.317 0.000
## Q3_9 0.944 0.102 9.250 0.000
## Q3_10 0.822 0.113 7.290 0.000
## Q4_1 0.829 0.124 6.706 0.000
## Q4_2 0.837 0.116 7.220 0.000
## Q4_3 0.804 0.128 6.267 0.000
## Q4_4 0.808 0.125 6.449 0.000
## Q4_5 0.805 0.125 6.449 0.000
## Q4_6 0.817 0.118 6.902 0.000
## Q4_7 0.812 0.109 7.443 0.000
## Q4_8 0.748 0.137 5.453 0.000
## Q4_9 0.628 0.144 4.354 0.000
## Q4_10 0.824 0.119 6.931 0.000
## Q5_1 0.828 0.114 7.271 0.000
## Q5_2 0.721 0.123 5.870 0.000
## Q5_4 0.750 0.130 5.757 0.000
## Q5_5 0.664 0.130 5.090 0.000
## Q5_6 0.691 0.139 4.970 0.000
## Q5_7 0.763 0.125 6.086 0.000
## Q5_8 0.574 0.146 3.934 0.000
## Q5_9 0.695 0.132 5.250 0.000
## Q5_10 0.768 0.128 6.007 0.000
## Q5_11 0.787 0.130 6.034 0.000
##
## Covariances:
## Estimate Std.Err z-value P(>|z|)
## .Q2_3 ~~
## .Q2_4 0.051 0.048 1.073 0.283
## .Q2_5 0.006 0.033 0.183 0.855
## .Q5_5 0.054 0.032 1.675 0.094
## .Q5_6 -0.013 0.019 -0.696 0.486
## .Q2_4 ~~
## .Q2_5 0.138 0.052 2.671 0.008
## .Q5_5 0.009 0.034 0.271 0.787
## .Q5_6 -0.036 0.024 -1.491 0.136
## .Q2_5 ~~
## .Q5_5 0.027 0.031 0.856 0.392
## .Q5_6 -0.034 0.025 -1.329 0.184
## .Q5_5 ~~
## .Q5_6 0.022 0.026 0.831 0.406
## .Q4_4 ~~
## .Q4_5 0.073 0.039 1.898 0.058
## .Q4_6 0.076 0.031 2.466 0.014
## .Q4_5 ~~
## .Q4_6 0.053 0.034 1.588 0.112
## .Q4_7 ~~
## .Q4_8 -0.019 0.037 -0.513 0.608
## .Q2_8 ~~
## .Q2_9 0.095 0.043 2.208 0.027
##
## Intercepts:
## Estimate Std.Err z-value P(>|z|)
## .Q2_1 4.294 0.105 40.813 0.000
## .Q2_2 4.206 0.103 40.778 0.000
## .Q2_3 4.471 0.090 49.929 0.000
## .Q2_4 4.275 0.102 41.893 0.000
## .Q2_5 4.314 0.103 41.960 0.000
## .Q2_6 4.431 0.097 45.889 0.000
## .Q2_7 4.598 0.082 55.849 0.000
## .Q2_8 4.431 0.090 49.021 0.000
## .Q2_9 4.500 0.084 53.539 0.000
## .Q3_1 4.480 0.092 48.866 0.000
## .Q3_2 4.490 0.093 48.415 0.000
## .Q3_3 4.539 0.085 53.341 0.000
## .Q3_4 4.490 0.087 51.370 0.000
## .Q3_5 4.569 0.086 53.099 0.000
## .Q3_6 4.628 0.081 56.984 0.000
## .Q3_7 4.304 0.112 38.565 0.000
## .Q3_8 4.078 0.136 30.071 0.000
## .Q3_9 3.951 0.144 27.373 0.000
## .Q3_10 4.245 0.104 40.756 0.000
## .Q4_1 4.539 0.087 51.979 0.000
## .Q4_2 4.500 0.089 50.843 0.000
## .Q4_3 4.598 0.085 54.329 0.000
## .Q4_4 4.559 0.088 51.620 0.000
## .Q4_5 4.529 0.092 49.415 0.000
## .Q4_6 4.490 0.090 50.124 0.000
## .Q4_7 4.373 0.099 44.194 0.000
## .Q4_8 4.657 0.081 57.187 0.000
## .Q4_9 4.343 0.104 41.676 0.000
## .Q4_10 4.520 0.086 52.379 0.000
## .Q5_1 4.324 0.099 43.596 0.000
## .Q5_2 4.412 0.096 45.760 0.000
## .Q5_4 4.588 0.082 55.657 0.000
## .Q5_5 4.529 0.080 56.269 0.000
## .Q5_6 4.647 0.077 60.544 0.000
## .Q5_7 4.520 0.087 51.716 0.000
## .Q5_8 4.412 0.101 43.563 0.000
## .Q5_9 4.647 0.075 61.556 0.000
## .Q5_10 4.412 0.094 46.737 0.000
## .Q5_11 4.588 0.082 55.657 0.000
##
## Variances:
## Estimate Std.Err z-value P(>|z|)
## .Q2_1 0.327 0.078 4.194 0.000
## .Q2_2 0.619 0.111 5.557 0.000
## .Q2_3 0.180 0.044 4.098 0.000
## .Q2_4 0.373 0.086 4.347 0.000
## .Q2_5 0.312 0.067 4.674 0.000
## .Q2_6 0.438 0.170 2.578 0.010
## .Q2_7 0.175 0.046 3.785 0.000
## .Q2_8 0.219 0.055 3.973 0.000
## .Q2_9 0.259 0.059 4.397 0.000
## .Q3_1 0.159 0.044 3.612 0.000
## .Q3_2 0.149 0.046 3.259 0.001
## .Q3_3 0.108 0.035 3.107 0.002
## .Q3_4 0.093 0.028 3.280 0.001
## .Q3_5 0.179 0.088 2.032 0.042
## .Q3_6 0.147 0.042 3.503 0.000
## .Q3_7 0.490 0.108 4.548 0.000
## .Q3_8 1.128 0.243 4.652 0.000
## .Q3_9 1.234 0.233 5.303 0.000
## .Q3_10 0.430 0.145 2.962 0.003
## .Q4_1 0.091 0.032 2.885 0.004
## .Q4_2 0.098 0.041 2.408 0.016
## .Q4_3 0.084 0.020 4.252 0.000
## .Q4_4 0.143 0.049 2.908 0.004
## .Q4_5 0.209 0.060 3.487 0.000
## .Q4_6 0.151 0.043 3.552 0.000
## .Q4_7 0.339 0.078 4.366 0.000
## .Q4_8 0.117 0.027 4.304 0.000
## .Q4_9 0.713 0.174 4.090 0.000
## .Q4_10 0.081 0.019 4.312 0.000
## .Q5_1 0.317 0.066 4.817 0.000
## .Q5_2 0.428 0.106 4.024 0.000
## .Q5_4 0.131 0.043 3.031 0.002
## .Q5_5 0.220 0.055 4.024 0.000
## .Q5_6 0.123 0.030 4.136 0.000
## .Q5_7 0.198 0.053 3.738 0.000
## .Q5_8 0.717 0.207 3.464 0.001
## .Q5_9 0.098 0.022 4.537 0.000
## .Q5_10 0.319 0.076 4.197 0.000
## .Q5_11 0.074 0.021 3.570 0.000
## CSE 1.000
csek12one.metric2 <- cfa(csek12one.mod4, data = csek12, std.lv = TRUE, missing = "FIML", estimator = "MLR", group = "highered", group.equal = "loadings") #metric model
## 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.476310e-17)
## is close to zero. This may be a symptom that the model is not identified.
summary(compareFit(csek12one.metric2, csek12one.config2))
## ################### Nested Model Comparison #########################
##
## Scaled Chi-Squared Difference Test (method = "satorra.bentler.2001")
##
## lavaan->unknown():
## lavaan NOTE: The "Chisq" column contains standard test statistics, not the
## robust test that should be reported per model. A robust difference test is
## a function of two standard (not robust) statistics.
## Df AIC BIC Chisq Chisq diff Df diff Pr(>Chisq)
## csek12one.config2 1374 18718 19694 4033.8
## csek12one.metric2 1412 18688 19524 4080.1 39.107 38 0.4199
##
## ####################### Model Fit Indices ###########################
## chisq.scaled df.scaled pvalue.scaled rmsea.robust cfi.robust
## csek12one.config2 2733.806† 1374 .000 .097 .886†
## csek12one.metric2 2779.993 1412 .000 .096† .886
## tli.robust srmr aic bic
## csek12one.config2 .877 .037† 18717.762 19693.795
## csek12one.metric2 .880† .053 18688.025† 19523.569†
##
## ################## Differences in Fit Indices #######################
## df.scaled rmsea.robust cfi.robust
## csek12one.metric2 - csek12one.config2 38 -0.001 0
## tli.robust srmr aic bic
## csek12one.metric2 - csek12one.config2 0.003 0.016 -29.737 -170.227
csek12one.scalar2 <- cfa(csek12one.mod4, data = csek12, std.lv = TRUE, missing = "FIML", estimator = "MLR", group = "highered", group.equal = c("loadings", "intercepts")) #scalar model
summary(compareFit(csek12one.scalar2, csek12one.metric2))
## ################### Nested Model Comparison #########################
##
## Scaled Chi-Squared Difference Test (method = "satorra.bentler.2001")
##
## lavaan->unknown():
## lavaan NOTE: The "Chisq" column contains standard test statistics, not the
## robust test that should be reported per model. A robust difference test is
## a function of two standard (not robust) statistics.
## Df AIC BIC Chisq Chisq diff Df diff Pr(>Chisq)
## csek12one.metric2 1412 18688 19524 4080.1
## csek12one.scalar2 1450 18660 19355 4127.5 51.682 38 0.06846 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## ####################### Model Fit Indices ###########################
## chisq.scaled df.scaled pvalue.scaled rmsea.robust cfi.robust
## csek12one.metric2 2779.993† 1412 .000 .096 .886†
## csek12one.scalar2 2840.198 1450 .000 .095† .885
## tli.robust srmr aic bic
## csek12one.metric2 .880 .053† 18688.025 19523.569
## csek12one.scalar2 .883† .054 18659.464† 19354.518†
##
## ################## Differences in Fit Indices #######################
## df.scaled rmsea.robust cfi.robust
## csek12one.scalar2 - csek12one.metric2 38 -0.001 -0.001
## tli.robust srmr aic bic
## csek12one.scalar2 - csek12one.metric2 0.003 0 -28.561 -169.051