Learn R Programming

msPCA (version 0.1.0)

tpw: Truncated Power Method

Description

Returns the leading sparse principal component of a matrix using the truncated power method.

Usage

tpw(Sigma, k, maxIter = 200L, verbose = TRUE, timeLimit = 10L)

Value

An object with 3 fields: `x_best` (p x 1 array containing the sparse PC), `objective_value`, `runtime`.

Arguments

Sigma

A matrix. The correlation or covariance matrix, whose sparse PCs will be computed.

k

An integer. Target sparsity of the PC.

maxIter

(optional) An integer. Maximum number of iterations of the algorithm. Default 200.

verbose

(optional) A Boolean. Controls console output. Default TRUE.

timeLimit

(optional) An integer. Maximum time in seconds. Default 10.

References

Yuan, X. T., & Zhang, T. (2013). Truncated power method for sparse eigenvalue problems. The Journal of Machine Learning Research, 14(1), 899-925.

Examples

Run this code
library(datasets)
TestMat <- cor(datasets::mtcars)
tpw(TestMat, 4)

Run the code above in your browser using DataLab