# cov_eigen: Computes the eigenvalue decomposition of the maximum... In sparsediscrim: Sparse and Regularized Discriminant Analysis

## Description

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.

## Usage

 1 cov_eigen(x, y, pool = FALSE, fast = FALSE, tol = 1e-06) 

## Arguments

 x data matrix with n observations and p feature vectors y class labels for observations (rows) in x 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 x are considered zero.

## Details

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().

## Value

a list containing the eigendecomposition for each class. If pool = TRUE, then a single list is returned.

## Examples

  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) 

sparsediscrim documentation built on July 1, 2021, 9:07 a.m.