Skip to contents

latents is an R package for modelling unobserved heterogeneity in response patterns, regression relationships and trajectories. It supports latent profile and class analysis, multilevel models, latent transition analysis, and mixture regression and growth models.

The package combines model estimation and comparison with tools for assessing parameter uncertainty, classification quality and solution stability. It also supports analyses relating latent membership to external variables and provides tables and plots for interpreting and reporting results.

Details

Latent profiles describe heterogeneity in continuous indicators through component-specific distributions. Latent classes describe heterogeneity in discrete response patterns. In the two-level model, observation-level profiles or classes are nested within groups, and latent group classes differ in their conditional probabilities of observation-level membership. The standard two-level formulation shares measurement parameters across group classes. Transition models additionally estimate dependence between latent states at successive occasions.

The number of latent classes and the measurement specification are supplied by the analyst. Estimation uses multiple starting values because different starts can converge to different local maxima. Convergence, replication of the selected likelihood, class sizes, parameter boundaries, and substantive interpretability should be considered together when evaluating a solution. Classification summaries describe uncertainty under the fitted model; they do not establish the substantive validity of the classes.

Model fitting

Use lpa or lca for single-level models and multilpa or multilca for two-level models. lta fits latent transition models, and mixture_regression fits finite mixtures of regression models. The family argument of multilpa provides additional model families documented on that function's help page. fit_staged estimates a two-level model with measurement parameters fixed at their first-stage estimates. descriptives describes the indicators, with their intraclass correlations, before a model is fitted.

Model evaluation and inference

enumerate_classes, enumerate_lpa, enumerate_lca, and enumerate_regressions fit candidate model sets. compare_models summarizes selected models, and bootstrap_lrt provides parametric bootstrap likelihood ratio tests for supported comparisons.

get_results extracts model-specific tables; diagnostics and sensitivity assess fitted solutions and sensitivity to starting values. parameter_inference provides parameter estimates, standard errors, and intervals for supported model families. three_step and r3step relate external variables to latent membership with correction for classification error. pool_imputations combines compatible analyses across imputed datasets. align_labels renumbers the profiles of one fit to match another's, so that fits to different samples or occasions can be read side by side.

Interpretation and assumptions

The measurement distribution, conditional independence assumptions, covariance constraints, and treatment of time depend on the selected model. Consult the fitting function for these assumptions and for restrictions on missing data, sampling weights, covariates, and parameter inference. Posterior class assignments are estimates with uncertainty. Class labels are arbitrary identifiers and should be interpreted through the estimated response patterns. Numerical fit and classification separation alone do not establish causal effects or distinct populations.

Getting started

The vignettes vignette("lpa", package = "latents") and vignette("lca", package = "latents") introduce the main workflows; class enumeration and latent transition analysis are covered in articles on the package website, https://pak.dynasite.org/latents/articles/. See plot_all and the other plot_ functions for graphical summaries, latents-predict for prediction, and latents-conditions for diagnostic conditions.