Closed mattansb closed 6 months ago
Similar or even the same regression-based tests can be used to test for under as well as overdispersion, just testing whether the dispersion parameter is less than one as well as grater than one. https://www.rdocumentation.org/packages/AER/versions/1.2-9/topics/dispersiontest
Beyond those, simulation based tests and LR Tetsu's comparing to a generalized Poisson, negative binomial, or CMP model are also common. Personally, I always just use model comparison and graphical tests
Do you have an example for underdispersion? It's already detected, but I think the message always says _over_dispersion.
library(performance)
# overdispersion
m1 <- glm(count ~ spp + mined, family = poisson, data = glmmTMB::Salamanders)
out <- check_overdispersion(m1)
out
#> # Overdispersion test
#>
#> dispersion ratio = 2.946
#> Pearson's Chi-Squared = 1873.710
#> p-value = < 0.001
#> Overdispersion detected.
plot(out)
#> `geom_smooth()` using method = 'loess' and formula = 'y ~ x'
#> `geom_smooth()` using method = 'loess' and formula = 'y ~ x'
# underdispersion
set.seed(3)
mu <- rpois(500, lambda = 3)
x <- rnorm(500, mu, mu * 3)
x <- ceiling(x)
x <- pmax(x, 0)
m <- MASS::glm.nb(x ~ mu)
out <- check_overdispersion(m)
out
#> # Overdispersion test
#>
#> dispersion ratio = 0.410
#> p-value = < 0.001
#> Underdispersion detected.
plot(out)
#> `geom_smooth()` using method = 'loess' and formula = 'y ~ x'
#> `geom_smooth()` using method = 'loess' and formula = 'y ~ x'
Created on 2024-03-17 with reprex v2.1.0
Maybe we should adjust the title to say Over/underdispersion?
Or just "Dispersion"? Or is that too short/confusing?
Let's do "Misspecified dispersion and zero-inflation"
Is there a way to test underdispersion?