I'm plotting 3-way interaction terms from a negative binomial models, and tested the models in two packages to check my work and as a sensitivity analysis. I used the effect function to extract the fit and CIs to plot.

model.lme <- glmer.nb(dv ~ condition * time * gender + (1 | id), 
                      family = nbinom(), data = df)

effect.out.lme <- effect(term = "condition * time * gender", 
                         xlevels = list(condition = c(0, 1), 
                                        gender = c(1, 2)), 
                         mod = model.lme)

model.admb <- glmmadmb(dv ~ condition * time * gender + (1 | id), 
                       data = df, family = nbinom2(), 
                       zeroInflation = FALSE) 

effect.out.admb <- effect(term = "condition * time * gender", 
                          xlevels = list(condition = c(0, 1), 
                                         gender = c(1, 2)), 
                          mod = model.admb)

When I examined the fitted values to plot, the estimates from glmer.nb() were in the expected range for the scale of the DV. However, the confidence intervals from glmmadmb() included negative values, and the fit estimates were much smaller than what would be expected given the range of the scale, so I assumed they were log transformed and exponentiated them. This got me fit estimates that were generally similar to those from glmer.nb(), but the glmmadmb() confidence intervals are much, much wider than those from glmer.nb(), and overlap substantially with each other when I graph them.

What's happening here?


It is difficult to see what is going on without having the data to try ourselves. But I would suggest that you also compare your results using the GLMMadaptive and the glmmTMB packages. The former fits the same model using the adaptive Gaussian quadrature that provides a better approximation to the integrals over the random effects than the Laplace approximation used by the other packages.

  • $\begingroup$ Here is some sample data: gofile.io/?c=iUdoTH I actually had tried with both of those packages but was unable to extract the fit using the effects function. GLMMadaptive gave me this the error: "Error in effects::Effect.default(focal.predictors, mod, ..., sources = args) : Effect plots are not implemented for families with more than one parameter in the variance function (e.g., negitave binomials)." glmmTMB gave me this error: "Error in mod.matrix %*% scoef : non-conformable arguments" $\endgroup$ – Emily Sep 20 '19 at 20:00
  • $\begingroup$ In GLMMadaptive you can use the effectPlotData() function instead - for more info check here: drizopoulos.github.io/GLMMadaptive/articles/… $\endgroup$ – Dimitris Rizopoulos Sep 20 '19 at 20:07
  • $\begingroup$ I'll try that. I just noticed an error in the data I uploaded; use this instead: gofile.io/?c=ICiriN $\endgroup$ – Emily Sep 20 '19 at 20:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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