Canonical (two-block) generalized PLS using sparse-friendly implicit matrix-vector products. Solves the SVD of the operator \(S = Xe' Ye\) without materializing \(Xe = Mx^{1/2} X Ax^{1/2}\) or \(Ye = My^{1/2} Y Ay^{1/2}\).
Arguments
- X
Numeric or Matrix, n x p.
- Y
Numeric or Matrix, n x q. Must have same n as `X`.
- Ax
Column metric for X (W_X): vector/diagonal/matrix; `NULL` ⇒ identity.
- Ay
Column metric for Y (W_Y): vector/diagonal/matrix; `NULL` ⇒ identity.
- Mx
Row metric for X (M_X): vector/diagonal/matrix; `NULL` ⇒ identity.
- My
Row metric for Y (M_Y): vector/diagonal/matrix; `NULL` ⇒ identity.
- ncomp
Number of components to extract (rank-k). Default 2.
- preproc_x, preproc_y
Optional `multivarious` preprocessors (e.g., `center()`). Defaults to `multivarious::pass()` (no-op).
- svd_backend
Character, one of `"RSpectra"` (default) or `"irlba"` for iterative SVD. If neither backend is available, a dense fallback is used for small problems by materializing S.
- svd_opts
List of options passed to the SVD backend, e.g., `tol`, `maxitr`.
- verbose
Logical; print brief progress messages.
Value
An object of class `c("genpls", "cross_projector", "projector")` with:
- vx, vy
X- and Y- weights usable with predict/transfer (stored in cross_projector)
- d
singular values (attached field)
- p, q
generalized weights \(W_X^{-1/2} u\), \(W_Y^{-1/2} v\) (attached)
- fi, fj
variable/component scores \(W_X p D\), \(W_Y q D\) (attached)
- lx, ly
row latent variables \(M_X^{1/2} X W_X p\), \(M_Y^{1/2} Y W_Y q\) (attached)
- metrics
the supplied metrics (attached)
Details
This follows the GPLSSVD/PLS-SVD formulation (Beaton, eqs. 10–14): the top `ncomp` singular triplets of S are computed by iterative SVD on the linear maps v -> S v and u -> S^T u, implemented with metric Cholesky multiplies/solves when possible. Works with dense or sparse `Matrix` inputs and constraint metrics.
Returns a `multivarious::cross_projector` with X-/Y-weights (vx, vy) chosen to provide natural projection of new data (`X Additional GPLSSVD quantities are attached to the object for access: singular values `d`, generalized weights `p`, `q`, variable scores `fi`, `fj`, and row latent variables `lx`, `ly`.
References
Beaton, Dougal. Generalized eigen, singular value, and partial least squares decompositions: The GSVD package. (Eqs. 10–14). 2020.
Examples
if (requireNamespace("RSpectra", quietly = TRUE) &&
requireNamespace("multivarious", quietly = TRUE)) {
set.seed(1)
n <- 100; p <- 40; q <- 30
X <- matrix(rnorm(n*p), n, p)
Y <- matrix(rnorm(n*q), n, q)
w <- runif(n); w <- w/sum(w)
Mx <- My <- Matrix::Diagonal(x = w)
fit <- genpls(X, Y, Mx = Mx, My = My, ncomp = 2,
preproc_x = multivarious::center(),
preproc_y = multivarious::center())
fit$d # singular values
}
#> [1] 1.401768 1.340951