bsoipca | R Documentation |
The online PCA algorithm of Mitliagkas et al. (2013) is a block-wise stochastic variant of the classical power-method.
bsoipca(x, q, U, B, center, byrow = FALSE)
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 |
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.
A matrix with the q
first eigenvectors/PCs in columns.
Mitliagkas et al. (2013). Memory limited, streaming PCA. Advances in Neural Information Processing Systems.
## 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
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.