RepositoryR
erichson

erichson/spca

Sparse Principal Component Analysis (SPCA) using Variable Projection

72stars
10forks
0issues
1views

Featured achievements

The project's latest awards

1
TINIX TRENDING·Topic: dimension-reduction

#1 Repository of the month

1
TINIX TRENDING·Topic: spca

#1 Repository of the month

2
TINIX TRENDING·Topic: pca

#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.

RepositoryR
erichson/rSVD

Randomized Matrix Decompositions using R

105
Nov 4, 2026
RepositoryJulia
JuliaStats/MultivariateStats.jl

A Julia package for multivariate statistics and data analysis (e.g. dimension reduction)

387
Sep 15, 2026
RepositoryPython
msmbuilder/msmbuilder

:building_construction: Statistical models for biomolecular dynamics :building_construction:

168
Jan 26, 2021
RepositoryPython
xarray-contrib/xeofs

Comprehensive EOF analysis in Python with xarray: A versatile, multidimensional, and scalable tool for advanced climate data analysis

136
Oct 23, 2026
RepositoryJavaScript
saehm/DruidJS

A JavaScript Library for Dimensionality Reduction

128
Nov 18, 2026
RepositoryJupyter Notebook
erichson/ristretto

Randomized Dimension Reduction Library

118
Apr 17, 2021
RepositoryR
easystats/parameters

:bar_chart: Computation and processing of models' parameters

502
Dec 1, 2026
RepositoryR
jlmelville/uwot

An R package implementing the UMAP dimensionality reduction method.

371
Nov 23, 2026
RepositoryR
faridcher/ml-course

Starter code of Prof. Andrew Ng's machine learning MOOC in R statistical language

173
Jul 19, 2025