Examples of Latent Change Score Models

The saved examples below were generated with nlpsem 1.0.0.9006; extdata/REGENERATED.txt records the versions and how the fits compare with the previous ones. Rendering this guide does not refit its disabled model-fitting chunks. Refit with the current version for a new analysis, use getDiagnostics() to check admissibility and uncertainty, and compare multiple starts for difficult nonlinear or mixture models. These examples are not evidence of numerical qualification.

The change plots follow the fitted LCSM interval recurrence. For exponential and Jenss-Bayley models this includes the midpoint approximation used in fitting. The rate plots show interval-average rates at the ending observation time, with joint-covariance pointwise intervals. Selecting fewer fitted waves retains all intervening increments and measures change from the first selected wave; it does not fit or integrate a new curve over the enlarged intervals.

Load nlpsem package, dependent packages and set CSOLNP as the optimizer

library(nlpsem)
mxOption(model = NULL, key = "Default optimizer", "CSOLNP", reset = FALSE)

Load pre-computed models

load(system.file("extdata", "getLCSM_examples.RData", package = "nlpsem"))

Load example data and preprocess data

# Load ECLS-K (2011) data
data("RMS_dat")
RMS_dat0 <- RMS_dat
# Re-baseline the data so that the estimated initial status is for the
# starting point of the study
baseT <- RMS_dat0$T1
RMS_dat0$T1 <- (RMS_dat0$T1 - baseT)/12
RMS_dat0$T2 <- (RMS_dat0$T2 - baseT)/12
RMS_dat0$T3 <- (RMS_dat0$T3 - baseT)/12
RMS_dat0$T4 <- (RMS_dat0$T4 - baseT)/12
RMS_dat0$T5 <- (RMS_dat0$T5 - baseT)/12
RMS_dat0$T6 <- (RMS_dat0$T6 - baseT)/12
RMS_dat0$T7 <- (RMS_dat0$T7 - baseT)/12
RMS_dat0$T8 <- (RMS_dat0$T8 - baseT)/12
RMS_dat0$T9 <- (RMS_dat0$T9 - baseT)/12
# Standardize time-invariant covariates (TICs)
## ex1 and ex2 are standardized growth TICs in models
RMS_dat0$ex1 <- scale(RMS_dat0$Approach_to_Learning)
RMS_dat0$ex2 <- scale(RMS_dat0$Attention_focus)
xstarts <- mean(baseT)/12

Example 1: Fit nonparametric LCSMs to assess the development of reading ability from Kindergarten to Grade 5, both with and without incorporating baseline teacher-reported approach to learning and attentional focus. The getSummary() function is used to generate a comprehensive summary table for these two models. Additionally, the visual representations of the interval-average growth rate and change from the baseline for both models.

Read_LCSM_NonP <- getLCSM(
  dat = RMS_dat0, t_var = "T", y_var = "R", curveFun = "nonparametric",
  intrinsic = FALSE, records = 1:9, growth_TIC = NULL,
  paramOut = TRUE
  )
Read_LCSM_NonP_TIC <- getLCSM(
  dat = RMS_dat0, t_var = "T", y_var = "R", curveFun = "nonparametric",
  intrinsic = FALSE, records = 1:9, growth_TIC = c("ex1", "ex2"),
  paramOut = TRUE
  )
getSummary(model_list = list(Read_LCSM_NonP@mxOutput, Read_LCSM_NonP_TIC@mxOutput))
#>    Model No_Params     -2ll      AIC      BIC Y_residuals
#> 1 Model1        13 32288.39 32314.39 32369.18     45.1379
#> 2 Model2        22 34575.48 34619.48 34712.20     45.1410
Figure1 <- getFigure(
  model = Read_LCSM_NonP@mxOutput, sub_Model = "LCSM", y_var = "R", curveFun = "NonP", 
  y_model = "LCSM", t_var = "T", records = 1:9, xstarts = xstarts, xlab = "Year",
  outcome = "Reading"
)
show(Figure1)
#> figOutput Object
#> --------------------
#> Trajectories: 1 
#> Figure 1:
#> `geom_smooth()` using method = 'gam' and formula = 'y ~ s(x, bs = "cs")'

Reading change from the first selected occasion over time in years from a nonparametric change-score model, with the smoothed observed change and pointwise 95 percent confidence limits.

#> Figure 2:

