Skip to content
Prev 4857 / 63421 Next

Bug in glm.fit() or plot.lm() (PR#778)

Here's what I think is going on.  

plot.lm() and everything I could see like it calls weights(object) and
resid(object).  The problem is that there is a resid.glm so one gets
deviance residuals, but there is not a weights.glm so weights.lm is used.  
The solution is to add weights.glm:

weights.glm <- function(object, type = c("prior", "working"), ...)
{
    type <- match.arg(type)
    if(type == "prior") object$prior.weights else object$weights
}

As far as I can see one either wants the default weights here and deviance
or Pearson residuals, or object$weights and the working residuals.  The
fitted object has the latter pair, which is sensible for inheriting from lm
(and compatible with S), but both plot.lm and your example use residuals()
which is not the same thing.

It seems reasonably clear from the labels that plot.lm is intended to use
standardized deviance residuals, but I am not at all sure that is the best
alternative. Davison & Snell (1991 Cox Festschrift) seem to suggest that
standardized Pearson residuals would be better, and offer other
alternatives.

I've added weights.glm.  We badly need to document the "glm" class
and subtle points like this.
On Tue, 19 Dec 2000 murdoch@stats.uwo.ca wrote:

            
Match the residuals and weights is the story.