mspca2: Rank-k Sparse Principal Components Analysis

Description Usage Arguments Details Value Examples

View source: R/mspca2.R

Description

This is an experimental version of mspca. It (1) modifies the deflation algorithm and (2) experiments with a "relaxed" lasso. This is not properly tested yet.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
mspca2(
  Z,
  k = 2,
  c = 1,
  maxit = 20,
  eps = sqrt(.Machine$double.eps),
  center = TRUE,
  scale = FALSE,
  deflation = c("Witten", "Shen"),
  relax = 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.

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

deflation

Character string indicating deflation procedure to use; either "Witten" or "Shen"

Details

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.

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
16
17
18
19
20
21
22
23
24
25
## Random matrix example, with n > p
set.seed(1)
Z <- matrix(rnorm(100), nrow = 20, ncol = 5)

## Witten deflation
spca:::mspca2(Z, c = 1.5, k = 5, deflation = "Witten")$svd[c("d", "v")]

## Shen deflation
spca:::mspca2(Z, c = 1.5, k = 5, deflation = "Shen")$svd[c("d", "v")]

## Random matrix example with n < p
Z2 <- matrix(rnorm(100), nrow = 5, ncol = 20)
spca:::mspca2(Z2, c = 1.5, k = 5, deflation = "Witten")$svd[c("d", "v")]
spca:::mspca2(Z2, c = 1.5, k = 5, deflation = "Shen")$svd[c("d", "v")]

## Relaxed lasso
spca:::mspca2(Z, c = 1.5, k = 5, relax = TRUE)$pve
spca:::mspca2(Z, c = 1.5, k = 5, relax = FALSE)$pve

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

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

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