[R-sig-ME] Deviance residuals don't sum up to deviance

Roelof Coster roelofcoster at gmail.com
Fri Aug 22 15:07:04 CEST 2014


Thanks for the suggestion!

I can use the example which you suggest:

> gm1 <- glmer(cbind(incidence, size - incidence) ~ period + (1 | herd),
data = cbpp, family = binomial)
> deviance(gm1)
[1] 184.0531
> sum(residuals(gm1, type= "deviance")^2)
[1] 73.47428

So here is what I don't understand: these deviance residuals, squared,
don't add up to the total deviance as I expected they would.

Best regards, Roelof Coster




2014-08-22 13:58 GMT+02:00 Martin Maechler <maechler at stat.math.ethz.ch>:

>
> > Hello,
> > I fitted a logistic regression model with glmer. In the resulting model,
> > the reported deviance is not the same as the sum of the squares of the
> > residual deviances. The deviance is 3909, the sum of square deviance
> > residuals is 3747.
>
> > These two should be equal, shouldn't they? The difference seems too large
> > for a roundoff error, I think.
>
> > My data are 150k observations and the fitted probabilities are generally
> > very small (between 1e-7 and 1e-2, median 1e-4).
>
> Can you at least show the exact R function calls that you did to
> produce it?  Even better,
> can you please use the 'gm1' from the first example in
> help(glmer),
>
>   (gm1 <- glmer(cbind(incidence, size - incidence) ~ period + (1 | herd),
>                 data = cbpp, family = binomial))
>
> and now show how you compute these to sums with *reproducible* R
> code.  That way we (the readers of R-SIG-ME) can be motivated
> much more to help you.
>
>
> > Thanks! Roelof Coster
>
> You are welcome ;-)
> Martin Maechler
>

	[[alternative HTML version deleted]]



More information about the R-sig-mixed-models mailing list