R/R2CV.R

Defines functions R2CV

Documented in R2CV

R2CV <- function(model){
  if (!any(class(model)=="lm")) stop("model must be class ``lm'' or ``glm''")
  yhat <- fitted(model)
  ehat <- residuals(model)
  y <- yhat + ehat
  hi <- influence(model)$hat
  yhatcve <- (yhat-hi*y)/(1-hi)
  cor(y,yhatcve)^2
}
  

Try the SMIR package in your browser

Any scripts or data that you put into this service are public.

SMIR documentation built on May 29, 2017, 10:39 a.m.