Full_Name: Julian Faraway Version: .90.1 OS: Linux+NT Submission from: (NULL) (141.211.66.172) In the following example, the deviance residuals are not correctly calculated:> dead <- c(2,8,15,23,27) > y <- cbind(dead,30-dead) > conc <- 0:4 > g <- glm(y ~ conc,family=binomial) > residuals(g)[1] -0.451015 0.359696 NaN 0.064302 -0.204493 Warning message: NaNs produced in: sqrt((object$family$dev.resids)(y, mu, wts)) The third residual should be zero. -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Tue, 11 Jan 2000 faraway@umich.edu wrote:> Full_Name: Julian Faraway > Version: .90.1 > OS: Linux+NT > Submission from: (NULL) (141.211.66.172) > > > In the following example, the deviance residuals are not correctly calculated: > > > dead <- c(2,8,15,23,27) > > y <- cbind(dead,30-dead) > > conc <- 0:4 > > g <- glm(y ~ conc,family=binomial) > > residuals(g) > [1] -0.451015 0.359696 NaN 0.064302 -0.204493 > Warning message: > NaNs produced in: sqrt((object$family$dev.resids)(y, mu, wts)) > > The third residual should be zero.Yes, and it is computed as sqrt(-5.169943e-21) on my machine. I have committed a fix for 0.99.0 -- Brian D. Ripley, ripley@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 272860 (secr) Oxford OX1 3TG, UK Fax: +44 1865 272595 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
maechler@stat.math.ethz.ch
2000-Jan-11 21:25 UTC
deviance residuals in binomial GLM (PR#399)
>>>>> "faraway" == faraway <faraway@umich.edu> writes:faraway> Full_Name: Julian Faraway faraway> Version: .90.1 faraway> OS: Linux+NT faraway> Submission from: (NULL) (141.211.66.172) faraway> In the following example, the deviance residuals are not faraway> correctly calculated: >> dead <- c(2,8,15,23,27) >> y <- cbind(dead,30-dead) >> conc <- 0:4 >> g <- glm(y ~ conc,family=binomial) >> residuals(g) faraway> [1] -0.451015 0.359696 NaN 0.064302 -0.204493 faraway> Warning message: faraway> NaNs produced in: sqrt((object$family$dev.resids)(y, mu, wts)) faraway> The third residual should be zero. yes, this is a bug. Diagnosis: A case of cancelation which makes the argument of sqrt(.) negative (~= -5e-21) instead of zero. The fix is in src/library/base/R/glm.R replace d.res <- sqrt((object$family$dev.resids)(y, mu, wts)) by d.res <- sqrt(pmax(0,(object$family$dev.resids)(y, mu, wts))) Thanks a lot for the report! Martin Maechler <maechler@stat.math.ethz.ch> http://stat.ethz.ch/~maechler/ Seminar fuer Statistik, ETH-Zentrum LEO D10 Leonhardstr. 27 ETH (Federal Inst. Technology) 8092 Zurich SWITZERLAND phone: x-41-1-632-3408 fax: ...-1228 <>< -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._