From ripley at stats.ox.ac.uk  Thu Jun 12 09:18:43 2003
From: ripley at stats.ox.ac.uk (Prof Brian Ripley)
Date: Thu Jun 12 09:19:06 2003
Subject: [Rd] bug in glm()? (PR#3223)
In-Reply-To: <5.2.0.9.1.20030612120050.00aef720@imaphost.wehi.edu.au>
Message-ID: <Pine.LNX.4.44.0306120814380.24674-100000@gannet.stats>

On Thu, 12 Jun 2003, Gordon Smyth wrote:

> At 01:37 AM 12/06/2003, bonnie.lafleur@vanderbilt.edu wrote:

> >In trying to answer the number of columns question I tried to find a problem
> >which I pretty much know has no reason to converge.  It is totally nonsensical
> >data (as you
> >can tell).  It does not converge in SAS or Splus for Windows, it does however
> >converge in R (version 1.6.1) for Windows and R (version 1.3.1) on linux -
> >though, of course the  stimates are obviously suspect.  I am enclosing 
> >simple R
> >commands
> >for these silly data for your perusal.  Thank you for you time, and again,
> >I am sorry for the premature post last night.
> >
> >R : Version 1.3.1 (2001-08-31) (on linux)
> >
> >Y <- c(1,1,1,1,0)
> >X1 <- factor(c(0,0,0,1,1))
> >X2 <- factor(c(0,0,1,0,0))
> >
> >logist<- glm(Y ~ X1*X2, family=binomial(link="logit"))
> >summary(logist)
> >    ## usual logistic output
> >logist$converged
> >   ## TRUE
> 
> Well, others can speak for themselves, but R does for this data exactly 
> what I would want a generalized linear model program to do. R finds the 
> correct fitted values c(1,1,1,0.5,0,5) to 5 decimal places and the correct 
> residual deviance -4*log(0.5) to 4 decimal places. The fitted values for 
> the coefficients and theoreticaly infinite, but R does the best that can be 
> done by giving large finite values and small t-statistics.
> 
> It is true that the fitted coefficients cannot converge for these data, 
> because the stationary values are at infinity, but the fitted values and 
> residual deviance can and do converge.

I agree with Gordon, and had already mentioned *exactly* this situation in 
my first reply.

If this example does not converge in SAS, do send a bug report to SAS.

However, none of this absolves users of GLMs knowing that they do not 
always have MLEs in the interior of the parameter space or that Wald tests 
can be arbitrarily unreliable or ....   That's why such things are covered 
in MASS4, for example.

-- 
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 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595


[Rd] bug in glm()? (PR#3223)
Prof Brian Ripley