Reading interval-average growth rate over time in years from a nonparametric change-score model, with pointwise 95 percent confidence limits.

Figure2 <- getFigure(
  model = Read_LCSM_NonP_TIC@mxOutput, sub_Model = "LCSM", y_var = "R", curveFun = "NonP", 
  y_model = "LCSM", t_var = "T", records = 1:9, xstarts = xstarts, xlab = "Year",
  outcome = "Reading"
)
show(Figure2)
#> figOutput Object
#> --------------------
#> Trajectories: 1 
#> Figure 1:
#> `geom_smooth()` using method = 'gam' and formula = 'y ~ s(x, bs = "cs")'

Reading change from the first selected occasion over time in years from a nonparametric change-score model with time-invariant covariates, with the smoothed observed change and pointwise 95 percent confidence limits.

#> Figure 2:

Reading interval-average growth rate over time in years from a nonparametric change-score model with time-invariant covariates, with pointwise 95 percent confidence limits.

Example 2: Fit LCSMs with quadratic, negative exponential and Jenss-Bayley functional forms. Additionally, the visual representations change from the baseline for three models.

Read_LCSM_QUAD <- getLCSM(
  dat = RMS_dat0, t_var = "T", y_var = "R", curveFun = "quadratic", intrinsic = FALSE,
  records = 1:9, paramOut = TRUE
  )
set.seed(20191029)
Read_LCSM_EXP_r <- getLCSM(
  dat = RMS_dat0, t_var = "T", y_var = "R", curveFun = "negative exponential",
  intrinsic = FALSE, records = 1:9, tries = 10, paramOut = TRUE
  )
set.seed(20191029)
Read_LCSM_JB_r <- getLCSM(
  dat = RMS_dat0, t_var = "T", y_var = "R", curveFun = "Jenss-Bayley",
  intrinsic = FALSE, records = 1:9, tries = 10, paramOut = TRUE
  )
Figure3 <- getFigure(
  model = Read_LCSM_QUAD@mxOutput, sub_Model = "LCSM", y_var = "R", curveFun = "QUAD", 
  y_model = "LCSM", t_var = "T", records = 1:9, xstarts = xstarts, xlab = "Year",
  outcome = "Reading"
)
show(Figure3)
#> figOutput Object
#> --------------------
#> Trajectories: 1 
#> Figure 1:
#> `geom_smooth()` using method = 'gam' and formula = 'y ~ s(x, bs = "cs")'

Reading change from the first selected occasion over time in years from a quadratic change-score model, with the smoothed observed change and pointwise 95 percent confidence limits.

#> Figure 2:

Reading interval-average growth rate over time in years from a quadratic change-score model, with pointwise 95 percent confidence limits.

Figure4 <- getFigure(
  model = Read_LCSM_EXP_r@mxOutput, sub_Model = "LCSM", y_var = "R", curveFun = "EXP", 
  y_model = "LCSM", t_var = "T", records = 1:9, xstarts = xstarts, xlab = "Year",
  outcome = "Reading"
)
show(Figure4)
#> figOutput Object
#> --------------------
#> Trajectories: 1 
#> Figure 1:
#> `geom_smooth()` using method = 'gam' and formula = 'y ~ s(x, bs = "cs")'

Reading change from the first selected occasion over time in years from a negative-exponential change-score model, with the smoothed observed change and pointwise 95 percent confidence limits.

#> Figure 2:

Reading interval-average growth rate over time in years from a negative-exponential change-score model, with pointwise 95 percent confidence limits.

Figure5 <- getFigure(
  model = Read_LCSM_JB_r@mxOutput, sub_Model = "LCSM", y_var = "R", curveFun = "JB", 
  y_model = "LCSM", t_var = "T", records = 1:9, xstarts = xstarts, xlab = "Year",
  outcome = "Reading"
)
show(Figure5)
#> figOutput Object
#> --------------------
#> Trajectories: 1 
#> Figure 1:
#> `geom_smooth()` using method = 'gam' and formula = 'y ~ s(x, bs = "cs")'

Reading change from the first selected occasion over time in years from a Jenss-Bayley change-score model, with the smoothed observed change and pointwise 95 percent confidence limits.

#> Figure 2:

Reading interval-average growth rate over time in years from a Jenss-Bayley change-score model, with pointwise 95 percent confidence limits.