pca_nspike: Number of spikes in PCA

Description Usage Arguments Value Examples

View source: R/outlier-hist.R

Description

Estimate the number of distant spikes based on the histogram of eigenvalues.

Usage

1
pca_nspike(eigval, breaks = "FD", nboot = 100)

Arguments

eigval

Eigenvalues (squared singular values).

breaks

Same parameter as for hist(). Default uses a robust version of Scott's rule. You can also use "FD" or nclass.FD for a bit more bins.

nboot

Number of bootstrap replicates to estimate limits more robustly. Default is 100.

Value

The estimated number of distant spikes.

Examples

1
2
3
4
5
6
7
8
9
N <- 400; M <- 2000; K <- 8
U <- matrix(0, N, K); U[] <- rnorm(length(U))
V <- matrix(0, M, K); V[] <- rnorm(length(V))
# X = U V^T + E
X <- tcrossprod(U, V) + 15 * rnorm(N * M)
pca <- prcomp(X)
eigval <- pca$sdev^2
plot(head(eigval, -1), log = "xy", pch = 20)
pca_nspike(eigval)

bigutilsr documentation built on April 14, 2021, 1:06 a.m.