Skip to content

Instantly share code, notes, and snippets.

View alexpawlowski's full-sized avatar

Alex Pawlowski alexpawlowski

View GitHub Profile
@alexpawlowski
alexpawlowski / PRESS.R
Last active August 29, 2015 14:12 — forked from tomhopper/PRESS.R
#' @title PRESS
#' @author Thomas Hopper
#' @description Returns the PRESS statistic (predictive residual sum of squares).
#' Useful for evaluating predictive power of regression models.
#' @param linear.model A linear regression model (class 'lm'). Required.
#'
PRESS <- function(linear.model) {
#' calculate the predictive residuals
pr <- residuals(linear.model)/(1-lm.influence(linear.model)$hat)
#' calculate the PRESS