compsvd: compsvd: Compute Singular Value Decomposition (SVD)

Description Usage Arguments Value Examples

View source: R/corral.R

Description

Computes SVD.

Usage

1
compsvd(mat, method = c("irl", "svd"), ncomp = 30, ...)

Arguments

mat

matrix, pre-processed input; can be sparse or full (pre-processing can be performed using corral_preproc from this package)

method

character, the algorithm to be used for svd. Default is irl. Currently supports 'irl' for irlba::irlba or 'svd' for stats::svd

ncomp

numeric, number of components; Default is 30

...

(additional arguments for methods)

Value

SVD result - a list with the following elements:

d

a vector of the diagonal singular values of the input mat. Note that using svd will result in the full set of singular values, while irlba will only compute the first ncomp singular values.

u

a matrix of with the left singular vectors of mat in the columns

v

a matrix of with the right singular vectors of mat in the columns

eigsum

sum of the eigenvalues, for calculating percent variance explained

Examples

1
2
3
4
mat <- matrix(sample(0:10, 2500, replace=TRUE), ncol=50)
compsvd(mat)
compsvd(mat, method = 'svd')
compsvd(mat, method = 'irl', ncomp = 5)

corral documentation built on Nov. 8, 2020, 8:25 p.m.