Description Usage Arguments Details Value Examples
View source: R/bootstrap_functions.R
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.
1 2 |
A |
matrix of dimension (n by m). This can be either of class |
nv |
number of high dimensional singular vectors to obtain. If n>m, this is the number of n-dimensional left singular vectors to be computed. If n<m, this is the number of m-dimensional right singular vectors to be computed. |
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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | 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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.