predict_cv function

Predict Function for glmnet_with_cv Models

Predict Function for glmnet_with_cv Models

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.

predict_cv(object, newdata, debias = FALSE, ...)

Arguments

  • object: An object returned by glmnet_with_cv.
  • newdata: A data frame of new predictor values.
  • debias: Logical; if TRUE, applies the debiasing linear model stored in object$debias_fit (if available). Default is FALSE.
  • ...: Additional arguments (not used).

Returns

A numeric vector of predictions.

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.

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)

See Also

glmnet_with_cv, SVEMnet, predict.svem_model

  • Maintainer: Andrew T. Karl
  • License: GPL-2 | GPL-3
  • Last published: 2024-12-21

Useful links