Learn R Programming

sjstats (version 0.10.2)

overdisp: Check overdispersion of GL(M)M's

Description

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.

Usage

overdisp(x, trafo = NULL)

zero_count(x)

Arguments

x

Fitted GLMM (merMod-class) or glm model.

trafo

A specification of the alternative, can be numeric or a (positive) function or NULL (the default). See 'Details' in dispersiontest in package AER. Does not apply to merMod objects.

Value

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.

Details

For merMod-objects, overdisp() is based on the code in the DRAFT r-sig-mixed-models FAQ, section How can I deal with overdispersion in GLMMs?. Note that this function only returns an approximate estimate of an overdispersion parameter.

For glm's, overdisp() simply wraps the dispersiontest from the AER-package.

References

DRAFT r-sig-mixed-models FAQ

Examples

Run this code
# 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