Quickly compute top rank singular vectors of a matrix A and
return them in a matrix. Especially useful in formulas in regression
objects.
Arguments
- A
A
matrix()orMatrix::Matrix()object.- rank
Rank of desired decomposition.
- ...
Arguments passed on to
irlba::irlbanvnumber of right singular vectors to estimate.
nunumber of left singular vectors to estimate (defaults to
nv).maxitmaximum number of iterations.
workworking subspace dimension, larger values can speed convergence at the cost of more memory use.
reorthif
TRUE, apply full reorthogonalization to both SVD bases, otherwise only apply reorthogonalization to the right SVD basis vectors; the latter case is cheaper per iteration but, overall, may require more iterations for convergence. AutomaticallyTRUEwhenfastpath=TRUE(see below).tolconvergence is determined when \(\|A^TU - VS\| < tol\|A\|\), and when the maximum relative change in estimated singular values from one iteration to the next is less than
svtol = tol(seesvtolbelow), where the spectral norm ||A|| is approximated by the largest estimated singular value, and U, V, S are the matrices corresponding to the estimated left and right singular vectors, and diagonal matrix of estimated singular values, respectively.voptional starting vector or output from a previous run of
irlbaused to restart the algorithm from where it left off (see the notes).right_onlylogical value indicating return only the right singular vectors (
TRUE) or both sets of vectors (FALSE). The right_only option can be cheaper to compute and use much less memory whennrow(A) >> ncol(A)but note that obtained solutions typically lose accuracy due to lack of re-orthogonalization in the algorithm and thatright_only = TRUEsetsfastpath = FALSE(only use this option for really large problems that run out of memory and whennrow(A) >> ncol(A)). Consider increasing theworkoption to improve accuracy withright_only=TRUE.verboselogical value that when
TRUEprints status messages during the computation.scaleoptional column scaling vector whose values divide each column of
A; must be as long as the number of columns ofA(see notes).centeroptional column centering vector whose values are subtracted from each column of
A; must be as long as the number of columns ofAand may not be used together with the deflation options below (see notes).shiftoptional shift value (square matrices only, see notes).
multDEPRECATED optional custom matrix multiplication function (default is
%*%, see notes).fastpathtry a fast C algorithm implementation if possible; set
fastpath=FALSEto use the reference R implementation. See the notes for more details.svtoladditional stopping tolerance on maximum allowed absolute relative change across each estimated singular value between iterations. The default value of this parameter is to set it to
tol. You can setsvtol=Infto effectively disable this stopping criterion. Settingsvtol=Infallows the method to terminate on the first Lanczos iteration if it finds an invariant subspace, but with less certainty that the converged subspace is the desired one. (It may, for instance, miss some of the largest singular values in difficult problems.)smallestset
smallest=TRUEto estimate the smallest singular values and associated singular vectors. WARNING: this option is somewhat experimental, and may produce poor estimates for ill-conditioned matrices.