predict.cv.missoNet {missoNet} | R Documentation |
Make predictions from a cv.missoNet object
Description
S3 method for making predictions of response values from a fitted 'cv.missoNet'
object.
Usage
## S3 method for class 'cv.missoNet'
predict(object, newx = NULL, s = "lambda.min", ...)
Arguments
object |
A fitted |
newx |
A predictor matrix of new values at which predictions are to be made. The columns of |
s |
Character string, the regularization parameter pair |
... |
Not used. Other arguments for predicting. |
Value
The matrix of predicted values: 'newy = mu_hat + newx %*% Beta_hat'
.
Author(s)
Yixiao Zeng yixiao.zeng@mail.mcgill.ca, Celia M.T. Greenwood and Archer Yi Yang.
Examples
## Simulate a dataset.
set.seed(123) # reproducibility
sim.dat <- generateData(n = 300, p = 10, q = 10, rho = 0.1, missing.type = "MCAR")
tr <- 1:240 # training set indices
tst <- 241:300 # test set indices
## Perform a five-fold cross-validation on the training set.
cvfit <- cv.missoNet(X = sim.dat$X[tr, ], Y = sim.dat$Z[tr, ], kfold = 5,
fit.1se = TRUE, permute = TRUE, with.seed = 486)
## Make predictions of response values on the test set.
newy1 <- predict(cvfit, newx = sim.dat$X[tst, ], s = "lambda.min")
newy2 <- predict(cvfit, newx = sim.dat$X[tst, ], s = "lambda.1se.Beta") # 'fit.1se' = TRUE
newy3 <- predict(cvfit, newx = sim.dat$X[tst, ], s = "lambda.1se.Theta") # 'fit.1se' = TRUE