Learn R Programming

KODAMA (version 3.3)

pca: 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)), ...)

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.

Arguments

x

A numeric matrix of data.

nv

Number of principal components to compute.

...

Currently unused, kept for backward compatibility.

Author

Stefano Cacciatore

References

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

Examples

Run this code
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)

Run the code above in your browser using DataLab