35.4 Vincoli sui residui
Esaminiamo ora il vincolo sulle covarianze residue. Iniziamo a specificare il modello in una nuova forma.
mg_math_lavaan_model4 <- "
# latent variable definitions
#intercept (note intercept is a reserved term)
eta_1 =~ 1*math2
eta_1 =~ 1*math3
eta_1 =~ 1*math4
eta_1 =~ 1*math5
eta_1 =~ 1*math6
eta_1 =~ 1*math7
eta_1 =~ 1*math8
#linear slope
eta_2 =~ 0*math2
eta_2 =~ 1*math3
eta_2 =~ 2*math4
eta_2 =~ 3*math5
eta_2 =~ 4*math6
eta_2 =~ 5*math7
eta_2 =~ 6*math8
# factor variances
eta_1 ~~ start(60)*eta_1
eta_2 ~~ start(.75)*eta_2
# covariances among factors
eta_1 ~~ eta_2
# factor means
eta_1 ~ start(35)*1
eta_2 ~ start(4)*1
# manifest variances (made equivalent by naming theta)
math2 ~~ c(theta1,theta2)*math2
math3 ~~ c(theta1,theta2)*math3
math4 ~~ c(theta1,theta2)*math4
math5 ~~ c(theta1,theta2)*math5
math6 ~~ c(theta1,theta2)*math6
math7 ~~ c(theta1,theta2)*math7
math8 ~~ c(theta1,theta2)*math8
# manifest means (fixed at zero)
math2 ~ 0*1
math3 ~ 0*1
math4 ~ 0*1
math5 ~ 0*1
math6 ~ 0*1
math7 ~ 0*1
math8 ~ 0*1
" # end of model definition
Adattiamo il modello ai dati.
mg_math_lavaan_fitM4 <- sem(mg_math_lavaan_model4,
data = nlsy_math_wide,
meanstructure = TRUE,
estimator = "ML",
missing = "fiml",
group = "lb_wght", # to separate groups
group.equal = c("loadings")
) # for constraints
Esaminiamo i risulati.
summary(mg_math_lavaan_fitM4, fit.measures = TRUE)
#> lavaan 0.6.15 ended normally after 62 iterations
#>
#> Estimator ML
#> Optimization method NLMINB
#> Number of model parameters 24
#> Number of equality constraints 12
#>
#> Number of observations per group: Used Total
#> 0 857 858
#> 1 75 75
#> Number of missing patterns per group:
#> 0 60
#> 1 25
#>
#> Model Test User Model:
#>
#> Test statistic 237.836
#> Degrees of freedom 58
#> P-value (Chi-square) 0.000
#> Test statistic for each group:
#> 0 190.833
#> 1 47.004
#>
#> Model Test Baseline Model:
#>
#> Test statistic 887.887
#> Degrees of freedom 42
#> P-value 0.000
#>
#> User Model versus Baseline Model:
#>
#> Comparative Fit Index (CFI) 0.787
#> Tucker-Lewis Index (TLI) 0.846
#>
#> Robust Comparative Fit Index (CFI) 1.000
#> Robust Tucker-Lewis Index (TLI) 0.294
#>
#> Loglikelihood and Information Criteria:
#>
#> Loglikelihood user model (H0) -7963.056
#> Loglikelihood unrestricted model (H1) -7844.138
#>
#> Akaike (AIC) 15950.111
#> Bayesian (BIC) 16008.159
#> Sample-size adjusted Bayesian (SABIC) 15970.048
#>
#> Root Mean Square Error of Approximation:
#>
#> RMSEA 0.082
#> 90 Percent confidence interval - lower 0.071
#> 90 Percent confidence interval - upper 0.092
#> P-value H_0: RMSEA <= 0.050 0.000
#> P-value H_0: RMSEA >= 0.080 0.607
#>
#> Robust RMSEA 0.000
#> 90 Percent confidence interval - lower 0.000
#> 90 Percent confidence interval - upper 0.000
#> P-value H_0: Robust RMSEA <= 0.050 1.000
#> P-value H_0: Robust RMSEA >= 0.080 0.000
#>
#> Standardized Root Mean Square Residual:
#>
#> SRMR 0.124
#>
#> Parameter Estimates:
#>
#> Standard errors Standard
#> Information Observed
#> Observed information based on Hessian
#>
#>
#> Group 1 [0]:
#>
#> Latent Variables:
#> Estimate Std.Err z-value P(>|z|)
#> eta_1 =~
#> math2 1.000
#> math3 1.000
#> math4 1.000
#> math5 1.000
#> math6 1.000
#> math7 1.000
#> math8 1.000
#> eta_2 =~
#> math2 0.000
#> math3 1.000
#> math4 2.000
#> math5 3.000
#> math6 4.000
#> math7 5.000
#> math8 6.000
#>
#> Covariances:
#> Estimate Std.Err z-value P(>|z|)
#> eta_1 ~~
#> eta_2 -0.063 1.161 -0.054 0.957
#>
#> Intercepts:
#> Estimate Std.Err z-value P(>|z|)
#> eta_1 35.481 0.365 97.257 0.000
#> eta_2 4.297 0.091 47.145 0.000
#> .math2 0.000
#> .math3 0.000
#> .math4 0.000
#> .math5 0.000
#> .math6 0.000
#> .math7 0.000
#> .math8 0.000
#>
#> Variances:
#> Estimate Std.Err z-value P(>|z|)
#> eta_1 62.287 5.728 10.873 0.000
#> eta_2 0.774 0.334 2.314 0.021
#> .math2 (tht1) 35.172 1.904 18.473 0.000
#> .math3 (tht1) 35.172 1.904 18.473 0.000
#> .math4 (tht1) 35.172 1.904 18.473 0.000
#> .math5 (tht1) 35.172 1.904 18.473 0.000
#> .math6 (tht1) 35.172 1.904 18.473 0.000
#> .math7 (tht1) 35.172 1.904 18.473 0.000
#> .math8 (tht1) 35.172 1.904 18.473 0.000
#>
#>
#> Group 2 [1]:
#>
#> Latent Variables:
#> Estimate Std.Err z-value P(>|z|)
#> eta_1 =~
#> math2 1.000
#> math3 1.000
#> math4 1.000
#> math5 1.000
#> math6 1.000
#> math7 1.000
#> math8 1.000
#> eta_2 =~
#> math2 0.000
#> math3 1.000
#> math4 2.000
#> math5 3.000
#> math6 4.000
#> math7 5.000
#> math8 6.000
#>
#> Covariances:
#> Estimate Std.Err z-value P(>|z|)
#> eta_1 ~~
#> eta_2 0.745 5.522 0.135 0.893
#>
#> Intercepts:
#> Estimate Std.Err z-value P(>|z|)
#> eta_1 32.800 1.407 23.314 0.000
#> eta_2 4.873 0.341 14.298 0.000
#> .math2 0.000
#> .math3 0.000
#> .math4 0.000
#> .math5 0.000
#> .math6 0.000
#> .math7 0.000
#> .math8 0.000
#>
#> Variances:
#> Estimate Std.Err z-value P(>|z|)
#> eta_1 79.627 25.629 3.107 0.002
#> eta_2 -0.157 1.477 -0.106 0.915
#> .math2 (tht2) 48.686 8.444 5.766 0.000
#> .math3 (tht2) 48.686 8.444 5.766 0.000
#> .math4 (tht2) 48.686 8.444 5.766 0.000
#> .math5 (tht2) 48.686 8.444 5.766 0.000
#> .math6 (tht2) 48.686 8.444 5.766 0.000
#> .math7 (tht2) 48.686 8.444 5.766 0.000
#> .math8 (tht2) 48.686 8.444 5.766 0.000
Facciamo un confronto tra la bontà di adattamento del modello M3 e del modello M4.
anova(mg_math_lavaan_fitM3, mg_math_lavaan_fitM4)
#>
#> Chi-Squared Difference Test
#>
#> Df AIC BIC Chisq Chisq diff RMSEA Df diff
#> mg_math_lavaan_fitM4 58 15950 16008 237.84
#> mg_math_lavaan_fitM3 59 15952 16005 241.18 3.3457 0.070948 1
#> Pr(>Chisq)
#> mg_math_lavaan_fitM4
#> mg_math_lavaan_fitM3 0.06738 .
#> ---
#> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Anche in questo caso non otteniamo un risultato che fornisce evidenza di differenze tra i due gruppi.