library(lavaan)

cormat <- '
1.000       
0.418 1.000      
0.394 0.627 1.000     
0.129 0.202 0.266 1.000    
0.189 0.284 0.208 0.365 1.000   
0.544 0.281 0.324 0.201 0.161 1.000  
0.507 0.225 0.314 0.172 0.174 0.546 1.000 
-0.357 -0.156 -0.038 -0.199 -0.277 -0.294 -0.174 1.000
'

sdev <- c(2.090, 3.430, 2.810, 1.950, 2.060, 2.160, 2.060, 3.650)

Cmat <- getCov(cormat)
Dmat <- diag(sdev)
covmat <- Dmat %*% Cmat %*% Dmat

colnames(covmat) <- c("Per1", "JS1", "JS2", "Mot1", "Mot2", "SE1", "SE2", "VI1")
rownames(covmat) <- colnames(covmat)

lv.pa.model <- '

PERFORM =~ 1*Per1
Per1 ~~ 0*Per1

ACHIEVE =~ Mot1 + Mot2
SATIS =~ JS1 + JS2
ESTEEM =~ SE1 + SE2

VERBAL =~ VI1
VI1 ~~ 0*VI1

PERFORM ~ ESTEEM
SATIS ~ ACHIEVE + VERBAL + PERFORM
'

lv.pa.fit <- sem(lv.pa.model, sample.cov = covmat, sample.nobs = 122)
summary(lv.pa.fit, fit.measures = T, standardized = T)
## lavaan 0.6.15 ended normally after 84 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        21
## 
##   Number of observations                           122
## 
## Model Test User Model:
##                                                       
##   Test statistic                                14.191
##   Degrees of freedom                                15
##   P-value (Chi-square)                           0.511
## 
## Model Test Baseline Model:
## 
##   Test statistic                               258.619
##   Degrees of freedom                                28
##   P-value                                        0.000
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    1.000
##   Tucker-Lewis Index (TLI)                       1.007
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -2134.734
##   Loglikelihood unrestricted model (H1)      -2127.638
##                                                       
##   Akaike (AIC)                                4311.468
##   Bayesian (BIC)                              4370.353
##   Sample-size adjusted Bayesian (SABIC)       4303.955
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.000
##   90 Percent confidence interval - lower         0.000
##   90 Percent confidence interval - upper         0.081
##   P-value H_0: RMSEA <= 0.050                    0.770
##   P-value H_0: RMSEA >= 0.080                    0.055
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.035
## 
## 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
##   PERFORM =~                                                            
##     Per1              1.000                               2.081    1.000
##   ACHIEVE =~                                                            
##     Mot1              1.000                               1.105    0.569
##     Mot2              1.169    0.336    3.484    0.000    1.292    0.630
##   SATIS =~                                                              
##     JS1               1.000                               2.704    0.787
##     JS2               0.834    0.134    6.221    0.000    2.254    0.801
##   ESTEEM =~                                                             
##     SE1               1.000                               1.648    0.766
##     SE2               0.861    0.137    6.283    0.000    1.419    0.692
##   VERBAL =~                                                             
##     VI1               1.000                               3.635    1.000
## 
## Regressions:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   PERFORM ~                                                             
##     ESTEEM            0.922    0.144    6.425    0.000    0.730    0.730
##   SATIS ~                                                               
##     ACHIEVE           1.179    0.452    2.609    0.009    0.482    0.482
##     VERBAL            0.175    0.085    2.065    0.039    0.235    0.235
##     PERFORM           0.583    0.138    4.223    0.000    0.449    0.449
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   ACHIEVE ~~                                                            
##     ESTEEM            0.741    0.294    2.516    0.012    0.407    0.407
##     VERBAL           -1.614    0.585   -2.761    0.006   -0.402   -0.402
##   ESTEEM ~~                                                             
##     VERBAL           -2.297    0.675   -3.402    0.001   -0.383   -0.383
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .Per1              0.000                               0.000    0.000
##    .VI1               0.000                               0.000    0.000
##    .Mot1              2.550    0.473    5.388    0.000    2.550    0.676
##    .Mot2              2.540    0.568    4.472    0.000    2.540    0.604
##    .JS1               4.480    1.161    3.860    0.000    4.480    0.380
##    .JS2               2.834    0.790    3.588    0.000    2.834    0.358
##    .SE1               1.913    0.419    4.564    0.000    1.913    0.413
##    .SE2               2.196    0.383    5.730    0.000    2.196    0.522
##    .PERFORM           2.023    0.391    5.170    0.000    0.467    0.467
##     ACHIEVE           1.222    0.494    2.473    0.013    1.000    1.000
##    .SATIS             3.893    1.190    3.273    0.001    0.533    0.533
##     ESTEEM            2.715    0.638    4.256    0.000    1.000    1.000
##     VERBAL           13.213    1.692    7.810    0.000    1.000    1.000

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