Lab 7 - Ten Growth Models - Simple to Advanced

Structural Equation Modeling - Instructor: Karen Nylund-Gibson

Adam Garber

May 17, 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

Let’s start modeling

Table. LSAY repeated measures
Name Labels Variable type
math_07 7th grade math score time varying covariate
math_08 8th grade math score
math_09 9th grade math score
math_10 10th grade math score
math_11 11th grade math score
math_12 12th grade math score
sci_07 7th grade science score model indicators (outcomes)
sci_08 8th grade science score
sci_09 9th grade science score
sci_10 10th grade science score
sci_11 11th grade science score
sci_12 12th grade science score

Model 01 - Fixed time effects

Load in the mplus.R functions

## [1] "Loaded rhdf5 package"

Plotting using gh5 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}