R/predict.mlkit.lm.fit.R

Defines functions predict.mlkit.lm.fit

Documented in predict.mlkit.lm.fit

#' Model Predictions for Linear Regression Model
#'
#' @description Custom implementation for prediction using model fits obtained
#' resulting from linear regression models in the \code{mlkit} package.
#'
#' @method predict mlkit.lm.fit
#'
#' @param object \code{mlkit.lm.fit} object generated by a call to a linear
#' regression method in the \code{mlkit} package that is used for prediction.
#' @param newdata optional matrix of explanatory variables to use in prediction.
#' Default is \code{NULL} in which case the in-sample predictions are returned.
#' @param ... additional arguments affecting the predictions produced.
#'
#' @return Atomic vector containing predictions based on the given model and
#' explanatory variables.
#'
#' @export
#'
predict.mlkit.lm.fit = function(object, newdata=NULL, ...) {
  return(data.matrix(newdata) %*% object$coefficients)
}
Accelerytics/mlkit documentation built on Dec. 31, 2020, 9:46 a.m.