powered by
Returns multiple sparse principal component of a matrix using an iterative deflation heuristic.
mspca( Sigma, r, ks, maxIter = 200L, verbose = TRUE, violationTolerance = 1e-04, stallingTolerance = 1e-08, maxIterTPW = 200L, timeLimitTPW = 20L )
An object with 4 fields: `x_best` (p x r array containing the sparse PCs), `objective_value`, `orthogonality_violation`, `runtime`.
A matrix. The correlation or covariance matrix, whose sparse PCs will be computed.
An integer. Number of principal components (PCs) to be computed.
A list of integers. Target sparsity of each PC.
(optional) An integer. Maximum number of iterations of the algorithm. Default 200.
(optional) A Boolean. Controls console output. Default TRUE.
(optional) A float. Tolerance for the violation of the orthogonality constraints. Default 1e-4
(optional) A float. Controls the objective improvement below which the algorithm is considered to have stalled. Default 1e-8
(optional) An integer. Maximum number of iterations of the truncated power method (inner iteration). Default 200.
(optional) An integer. Maximum time in seconds for the truncated power method (inner iteration). Default 20.
library(datasets) TestMat <- cor(datasets::mtcars) mspca(TestMat, 2, c(4,4))
Run the code above in your browser using DataLab