Description Usage Arguments Details Value Examples
For the classes given in the vector y, we compute the eigenvalue
(spectral) decomposition of the class sample covariance matrices (MLEs) using
the data matrix x.
1 |
x |
data matrix with |
y |
class labels for observations (rows) in |
pool |
logical. Should the sample covariance matrices be pooled? |
fast |
logical. Should the Fast SVD be used? See details. |
tol |
tolerance value below which the singular values of |
If the fast argument is selected, we utilize the so-called Fast
Singular Value Decomposition (SVD) to quickly compute the eigenvalue
decomposition. To compute the Fast SVD, we use the corpcor::fast.svd()
function, which employs a well-known trick for tall data (large n,
small p) and wide data (large p, small n) to compute the
SVD corresponding to the nonzero singular values. For more information about
the Fast SVD, see corpcor::fast.svd().
a list containing the eigendecomposition for each class. If
pool = TRUE, then a single list is returned.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | cov_eigen(x = iris[, -5], y = iris[, 5])
cov_eigen(x = iris[, -5], y = iris[, 5], pool = TRUE)
cov_eigen(x = iris[, -5], y = iris[, 5], pool = TRUE, fast = TRUE)
# Generates a data set having fewer observations than features.
# We apply the Fast SVD to compute the eigendecomposition corresponding to the
# nonzero eigenvalues of the covariance matrices.
set.seed(42)
n <- 5
p <- 20
num_classes <- 3
x <- lapply(seq_len(num_classes), function(k) {
replicate(p, rnorm(n, mean = k))
})
x <- do.call(rbind, x)
colnames(x) <- paste0("x", 1:ncol(x))
y <- gl(num_classes, n)
cov_eigen(x = x, y = y, fast = TRUE)
cov_eigen(x = x, y = y, pool = TRUE, fast = TRUE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.