easystats / easystats/performance

Should check_overdispersion give warning when applied to quasipoisson?

Open
#734 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

3 investigators :grey_question::question:
Dominant language
R
Stars
1.2k
Forks
109
Avg merge
6h 34m
Merged PRs (30d)
8

Description

check_overdispersion() seems to just be returning the same results for poisson and quasipoisson. I think the latter should be based on simulated residuals, but that's not enabled yet so maybe that's why?

library(easystats)
#> # Attaching packages: easystats 0.7.2
#> ✔ bayestestR  0.13.2.2   ✔ correlation 0.8.4   
#> ✔ datawizard  0.11.0.2   ✔ effectsize  0.8.8.1 
#> ✔ insight     0.20.1     ✔ modelbased  0.8.8   
#> ✔ performance 0.12.0     ✔ parameters  0.21.7.4
#> ✔ report      0.5.8      ✔ see         0.8.4

Poisson - correct

fit <- glm(
  formula = DriversKilled ~ PetrolPrice,
  family = poisson(link = "log"),
  data = Seatbelts
)
check_overdispersion(fit)
#> # Overdispersion test
#> 
#>        dispersion ratio =   4.470
#>   Pearson's Chi-Squared = 849.362
#>                 p-value = < 0.001
#> Overdispersion detected.
simulate_residuals(fit)
#> Simulated residuals from a model of class `glm` based on 250
#>   simulations. Use `check_residuals()` to check uniformity of residuals or
#>   `residuals()` to extract simulated residuals. It is recommended to refer
#>   to `?DHARMa::simulateResiudals` and `vignette("DHARMa")` for more
#>   information about different settings in particular situations or for
#>   particular models.

Quasi-poisson - incorrect?

fit2 <- glm(
  formula = DriversKilled ~ PetrolPrice,
  family = quasipoisson(link = "log"),
  data = Seatbelts
)
check_overdispersion(fit2)
#> # Overdispersion test
#> 
#>        dispersion ratio =   4.470
#>   Pearson's Chi-Squared = 849.362
#>                 p-value = < 0.001
#> Overdispersion detected.
simulate_residuals(fit2)
#> Error in simulate.lm(object, nsim = nsim, ...): family 'quasipoisson' not implemented

Created on 2024-06-13 with reprex v2.1.0

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the reported examples with check_overdispersion() for poisson and quasipoisson models, then inspect how it handles the quasipoisson family and compare that with simulate_residuals(). Confirm the intended warning or residual-based behavior and add coverage showing that the result is correct for quasipoisson models.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
data
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.