[R] residuals and glm

David Barron mothsailor at googlemail.com
Thu Feb 22 14:25:42 CET 2007


You really need to look at ?glm and ?residuals.glm.

resfit$residuals are the *working* residuals, which are not typically
very useful in themselves.  Far better to use the extractor function.
This enables you to obtain a number of different types of residuals,
but the default (and therefore the type you have obtained) are
deviance residuals.  You can also specify other types, such as pearson
residuals.

Hope this helps.
David

On 22/02/07, Martin Olivier <olivier.martin at avignon.inra.fr> wrote:
> Hi all,
>
> I have some problems to compute the residuals from a glm model with
> binomial distribution.
>
> Suppose I have the following result :
> resfit<-glm(y~x1+x2,weights=we,family=binomial(link="logit"))
>
> Now I would like to obtain the residuals .
> the command residuals(resfit) and the vector resfit$residuals give
> different
> results, and they do not correspond to residuals E(yi)-yi (that is
> resfit$fitted-resfit$y)
>
> so, I would like to know what formula  is applied to compute these
> residuals.
> And moreover,  if I want to compute the standardized residuals, what is the
> right command from the glmfit result.
> Is it
> (resfit$fitted-resfit$y)/sqrt(1/resfit$prior*resfit$fitt*(1-resfit$fitt)) ??
>
>
> Thanks for your help,
> Olivier.
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>


-- 
=================================
David Barron
Said Business School
University of Oxford
Park End Street
Oxford OX1 1HP



More information about the R-help mailing list