Learn R Programming

Rdimtools (version 0.3.2)

do.spca: Sparse Principal Component Analysis

Description

Sparse PCA (do.spca) is a variant of PCA in that each loading - or, principal component - should be sparse. Instead of using generic optimization package, we opt for formulating a problem as semidefinite relaxation and utilizing ADMM. For more details of modeling and algorithmic aspects, please see admm.spca.

Usage

do.spca(X, ndim = 2, preprocess = c("center", "scale", "cscale",
  "decorrelate", "whiten"), mu = 1, rho = 1, abstol = 1e-04,
  reltol = 0.01, maxiter = 1000)

Arguments

X

an \((n\times p)\) matrix or data frame whose rows are observations and columns represent independent variables.

ndim

an integer-valued target dimension.

preprocess

an additional option for preprocessing the data. Default is "center". See also aux.preprocess for more details.

mu

an augmented Lagrangian parameter.

rho

a regularization parameter for sparsity.

abstol

absolute tolerance stopping criterion.

reltol

relative tolerance stopping criterion.

maxiter

maximum number of iterations.

Value

a named list containing

Y

an \((n\times ndim)\) matrix whose rows are embedded observations.

projection

a \((p\times ndim)\) whose columns are principal components.

trfinfo

a list containing information for out-of-sample prediction.

history

a length-ndim list where each element is an iteration history. See admm.spca for more details.

References

zou_sparse_2006Rdimtools

daspremont_direct_2007Rdimtools

ma_alternating_2013ADMM

See Also

do.pca, admm.spca

Examples

Run this code
# NOT RUN {
## generate default dataset and make its dimension three-folds.
Xp <- aux.gensamples()
X  <- cbind(Xp,Xp,Xp)

## try different regularization parameters for sparsity
out1 <- do.spca(X,ndim=2,rho=0.01)
out2 <- do.spca(X,ndim=2,rho=1)
out3 <- do.spca(X,ndim=2,rho=100)

## Visualize principal components as columns in an image
par(mfrow=c(1,3))
image(t(out1$projection), main="SPCA::rho=0.01")
image(t(out2$projection), main="SPCA::rho=1")
image(t(out3$projection), main="SPCA::rho=100")
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab