1

I am trying to fit a mixed-effect negative binomial model with glmer.nb() from package lme4.

m1 <- glmer.nb(NumberEvents ~ offset(log(days)) + x + (1|ID), data=dfr, nAGQ = 20)

I get the following warning:

Warning message: In theta.ml(Y, mu, weights = object@resp$weights, limit = limit, : iteration limit reached

I suppose I should increase the limit in the number of iterations of theta.ml.

theta.ml(limit = 1000)

How to do it? How can I call theta.ml() within glmer.nb()? Any help is appreciated!

AlSub
  • 1,384
  • 1
  • 14
  • 33
Pierpaolo
  • 11
  • 2
  • I suggest you can set the limit inside `glmer.nb` as `initCtrl=list(limit=1000))` – AlSub Feb 20 '21 at 16:23
  • Hi @AlvaroMartinez, I am facing the same error message, so I added in `initCtrl=list(limit=1000)` in `glmer.nb` as you suggested. But R shows the error message `unused argument (initCtrl = list(limit = 1000))`. I am wondering if you know how to solve it? – karyn-h Jan 05 '22 at 23:07
  • @karyn-h Try `optCtrl=list(limit=1e5)`. – jay.sf Nov 12 '22 at 08:28

1 Answers1

4

Although this is very old, I'll answer it for the record.

Once you hit the iteration limit, it is almost certainly the case that your data are equi- or underdispersed (i.e. variance <= mean). glmer.nb is trying to fit a negative binomial model, which becomes equi-dispersed (variance = mean) as the shape parameter goes to infinity. If you look at the estimated shape parameter, you will typically find it is very large.

The appropriate solution is usually to revert to a Poisson model.

Ben Bolker
  • 211,554
  • 25
  • 370
  • 453