powered by
Returns the leading sparse principal component of a matrix using the truncated power method.
tpw(Sigma, k, maxIter = 200L, verbose = TRUE, timeLimit = 10L)
An object with 3 fields: `x_best` (p x 1 array containing the sparse PC), `objective_value`, `runtime`.
A matrix. The correlation or covariance matrix, whose sparse PCs will be computed.
An integer. Target sparsity of the PC.
(optional) An integer. Maximum number of iterations of the algorithm. Default 200.
(optional) A Boolean. Controls console output. Default TRUE.
(optional) An integer. Maximum time in seconds. Default 10.
Yuan, X. T., & Zhang, T. (2013). Truncated power method for sparse eigenvalue problems. The Journal of Machine Learning Research, 14(1), 899-925.
library(datasets) TestMat <- cor(datasets::mtcars) tpw(TestMat, 4)
Run the code above in your browser using DataLab