nlpsem

nlpsem provides tools for fitting linear and nonlinear longitudinal models within the structural equation modeling (SEM) framework. The package is built on top of OpenMx and is designed for settings where the trajectory shape is nonlinear and may be intrinsically nonlinear rather than a simple reparameterization of a linear growth model.

Portfolio positioning

nlpsem is a statistical software and measurement-methods asset. It supports nonlinear longitudinal modeling, latent growth and latent change models, mixture modeling, multivariate longitudinal processes, multiple-group comparisons, and psychometric/measurement-science workflows in R.

For AI evaluation roles, the package is relevant because repeated AI behavior across prompts, models, seeds, raters, and deployment conditions can be studied with the same measurement mindset used for longitudinal human-development and latent-process modeling: define the measurement occasions, model systematic variation, quantify reliability, and separate signal from instability.

For hiring reviewers

This repository demonstrates:

The methods implemented in this package are described in:

Liu, J. (2025). Examination of nonlinear longitudinal processes in the framework of structural equation modeling: The R package nlpsem. Behavior Research Methods. https://doi.org/10.3758/s13428-025-02596-4

Connection to AI evaluation

The same measurement-science principles used for longitudinal human-development modeling also inform evaluation of AI system behavior over prompts, models, seeds, raters, and deployment conditions. In both settings, the central questions are how behavior changes across repeated conditions, which sources of variation are meaningful, and how much confidence a reviewer should place in an observed pattern.

Main modeling scenarios

The package supports four broad longitudinal modeling settings:

  1. Univariate longitudinal models with growth factors, with or without time-invariant covariates (TICs) and time-varying covariates (TVCs)
  2. Multivariate longitudinal models for assessing correlated or potentially directional development across multiple processes
  3. Multiple-group longitudinal models for comparing manifested groups
  4. Longitudinal mixture models for identifying latent trajectory classes

Core functions

Model-fitting functions

Post-processing functions

Supported functional forms

For latent growth curve models, nlpsem supports:

For latent change score models, nlpsem supports:

Negative exponential, Jenss-Bayley, and bilinear spline models can be fit in their intrinsically nonlinear forms by setting intrinsic = TRUE.

Installation

If the package is available on CRAN:

install.packages("nlpsem")

To install the development version from GitHub:

# install.packages("remotes")
# remotes::install_github("Veronica0206/nlpsem")
install.packages("nlpsem", repos = c('https://veronica0206.r-universe.dev', 'https://cloud.r-project.org'))

Quick example

library(nlpsem)

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

data("RMS_dat")
RMS_dat0 <- RMS_dat

# Re-baseline the measurement occasions
baseT <- RMS_dat0$T1
for (i in 1:9) {
  RMS_dat0[[paste0("T", i)]] <- RMS_dat0[[paste0("T", i)]] - baseT
}

# Fit a bilinear spline LGCM with a fixed knot
Math_BLS <- getLGCM(
  dat = RMS_dat0,
  t_var = "T",
  y_var = "M",
  curveFun = "BLS",
  intrinsic = FALSE,
  records = 1:9,
  paramOut = TRUE
)

# Inspect estimates
printTable(Math_BLS)

What is new in version 0.4

Version 0.4 keeps the modeling scope of version 0.3 while substantially improving robustness, usability, and documentation.

Highlights include:

See NEWS.md for a more comprehensive summary of changes from version 0.3.

Documentation

The package includes an overview vignette and scenario-specific example vignettes:

License

GPL (>= 3)