[R-sig-ME] handling overdispersion in poisson random effects models

O'Reilly, Kathleen M k.oreilly at imperial.ac.uk
Fri Jul 1 14:04:54 CEST 2011


Dear R users,

Apologies in advance if this is really obvious to solve.

I've following previous threads on handling overdispersion in poisson random effects models, and the suggestions have been very helpful.

Following on from R help thread "Mixed-effects model for overdispersed count data?" and some code written by other users, To account for overdispersion through having each individual as a random effect, the following code should work:

data(cbpp)
names(cbpp)
cbpp$id<-1:(dim(cbpp)[1])
#without overdispersion
M1 <- lmer(incidence~size+(1|herd),data=cbpp,family=poisson)
#to include overdispersion
M2 <- glmer(incidence~size+(1|herd)+(1|id),data=cbpp,family=poisson)
summary(M2)

However I get the following error when running M2
"Error in function (fr, FL, glmFit, start, nAGQ, verbose)  : 
  Number of levels of a grouping factor for the random effects
must be less than the number of observations"

Other people seem to run the equivalent of M2 without error.

Could someone please explain what I'm missing.

Thanking you in advance for your help,

Kath O'Reilly




More information about the R-sig-mixed-models mailing list