erichson/spca
Sparse Principal Component Analysis (SPCA) using Variable Projection
Featured achievements
The project's latest awards
#1 Repository of the month
#1 Repository of the month
#2 Repository of the month
🔍 SPCA via Variable Projection
Find PCA components built from only a few original variables.
spca is an R package for sparse principal component analysis (SPCA). Unlike standard PCA, SPCA finds sparse weight vectors (loadings), so each principal component is a linear combination of only a few original variables. This improves interpretability and helps avoid overfitting in high-dimensional settings where the number of variables is greater than the number of observations.
✨ Highlights
- spca(): Core sparse PCA routine using variable projection.
- rspca(): Randomized accelerated SPCA for faster computation.
- robspca(): Robust SPCA variant.
- Elastic net regularization: Minimizes 1/2⋅‖X - X⋅B⋅Aᵀ‖² + α⋅‖B‖₁ + 1/2⋅β‖B‖² with AᵀA = I, using l1 and l2 norms to control sparsity and conditioning.
- Sparse loadings to scores: Forms principal components as Z = X %*% B.
- Tunable controls: Exposes alpha (sparsity), beta (ridge shrinkage), center, scale, k, max_iter, tol, and verbose.
- Easy install: Available on CRAN via install.packages("sparsepca") or from GitHub via devtools::install_github("erichson/spca").
💡 Why it matters
SPCA keeps the goal of variance capture from PCA, but replaces dense loadings with sparse ones. That tradeoff makes components easier to read (e.g. eigenfaces that highlight only select facial regions) without forcing every original variable into each component.
#R #SPCA #PCA #DimensionalityReduction #TiniX
Similar Projects
Discover other similar projects and AI models.
A Julia package for multivariate statistics and data analysis (e.g. dimension reduction)
:building_construction: Statistical models for biomolecular dynamics :building_construction:
Comprehensive EOF analysis in Python with xarray: A versatile, multidimensional, and scalable tool for advanced climate data analysis
Starter code of Prof. Andrew Ng's machine learning MOOC in R statistical language