[R] extracting residuals from glm object
utkarshsinghal
utkarsh.singhal at global-analytics.com
Tue May 12 10:50:31 CEST 2009
Hi All,
Can anybody explain why the following three ways of extracting residuals
from a glm object are giving me different outputs:
> idv = runif(1000,0,1)
> dv = rbinom(1000,1,0.5)
> d = data.frame(idv,dv)
> fit = glm(dv~idv, data=d, family=binomial)
> head(residuals(fit))
1 2 3 4 5 6
1.216862 -1.161059 -1.156795 1.204759 -1.141068 1.201437
> head(fit$residuals)
1 2 3 4 5 6
2.096724 -1.962126 -1.952454 2.066224 -1.917492 2.057981
> head(d$dv-fit$fitted.values)
1 2 3 4 5 6
0.5230655 -0.4903489 -0.4878241 0.5160253 -0.4784855 0.5140869
Regards
Utkarsh
More information about the R-help
mailing list