X = U D V' on the centred (optionally scaled) data; components are the
columns of V with sign fixed so the largest-magnitude loading is positive,
eigenvalues D^2 / (n - 1) (ESL eqs 14.49-14.55, prcomp).
Usage
morie_esl_pca_svd(X, k, center = TRUE, scale = FALSE)
Arguments
- X
Data, n by p.
- k
Number of components.
- center, scale
Centre and scale the columns.
Value
Named list: estimate, eigenvalues, singular_values, components (k by
p), scores (n by k), explained_variance_ratio, cumulative_ratio, mean, sd,
centered, scaled, n, p, k.
References
Hastie, Tibshirani & Friedman (2009), sec. 14.5.1.
Examples
morie_esl_pca_svd(cbind(sin(1:20), cos(1:20), sin(1:20) + cos(2 * (1:20))), 2)$eigenvalues
#> [1] 1.3336907 0.5098581