library(lavaan)

lower <- '
323.800
272.989    291.549
271.535    264.022    298.744
0.005     -0.046      0.134      0.242
'

covmat <- getCov(lower)
colnames(covmat) <- c('total1','total2','total3','gender')
rownames(covmat) <- colnames(covmat)

cond.model <- "

final =~ 1*total1 + 1*total2 + 1*total3
slope =~ (-2)*total1 + (-1)*total2 + 0*total3

final ~ gender
slope ~ gender

total1 ~~ a*total1
total2 ~~ a*total2
total3 ~~ a*total3

"

cond.fit <- sem(cond.model, sample.cov = covmat, sample.nobs = 324)
summary(cond.fit, fit.measures = T, standardized = T)
## lavaan 0.6.15 ended normally after 78 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                         8
##   Number of equality constraints                     2
## 
##   Number of observations                           324
## 
## Model Test User Model:
##                                                       
##   Test statistic                                 2.821
##   Degrees of freedom                                 3
##   P-value (Chi-square)                           0.420
## 
## Model Test Baseline Model:
## 
##   Test statistic                              1078.363
##   Degrees of freedom                                 6
##   P-value                                        0.000
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    1.000
##   Tucker-Lewis Index (TLI)                       1.000
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -3619.032
##   Loglikelihood unrestricted model (H1)      -3617.621
##                                                       
##   Akaike (AIC)                                7250.063
##   Bayesian (BIC)                              7272.748
##   Sample-size adjusted Bayesian (SABIC)       7253.717
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.000
##   90 Percent confidence interval - lower         0.000
##   90 Percent confidence interval - upper         0.092
##   P-value H_0: RMSEA <= 0.050                    0.705
##   P-value H_0: RMSEA >= 0.080                    0.093
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.015
## 
## Parameter Estimates:
## 
##   Standard errors                             Standard
##   Information                                 Expected
##   Information saturated (h1) model          Structured
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   final =~                                                              
##     total1            1.000                              16.231    0.912
##     total2            1.000                              16.231    0.936
##     total3            1.000                              16.231    0.947
##   slope =~                                                              
##     total1           -2.000                              -4.262   -0.240
##     total2           -1.000                              -2.131   -0.123
##     total3            0.000                               0.000    0.000
## 
## Regressions:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   final ~                                                               
##     gender            0.395    1.922    0.205    0.837    0.024    0.012
##   slope ~                                                               
##     gender            0.267    0.503    0.530    0.596    0.125    0.061
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##  .final ~~                                                              
##    .slope            -1.138    4.438   -0.256    0.798   -0.033   -0.033
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .total1     (a)   30.533    2.399   12.728    0.000   30.533    0.096
##    .total2     (a)   30.533    2.399   12.728    0.000   30.533    0.102
##    .total3     (a)   30.533    2.399   12.728    0.000   30.533    0.104
##    .final           263.394   22.781   11.562    0.000    1.000    1.000
##    .slope             4.523    1.964    2.304    0.021    0.996    0.996

© Copyright 2024 @Yi Feng and @Gregory R. Hancock.