Compute the top-k singular triplets of \(S = Xe' Ye\) without materializing the whitened matrices \(Xe = Mx^{1/2} X Wx^{1/2}\), \(Ye = My^{1/2} Y Wy^{1/2}\) when doing so would densify sparse data. When the whitening is sparsity-preserving (identity/diagonal metrics) or the data are dense, the whitened blocks are precomputed once so each matrix-vector product in the iterative SVD costs two multiplies.
Arguments
- X
n x I matrix (numeric or Matrix)
- Y
n x J matrix (numeric or Matrix)
- XLW
Row metric for X (M_X): NULL/identity, numeric length-n, diagonalMatrix, or PSD Matrix
- YLW
Row metric for Y (M_Y)
- XRW
Column metric for X (W_X)
- YRW
Column metric for Y (W_Y)
- k
Number of components. If
kexceedsmin(ncol(X), ncol(Y)), a warning is issued andkis silently truncated to that maximum.- center, scale
Logical; pre-center/scale columns of X, Y before metrics
- svd_backend
One of "eigencore" (default) or "irlba"; "RSpectra" is accepted as a deprecated alias of "eigencore". Ignored whenever both
ncol(X) <= 64andncol(Y) <= 64, in which caseSis materialized densely and solved withbase::svd().- svd_opts
List of options for the backend:
tol(both backends) andmaxitr(irlba only; the eigencore partial SVD has no iteration cap). An incomplete eigencore solve raisesgenpca_solver_nonconvergence; try a less stringenttolif the requested accuracy cannot be reached.- constraints_remedy
What to do with a metric that is not positive semi-definite:
"error"(default),"ridge","clip"or"identity"; repairs emit agenpca_metric_repairedwarning. Seegenpca().
Value
A list with elements:
- d
Length-
knumeric vector of singular values of \(S = Xe' Ye\).- u
I x kmatrix; left singular vectors ofS(orthonormal in the Euclidean metric).- v
J x kmatrix; right singular vectors ofS(orthonormal in the Euclidean metric).- p
I x kmatrix of generalized X-weights, \(p = W_X^{-1/2} u\).- q
J x kmatrix of generalized Y-weights, \(q = W_Y^{-1/2} v\).- fi
I x kmatrix of X-variable scores, \(F_i = W_X p D\) (columns ofprescaled by the singular values).- fj
J x kmatrix of Y-variable scores, \(F_j = W_Y q D\).- lx
N x kmatrix of X row latent variables, \(L_x = M_X^{1/2} X W_X p\).- ly
N x kmatrix of Y row latent variables, \(L_y = M_Y^{1/2} Y W_Y q\).- k
Integer; number of components actually returned (may be less than the requested
kif it exceededmin(I, J)).- dims
A list
list(N, I, J)with the row countNand column countsI = ncol(X),J = ncol(Y).- center
A list
list(X, Y)of the length-I/ length-Jcolumn means subtracted fromX/Y(all zero whencenter = FALSE).- scale
A list
list(X, Y)of the length-I/ length-Jcolumn scale factors divided out ofX/Y(all one whenscale = FALSE).
Details
Naming map: this function names its metrics XLW/YLW (left/row
weights) and XRW/YRW (right/column weights); these correspond to
Mx/My (row metrics) and Ax/Ay (column metrics) in genpca()'s and
genpls()'s M/A convention.