compsvd: compsvd: Compute Singular Value Decomposition (SVD)

View source: R/corral.R

compsvdR Documentation

compsvd: Compute Singular Value Decomposition (SVD)

Description

Computes SVD.

Usage

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

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

laurenhsu1/corral documentation built on Feb. 19, 2023, 10:37 p.m.