Robust Latent Profile Analysis
Overview
Provides a comprehensive toolset for estimating Latent Profile Analysis (LPA) models that are robust to multivariate outliers and missing data. By integrating a high-performance 'C++' engine via 'RcppArmadillo', it reliably extracts latent profiles using both Expectation-Maximization (EM) and Markov Chain Monte Carlo (MCMC) Bayesian estimation. Robustness is obtained either by Huber-type down-weighting or by mixtures of multivariate t distributions (a likelihood-based robust model, see Peel and McLachlan (2000) doi:10.1023/A:1008981510081). Missing data are handled by full information maximum likelihood with the exact EM treatment of incomplete observations (data augmentation in the MCMC engine). The EM engine also supports LASSO regularization with k-fold cross-validation for penalty tuning; the MCMC engine uses a Bayesian Lasso with Laplace priors, multiple chains, Gelman-Rubin/effective sample size diagnostics and the widely applicable information criterion. It supports six geometric variance-covariance models, along with functions for bootstrapped likelihood ratio tests (BLRT), BCH auxiliary variable analysis, and plotting. For longitudinal data, it fits robust growth mixture models and latent class growth analysis (Muthen and Shedden (1999) doi:10.1111/j.0006-341X.1999.00463.x) for one or several outcomes measured on unbalanced occasions, with Gaussian, Huber-weighted or multivariate-t (Pinheiro, Liu and Wu (2001) doi:10.1198/10618600152628059) latent classes, by EM and MCMC, and optional adaptive LASSO penalties (Zou (2006) doi:10.1198/016214506000000735) that identify stable trajectories and the outcomes that differentiate the classes. For methodological details on the Bootstrapped Likelihood Ratio Test, see Nylund et al. (2007) doi:10.1080/10705510701575396. For robust clustering methods, see Garcia-Escudero et al. (2010) doi:10.1007/s11634-010-0064-5. For BCH auxiliary variable analysis, see Bolck et al. (2004) doi:10.1093/pan/mph001.
This release adds robust growth mixture models for longitudinal data and
is also a correctness release: every estimator in the package was
re-checked against a known reference (closed-form maximum likelihood,
mclust, lme4/nlme, or simulation with known truth), and the problems
found are fixed below. Several of them change numerical results relative
to 1.0.0; re-running analyses fitted with 1.0.0 is recommended.
New: robust growth mixture models for longitudinal data
- **
robust_gmm()** fits growth mixture models (finite mixtures of linear mixed-effects models; Verbeke & Lesaffre, 1996; Muthen & Shedden, 1999) and, withrandom = "none", latent class growth analysis (Nagin, 1999), for one or several outcomes measured repeatedly on unbalanced occasions (long-format data; persons may have different visit times and missing outcomes). Each class has a polynomial mean trajectory per outcome (degree); within classes, persons have correlated random intercepts or intercepts and slopes (random,re_structure), with covariance and residual variances shared or class-specific (re_cov,resid_var). Every person contributes the exact likelihood of the values actually observed, so estimation is valid under missing-at-random drop-out.
Show all changes in 1.1.0Hide the rest of the changes in 1.1.0
- Robust versions: multivariate-t classes (
robust_method = "t"; the t linear mixed model of Pinheiro, Liu & Wu, 2001, withnuestimated), which down-weight whole outlying persons and keep a proper likelihood, or Huber weights. - EM engine: alternating ECM (Meng & van Dyk, 1997) with GLS updates of the trajectories and SQUAREM acceleration (Varadhan & Roland, 2008). The one-class model reproduces the maximum-likelihood linear mixed model of
lme4/nlmeexactly (checked in the tests). - MCMC engine: blocked Gibbs sampler (trajectories drawn with the random effects integrated out; persons allocated with random effects and latent scales integrated out), scaled inverse-Wishart prior on the random-effect covariances sampled by parameter expansion (Liu & Wu, 1999; Gelman et al., 2008), WAIC, Gelman-Rubin diagnostics and trace plots (
plot_mcmc_chains()). - **LASSO for trajectories**, in both engines:
lambda_growthshrinks the growth terms of every class toward zero (identifying classes that are stable on an outcome);lambda_diffshrinks the class trajectories toward each other, element-wise or by outcome (group_diff = TRUE, which selects the outcomes that differentiate the classes; Xie, Pan & Shen, 2008; the groups are standardized by the information of their coefficients, Simon & Tibshirani, 2012). Penalties are adaptive by default (Zou, 2006; Wang & Leng, 2008), so thatlambda = z^2 / Nsets to zero terms whose Wald statistic is below aboutz; the penalized step is solved exactly by ADMM, the BIC counts only the free coefficients,relax = TRUErefits the selected model without penalty (relaxed Lasso), and the MCMC engine uses the corresponding Bayesian (group, adaptive) Lasso priors. - **
estimate_gmm_robust()** fits a grid of numbers of classes (and random-effect specifications), optionally tuning the LASSO penalties by BIC or by K-fold cross-validation over persons. - **
blrt_gmm_robust()**: bootstrapped likelihood ratio test for the number of classes, simulating from the fitted null model on the observed visit schedule and missingness pattern. - **
plot_robust_gmm()** plots the class trajectories over the observed individual trajectories;print()andsummary()methods. - **
bch_robust()** acceptsrobust_gmm()fits, to relate the trajectory classes to baseline characteristics or distal outcomes (one value per person, in the order of$ids); its bootstrap correction resamples whole persons. - New example dataset **
neuro_long** (400 simulated persons, up to six annual visits, three outcomes, drop-out and gross errors; its generating script is installed ininst/scripts/) and a second vignette,vignette("robust-growth-mixture", package = "RobustLPA").
Bug fixes
- **Parameter count, AIC, BIC and SABIC of
robust_lpa().** 1.0.0 left out of the count every mean with absolute value below 1e-5, even without a LASSO penalty. On standardized data with one profile all means are 0, sopparameters were missing (model 1 on the fiveneuro_datavariables: 5 instead of 10; model 6: 15 instead of 20) and the BIC ofG = 1was about 27.6 too low, favouring one profile. Means are now left out only when the EM LASSO (lambda > 0) has set them exactly to zero. - **Parallel workers on Windows.** With
cores > 1the worker processes loaded RobustLPA from the default library, which could hold another version than the one used in the session (e.g. a new version installed in a separate library), silently mixing code from the two. They now load the session's copy, and a warning is given if they cannot. - **BCH (
bch_robust()) now estimates the classification error matrix correctly.** 1.0.0 computedD[g, c]as the average posterior of profilegamong observations assigned toc, i.e. P(C = g | assigned c), the reverse of the P(assigned s | C = t) required by Bolck, Croon & Hagenaars (2004) / Vermunt (2010), and indexed the weight matrixW = D^-1with transposed subscripts. The two errors cancel only for symmetric classification error. With unequal, overlapping profiles (80/20, entropy about 0.55; true difference in the distal mean = 1) the corrected profile-2 mean had a median bias of +0.44 and RMSE of 1.9 in 1.0.0 (worse than the uncorrected comparison), versus -0.05 and 0.19 now. Rows of$Classification_Matrixnow sum to 1. - **Constrained models (1-5) could return an unconstrained solution.** The EM initialization did not apply the variance-covariance constraints, and the "keep the best iterate" logic could then return those unconstrained starting values. For example,
model = 1onneuro_datareturned non-diagonal, profile-specific covariances with a log-likelihood (-1395.4) *higher* than the model-1 maximum (-1469.5, as found bymclustEEI), which also invalidated BIC comparisons across models. Classical fits now reproduce themclustmaximum-likelihood solutions for models 1, 2, 3 and 6. - **Missing data are now handled by exact maximum likelihood.** The E-step already used the observed-data (FIML) density, but the M-step used pairwise available-case moments, which are biased under MAR. The M-step now uses the exact EM for incomplete data (conditional expectations of the missing entries plus their conditional covariance; Ghahramani & Jordan, 1994). Example: with 30% MAR missingness the estimated mean of the incomplete variable was -0.37 (truth 0) in 1.0.0 and now matches the closed-form ML solution. The MCMC engine now uses the equivalent data augmentation step.
- **Numerical underflow for outlying observations.** Densities are now computed on the log scale throughout (log-sum-exp), so extreme observations receive valid posterior probabilities. In 1.0.0 an extreme outlier could get a posterior row of all zeros and a random profile.
- **MCMC models 1 and 5 now match the EM definitions.** 1.0.0's sampler used a single variance shared by all variables (a spherical model) for models 1 and 5; they now use variable-specific variances, as documented and as in the EM engine.
- **Models 4 and 5 are now fitted properly by both engines.** The EM engine used an approximate M-step that made the likelihood decrease and stopped at poor solutions; it now uses conditional-maximization steps that never decrease the likelihood. On
neuro_data(classical fit, G = 2), model 4 improves from log-likelihood -1358.7 (83% classification accuracy) to -1315.4 (94%), and model 5 from -1387.6 (52%) to -1318.8 (89%). The MCMC engine now samples the scales exactly (slice sampling) and the correlation matrices by Metropolis steps, instead of an approximate conditional that drifted away from the posterior. - **Huber weights now accumulate across EM iterations.** In 1.0.0 each M-step recomputed the weights against a fresh *non-robust* estimate, so outliers could mask themselves; the weights are now computed against the current robust estimates (an iteratively reweighted M-estimator). Because the Huber fixed point is not a maximizer of the Gaussian likelihood, the final iterate is returned and no log-likelihood-decrease warnings are issued for Huber fits.
bch_robust(correction = "bootstrap")refits now run withcores = 1inside each replicate (previously they inherited the original fit'scores, causing nested parallelism).- Profile labels (MCMC draws, bootstrap refits) are now matched by an exact optimal assignment (Hungarian algorithm) on standardized means, instead of a greedy nearest-mean rule. MCMC draws are relabeled to a fixed pivot (the preliminary EM solution).
estimate_profiles_robust()warns instead of silently ignoringtune_lasso = TRUEwith the MCMC engine, validates its inputs, reports why a model failed, and uses the same parallel backend as the rest of the package.
New features
- **Multivariate-t mixtures** (
robust_lpa(robust_method = "t"), withnuestimated by default or fixed): a likelihood-based robust model (Peel & McLachlan, 2000) fitted by ECME in the EM engine and by an exact Gibbs sampler (latent scales;nuupdated with the scales integrated out) in the MCMC engine. AIC/BIC, the BLRT and BCH are all used as intended with this model, and it is markedly more resistant than Huber weighting to gross outliers (in a test with 5% gross outliers on data with unit variances, the Huber variance estimates were 2.3-3.6 -- 3.5-6.1 in 1.0.0 -- while the t fit estimated nu = 2.4 and a core scale of 0.7-0.8). $weights: every fit now reports each observation's robustness weight (small values flag outliers).- The MCMC engine reports the **WAIC** (
$fit$WAIC,$waic), starts its chains from a preliminary EM fit with dispersed perturbations, and adapts its Metropolis step sizes during burn-in. blrt_robust()simulates the null data from the fitted model family (multivariate t forrobust_method = "t").- **Reproducibility:**
set.seed()now gives identical results for any value ofcores(one seed is drawn per work unit before dispatch). - EM starts are initialized by k-means by default (
init = "kmeans";init = "random"restores random soft partitions). - EM fits report
$convergedand$iterations. - A
testthattest suite checks every estimator against closed-form or reference solutions.
From NEWS.md in the release
Install
Health
- OK13 OK2026-08-05
- NOTE12 OK, 1 NOTE2026-08-01
- OK6 OK2026-07-06
Documentation
- Help pages
- 21 (4 internal)includes a package overview page
- Examples that run
- 87%13 run in a plain check · 2 only when donttest examples are enabled (R CMD check --as-cran)
- Exported functions with examples
- 100%
- Documented parameters
- 91%
- Return-value docs
- 100%
- Help pages citing references
- 29%
Downloads
Dependencies
Code & Tests
Datasets
People & History
Pick two releases to compare their code metrics.
- 1.1.0Latest2026-09-27 · current release · diff ↗ ·
added 4 exports
blrt_gmm_robust, estimate_gmm_robust, plot_robust_gmm, robust_gmm - 1.0.0
- 0.1.02026-07-05
- RR 4.6.0 released · 2026-04-24
Package metadata
- First published
- 2026-07-05
- Total releases
- 3 / 1 yrs
- License
- GPL (>= 3) OSI
- Minimum R
- ≥ 3.6
- Bundled data
- 21 KB / 2 files
- Download size
- 314 KB
Cite
Cite this package
Run in R for the authors' preferred citation:
citation("RobustLPA")This package has no citation file, so citation() returns this entry built from DESCRIPTION.
Cite the R Observatory
For a number measured here: a download total, a coverage figure, an archival date.
From data release v2026-10-22, which the citation names so these numbers can be found later. More on citing and the projects behind them.