[R] glm convergence warning
Prof Brian Ripley
ripley at stats.ox.ac.uk
Fri May 18 09:36:06 CEST 2012
On 17/05/2012 20:35, Sophie Baillargeon wrote:
> Hi,
>
> When I run the following code :
>
> Y<- c(rep(0,35),1,2,0,6,8,16,43)
> cst<- log(choose(42, 42:1))
> beta<- 42:1
> tau<- (beta^2)/2
> fit<- glm(formula = Y ~ offset(cst) + beta + tau, family = poisson)
> fit
> fit$converged
>
> glm prints a warning saying that the algorithm did not converge.
Actually, no, it did not. The actual message is
> Warning: glm.fit: algorithm did not converge
Had you shown us that rather than misquote it, all would have been clearer.
> However, fit$converged takes the value TRUE.
>
> I don't understand why fit$converged is not always FALSE when the
warning "algorithm did not converge" is produced. Could someone help me
understand why I get this result?
Because there are two fits involved, and one of them does not converge.
Because you have an intercept and offset in your model, the null fit
also needs to be done, and that fit did not converge.
So the main results from your fit are reliable, but the null.deviance
component is not. Increase maxit to allow the null fit to converge.
> Thanks a lot,
>
> Sophie
>
> ______________________________________________
> 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.
--
Brian D. Ripley, ripley at 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
More information about the R-help
mailing list