[R] residuals and glm

Frank E Harrell Jr f.harrell at vanderbilt.edu
Thu Feb 22 14:38:15 CET 2007


David Barron wrote:
> 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

And in the Design package's lrm and residuals.lrm function (called by 
resid(fit)) you can get partial residuals that when smoothed estimate 
covariate effects.  I do prefer direct modeling instead of looking at 
any of the residuals though, e.g., adding nonlinear or interaction terms 
to logistic models.  Usually I find that residuals in simple binary 
logistic models are most useful in checking for overly influential 
observations.

Frank Harrell

> 
> 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.
>>
> 
> 


-- 
Frank E Harrell Jr   Professor and Chair           School of Medicine
                      Department of Biostatistics   Vanderbilt University



More information about the R-help mailing list