View source: R/predict.missoNet.R
predict.missoNet | R Documentation |
missoNet
modelsGenerate 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}.
## 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"),
...
)
object |
A fitted |
newx |
Numeric matrix of predictors with |
s |
Character string selecting the stored solution; one of
|
... |
Ignored; included for S3 compatibility. |
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).
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).
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.
missoNet
, cv.missoNet
, plot.missoNet
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
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.