[R] question about glm behavior

Emmanuel Charpentier charpent at bacbuc.dyndns.org
Tue Nov 13 21:36:17 CET 2007


Yip a écrit :
> Hello,
> 
> I was trying a glm fitting (as shown below) and I got a warning and a fitted
> residual deviance larger than the null deviance. Is this the expected
> behavor of glm? I would expect that even though the warning might be
> warranted I should not get worse fitting with an additional covariate in the
> model. Could anyone tell me what I'm missing?

[ Big snip ... ]

>> table(f,g)
>    g
> f    0  1  2
>   0  0  0 44
>   1  2 38  3

Ah, ah : please note that (f==1)==(g<2)

>> glm(f~x1+x2+g, family=binomial(link="logit"), na.action=na.omit)
> 
> Call:  glm(formula = f ~ x1 + x2 + g, family = binomial(link = "logit"),     
> na.action = na.omit) 
> 
> Coefficients:
> (Intercept)           x1           x2            g  
>   9.184e+15   -4.359e+15    7.889e+14   -6.190e+15  
> 
> Degrees of Freedom: 86 Total (i.e. Null);  83 Residual
> Null Deviance:      120.6 
> Residual Deviance: 216.3        AIC: 224.3 
> Warning message:
> fitted probabilities numerically 0 or 1 occurred in: glm.fit(x = X, y = Y,
> weights = weights, start = start, etastart = etastart,  

This is discussed in MASS, chap. 7, "Generalized" Linear models" in a
section named "Problems with binomial GLMs", pp 197-9 an in the
literature cited herein. I won't insult Venables and Ripley's excellent
writing by trying to paraphrase them.

However, I note that glm tells you that he fitted probabilities to 0 or
1, i. e. infinite odd-ratios. Is that representable in a computer ?

Furthermore, the extremely large absolute values of the coefficients
should also ring an alarm bell...

Did you try this ? :

glm(f~x1+x2, subset=(g==2), family=binomial(link=logit))

					Emmanuel Charpentier



More information about the R-help mailing list