Learn R Programming

bootSVD (version 0.1)

fastSVD: Fast SVD of a wide or tall matrix

Description

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'$.

Usage

fastSVD(A, nv = min(dim(A)), warning_type = "silent")

Arguments

A
matrix of dimension ($n$ by $m$).
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
warning_type
passed to qrSVD, which calculates svd(tcrossprod(A))

Value

  • 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. For matrices where one dimension is substantially large than the other, calculation times are considerably faster than the standard svd function.

Examples

Run this code
Y<-simEEG(n=100,centered=TRUE,wide=TRUE)
svdY<-fastSVD(Y)
V<-svdY$v #sample PCs for a wide matrix are the right singular vectors
matplot(V[,1:5],type='l',lty=1) #PCs from simulated data

#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.

Run the code above in your browser using DataLab