R/predict.R

Defines functions predict.ridge_regression

#' Predict based on ridge regression parameters.
#' @example ridge_predict(x, iris)


predict.ridge_regression <- function(object, ...) {
  dots <- list(...)
  x_frame <- dots[[1]]
  if (!is.data.frame(x_frame)) {
    stop(red("The first argument should be a data.frame of values",
             "to predict"))
  }
  X <- model.matrix(attributes(object)$formula, x_frame)
  X %*% object
}
Shuang-Song/bis557 documentation built on Nov. 25, 2019, 8:26 a.m.