library(lavaan)

cormat <- '
1.000
0.725 1.000
0.595 0.705 1.000
0.566 0.624 0.706 1.000
'

smeans <- c(1.338,1.591,2.019,2.364)
sdev <- c(1.260,1.334,1.440,1.376)

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

colnames(covmat) <- c('alc12', 'alc14', 'alc16', 'alc18')
rownames(covmat) <- colnames(covmat)

linear.model <- '
final =~ 1*alc12 + 1*alc14 + 1*alc16 + 1*alc18
slope =~ (-6)*alc12 + (-4)*alc14 + (-2)*alc16 + 0*alc18

alc14 ~~ alc16
'

linear.fit <- growth(linear.model, sample.cov = covmat, sample.mean = smeans, sample.nobs = 357)
summary(linear.fit, fit.measures = T, standardized = T)
## lavaan 0.6.15 ended normally after 35 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        10
## 
##   Number of observations                           357
## 
## Model Test User Model:
##                                                       
##   Test statistic                                 5.292
##   Degrees of freedom                                 4
##   P-value (Chi-square)                           0.259
## 
## Model Test Baseline Model:
## 
##   Test statistic                               799.900
##   Degrees of freedom                                 6
##   P-value                                        0.000
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.998
##   Tucker-Lewis Index (TLI)                       0.998
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -2056.451
##   Loglikelihood unrestricted model (H1)      -2053.804
##                                                       
##   Akaike (AIC)                                4132.901
##   Bayesian (BIC)                              4171.679
##   Sample-size adjusted Bayesian (SABIC)       4139.954
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.030
##   90 Percent confidence interval - lower         0.000
##   90 Percent confidence interval - upper         0.090
##   P-value H_0: RMSEA <= 0.050                    0.630
##   P-value H_0: RMSEA >= 0.080                    0.096
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.020
## 
## 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 =~                                                              
##     alc12             1.000                               1.269    1.011
##     alc14             1.000                               1.269    0.938
##     alc16             1.000                               1.269    0.878
##     alc18             1.000                               1.269    0.925
##   slope =~                                                              
##     alc12            -6.000                              -1.020   -0.813
##     alc14            -4.000                              -0.680   -0.503
##     alc16            -2.000                              -0.340   -0.235
##     alc18             0.000                               0.000    0.000
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##  .alc14 ~~                                                              
##    .alc16             0.201    0.054    3.747    0.000    0.201    0.286
##   final ~~                                                              
##     slope             0.108    0.021    5.117    0.000    0.500    0.500
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .alc12             0.000                               0.000    0.000
##    .alc14             0.000                               0.000    0.000
##    .alc16             0.000                               0.000    0.000
##    .alc18             0.000                               0.000    0.000
##     final             2.359    0.072   32.826    0.000    1.860    1.860
##     slope             0.173    0.011   15.995    0.000    1.017    1.017
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .alc12             0.217    0.076    2.844    0.004    0.217    0.138
##    .alc14             0.618    0.062    9.914    0.000    0.618    0.338
##    .alc16             0.795    0.076   10.415    0.000    0.795    0.381
##    .alc18             0.271    0.092    2.946    0.003    0.271    0.144
##     final             1.609    0.154   10.464    0.000    1.000    1.000
##     slope             0.029    0.005    6.209    0.000    1.000    1.000

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