| Title: | Robust Latent Profile Analysis |
|---|---|
| Description: | 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' with a Full Information Maximum Likelihood (FIML) approach and Huber weighting, it reliably extracts latent profiles even in complex datasets. It supports multiple geometric variance-covariance models, along with functions for bootstrapped likelihood ratio tests and plotting. 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>. |
| Authors: | Valerio Riccardo Aquila [aut, cre] (ORCID: <https://orcid.org/0009-0004-2231-2141>) |
| Maintainer: | Valerio Riccardo Aquila <[email protected]> |
| License: | GPL (>= 3) |
| Version: | 0.1.0 |
| Built: | 2026-07-06 08:40:52 UTC |
| Source: | https://github.com/cran/RobustLPA |
Compares a robust LPA model with G profiles against a null model with G-1 profiles using parametric bootstrapping. Supports FIML simulation conditions.
blrt_robust(data, G, model = 6, n_samples = 50, n_starts = 2)blrt_robust(data, G, model = 6, n_samples = 50, n_starts = 2)
data |
A matrix or data.frame. |
G |
The number of profiles for the alternative hypothesis (compared against G-1). |
model |
An integer (1 to 6) specifying the variance-covariance parameterization. |
n_samples |
Number of bootstrap samples. Default is 50 for speed; 200+ is recommended for publications. |
n_starts |
Number of starts for the EM algorithm execution. |
A list containing the observed LRT statistic, the vector of bootstrap replicates, and the empirical p-value.
# Fast demonstration of the robust BLRT data(iris) blrt_res <- blrt_robust(iris[1:30, 1:2], G = 2, model = 1, n_samples = 2, n_starts = 1) # Print the summary of the results blrt_res# Fast demonstration of the robust BLRT data(iris) blrt_res <- blrt_robust(iris[1:30, 1:2], G = 2, model = 1, n_samples = 2, n_starts = 1) # Print the summary of the results blrt_res
This function provides a user-friendly interface to fit multiple robust LPA models simultaneously across different numbers of profiles and model structures, returning a comprehensive fit summary table.
estimate_profiles_robust( data, n_profiles = 1:3, models = c(1, 2, 3, 4, 5, 6), n_starts = 5 )estimate_profiles_robust( data, n_profiles = 1:3, models = c(1, 2, 3, 4, 5, 6), n_starts = 5 )
data |
A matrix or data.frame. |
n_profiles |
A vector of integers specifying the number of profiles to run (e.g., 1:3). |
models |
A vector of LPA models to run (e.g., c(1, 2, 3, 4, 5, 6)). Default is c(1, 2, 3, 4, 5, 6). |
n_starts |
Number of initializations per model. |
A list containing the fit comparison table and the estimated models.
# Quick evaluation of multiple profiles data(iris) res <- estimate_profiles_robust(iris[1:30, 1:2], n_profiles = 1:2, models = 1, n_starts = 1) res$fit_table# Quick evaluation of multiple profiles data(iris) res <- estimate_profiles_robust(iris[1:30, 1:2], n_profiles = 1:2, models = 1, n_starts = 1) res$fit_table
Automatically generates a professional profile plot using ggplot2 from an estimated robust LPA model.
plot_robust_lpa( model, title = "Robust Latent Profiles", xlab = "Variables", ylab = "Value", var_labels = NULL, legend_title = "Class" )plot_robust_lpa( model, title = "Robust Latent Profiles", xlab = "Variables", ylab = "Value", var_labels = NULL, legend_title = "Class" )
model |
A model object returned by robust_lpa or estimate_profiles_robust. |
title |
The title of the plot. Default is "Robust Latent Profiles". |
xlab |
The x-axis label. Default is "Variables". |
ylab |
The y-axis label. Default is "Value". |
var_labels |
A character vector to manually rename the variables on the X axis. Default is NULL (auto-detect). |
legend_title |
The title of the legend. Default is "Class". |
A ggplot object.
data(iris) fit <- robust_lpa(data = iris[1:30, 1:2], G = 2, model = 1, n_starts = 1) plot_robust_lpa(fit)data(iris) fit <- robust_lpa(data = iris[1:30, 1:2], G = 2, model = 1, n_starts = 1) plot_robust_lpa(fit)
This function estimates a single robust Latent Profile Analysis (LPA) model for a specified number of profiles and model structure. It automatically handles missing data via robust FIML if present.
robust_lpa(data, G, model = 6, max_iter = 100, tol = 1e-06, n_starts = 5)robust_lpa(data, G, model = 6, max_iter = 100, tol = 1e-06, n_starts = 5)
data |
A matrix or data.frame of observations. |
G |
The number of latent profiles to extract. |
model |
An integer (1 to 6) specifying the model parameterization. |
max_iter |
Maximum number of EM iterations. |
tol |
Tolerance for convergence. |
n_starts |
Number of random initializations. |
A list containing parameters, fit indices, and assignments.
# Quick example using a small subset of the iris dataset data(iris) fit <- robust_lpa(data = iris[1:30, 1:2], G = 2, model = 1, n_starts = 1) # Print the fit indices fit$fit# Quick example using a small subset of the iris dataset data(iris) fit <- robust_lpa(data = iris[1:30, 1:2], G = 2, model = 1, n_starts = 1) # Print the fit indices fit$fit
Perform a Robust M-Step for Latent Profile Analysis
robust_m_step(data, z, alpha = 0.05)robust_m_step(data, z, alpha = 0.05)
data |
A matrix or data.frame of observations. |
z |
A numeric vector containing the posterior probabilities of belonging to this cluster. |
alpha |
Significance level for the Chi-squared outlier cutoff (default is 0.05). |
A list containing the robust 'mean' vector and the robust 'covariance' matrix.
data(iris) # Simulate initial probabilities for a single profile z_init <- runif(30) z_init <- z_init / sum(z_init) m_step_res <- robust_m_step(iris[1:30, 1:2], z = z_init) # Print the robust mean calculated in the M-step m_step_res$meandata(iris) # Simulate initial probabilities for a single profile z_init <- runif(30) z_init <- z_init / sum(z_init) m_step_res <- robust_m_step(iris[1:30, 1:2], z = z_init) # Print the robust mean calculated in the M-step m_step_res$mean
Calculate the robust mean
robust_mean(data, threshold = 10)robust_mean(data, threshold = 10)
data |
A matrix or data.frame |
threshold |
Maximum distance allowed to not be considered an outlier |
A numeric vector representing the robust mean of the variables.
data(iris) r_mean <- robust_mean(iris[1:30, 1:2]) # Print the calculated robust means r_meandata(iris) r_mean <- robust_mean(iris[1:30, 1:2]) # Print the calculated robust means r_mean