overdisp()
checks generalized linear (mixed) models for
overdispersion, while zero_count()
checks whether models
from Poisson-families are over- or underfitting zero-counts in
the outcome.
overdisp(x, ...)zero_count(x, tolerance = 0.05)
Fitted model of class merMod
, glmmTMB
, glm
,
or glm.nb
(package MASS).
Currently not used.
The tolerance for the ratio of observed and predicted
zeros to considered as over- or underfitting zero-counts. A ratio
between 1 +/- tolerance
is considered as OK, while a ratio
beyond or below this treshold would indicate over- or underfitting.
For overdisp()
, information on the overdispersion test; for
zero_count()
, the amount of predicted and observed zeros in
the outcome, as well as the ratio between these two values.
For merMod
- and glmmTMB
-objects, overdisp()
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 glmmTMB
).
The same code as above for mixed models is also used to check overdispersion for negative binomial models.
For Poisson-models, the overdispersion test is based on the code from Gelman and Hill (2007), page 115.
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
# NOT RUN {
library(sjmisc)
data(efc)
# response has many zero-counts, Poisson models
# might be overdispersed
barplot(table(efc$tot_sc_e))
fit <- glm(tot_sc_e ~ neg_c_7 + e42dep + c160age,
data = efc, family = poisson)
overdisp(fit)
zero_count(fit)
library(lme4)
efc$e15relat <- to_factor(efc$e15relat)
fit <- glmer(tot_sc_e ~ neg_c_7 + e42dep + c160age + (1 | e15relat),
data = efc, family = poisson)
overdisp(fit)
zero_count(fit)
# }
Run the code above in your browser using DataLab