Lab 6 - Latent Growth Models

Structural Equation Modeling - Instructor: Karen Nylund-Gibson

Adam Garber

May 07, 2020

University of California, Santa Barbara


Lab preparation


Creating a version-controlled R-Project with Github

Download repository here: https://github.com/garberadamc/SEM-Lab6

On the Github repository webpage:

  1. fork your own branch of the lab repository
  2. copy the repository web URL address from the clone or download menu

Within R-Studio:

  1. click “NEW PROJECT”
  2. choose option Version Control
  3. choose option Git
  4. paste the repository web URL path copied from the clone or download menu on Github page
  5. choose location of the R-Project (too many nested folders will result in filepath error)

Data sources:

  1. The first 3 models utilize a public use data subset the Longitudinal Survey of American Youth (LSAY) \(\color{blue}{\text{See documentation here}}\)

  2. The 4th model utilizes a public use data subset the High School Longitudinal Study (HSLS) \(\color{blue}{\text{See documentation here}}\)


Load packages


LSAY data example - Math Scores across 6 timepoints


Read in data


View metadeta

Write a CSV file

Read in the CSV file (SPSS labels removed)


Table. LSAY repeated measures
Name Labels
math_07 7th grade math score (imputed)
math_08 8th grade math score (imputed)
math_09 9th grade math score (imputed)
math_10 10th grade math score (imputed)
math_11 11th grade math score (imputed)
math_12 12th grade math score (imputed)


Plotting using gh5 plot data generated by Mplus

  1. View plots available for a given model
  2. Generate plots using the get.plot.___ function
  3. Extract data and transform to tidy format
  4. Plot with ggplot

Prepare plot data

Plot the model estimated means superimposted on the obserbed individual values

Animate the plot with {gganimate}


HSLS data example - Academic expectations



Table. HSLS repeated measures

Question stem - Highest level of education expected...
Name Labels Levels
s1eduexp 9th grade (2009) 1 = less HS, 2 = HS, 3 = Bach, 5 = Master, 6 = Ph.D
s2eduexp 11th grade (2012) 1 = less HS, 2 = HS, 3 = Bach, 5 = Master, 6 = Ph.D
s4eduexp 3 years post high school (2016) 1 = less HS, 2 = HS, 3 = Bach, 5 = Master, 6 = Ph.D

Model 4 - Latent growth model with categorical outcomes



Prepare plot data

Plot the model estimated probabilities (categorical outcomes)

Create an animated plot with {gganimate}


References

Hallquist, M. N., & Wiley, J. F. (2018). MplusAutomation: An R Package for Facilitating Large-Scale Latent Variable Analyses in Mplus. Structural equation modeling: a multidisciplinary journal, 25(4), 621-638.

Ingels, S. J., Pratt, D. J., Herget, D. R., Burns, L. J., Dever, J. A., Ottem, R., … & Leinwand, S. (2011). High School Longitudinal Study of 2009 (HSLS: 09): Base-Year Data File Documentation. NCES 2011-328. National Center for Education Statistics.

Miller, J. D., Hoffer, T., Suchner, R., Brown, K., & Nelson, C. (1992). LSAY codebook. Northern Illinois University.

Muthén, B. O., Muthén, L. K., & Asparouhov, T. (2017). Regression and mediation analysis using Mplus. Los Angeles, CA: Muthén & Muthén.

Muthén, L.K. and Muthén, B.O. (1998-2017). Mplus User’s Guide. Eighth Edition. Los Angeles, CA: Muthén & Muthén

R Core Team (2017). R: A language and environment for statistical computing. R Foundation for Statistical Computing, Vienna, Austria. URL http://www.R-project.org/

Wickham et al., (2019). Welcome to the tidyverse. Journal of Open Source Software, 4(43), 1686, https://doi.org/10.21105/joss.01686