[R] Error message when fitting a binomial response model using glm

David Winsemius dwinsemius at comcast.net
Sat May 24 17:40:35 CEST 2014


On May 23, 2014, at 2:04 PM, Adams, Jean wrote:

> Roland,
> 
> I did a google search for
>     R Error: inner loop 2; cannot correct step size
> and found an old R-help message that suggests the glm() algorithm cannot
> converge.
>     https://stat.ethz.ch/pipermail/r-help/2009-December/223142.html
> 
> I get the same error message as you when I fit
>     glm(cbind(resp,nresp)~d+I(d^2)+I(d^3),data=test,family=
> binomial(clog()))

Six redictor factor levels?  With zeros at the extremes. Fitting to three parameters?

> but no error message if I get rid of the last parameter
>     glm(cbind(resp,nresp)~d+I(d^2),data=test,family=binomial(clog()))

I thought perhaps removing the correlation of d^2 and d^3 might help, but even using:  ~ poly(d, 3) fails. If you remove the `clog()` call and use the canonical link, you get estimates with a warning (as one might expect with this data:

Warning message:
glm.fit: fitted probabilities numerically 0 or 1 occurred 



-- 
David.

> 
> Hope this helps
> 
> Jean
> 
> 
> On Fri, May 23, 2014 at 7:13 AM, Roland Deutsch <roland.deutsch at tuwien.ac.at
>> wrote:
> 
>> Dear R-help,
>> 
>> during a simulation study using glm, I got the following error message
>> for which I cannot determine the cause:
>> 
>> Error: inner loop 2; cannot correct step size
>> 
>> Below is the code for which this error occurred is
>> 
>> clog<-function(){
>>   linkfun<-function(mu) qexp(mu)
>>   linkinv<-function(eta) pmax(.Machine$double.eps,pexp(eta))
>>   mu.eta<-function(eta) pmax(dexp(eta),.Machine$double.eps)
>>   valideta<-function(eta) all(eta>0)
>>   link<-"clog"
>> 
>> 
>> structure(list(linkfun=linkfun,linkinv=linkinv,mu.eta=mu.eta,valideta=valideta,name="link"),class="link-glm")
>> }
>> 
>> test<-data.frame(d=c(0,0.04,0.2,0.6,2,4),resp=c(0,1,3,4,24,28),nresp=c(18,21,19,17,1,0))
>> glm(cbind(resp,nresp)~d+I(d^2)+I(d^3),data=test,family=binomial(clog()))
>> 
>> Any help on why this error occurs and, more importantly, how I can
>> filter data producing this error would be highly appreciated.
>> 
>> Sincerely,
>> Roland Deutsch


David Winsemius
Alameda, CA, USA



More information about the R-help mailing list