lcmm() Graphing Models Fit with Random Intercept Only or Random Intercept and Slope

20 views Asked by At

I fit several growth mixture models (GMM) using hlme() from package lcmm. Then I generated graphs to show me the trajectories of each class identified in these models. Specifically, I fit one- and three- class models with random intercepts only (gmm1 and gmm3) or with random intercepts and slopes (gmm1_slope and gmm3_slope).

I anticipated that the graph of gmm3 would contain three parallel lines whereas the graph of gmm3_slope would contain three (not necessarily parallel) lines. That said, the graphs for my random intercepts only model (gmm3) appears to have random slopes...

Have I misspecified my model(s)? Or maybe incorrectly created the plots to see average class trajectory? Code and resulting images supplied below:

Sample Code

library(dplyr)
library(lcmm)
sample <- as.data.frame(matrix(data=c(1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 
                                        0, 3, 8, 15, 25, 0, 3, 8, 15, 25, 0, 3, 8, 15, 25, 0, 3, 8, 15, 25, 
                                        -0.0924870160, 0.0274498752, 0.2398900582, 
                                        0.1422529358, 
                                        0.1440320863, -0.0869990920, 0.1423375351, 
                                        -0.239953000, -0.2378607918, 0.1893095329, 
                                        0.0470979475, 0.0681092844, 0.0643890367, 
                                        -0.1299717236, 0.0284062668, 0.0249408593, 
                                        0.2341043359, 0.0866213575, 0.1003340839, 
                                        0.2721473565), ncol=3))|>
  mutate(ID=V1, time=V2, wblv_z=V3)|>
  select(-starts_with("V"))
gmm1z <- hlme(wblv_z ~ time, subject="ID", var.time="time", random=~1, 
              ng=1, data=sample)
gmm3z <- gridsearch(rep=100, maxiter=10, minit=gmm1z, 
                    hlme(wblv_z~time, subject="ID", random=~1, 
                         ng=3, nwg=T, data=sample, mixture=~time))
gmm1z_slope <- hlme(wblv_z~time, subject="ID", var.time="time", random=~1+time, 
                    ng=1, data=sample)
gmm3z_slope <- gridsearch(rep=100, maxiter=10, minit=gmm1z_slope, 
                          hlme(wblv_z~time, subject="ID", random=~1+time, 
                               ng=3, nwg=T, data=sample, mixture=~time))
plot(predictY(gmm3z, sample, var.time="time"), 
     legend.loc="bottomright", bty="l", 
     main="Three Classes w/ Random Intercepts Only")
plot(predictY(gmm3z_slope, sample, var.time="time"), 
     legend.loc="bottomright", bty="l", 
     main="Three Classes w/ Random Intercepts and Slopes")

Graphs Generated

Graph of Random Intercepts Only Model

Graph of Random Intercepts and Slopes Model

0

There are 0 answers