predict.msma: Project and Reconstruct New Data with an msma Fit

View source: R/src.r

predict.msmaR Documentation

Project and Reconstruct New Data with an msma Fit

Description

Projects supplied X-side and, for PLS, Y-side data into the fitted component spaces and returns component scores and low-rank reconstructions.

Usage

## S3 method for class 'msma'
predict(object, newX, newY = NULL, ...)

Arguments

object

an object of class \"msma\".

newX

a numeric matrix or list of numeric matrices for the X side.

newY

an optional numeric matrix or list of numeric matrices for the Y side. Fitted PLS prediction requires newY. The supplied Y data are projected and reconstructed independently and are not predicted from newX.

...

additional prediction controls:

preprocessing

Either \"legacy\" or \"fitted\". The default preserves historical numerical behavior; fitted preprocessing reuses training center and scale.

reconstruction

Either \"batch\" or \"fitted\". Fitted reconstruction uses training-derived coefficients and is independent of prediction-batch composition.

output_scale

Either \"analysis\" or \"original\". Original output applies inverse fitted preprocessing to reconstructed X and Y blocks.

Details

This method does not predict Y from X. When newY is supplied, X and Y are projected and reconstructed independently in their corresponding fitted component spaces.

Historical prediction behavior remains the default. Additional Version 5 prediction controls can be supplied through ....

Fitted reconstruction and original-scale output require preprocessing = \"fitted\". Scores remain on the analysis scale.

Value

a list with four elements:

X

X-side low-rank reconstructions.

sbX

X-side component scores on the analysis scale.

Y

Y-side low-rank reconstructions, or NULL for PCA.

sbY

Y-side component scores, or NULL for PCA.

Examples

set.seed(1)
X <- matrix(rnorm(180), nrow = 30, ncol = 6)
colnames(X) <- paste0("x", seq_len(ncol(X)))
fit <- msma(X = X, comp = 2, scaling = TRUE, intseed = 3)
prediction <- predict(
  fit,
  newX = X[1:5, , drop = FALSE],
  preprocessing = "fitted",
  reconstruction = "fitted",
  output_scale = "original"
)
names(prediction)


msma documentation built on Nov. 7, 2026, 9:06 a.m.