#' @title Predict Method for Ridge Regression Model Fits
#' @description Predicted values based on linear model object
#' @param object object of class inheriting from "my_lm_ridge"
#' @param ... further arguments passed to or from other methods
#'
#' @examples
#' data(iris)
#' ridge_fit <- my_lm_ridge(form = Sepal.Length ~ ., data = iris, lambda = 0.5)
#' predict(ridge_fit, iris)
#' @export
predict.my_lm_ridge <- function(object, ...){
dots <- list(...)
data <- dots[[1]]
if(!inherits(data, "data.frame")){
stop("Second argument must be a data frame.")
}
m <- model.matrix(object$form, data)
m %*% object$coefficients
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.