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

SATIS =~ JS1 + JS2
ESTEEM =~ SE1 + SE2

VERBAL =~ VI1
VI1 ~~ 0*VI1

PERFORM ~ ESTEEM
SATIS ~ 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 65 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        14
## 
##   Number of observations                           122
## 
## Model Test User Model:
##                                                       
##   Test statistic                                11.747
##   Degrees of freedom                                 7
##   P-value (Chi-square)                           0.109
## 
## Model Test Baseline Model:
## 
##   Test statistic                               212.828
##   Degrees of freedom                                15
##   P-value                                        0.000
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.976
##   Tucker-Lewis Index (TLI)                       0.949
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -1641.545
##   Loglikelihood unrestricted model (H1)      -1635.672
##                                                       
##   Akaike (AIC)                                3311.090
##   Bayesian (BIC)                              3350.346
##   Sample-size adjusted Bayesian (SABIC)       3306.081
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.075
##   90 Percent confidence interval - lower         0.000
##   90 Percent confidence interval - upper         0.147
##   P-value H_0: RMSEA <= 0.050                    0.251
##   P-value H_0: RMSEA >= 0.080                    0.511
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.049
## 
## 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
##   SATIS =~                                                              
##     JS1               1.000                               2.745    0.802
##     JS2               0.799    0.151    5.280    0.000    2.194    0.783
##   ESTEEM =~                                                             
##     SE1               1.000                               1.639    0.762
##     SE2               0.860    0.139    6.198    0.000    1.409    0.687
##   VERBAL =~                                                             
##     VI1               1.000                               3.635    1.000
## 
## Regressions:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   PERFORM ~                                                             
##     ESTEEM            0.937    0.147    6.358    0.000    0.738    0.738
##   SATIS ~                                                               
##     VERBAL            0.049    0.072    0.678    0.498    0.065    0.065
##     PERFORM           0.706    0.141    5.017    0.000    0.535    0.535
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   ESTEEM ~~                                                             
##     VERBAL           -2.296    0.674   -3.408    0.001   -0.385   -0.385
## 
## 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
##    .JS1               4.170    1.390    2.999    0.003    4.170    0.356
##    .JS2               3.040    0.908    3.348    0.001    3.040    0.387
##    .SE1               1.941    0.425    4.565    0.000    1.941    0.419
##    .SE2               2.222    0.387    5.746    0.000    2.222    0.528
##    .PERFORM           1.974    0.396    4.985    0.000    0.456    0.456
##    .SATIS             5.496    1.464    3.754    0.000    0.729    0.729
##     ESTEEM            2.687    0.639    4.204    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.