Here is an example of what I think would be a latent growth model with groups. This first model only estimates the variances for each time point among each group, which mostly works (does converge, but has some negative variances, which is not good). I am assuming 180 total participants measured over four time points with 20 Hispanic, 20 Black, 10 Native American, 20 Asian American, and 110 White.
library(lavaan)
## Warning: package 'lavaan' was built under R version 3.2.5
## This is lavaan 0.5-23.1097
## lavaan is BETA software! Please report any bugs.
set.seed(123)
time1 = rnorm(720/4)
time2 = rnorm(720/4)
time3 = rnorm(720/4)
time4 = rnorm(720/4)
eth = c(rep("HIS", 20), rep("BL", 20), rep("AI", 10), rep("AA", 20), rep("WHITE", 180-70))
eth = as.data.frame(eth)
dataTest = cbind(time1, time2, time3, time4, eth)
names(dataTest) = c("t1", "t2", "t3", "t4" , "eth")
dataTest = as.data.frame(dataTest)
model <- ' i =~ 1*t1 + 1*t2 + 1*t3 + 1*t4
s =~ 0*t1 + 1*t2 + 2*t3 + 3*t4 '
fit <- growth(model, data=dataTest, group = "eth", estimator = "MLM")
## Warning in lav_object_post_check(object): lavaan WARNING: some estimated lv
## variances are negative
summary(fit)
## lavaan (0.5-23.1097) converged normally after 88 iterations
##
## Number of observations per group
## HIS 20
## BL 20
## AI 10
## AA 20
## WHITE 110
##
## Estimator ML Robust
## Minimum Function Test Statistic 17.707 20.089
## Degrees of freedom 25 25
## P-value (Chi-square) 0.855 0.742
## Scaling correction factor 0.881
## for the Satorra-Bentler correction
##
## Chi-square for each group:
##
## HIS 3.010 3.415
## BL 1.181 1.340
## AI 5.891 6.684
## AA 1.922 2.181
## WHITE 5.702 6.470
##
## Parameter Estimates:
##
## Information Expected
## Standard Errors Robust.sem
##
##
## Group 1 [HIS]:
##
## Latent Variables:
## Estimate Std.Err z-value P(>|z|)
## i =~
## t1 1.000
## t2 1.000
## t3 1.000
## t4 1.000
## s =~
## t1 0.000
## t2 1.000
## t3 2.000
## t4 3.000
##
## Covariances:
## Estimate Std.Err z-value P(>|z|)
## i ~~
## s -0.218 0.178 -1.223 0.221
##
## Intercepts:
## Estimate Std.Err z-value P(>|z|)
## .t1 0.000
## .t2 0.000
## .t3 0.000
## .t4 0.000
## i 0.064 0.210 0.305 0.761
## s -0.011 0.109 -0.099 0.922
##
## Variances:
## Estimate Std.Err z-value P(>|z|)
## .t1 0.377 0.328 1.152 0.249
## .t2 0.622 0.196 3.168 0.002
## .t3 0.724 0.233 3.111 0.002
## .t4 0.617 0.269 2.292 0.022
## i 0.534 0.345 1.548 0.122
## s 0.127 0.101 1.253 0.210
##
##
## Group 2 [BL]:
##
## Latent Variables:
## Estimate Std.Err z-value P(>|z|)
## i =~
## t1 1.000
## t2 1.000
## t3 1.000
## t4 1.000
## s =~
## t1 0.000
## t2 1.000
## t3 2.000
## t4 3.000
##
## Covariances:
## Estimate Std.Err z-value P(>|z|)
## i ~~
## s 0.153 0.095 1.609 0.108
##
## Intercepts:
## Estimate Std.Err z-value P(>|z|)
## .t1 0.000
## .t2 0.000
## .t3 0.000
## .t4 0.000
## i -0.029 0.142 -0.203 0.839
## s -0.015 0.072 -0.205 0.838
##
## Variances:
## Estimate Std.Err z-value P(>|z|)
## .t1 0.908 0.300 3.032 0.002
## .t2 1.054 0.310 3.399 0.001
## .t3 0.732 0.172 4.249 0.000
## .t4 0.667 0.327 2.039 0.041
## i -0.261 0.249 -1.052 0.293
## s -0.061 0.058 -1.058 0.290
##
##
## Group 3 [AI]:
##
## Latent Variables:
## Estimate Std.Err z-value P(>|z|)
## i =~
## t1 1.000
## t2 1.000
## t3 1.000
## t4 1.000
## s =~
## t1 0.000
## t2 1.000
## t3 2.000
## t4 3.000
##
## Covariances:
## Estimate Std.Err z-value P(>|z|)
## i ~~
## s 0.050 0.106 0.470 0.638
##
## Intercepts:
## Estimate Std.Err z-value P(>|z|)
## .t1 0.000
## .t2 0.000
## .t3 0.000
## .t4 0.000
## i 0.058 0.258 0.227 0.821
## s -0.137 0.094 -1.457 0.145
##
## Variances:
## Estimate Std.Err z-value P(>|z|)
## .t1 0.803 0.360 2.229 0.026
## .t2 0.468 0.207 2.261 0.024
## .t3 0.757 0.226 3.347 0.001
## .t4 1.380 0.280 4.920 0.000
## i 0.089 0.277 0.320 0.749
## s -0.119 0.060 -1.984 0.047
##
##
## Group 4 [AA]:
##
## Latent Variables:
## Estimate Std.Err z-value P(>|z|)
## i =~
## t1 1.000
## t2 1.000
## t3 1.000
## t4 1.000
## s =~
## t1 0.000
## t2 1.000
## t3 2.000
## t4 3.000
##
## Covariances:
## Estimate Std.Err z-value P(>|z|)
## i ~~
## s -0.109 0.082 -1.325 0.185
##
## Intercepts:
## Estimate Std.Err z-value P(>|z|)
## .t1 0.000
## .t2 0.000
## .t3 0.000
## .t4 0.000
## i 0.151 0.176 0.857 0.391
## s -0.100 0.116 -0.858 0.391
##
## Variances:
## Estimate Std.Err z-value P(>|z|)
## .t1 0.644 0.254 2.538 0.011
## .t2 0.976 0.302 3.235 0.001
## .t3 1.295 0.393 3.291 0.001
## .t4 1.190 0.671 1.774 0.076
## i 0.082 0.169 0.484 0.629
## s 0.075 0.071 1.054 0.292
##
##
## Group 5 [WHITE]:
##
## Latent Variables:
## Estimate Std.Err z-value P(>|z|)
## i =~
## t1 1.000
## t2 1.000
## t3 1.000
## t4 1.000
## s =~
## t1 0.000
## t2 1.000
## t3 2.000
## t4 3.000
##
## Covariances:
## Estimate Std.Err z-value P(>|z|)
## i ~~
## s -0.006 0.060 -0.092 0.926
##
## Intercepts:
## Estimate Std.Err z-value P(>|z|)
## .t1 0.000
## .t2 0.000
## .t3 0.000
## .t4 0.000
## i 0.040 0.079 0.502 0.616
## s -0.017 0.043 -0.406 0.685
##
## Variances:
## Estimate Std.Err z-value P(>|z|)
## .t1 0.932 0.179 5.196 0.000
## .t2 1.059 0.150 7.066 0.000
## .t3 0.801 0.109 7.321 0.000
## .t4 0.905 0.191 4.740 0.000
## i 0.015 0.125 0.123 0.902
## s 0.015 0.038 0.380 0.704
Now here is the same data set, but now I am going to estimate slopes and intercepts for each group among each time point. As you can see in the output the model breaks down. Not sure if I am setting this model up right or if the model is just too complex for the amount of data that we are expecting.
library(lavaan)
set.seed(123)
time1 = rnorm(720/4)
time2 = rnorm(720/4)
time3 = rnorm(720/4)
time4 = rnorm(720/4)
eth = c(rep("HIS", 20), rep("BL", 20), rep("AI", 10), rep("AA", 20), rep("WHITE", 180-70))
eth = as.data.frame(eth)
dataTest = cbind(time1, time2, time3, time4, eth)
names(dataTest) = c("t1", "t2", "t3", "t4" , "eth")
dataTest = as.data.frame(dataTest)
model <- ' i =~ t1 + t2 + t3 + t4
s =~ t1 + t2 + t3 + t4 '
fit <- growth(model, data=dataTest, group = "eth", estimator = "MLM")
## Warning in lavaan::lavaan(model = model, data = dataTest, group = "eth", :
## lavaan WARNING: model has NOT converged!
summary(fit)
## ** WARNING ** lavaan (0.5-23.1097) did NOT converge after 10000 iterations
## ** WARNING ** Estimates below are most likely unreliable
##
## Number of observations per group
## HIS 20
## BL 20
## AI 10
## AA 20
## WHITE 110
##
## Estimator ML
## Minimum Function Test Statistic NA
## Degrees of freedom NA
## P-value NA
##
## Chi-square for each group:
##
## HIS NA
## BL NA
## AI NA
## AA NA
## WHITE NA
##
## Parameter Estimates:
##
## Information Expected
## Standard Errors Robust.sem
##
##
## Group 1 [HIS]:
##
## Latent Variables:
## Estimate Std.Err z-value P(>|z|)
## i =~
## t1 1.000
## t2 444.990 NA
## t3 -0.045 NA
## t4 -114.537 NA
## s =~
## t1 1.000
## t2 433.280 NA
## t3 -0.126 NA
## t4 -253.207 NA
##
## Covariances:
## Estimate Std.Err z-value P(>|z|)
## i ~~
## s -0.029 NA
##
## Intercepts:
## Estimate Std.Err z-value P(>|z|)
## .t1 0.000
## .t2 0.000
## .t3 0.000
## .t4 0.000
## i -0.000 NA
## s -0.000 NA
##
## Variances:
## Estimate Std.Err z-value P(>|z|)
## .t1 0.918 NA
## .t2 -163.593 NA
## .t3 0.929 NA
## .t4 -567.255 NA
## i 0.029 NA
## s 0.029 NA
##
##
## Group 2 [BL]:
##
## Latent Variables:
## Estimate Std.Err z-value P(>|z|)
## i =~
## t1 1.000
## t2 4.059 NA
## t3 -2.345 NA
## t4 271.869 NA
## s =~
## t1 1.000
## t2 3.675 NA
## t3 -2.006 NA
## t4 403.917 NA
##
## Covariances:
## Estimate Std.Err z-value P(>|z|)
## i ~~
## s 0.087 NA
##
## Intercepts:
## Estimate Std.Err z-value P(>|z|)
## .t1 0.000
## .t2 0.000
## .t3 0.000
## .t4 0.000
## i 0.064 NA
## s -0.043 NA
##
## Variances:
## Estimate Std.Err z-value P(>|z|)
## .t1 0.672 NA
## .t2 1.383 NA
## .t3 1.003 NA
## .t4 -325.110 NA
## i -0.135 NA
## s -0.053 NA
##
##
## Group 3 [AI]:
##
## Latent Variables:
## Estimate Std.Err z-value P(>|z|)
## i =~
## t1 1.000
## t2 61.468 NA
## t3 389.501 NA
## t4 274.446 NA
## s =~
## t1 1.000
## t2 61.472 NA
## t3 389.529 NA
## t4 274.465 NA
##
## Covariances:
## Estimate Std.Err z-value P(>|z|)
## i ~~
## s 54.332 NA
##
## Intercepts:
## Estimate Std.Err z-value P(>|z|)
## .t1 0.000
## .t2 0.000
## .t3 0.000
## .t4 0.000
## i -405.608 NA
## s 405.578 NA
##
## Variances:
## Estimate Std.Err z-value P(>|z|)
## .t1 1.052 NA
## .t2 0.545 NA
## .t3 4.030 NA
## .t4 -1.046 NA
## i -41.788 NA
## s -66.874 NA
##
##
## Group 4 [AA]:
##
## Latent Variables:
## Estimate Std.Err z-value P(>|z|)
## i =~
## t1 1.000
## t2 -0.113 NA
## t3 1.050 NA
## t4 30.398 NA
## s =~
## t1 1.000
## t2 -0.085 NA
## t3 1.023 NA
## t4 -39.216 NA
##
## Covariances:
## Estimate Std.Err z-value P(>|z|)
## i ~~
## s -0.179 NA
##
## Intercepts:
## Estimate Std.Err z-value P(>|z|)
## .t1 0.000
## .t2 0.000
## .t3 0.000
## .t4 0.000
## i 0.094 NA
## s 0.079 NA
##
## Variances:
## Estimate Std.Err z-value P(>|z|)
## .t1 0.952 NA
## .t2 0.902 NA
## .t3 1.450 NA
## .t4 -597.370 NA
## i 0.049 NA
## s 0.083 NA
##
##
## Group 5 [WHITE]:
##
## Latent Variables:
## Estimate Std.Err z-value P(>|z|)
## i =~
## t1 1.000
## t2 -2.477 NA
## t3 -1.785 NA
## t4 570.632 NA
## s =~
## t1 1.000
## t2 -2.477 NA
## t3 -1.785 NA
## t4 570.016 NA
##
## Covariances:
## Estimate Std.Err z-value P(>|z|)
## i ~~
## s 40.215 NA
##
## Intercepts:
## Estimate Std.Err z-value P(>|z|)
## .t1 0.000
## .t2 0.000
## .t3 0.000
## .t4 0.000
## i 36.542 NA
## s -36.582 NA
##
## Variances:
## Estimate Std.Err z-value P(>|z|)
## .t1 0.942 NA
## .t2 1.069 NA
## .t3 0.859 NA
## .t4 -413.180 NA
## i -39.094 NA
## s -41.338 NA