Plotting latent growth curve adjusted for covariates

176 views
Skip to first unread message

JONATHAN LOUIS CHIA JIE SHENG _

unread,
Sep 14, 2022, 1:47:59 AM9/14/22
to lavaan
Hi all, 

Is there a way to plot latent growth trajectories adjusted for the influence of covariates
I have scoured the internet but have not found an answer. 

If so, is there a sample code I may refer to? 

Thank you so much!
Jon

Terrence Jorgensen

unread,
Sep 14, 2022, 8:24:33 AM9/14/22
to lavaan
Is there a way to plot latent growth trajectories adjusted for the influence of covariates

Adjusted (controlling for) or conditioned on (moderated by)?  The former implies your covariate only influences the latent intercept.  The latter implies your covariate influences the latent slope (so time's effect is moderated by the covariate).

Terrence D. Jorgensen
Assistant Professor, Methods and Statistics
Research Institute for Child Development and Education, the University of Amsterdam

JONATHAN LOUIS CHIA JIE SHENG _

unread,
Sep 15, 2022, 12:50:13 AM9/15/22
to lavaan
Hi Terrence, 

Both-- covariates influencing the latent intercept and latent slopes (linear and quadratic) :)

Is there a way to plot these growth trajectories? 

Thank you so much!

Michael Zyphur

unread,
Sep 15, 2022, 2:55:56 AM9/15/22
to lavaan
Hi Jon
Great question! There are at least two ways to control for covariates in models like these. Consistent with a MIMIC model, you can include your control variables as predictors of the observed longitudinal variables and/or the intercept and slope factors. In these cases you'd want to grand-mean center the control variables first to ensure the mean structure of the longitudinal variables and intercept/slope factors remain easily interpretable and useful for LGM.

This and other topics are described in the Instats seminar on Longitudinal SEM in R, including example program code and data for these types of models -- with controls on observed and the latent LGM variables.

Hope this helps!
Mike

JONATHAN LOUIS C

unread,
Sep 16, 2022, 1:59:01 AM9/16/22
to lavaan
Hi Mike, 

Thanks for the advice. I am aware of how to control for these covariates, but it's trying to plot these adjusted/conditioned trajectories that I am having trouble with. 

Cheers,
Jon

Michael Zyphur

unread,
Sep 16, 2022, 2:32:50 AM9/16/22
to lav...@googlegroups.com
Hi Jon
No worries! There are various ways to do this, but in all cases you would probably want to condition the observed longitudinal variables on the controls while estimating the LGM. Then you can request factor scores and generate plots based on those. This is also covered explicitly in the Longitudinal SEM in R seminar by Instats. Here is some example code from Session 2 (out of 8 Sessions) from the seminar. The only change you would need to make is to control for the covariates by predicting the observed time series variables, which this example does not do (a previous example does this):


# Now let's plot predicted individual linear LGM trajectories
# Plot 5
ourModel <- '
  I =~  1*cig97 + 1*cig98 + 1*cig99 + 1*cig00 + 1*cig01 + 1*cig02
  S =~  0*cig97 + 1*cig98 + 2*cig99 + 3*cig00 + 4*cig01 + 5*cig02
'
fit <- growth(ourModel, data = nlsy, mimic="Mplus", estimator="MLR")
plot_dat <- na.omit(data.frame(lavPredict(fit)))
head(plot_dat)

plot_dat$participant_n <-
  1:nrow(plot_dat)

ggplot(data=plot_dat) +
  scale_x_continuous(name = "Timepoint",
    limits=c(0, 5), breaks = c(0, 1, 2, 3, 4, 5),
    labels = c('0', '1', '2', '3', '4', '5')) +
  scale_y_continuous(name = "Cig Use", limits=c(0,25))+
  geom_abline(data = plot_dat, mapping =
              aes(slope=S, intercept=I, color = participant_n), alpha = 0.05) +
  labs(title = 'Predicted trajectories of Cig Use')  +
  theme(legend.position = 'none')


Hope this helps!
Mike


--
You received this message because you are subscribed to a topic in the Google Groups "lavaan" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/lavaan/VajFUocCgVQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to lavaan+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lavaan/93207ab0-f2d1-4616-aaf3-093350bbda94n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages