pca: Truncated Principal Components Analysis

View source: R/KOD.R

pcaR Documentation

Truncated Principal Components Analysis

Description

Performs PCA using KODAMA's internal vendored IRLBA backend (with a small-matrix svd() fallback) and returns a prcomp-compatible object.

Usage

pca(x, nv = min(50L, ncol(x)), ...)

Arguments

x

A numeric matrix of data.

nv

Number of principal components to compute.

...

Currently unused, kept for backward compatibility.

Value

The function returns a list with class prcomp containing:

sdev

standard deviations of the retained principal components.

rotation

matrix of variable loadings (columns are retained components).

x

scores matrix equivalent to u %*% diag(d) from truncated SVD.

center, scale

set to FALSE; centering/scaling are expected upstream when needed.

txt

percentage-of-variance labels for each retained component.

Author(s)

Stefano Cacciatore

References

Baglama J, Reichel L.
Augmented implicitly restarted Lanczos bidiagonalization methods.
SIAM Journal on Scientific Computing 2005;27(1):19-42.

Examples

data(MetRef)
u <- MetRef$data
u <- u[, -which(colSums(u) == 0)]
u <- normalization(u)$newXtrain
u <- scaling(u)$newXtrain
class <- as.numeric(as.factor(MetRef$gender))
cc <- pca(u, nv = 5)
plot(cc$x, pch = 21, bg = class)

KODAMA documentation built on March 17, 2026, 5:07 p.m.