spEigen: Sparse Spectral Decomposition of a Matrix

Description Usage Arguments Value Author(s) References Examples

Description

Computes sparse (orthogonal) eigenvectors of covariance matrix or directly of data matrix.

Usage

1
2
spEigen(X, q = 1, rho = 0.5, data = FALSE, d = NA, V = NA,
  thres = 1e-09)

Arguments

X

m-by-m covariance matrix or n-by-m data matrix (n samples, m variables). Both real and complex matrices are accepted.

q

number of eigenvectors to be estimated.

rho

sparsity weight factor. Any nonnegative number (suggested range [0,1]).

data

boolean variable. If TRUE, X is treated as a data matrix, else as a covariance matrix (default).

d

vector with q weights. The default value is seq(from = 1, to = 0.5, length.out = q).

V

initial m-by-q matrix point. If not provided, the eigenvectors of the sample covariance matrix are used.

thres

threshold value. All the entries of the sparse eigenvectors less or equal to thres are set to 0. The default value is 1e-9.

Value

A list with the following components:

vectors

m-by-q matrix, columns corresponding to the q leading sparse eigenvectors.

standard_vectors

m-by-q matrix, columns corresponding to standard (non-sparse) leading eigenvectors.

values

vector with the q leading eigenvalues (in decreasing order).

Author(s)

Konstantinos Benidis and Daniel P. Palomar

References

K. Benidis, Y. Sun, P. Babu, and 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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
library(sparseEigen)
n <- 100  # 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 eigenvectors
res_standard <- eigen(cov(X))
res_sparse <- spEigen(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

dppalomar/sparseEigen documentation built on May 5, 2019, 12:31 p.m.