[R] GLM output for deviance and loglikelihood

From: Jeffrey Pollock <jpollock_at_williamhill.co.uk>
Date: Fri, 15 Apr 2011 12:00:32 +0100


It has always been my understanding that deviance for GLMs is defined by;  

D = -2(loglikelihood(model) - loglikelihood(saturated model))  

and this can be calculated by (or at least usually is);  

D = -2(loglikelihood(model))  

As is done so in the code for 'polr' by Brian Ripley (in the package 'MASS') where the -loglikehood is minimised using optim;  

res <- optim(s0, fmin, gmin, method = "BFGS", hessian = Hess, ...)

.

.

.

deviance <- 2 * res$value  

If so, why is it that;  

> x = rnorm(10)

> y = rpois(10,lam=exp(1 + 2*x))

> test = glm(formula = y ~ x, family = poisson)

> deviance(test)

[1] 5.483484

> -2*logLik(test)

[1] 36.86335  

I'm clearly not understanding something here, can anyone shed any light? Why is;  

-2*logLik(test) =/= deviance(test) ???  

I think this is something that is poorly understood all over the internet (at least from my google searches anyway!)  

Thanks,  

Jeff  

        [[alternative HTML version deleted]]



R-help_at_r-project.org 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. Received on Fri 15 Apr 2011 - 12:26:19 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 21 Apr 2011 - 10:20:32 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive