Statistical Significance Testing for Principal Components

Identifies principal components whose eigenvalues exceed those expected under noise. Implements analytical thresholds derived from the Marchenko-Pastur distribution (Marchenko and Pastur, 1967) and empirical permutation tests, and provides functions for visualizing observed and null eigenvalue spectra.


sigPCA

The sigPCA package provides tools to assess the statistical significance of principal components using methods from random matrix theory, particularly the Marchenko–Pastur (MP) distribution. It also includes an optional permutation-based method for empirical validation.

Installation

# 
install.packages("pak")
pak::pak("guillermodeandajauregui/sigPCA")

Example 1: White Noise (No Signal Expected)

set.seed(123)
X_white <- matrix(rnorm(1000), nrow = 100, ncol = 10)
result_white <- sigPCA(X_white, method = "both", num_permutations = 100)
result_white$mp$significant_components
#> integer(0)
plot_sigPCA(result_white$mp$eigenvalues, result_white$mp$mp_bounds)

Example 2: Latent Structure (Signal Expected)

set.seed(456)
{
  n <- 100
  p <- 10
  k <- 2
  latent <- matrix(rnorm(n * k, mean = 3), nrow = n, ncol = k)
  loadings <- matrix(rnorm(p * k), nrow = k, ncol = p)
  noise <- matrix(rnorm(n * p, sd = 0.3), nrow = n, ncol = p)
  X_signal <- latent %*% loadings + noise
  result_signal <- sigPCA(X_signal, method = "both", num_permutations = 100)
}
result_signal$mp$significant_components
#> [1] 1 2
plot_sigPCA(result_signal$mp$eigenvalues, result_signal$mp$mp_bounds)

Interpretation

Components with eigenvalues beyond the theoretical Marchenko–Pastur upper bound are considered statistically significant. This method is particularly effective for high-dimensional datasets where traditional heuristics like scree plots may be misleading.

The permutation-based method provides empirical p-values and is useful as a secondary or confirmatory approach.

References

  • Marchenko, V.A. and Pastur, L.A. (1967). Distribution of eigenvalues for some sets of random matrices. Mathematics of the USSR-Sbornik, 1(4), 457–483.
  • Hernández-Lemus, E. (in preparation).

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("sigPCA")

0.1.0 by Guillermo de Anda-Jáuregui, 2 months ago


https://github.com/guillermodeandajauregui/sigPCA


Report a bug at https://github.com/guillermodeandajauregui/sigPCA/issues


Browse source code at https://github.com/cran/sigPCA


Authors: Guillermo de Anda-Jáuregui [aut, cre, cph] , Enrique Hernández-Lemus [aut, cph]


Documentation:   PDF Manual  


MIT + file LICENSE license


Imports ggplot2, stats

Suggests knitr, palmerpenguins, rmarkdown, testthat


See at CRAN