predict_cv {SVEMnet} | R Documentation |
Predict Function for glmnet_with_cv Models
Description
Generate predictions from the model fitted by glmnet_with_cv
. This function accepts
new data and returns predictions, optionally debiased if a debiasing linear model was fit.
Usage
predict_cv(object, newdata, debias = FALSE, ...)
Arguments
object |
An object returned by |
newdata |
A data frame of new predictor values. |
debias |
Logical; if |
... |
Additional arguments (not used). |
Details
Predictions are computed by forming the model matrix from newdata
using the stored formula
and terms
in the fitted model object. The coefficients used are those stored in parms
. If debias=TRUE
and a
debias_fit
linear model is available, predictions are adjusted by that model.
Value
A numeric vector of predictions.
See Also
glmnet_with_cv
, SVEMnet
, predict.svem_model
Examples
set.seed(0)
n <- 50
X1 <- runif(n)
X2 <- runif(n)
y <- 1 + 2*X1 + 3*X2 + rnorm(n)
data <- data.frame(y, X1, X2)
model_cv <- glmnet_with_cv(y ~ X1 + X2, data = data, glmnet_alpha = c(0,0.5,1))
predictions <- predict_cv(model_cv, data)
predictions_debiased <- predict_cv(model_cv, data, debias = TRUE)
[Package SVEMnet version 1.3.0 Index]