spEigenCov {sparseEigen} | R Documentation |
Covariance Matrix Estimation with Sparse Eigenvectors
Description
Estimates the covariance matrix with sparse (orthogonal) eigenvectors (in other words, it jointly estimates the sparse eigenvectors and the eigenvalues).
Usage
spEigenCov(S, q = 1, rho = 0.5, thres = 1e-09)
Arguments
S |
m-by-m sample covariance matrix. It is required that |
q |
number of sparse eigenvectors. |
rho |
sparsity weight factor. Any nonnegative number (suggested range [0,1]). |
thres |
threshold value. All the entries of the sparse eigenvectors less or equal to |
Value
A list with the following components:
vectors |
m-by-m matrix, columns corresponding to eigenvectors. |
values |
m-by-1 vector corresponding to eigenvalues. |
Author(s)
Konstantinos Benidis and Daniel P. Palomar
References
K. Benidis, Y. Sun, P. Babu, D. P. Palomar, "Orthogonal Sparse PCA and Covariance Estimation via Procrustes Reformulation," IEEE Transactions on Signal Processing, vol. 64, no. 23, pp. 6211-6226, Dec. 2016.
Examples
## Not run:
library(sparseEigen)
n <- 600 # samples
m <- 500 # dimension
q <- 3 # number of sparse eigenvectors to be estimated
sp_card <- 0.1*m # sparsity of each eigenvector
# generate covariance matrix with sparse eigenvectors
V <- matrix(0, m, q)
V[cbind(seq(1, q*sp_card), rep(1:q, each = sp_card))] <- 1/sqrt(sp_card)
V <- cbind(V, matrix(rnorm(m*(m-q)), m, m-q))
V <- qr.Q(qr(V)) # orthogonalize eigenvectors
lmd <- c(100*seq(from = q, to = 1), rep(1, m-q)) # generate eigenvalues
R <- V %*% diag(lmd) %*% t(V) # covariance matrix
# generate data
X <- MASS::mvrnorm(n, rep(0, m), R) # random data with underlying sparse structure
# standard and sparse estimation
res_standard <- eigen(cov(X))
res_sparse <- spEigenCov(cov(X), q)
# show inner product between estimated eigenvectors and originals (the closer to 1 the better)
abs(diag(t(res_standard$vectors) %*% V[, 1:q])) #for standard estimated eigenvectors
abs(diag(t(res_sparse$vectors) %*% V[, 1:q])) #for sparse estimated eigenvectors
# show error between estimated and true covariance
norm(cov(X) - R, type = 'F') #for sample covariance matrix
norm(res_sparse$cov - R, type = 'F') #for covariance with sparse eigenvectors
## End(Not run)