overdisp_fun: Overdispersion with glmer

View source: R/overdispersion.R

overdisp_funR Documentation

Overdispersion with glmer

Description

Test for overdispersion and compute overdispersion factor for generalized linear mixed models.

Usage

overdisp_fun(model)

quasi_table(
  model,
  ctab = coef(summary(model)),
  phi = overdisp_fun(model)["ratio"]
)

Arguments

model

a model fitted using a generalized linear mixed model family without an independent scale parameter, i.e. poisson or binomial with counts (not with a 0/1 response for logistic regression)

Details

Two functions overdisp_fun and quasi_table are adapted from the from the GLMM FAQ by Ben Bolker.

Functions

  • quasi_table(): display coefficient table with standard errors adjusted for overdispersion

Examples

library(lme4)
library(spida2)
set.seed(123)
zd <- expand.grid(plate = 1:100) #treat = c('A','B'), batch = 1:10, plate = 1:5)
zd <- within(zd,
     {  
         treat <- plate %% 2 + 1
         batch <- plate %% 10 + 1
         eta <- rnorm(10)[batch]+ 0 * rnorm(100) + 5 * (treat == 2)
         eta_od <- rnorm(10)[batch]+ rnorm(100) + 5 * (treat == 2)
         count <- rpois(nrow(zd), exp(eta))
         count_od <- rpois(nrow(zd), exp(eta_od))
     }
)
fit <- glmer(count ~ treat + (1|batch), zd, family = 'poisson')
fit_od <- glmer(count_od ~ treat + (1|batch), zd, family = 'poisson')
summary(fit)
summary(fit_od)
overdisp_fun(fit)
overdisp_fun(fit_od)
quasi_table(fit)
quasi_table(fit_od)
wald(fit)

wald(fit_od)
wald(fit_od, overdispersion = T)

gmonette/spida2 documentation built on Aug. 11, 2024, 7:52 p.m.