check_overdispersion() checks generalized linear (mixed) models
Fitted model of class
Currently not used.
A list with results from the overdispersion test, like chi-squared statistics, p-value or dispersion ratio.
If the dispersion ratio is close to one, a poisson model fits well to the data. Dispersion ratios larger than one indicate overdispersion, thus a negative binomial model or similar might fit better to the data. A p-value < .05 indicates overdispersion.
For Poisson models, the overdispersion test is based on the code from Gelman and Hill (2007), page 115.
is based on the code in the GLMM FAQ,
section How can I deal with overdispersion in GLMMs?. Note that
this function only returns an approximate estimate of an
overdispersion parameter, and is probably inaccurate for zero-inflated
mixed models (fitted with
Overdispersion can be fixed by either modelling the dispersion parameter, or by choosing a different distributional family (like Quasi-Poisson, or negative binomial, see Gelman and Hill (2007), pages 115-116).
Bolker B et al. (2017): GLMM FAQ.
Gelman, A., & Hill, J. (2007). Data analysis using regression and multilevel/hierarchical models. Cambridge; New York: Cambridge University Press.
library(glmmTMB) data(Salamanders) m <- glm(count ~ spp + mined, family = poisson, data = Salamanders) check_overdispersion(m)#> # Overdispersion test #> #> dispersion ratio = 2.946 #> Pearson's Chi-Squared = 1873.710 #> p-value = < 0.001 #>#>m <- glmmTMB( count ~ mined + spp + (1 | site), family = poisson, data = Salamanders ) check_overdispersion(m)#> # Overdispersion test #> #> dispersion ratio = 2.324 #> Pearson's Chi-Squared = 1475.875 #> p-value = < 0.001 #>#>