View source: R/OverdispersionTest.R
GLMEROverdispersion | R Documentation |
Tests for over-dispersion in the residuals of a mixed-effects model
GLMEROverdispersion(model)
model |
A mixed-effects model, of class 'lmerMod' or 'glmerMod' |
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)
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
Tim Newbold <t.newbold@ucl.ac.uk>
http://glmm.wikidot.com/faq
# 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.