fastSVD {bootSVD} | R Documentation |
fastSVD
uses the inherent low dimensionality of a wide, or tall, matrix to quickly calculate its SVD. For a matrix A
, this function solves svd(A)=UDV'
.
This function can be applied to either standard matrices, or, when the data is too large to be stored in memeory, to matrices with class ff
. ff
objects have a representation in memory, but store their contents on disk. In these cases, fastSVD
will implement block matrix algebra to compute the SVD.
fastSVD(A, nv = min(dim(A)), warning_type = "silent", center_A = FALSE,
pattern = NULL)
A |
matrix of dimension ( |
nv |
number of high dimensional singular vectors to obtain. If |
warning_type |
passed to |
center_A |
Whether the matrix |
pattern |
passed to |
Users might also consider changing the global option ffbatchbytes
, from the ff
package. When a ff
object is entered, the ffbatchbytes
option determines the maximum block size in the block matrix algebra used to calculate the SVD.
Let r
be the rank of the matrix A
. fastSVD
solves svd(A)=UDV'
, where U
is an (n
by r
) orthonormal matrix, D
is an (r
by r
) diagonal matrix; and V
is a (m
by r
) orthonormal matrix. When A
is entered as an ff
object, the high dimensional singular vectors of A
will be returned as an ff
object as well. For matrices where one dimension is substantially large than the other, calculation times are considerably faster than the standard svd
function.
Y<-simEEG(n=100,centered=TRUE,wide=TRUE)
svdY<-fastSVD(Y)
svdY
matplot(svdY$v[,1:5],type='l',lty=1) #sample PCs for a wide matrix are the right singular vectors
#Note: For a tall, demeaned matrix Y, with columns corresponding
#to subjects and rows to measurements,
#the PCs are the high dimensional left singular vectors.
#Example with 'ff'
dev.off()
library(ff)
Yff<-as.ff(Y)
svdYff<-fastSVD(Yff)
svdYff
matplot(svdYff$v[,1:5],type='l',lty=1)