predict.missoNet: Predict method for 'missoNet' models

View source: R/predict.missoNet.R

predict.missoNetR Documentation

Predict method for missoNet models

Description

Generate predicted responses for new observations from a fitted missoNet (or cross-validated) model. The prediction at a given regularization choice (\lambda_B,\lambda_\Theta) uses the fitted intercept(s) \hat{\mu} and coefficient matrix \hat{B}:

\hat{Y} = \mathbf{1}_n \hat{\mu}^{\mathsf{T}} + X_\mathrm{new}\,\hat{B}.

Usage

## S3 method for class 'missoNet'
predict(
  object,
  newx,
  s = c("lambda.min", "lambda.1se.beta", "lambda.1se.theta"),
  ...
)

## S3 method for class 'cv.missoNet'
predict(
  object,
  newx,
  s = c("lambda.min", "lambda.1se.beta", "lambda.1se.theta"),
  ...
)

Arguments

object

A fitted missoNet (or cross-validated missoNet) object that contains the components $est.min (and optionally $est.1se.beta, $est.1se.theta), each with numeric fields $mu (length q) and $Beta (p x q).

newx

Numeric matrix of predictors with p columns (no intercept column of 1s). Missing or non-finite values are not allowed. Columns must be in the same order/scale used to fit object.

s

Character string selecting the stored solution; one of c("lambda.min","lambda.1se.beta","lambda.1se.theta").

...

Ignored; included for S3 compatibility.

Details

This method does not modify or standardize newx. If the model was trained with standardization, ensure that newx has been prepared in the same way as the training data (same centering/scaling and column order).

Value

A numeric matrix of predicted responses of dimension n_\mathrm{new} x q. Row names are taken from newx (if any), and column names are inherited from the fitted coefficient matrix (if any).

Which solution is used

The s argument selects the stored solution:

  • "lambda.min" (default): the minimum CV error or selected GoF solution, stored in object$est.min.

  • "lambda.1se.beta": the 1-SE solution favoring larger \lambda_B, stored in object$est.1se.beta.

  • "lambda.1se.theta": the 1-SE solution favoring larger \lambda_\Theta, stored in object$est.1se.theta.

1-SE solutions are available only if the model was fit with compute.1se = TRUE during training or cross-validation.

See Also

missoNet, cv.missoNet, plot.missoNet

Examples

sim <- generateData(n = 200, p = 8, q = 6, rho = 0.1,
                    missing.type = "MCAR", seed = 123)
tr  <- 1:150
tst <- 151:200


## Cross-validated fit, keeping 1-SE solutions
cvfit <- cv.missoNet(X = sim$X[tr, ], Y = sim$Z[tr, ], kfold = 5,
                     compute.1se = TRUE, verbose = 0)

## Predict on held-out set
yhat_min  <- predict(cvfit, newx = sim$X[tst, ], s = "lambda.min")
yhat_b1se <- predict(cvfit, newx = sim$X[tst, ], s = "lambda.1se.beta")
yhat_t1se <- predict(cvfit, newx = sim$X[tst, ], s = "lambda.1se.theta")
dim(yhat_min)  # 50 x q



missoNet documentation built on Sept. 9, 2025, 5:55 p.m.