35.2 Vincoli sulle medie

Trasformiamo ora il modello restrittivo specificato in precedenza allentando via via i vincoli che abbiamo introdotto. In questo modello rendiamo possibile la differenza tra le medie nei due gruppi.

mg_math_lavaan_fitM2 <- sem(mg_math_lavaan_model,
  data = nlsy_math_wide,
  meanstructure = TRUE,
  estimator = "ML",
  missing = "fiml",
  group = "lb_wght", # to separate groups
  group.equal = c(
    "loadings", # for constraints
    # "means", commented out so can differ
    "lv.variances",
    "lv.covariances",
    "residuals"
  )
)

Esaminiamo il risultato.

summary(mg_math_lavaan_fitM2, fit.measures = TRUE)
#> lavaan 0.6.15 ended normally after 31 iterations
#> 
#>   Estimator                                         ML
#>   Optimization method                           NLMINB
#>   Number of model parameters                        24
#>   Number of equality constraints                    16
#> 
#>   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                               243.910
#>   Degrees of freedom                                62
#>   P-value (Chi-square)                           0.000
#>   Test statistic for each group:
#>     0                                          191.440
#>     1                                           52.470
#> 
#> 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.785
#>   Tucker-Lewis Index (TLI)                       0.854
#>                                                       
#>   Robust Comparative Fit Index (CFI)             1.000
#>   Robust Tucker-Lewis Index (TLI)                0.326
#> 
#> Loglikelihood and Information Criteria:
#> 
#>   Loglikelihood user model (H0)              -7966.093
#>   Loglikelihood unrestricted model (H1)      -7844.138
#>                                                       
#>   Akaike (AIC)                               15948.185
#>   Bayesian (BIC)                             15986.884
#>   Sample-size adjusted Bayesian (SABIC)      15961.477
#> 
#> Root Mean Square Error of Approximation:
#> 
#>   RMSEA                                          0.079
#>   90 Percent confidence interval - lower         0.069
#>   90 Percent confidence interval - upper         0.090
#>   P-value H_0: RMSEA <= 0.050                    0.000
#>   P-value H_0: RMSEA >= 0.080                    0.472
#>                                                       
#>   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.127
#> 
#> 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   (.17.)   -0.035    1.144   -0.031    0.975
#> 
#> Intercepts:
#>                    Estimate  Std.Err  z-value  P(>|z|)
#>     eta_1            35.488    0.369   96.080    0.000
#>     eta_2             4.292    0.092   46.898    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   (.15.)   63.704    5.637   11.301    0.000
#>     eta_2   (.16.)    0.699    0.325    2.147    0.032
#>    .math2   (thet)   36.321    1.871   19.413    0.000
#>    .math3   (thet)   36.321    1.871   19.413    0.000
#>    .math4   (thet)   36.321    1.871   19.413    0.000
#>    .math5   (thet)   36.321    1.871   19.413    0.000
#>    .math6   (thet)   36.321    1.871   19.413    0.000
#>    .math7   (thet)   36.321    1.871   19.413    0.000
#>    .math8   (thet)   36.321    1.871   19.413    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   (.17.)   -0.035    1.144   -0.031    0.975
#> 
#> Intercepts:
#>                    Estimate  Std.Err  z-value  P(>|z|)
#>     eta_1            32.733    1.244   26.314    0.000
#>     eta_2             4.905    0.320   15.320    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   (.15.)   63.704    5.637   11.301    0.000
#>     eta_2   (.16.)    0.699    0.325    2.147    0.032
#>    .math2   (thet)   36.321    1.871   19.413    0.000
#>    .math3   (thet)   36.321    1.871   19.413    0.000
#>    .math4   (thet)   36.321    1.871   19.413    0.000
#>    .math5   (thet)   36.321    1.871   19.413    0.000
#>    .math6   (thet)   36.321    1.871   19.413    0.000
#>    .math7   (thet)   36.321    1.871   19.413    0.000
#>    .math8   (thet)   36.321    1.871   19.413    0.000

Eseguiamo il confronto tra i due modelli.

anova(mg_math_lavaan_fitM1, mg_math_lavaan_fitM2)
#> 
#> Chi-Squared Difference Test
#> 
#>                      Df   AIC   BIC  Chisq Chisq diff    RMSEA Df diff
#> mg_math_lavaan_fitM2 62 15948 15987 243.91                            
#> mg_math_lavaan_fitM1 64 15949 15978 249.11     5.2005 0.058601       2
#>                      Pr(>Chisq)  
#> mg_math_lavaan_fitM2             
#> mg_math_lavaan_fitM1    0.07425 .
#> ---
#> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Non vi è evidenza che consentire una differenza tra medie tra gruppi migliori l’adattamento del modello.