Skip to contents

Make predictions on new data by a msaenet model object.

Usage

# S3 method for class 'msaenet'
predict(object, newx, ...)

Arguments

object

An object of class msaenet produced by aenet, amnet, asnet, msaenet, msamnet, or msasnet.

newx

New data to predict with.

...

Additional parameters, particularly prediction type in predict.glmnet, predict.ncvreg, or predict.ncvsurv.

Value

Numeric matrix of the predicted values.

Author

Nan Xiao <https://nanx.me>

Examples

dat <- msaenet.sim.gaussian(
  n = 150, p = 500, rho = 0.6,
  coef = rep(1, 5), snr = 2, p.train = 0.7,
  seed = 1001
)

msaenet.fit <- msaenet(
  dat$x.tr, dat$y.tr,
  alphas = seq(0.2, 0.8, 0.2),
  nsteps = 3L, seed = 1003
)

msaenet.pred <- predict(msaenet.fit, dat$x.te)
msaenet.rmse(dat$y.te, msaenet.pred)
#> [1] 2.839212