mspca: Rank-k Sparse Principal Components Analysis

Description Usage Arguments Details Value Examples

View source: R/mspca.R

Description

Multifactor version of the rank-1 SPCA of spca.Cmponents are found by applying spca to the original matrix after deflation by deducting the components already found. It is possible to apply different penalties to different components.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
mspca(
  Z,
  k = 2,
  c = 1,
  start = c("independent", "predetermined"),
  maxit = 20,
  eps = sqrt(.Machine$double.eps),
  center = TRUE,
  scale = FALSE
)

Arguments

Z

Matrix to be decomposed

k

Required rank of the result

c

L1-norm bound for V (greater than or equal to 1), either length-1, or with k entries (one for each component). Feasible solutions are available for values greater than or equal to 1. For values larger than sqrt(ncow(Z), it has no effect.

start

Starting values to use for the v vector in each iteration: Either "independent" or "predetermined". The former uses the first right singular vector of the residual matrix after removing previous components in each step, while the former uses the right singular vectors of the SVD of Z

maxit

Maximum number of iterations

eps

Stopping criterion, and absolute error tolerance on the mean squared reconstruction error

center

Logical indicating whether to column-centre the matrix Z

scale

Logical indicating whether to set the standard deviations of the columns of Z equal to one before analysis

Details

This is similar to SPC, but differs especially with respect to the centring of the matrix.

Value

A list with the following components:

scores

The data matrix after projection to the principal component space

loadings

The matrix of component loadings

sdev

The standard deviations of each of the principal components

pve

Data frame giving the proportion of variance explained by the obtained components

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
## Random matrix example, with n > p
set.seed(1)
Z <- matrix(rnorm(100), nrow = 20, ncol = 5)
mspca(Z, c = 1.25, k = 5)

## Random matrix example with n < p
Z2 <- matrix(rnorm(100), nrow = 5, ncol = 20)
mspca(Z2, c = 2.5, k = 5)

## Example with different c for components 1 and 2
mspca(Z, k = 2, c = c(1.5, 1.1))

## Comparison to PCA
summary(prcomp(Z2))
mspca(Z2, k = 5, c = max(dim(Z2)))$pve

schoonees/spca documentation built on Jan. 31, 2021, 6:21 p.m.