easystats / easystats/performance

Differences in DHARMa::plotQQunif and check_residuals() for glms

Open
#807 10 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Waiting for response :love_letter:
Dominant language
R
Stars
1.2k
Forks
109
Avg merge
6h 34m
Merged PRs (30d)
8

Description

So, I've noticed when plotting simulated quantile residuals, the results can be quite different between using DHARMa and performance.

For example, in this code:

library(DHARMa)
library(lme4)
library(performance)

library(DHARMa)
library(lme4)
library(performance)

set.seed(31415)
testData = createData(sampleSize = 10, overdispersion = 0.5, family = poisson())
fittedModel <- glm(observedResponse ~ Environment1,
                     family = "poisson", data = testData)

simulationOutput <- simulateResiduals(fittedModel = fittedModel)

plotQQunif(simulationOutput,
           testDispersion = FALSE,
           testUniformity = FALSE,
           testOutliers = FALSE)

check_residuals(simulationOutput) |> plot()

This produces

Image

Image

While qualitatively these match, there are some big differences at the upper tail with the performance version looking really problematic while the DHARMa version does not.

What's going on here? This seems like there shouldn't be disagreement, and it makes me nervous that there is!

This is a reprex, but in working with real data, the discrepencies are even larger - although the KS tests agree. So, the values are the same? I'm confused.

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

Start by running the issue's reprex and comparing DHARMa::plotQQunif() with performance::check_residuals() on the same simulated residuals. Trace how each function produces its plot and verify whether their underlying values and KS tests agree. Done means explaining the upper-tail difference and identifying whether it is expected behavior or a performance bug.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.