# [Rd] Pearson residuals (PR#1123)

**Thomas Lumley
**
tlumley@u.washington.edu

*Thu, 11 Oct 2001 08:52:57 -0700 (PDT)*

On Thu, 11 Oct 2001 p.dalgaard@biostat.ku.dk wrote:
>* We can easily agree that it's not right... The culprit is this
*>*
*>* revision 1.54
*>* date: 2001/06/07 17:43:06; author: tlumley; state: Exp; lines: +1 -1
*>* wrong sign of pearson residual for inverse link (PR#862)
*>*
*>* diff -u -r1.53 -r1.54
*>* --- src/library/base/R/glm.R 1 Jun 2001 11:48:34 -0000 1.53
*>* +++ src/library/base/R/glm.R 7 Jun 2001 17:43:06 -0000 1.54
*>* @@ -651,7 +651,7 @@
*>* d.res <-
*>* sqrt(pmax((object$family$dev.resids)(y, mu, wts), 0))
*>* ifelse(y > mu, d.res, -d.res)
*>* } else rep(0, length(mu)),
*>* - pearson = r * sqrt(object$weights),
*>* + pearson = (y-mu)/sqrt(object$weights),
*>* working = r,
*>* response = y - mu,
*>*
*>* Which is listed as Thomas' doing, but I suspect it was discussed
*>* internally, and thus a collective piece of absentmindedness.
*>*
*
Yes, in response to a previous bug report (?Atkinson) pointing out that
the old version was wrong when the link function was monotone decreasing
(Gamma/reciprocal). It wasn't a confusion of * and /, it was a deeper
absentmindedness.
We can't just use $weights, although it does work for canonical links. We
need (y-mu)/sqrt(prior.weights*variance(mu))
-thomas
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._