library(lavaan)
library(simsem)
popmodel <- '

INTERC =~ 1*V1 + 1*V2 + 1*V3 + 1*V4
SLOPE =~ 0*V1 + 1*V2 + 2*V3 + 3*V4

INTERC ~~ 1*INTERC
SLOPE ~~ .04*SLOPE
INTERC ~~ -.10*SLOPE

INTERC ~ 5*1
SLOPE ~ .5*1

V1 ~~ .25*V1
V2 ~~ .25*V2
V3 ~~ .25*V3
V4 ~~ .25*V4

V1 ~ 0*1
V2 ~ 0*1
V3 ~ 0*1
V4 ~ 0*1

'
Analyze.model <- '

INTERC =~ 1*V1 + 1*V2 + 1*V3 + 1*V4
SLOPE =~ 0*V1 + 1*V2 + 2*V3 + 3*V4

INTERC ~~ INTERC
SLOPE ~~ SLOPE
INTERC ~~ SLOPE

INTERC ~ 1
SLOPE ~ 1

V1 ~~ V1
V2 ~~ V2
V3 ~~ V3
V4 ~~ V4

V1 ~ 0*1
V2 ~ 0*1
V3 ~ 0*1
V4 ~ 0*1
'
Output <- sim(1000, Analyze.model, n = 130, generate = popmodel, lavaanfun = "sem")
summary(Output)
## RESULT OBJECT
## Model Type
## [1] "lavaan"
## ========= Fit Indices Cutoffs ============
##            Alpha
## Fit Indices      0.1     0.05     0.01    0.001     Mean     SD
##       chisq    9.116   11.144   14.342   18.761    4.916  3.108
##       aic   1218.903 1229.157 1248.090 1268.953 1176.910 32.507
##       bic   1244.711 1254.965 1273.898 1294.760 1202.717 32.507
##       rmsea    0.080    0.097    0.120    0.146    0.024  0.035
##       cfi      0.988    0.983    0.973    0.956    0.997  0.006
##       tli      0.986    0.980    0.967    0.947    1.000  0.011
##       srmr     0.052    0.060    0.073    0.086    0.034  0.014
## ========= Parameter Estimates and Standard Errors ============
##                Estimate Average Estimate SD Average SE
## INTERC~~INTERC            0.985       0.152      0.147
## SLOPE~~SLOPE              0.040       0.015      0.014
## INTERC~~SLOPE            -0.099       0.036      0.035
## INTERC~1                  4.998       0.097      0.094
## SLOPE~1                   0.500       0.026      0.026
## V1~~V1                    0.249       0.068      0.066
## V2~~V2                    0.251       0.043      0.043
## V3~~V3                    0.249       0.042      0.042
## V4~~V4                    0.253       0.066      0.063
##                Power (Not equal 0) Std Est Std Est SD Std Ave SE
## INTERC~~INTERC               1.000   1.000      0.000      0.000
## SLOPE~~SLOPE                 0.817   1.000      0.000      0.000
## INTERC~~SLOPE                0.833  -0.500      0.119      0.122
## INTERC~1                     1.000   5.083      0.416      0.395
## SLOPE~1                      1.000   2.677      0.664      0.654
## V1~~V1                       0.978   0.203      0.057      0.054
## V2~~V2                       1.000   0.234      0.040      0.039
## V3~~V3                       1.000   0.251      0.041      0.041
## V4~~V4                       0.990   0.253      0.063      0.062
##                Average Param Average Bias Coverage
## INTERC~~INTERC          1.00       -0.015    0.939
## SLOPE~~SLOPE            0.04        0.000    0.950
## INTERC~~SLOPE          -0.10        0.001    0.939
## INTERC~1                5.00       -0.002    0.932
## SLOPE~1                 0.50        0.000    0.948
## V1~~V1                  0.25       -0.001    0.943
## V2~~V2                  0.25        0.001    0.955
## V3~~V3                  0.25       -0.001    0.940
## V4~~V4                  0.25        0.003    0.943
## ========= Correlation between Fit Indices ============
##        chisq    aic    bic  rmsea    cfi    tli   srmr
## chisq  1.000  0.077  0.077  0.946 -0.913 -0.993  0.788
## aic    0.077  1.000  1.000  0.063 -0.048 -0.079  0.074
## bic    0.077  1.000  1.000  0.063 -0.048 -0.079  0.074
## rmsea  0.946  0.063  0.063  1.000 -0.932 -0.938  0.729
## cfi   -0.913 -0.048 -0.048 -0.932  1.000  0.918 -0.668
## tli   -0.993 -0.079 -0.079 -0.938  0.918  1.000 -0.787
## srmr   0.788  0.074  0.074  0.729 -0.668 -0.787  1.000
## ================== Replications =====================
## Number of replications = 1000 
## Number of converged replications = 998 
## Number of nonconverged replications: 
##    1. Nonconvergent Results = 0 
##    2. Nonconvergent results from multiple imputation = 0 
##    3. At least one SE were negative or NA = 0 
##    4. Nonpositive-definite latent or observed (residual) covariance matrix 
##       (e.g., Heywood case or linear dependency) = 1

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