R/GLMprediction.R

Defines functions GLMprediction

Documented in GLMprediction

#' GLMprediction
#' 
#' This function takes a trained Generalized Linear Model and returns predictions on the given test set.
#' 
#' 
#' @param model The fit GLM model to run predictions through.
#' @param test The dataset to make predictions on.
#' 
#' 
#' @export

GLMprediction <- function(model,test){
  
  preds <- stats::predict(model,test,type='response',se.fit=TRUE)
  
  z <- qnorm(.99)
  
  lower <- preds$fit - z*preds$se.fit
  upper <- preds$fit + z*preds$se.fit
  
  dum <- rep("0",length(preds$fit))
  dum[preds$fit>.5]="1"

  table <- data.frame(Date=test$Date,Team=test$Team,Lo=lower,Avg=preds$fit,Hi=upper,PrWL=dum)
  table[3:5] <- round(table[3:5],digits = 3)
  return(table)
}
dennist2/MerlinV1 documentation built on Dec. 11, 2019, 8:41 p.m.