rrpca: Randomized robust principal component analysis (rrpca).

Description Usage Arguments Details Value Author(s) References Examples

View source: R/rrpca.R

Description

Robust principal components analysis separates a matrix into a low-rank plus sparse component.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
rrpca(
  A,
  lambda = NULL,
  maxiter = 50,
  tol = 1e-05,
  p = 10,
  q = 2,
  trace = FALSE,
  rand = TRUE
)

Arguments

A

array_like;
a real (m, n) input matrix (or data frame) to be decomposed.
na.omit is applied, if the data contain NAs.

lambda

scalar, optional;
tuning parameter (default lambda = max(m,n)^-0.5).

maxiter

integer, optional;
maximum number of iterations (default maxiter = 50).

tol

scalar, optional;
precision parameter (default tol = 1.0e-5).

p

integer, optional;
oversampling parameter for rsvd (default p=10), see rsvd.

q

integer, optional;
number of additional power iterations for rsvd (default q=2), see rsvd.

trace

bool, optional;
print progress.

rand

bool, optional;
if (TRUE), the rsvd routine is used, otherwise svd is used.

Details

Robust principal component analysis (RPCA) is a method for the robust seperation of a a rectangular (m,n) matrix A into a low-rank component L and a sparse comonent S:

A = L + S

To decompose the matrix, we use the inexact augmented Lagrange multiplier method (IALM). The algorithm can be used in combination with either the randomized or deterministic SVD.

Value

rrpca returns a list containing the following components:

L

array_like;
low-rank component; (m, n) dimensional array.

S

array_like
sparse component; (m, n) dimensional array.

Author(s)

N. Benjamin Erichson, erichson@berkeley.edu

References

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
library('rsvd')

# Create toy video
# background frame
xy <- seq(-50, 50, length.out=100)
mgrid <- list( x=outer(xy*0,xy,FUN="+"), y=outer(xy,xy*0,FUN="+") )
bg <- 0.1*exp(sin(-mgrid$x**2-mgrid$y**2))
toyVideo <- matrix(rep(c(bg), 100), 100*100, 100)

# add moving object
for(i in 1:90) {
  mobject <- matrix(0, 100, 100)
  mobject[i:(10+i), 45:55] <- 0.2
  toyVideo[,i] =  toyVideo[,i] + c( mobject )
}

# Foreground/Background separation
out <- rrpca(toyVideo, trace=TRUE)

# Display results of the seperation for the 10th frame
par(mfrow=c(1,4))
image(matrix(bg, ncol=100, nrow=100)) #true background
image(matrix(toyVideo[,10], ncol=100, nrow=100)) # frame
image(matrix(out$L[,10], ncol=100, nrow=100)) # seperated background
image(matrix(out$S[,10], ncol=100, nrow=100)) #seperated foreground

Benli11/rPCA documentation built on April 20, 2021, 6:50 a.m.