[R] residuals and glm
Prof Brian Ripley
ripley at stats.ox.ac.uk
Thu Feb 22 14:36:13 CET 2007
On Thu, 22 Feb 2007, Martin Olivier wrote:
> 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)
?residuals.glm should help you, but note that residuals are always
conventionally (observed - fitted), not as you give.
?glm tells you what resfit$residuals is, and it seems to be not what you
think it is.
> 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))
> ??
See ?rstandard and print(rstandard.glm).
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-help
mailing list