[Rd] Standardized Pearson residuals

Brett Presnell presnell at stat.ufl.edu
Mon Mar 14 22:25:21 CET 2011


Is there any reason that rstandard.glm doesn't have a "pearson" option?
And if not, can it be added?

Background: I'm currently teaching an undergrad/grad-service course from
Agresti's "Introduction to Categorical Data Analysis (2nd edn)" and
deviance residuals are not used in the text.  For now I'll just provide
the students with a simple function to use, but I prefer to use R's
native capabilities whenever possible.

I think something along the following lines should do it:

rstandard.glm <-
  function(model,
           infl=influence(model, do.coef=FALSE),
           type=c("deviance", "pearson"), ...)
{
  res <- switch(type, pearson = infl$pear.res, infl$dev.res)
  res <- res/sqrt(1-infl$hat)
  res[is.infinite(res)] <- NaN
  res
}



More information about the R-devel mailing list