I want to model counts as being dependent on two nominal variables, one continuous variable (all as fixed effects) with 3rd-order interactions and one grouping variable (as random effect). However, I have an overdispersion in outcomes (I used the glmer
function from lme4
library). How should I manage this? I have found some solution for the problem (https://stats.stackexchange.com/a/9670/38080) but I am not able to incorporate that recommendation into my model.
Here is my model:
m1<-glmer(dependent.var ~ cat.var1 * cat.var2 * contin.var + (1|group),
data = dat, family = "poisson")
Any suggestion?
(I did it also like a marginal model with 'geeglm' function (library geepack), but I would like to calculate R-squared of the model, which is possible to obtain just from former GLMM (see Nakagawa & Schielzeth 2013; http://onlinelibrary.wiley.com/doi/10.1111/j.2041-210x.2012.00261.x/abstract).)
Best Answer
Pulling out the answer from the discussion in the comments: If you create an
obs_effect
variable (observation-level random effect) with a unique value for each observation (say,1:nrow(dat)
), then you can incorporate overdispersion in the model by fittingYou also state in the comments that your problem is that the residual plot is triangle-shaped, which I interpret as the variability of the residuals increases with the predicted value. Depending on what kind of residuals you are plotting, this might mean nothing (the variability of
observed - fitted
should increase withfitted
), or might mean that you have a problem other than overdispersion, which does not show up in a residual plot.Reference: Harrison, X.A., 2014. Using observation-level random effects to model overdispersion in count data in ecology and evolution. PeerJ 2, e616. doi:10.7717/peerj.616