Learn R Programming

onlinePCA (version 1.3.2)

bsoipca: Block Stochastic Orthononal Iteration (BSOI)

Description

The online PCA algorithm of Mitliagkas et al. (2013) is a block-wise stochastic variant of the classical power-method.

Usage

bsoipca(x, q, U, B, center, byrow = FALSE)

Value

A matrix with the q first eigenvectors/PCs in columns.

Arguments

x

data matrix.

q

number of PC to compute.

U

matrix of initial PCs in columns (optional).

B

size of block updates (optional).

center

centering vector (optional).

byrow

are the data vectors in x stored in rows (TRUE) or columns (FALSE)?

Details

The default value of B is \(floor(n/nblock)\) with \(n\) the number of data vectors in x, \(d\) the number of variables, and \(nblock=ceiling(log(d))\) the number of blocks.
If U is specified, q defaults to ncol(U); otherwise the initial PCs are computed from the first block of data and q must be specified explicitly.
Although the algorithm does not give eigenvalues, they can easily be estimated by computing the variance of the data along the PCs.

References

Mitliagkas et al. (2013). Memory limited, streaming PCA. Advances in Neural Information Processing Systems.

Examples

Run this code
## Simulate Brownian Motion
n <- 100 # number of sample paths
d <- 50 # number of observation points
x <- matrix(rnorm(n*d,sd=1/sqrt(d)),n,d)
x <- t(apply(x,1,cumsum)) # dim(x) = c(100,50)

q <- 10 # number of PC to compute
B <- 20 # block size

## BSOI PCA 
U <- bsoipca(x, q, B=B, byrow=TRUE) # PCs
lambda <- apply(x %*% U, 2, var) # eigenvalues 

Run the code above in your browser using DataLab