Truncated Power Method
tpm.RdReturns the leading sparse principal component of a dataset using the truncated
power method. As in mspca(), the data is passed as a single argument M whose
interpretation is set by type: "Sigma" (default) for a covariance/correlation
matrix (p x p) or "X" for a raw data matrix (n x p). See mspca() for the
raw-data preprocessing controls.
Arguments
- M
A matrix. The data, interpreted according to
type: a covariance/ correlation matrix (p x p) whentype = "Sigma", or a raw data matrix (n x p) whentype = "X".- k
An integer. Target sparsity of the PC.
- type
(optional) Either "Sigma" (default;
Mis a covariance/correlation matrix) or "X" (Mis a raw data matrix).- 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.
- center
(optional, type = "X") A Boolean. Center the columns of
M. Default TRUE.- scale
(optional, type = "X") A Boolean. Scale the columns of
Mto unit variance. Default FALSE.- divisor
(optional, type = "X") Either "n-1" (default) or "n".
- checkPSD
(optional, type = "Sigma") A Boolean. Verify
Mis PSD. Default TRUE.- symTolerance
(optional, type = "Sigma") A float. Symmetry-check tolerance. Default 1e-8.
- psdTolerance
(optional, type = "Sigma") A float. PSD-check tolerance. Default 1e-8.
Value
An object of class "tpm" (a list) with fields: x_best (p x 1
matrix containing the sparse PC loading), objective_value, and runtime.
With type = "X" it additionally records inputType, center, scale,
divisor, nObs, and p.
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
TestMat <- cor(mtcars)
tpm(TestMat, 4)
#> $objective_value
#> [1] 3.570419
#>
#> $runtime
#> [1] 0.001
#>
#> $x_best
#> [,1]
#> [1,] -0.4994873
#> [2,] 0.4952721
#> [3,] 0.5096592
#> [4,] 0.0000000
#> [5,] 0.0000000
#> [6,] 0.4954447
#> [7,] 0.0000000
#> [8,] 0.0000000
#> [9,] 0.0000000
#> [10,] 0.0000000
#> [11,] 0.0000000
#>
#> $inputType
#> [1] "Sigma"
#>
#> attr(,"class")
#> [1] "tpm"