From presnell at stat.ufl.edu  Mon Mar 14 22:25:21 2011
From: presnell at stat.ufl.edu (Brett Presnell)
Date: Mon, 14 Mar 2011 17:25:21 -0400
Subject: [Rd] Standardized Pearson residuals
Message-ID: <87pqpts8ce.fsf@stat.ufl.edu>


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
}



[Rd] Standardized Pearson residuals
Brett Presnell