I am having some computational trouble estimating the following model with the glmer function in lme4:

glmer(Y ~ x1*x2 + x2*x3 + (1+x1+x2|class) + (1|obs), family=poisson)
  • where class refers to my groupings,
  • obs refers to observation (because I would like to an observation-level random effect).

I'd like to try the MCMCglmm package (without deep knowledge of MCMC unfortunately), but cannot figure out how to specify the random effects. So far, my draft command is:

MCMCglmm(fixed = Y ~ x1*x2 + x2*x3, 
  random = ~ class + x1:class + x2:class + obs, family="poisson")

Could you please help me specify the model?


2 Answers 2


According to MCMCglmm documentation: "Multiple random terms can be passed using the + operator" (as you already do). Having said that you appear to be defining multiple random intercepts and no random slopes.

In general you need to use a syntax similar to ~us(1+x1):x2, where x2 is your discrete variables (for the intercepts), x1 is your continuous variable (for the slopes) and us denotes an unstructured random covariance. You may want to check other covariance structures (eg. idh for an identity one). Please check the chapters 3 and 4 in dealing with Categorical Random Interactions and Continuous Random Interactions respectively in the related MCMCglmm Course Notes. The general overview document is also very helpful (and more concise). I cannot emphasise enough how helpful these notes are, using MCMCglmm without reading them would be nearly impossible for me.

I suspect you want a structure similar to: ~us(1+x1+x2):class + obs but please check this twice before using it. Note that a global intercept is not fitted by default for variance structure models so you need the +1 that was otherwise redundant for lmer.

Good luck specifying your priors! :D


To my understanding, MCMCglmm poisson models include an observation-level random effect by default, as the author seems to believe that over-dispersion is the regular case, not the exception. In the manual it is called additive over-dispersion. In MCMCglmm summaries it is called the unit effect


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.