GLMEROverdispersion: Test for over-dispersion

View source: R/OverdispersionTest.R

GLMEROverdispersionR Documentation

Test for over-dispersion

Description

Tests for over-dispersion in the residuals of a mixed-effects model

Usage

GLMEROverdispersion(model)

Arguments

model

A mixed-effects model, of class 'lmerMod' or 'glmerMod'

Details

Compares residual deviance and residual degrees of freedom of a mixed-effects model to a chi-sqaure distribution. Adapted from code taken from the GLMM Wiki (see references)

Value

Reports the residual deviance, residual degrees of freedom and the ratio of these, and also a the P-value of a chi-square test comparing the residual deviance and degrees of freedom to a chi-square distribution

Author(s)

Tim Newbold <t.newbold@ucl.ac.uk>

References

http://glmm.wikidot.com/faq

Examples

# Load example data (site-level effects of land use on biodiversity from the PREDICTS database)
data(PREDICTSSiteData)

# Run a model of species richness as a function of land use, human population density
# and distance to nearest road (with an interaction between human population density
# and road distance)
m1 <- GLMER(modelData = PREDICTSSites,responseVar = "Species_richness",fitFamily = "poisson",
fixedStruct = "LandUse",randomStruct = "(1|SS)+(1|SSB)",REML = TRUE)

# Test for overdispersion
GLMEROverdispersion(m1$model)

# Try adding an observation-level random intercept (which can control for overdispersion)
m2 <- GLMER(modelData = PREDICTSSites,responseVar = "Species_richness",fitFamily = "poisson",
fixedStruct = "LandUse",randomStruct = "(1|SS)+(1|SSB)+(1|SSBS)",REML = TRUE)

# Test for overdispersion again
GLMEROverdispersion(m2$model)

timnewbold/StatisticalModels documentation built on Aug. 25, 2023, 4:58 p.m.