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:

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}