[R] glm null deviance

yudi@hermes.ucd.ie yudi at hermes.ucd.ie
Tue Feb 2 13:52:36 CET 1999


> Date:          Tue, 02 Feb 1999 09:11:21 +0100 (MET)
> From:          Jim Lindsey <jlindsey at alpha.luc.ac.be>
> I have never really understood of what use is the null deviance
> printed out by glm or how it could be interpreted. No such idea
> exists in GLIM. Here is exactly the same model fitted 4 time with 4
> different answers.

Before some people think this is a bug, there is nothing
pathological or undesirable in Jim's examples. First,
the deviance in the Bernoulli model (0-1 outcome) is
simply equal to 
     -2 log lik = -2 sum (y*log phat + (1-y)*log(1-phat) )
where phat is the estimated prob's from the model.

> y <- rbinom(20,1,0.5)
> ind <- rep(1,20)
> glm(y~1,family=binomial)
the null deviance here is the deviance of the model with constant
term, which the same as the full model, so the null-dev is the same
as the residual deviance. 

> glm(y~ind-1,family=binomial)
Here the null-model is logit p =0, so under this model phat=0.5,
and the null-dev has n degrees of freedom. If this is not a 
meaningful model, then make the constant model the null
model. The residual deviance is from the model with constant
term, so the same as the first case.

> glm(y~ind-1,family=binomial(link=log))
Here null-model is log p = 0, so phat = 1. The deviance 
formula then computes log (1-1)=Inf for null-dev.
Residual deviance  is from the model with constant
term, so the same as the first case.

> glm(y~ind-1,family=binomial(link=cloglog))
here the null model is log(-log(1-p))=0, so 
phat = 1- exp(-exp(0))= 0.63. Again, the
residual deviance  is from the model with constant
term, so the same as the first case.


Question to the devel:
       shouldn't the cloglog = log(-log(p))?
       rather than   log(-log(1-p)) as implemented?

-Yudi-

------------------------------
Yudi Pawitan: yudi at ucd.ie
Department of Statistics, UCD
Dublin 4, Ireland
Ph : 353-1-706 7641
Fax: 353-1-706 1186
------------------------------
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help 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-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list