Learn R Programming

msPCA (version 0.1.0)

mspca: Multiple Sparse PCA

Description

Returns multiple sparse principal component of a matrix using an iterative deflation heuristic.

Usage

mspca(
  Sigma,
  r,
  ks,
  maxIter = 200L,
  verbose = TRUE,
  violationTolerance = 1e-04,
  stallingTolerance = 1e-08,
  maxIterTPW = 200L,
  timeLimitTPW = 20L
)

Value

An object with 4 fields: `x_best` (p x r array containing the sparse PCs), `objective_value`, `orthogonality_violation`, `runtime`.

Arguments

Sigma

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

r

An integer. Number of principal components (PCs) to be computed.

ks

A list of integers. Target sparsity of each PC.

maxIter

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

verbose

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

violationTolerance

(optional) A float. Tolerance for the violation of the orthogonality constraints. Default 1e-4

stallingTolerance

(optional) A float. Controls the objective improvement below which the algorithm is considered to have stalled. Default 1e-8

maxIterTPW

(optional) An integer. Maximum number of iterations of the truncated power method (inner iteration). Default 200.

timeLimitTPW

(optional) An integer. Maximum time in seconds for the truncated power method (inner iteration). Default 20.

Examples

Run this code
library(datasets)
TestMat <- cor(datasets::mtcars)
mspca(TestMat, 2, c(4,4))

Run the code above in your browser using DataLab