Non-randomised PIT for integer forecasts drops forecasts whose observation exceeds all samples

Open Beginner friendly
#1,260 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
82/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
r
Domain
data

Research direction

Start with pit_histogram_sample() in R/metrics-sample.R and trace how its conditional CDF assigns values at bin boundaries. Reproduce the reported case with observations above and below the sample range, then add the suggested regression test. Done means both cases contribute all forecasts to the expected PIT histogram, including the upper endpoint.

Written by the indexing model from the issue text.

Description

CLAUDE: With integers = "nonrandom" (the default for count data), forecasts whose observation is larger than every predictive sample contribute nothing to the PIT histogram, so the histogram no longer sums to the number of forecasts. This hides exactly the under-prediction a PIT histogram should reveal.

library(scoringutils)
P <- matrix(rep(1:10, 4), nrow = 4, byrow = TRUE)
pit_histogram_sample(c(20, 20, 20, 20), P, quantiles = seq(0, 1, 0.25))
#> [1] 0 0 0 0      # expected 0 0 0 4
pit_histogram_sample(c(0, 0, 0, 0), P, quantiles = seq(0, 1, 0.25))
#> [1] 4 0 0 0      # the mirror case is correct

The same happens through get_pit_histogram().

Location: pit_histogram_sample() in R/metrics-sample.R: when p_xm1 == p_x == 1, the conditional CDF at u = 1 takes the first fcase branch (u <= p_xm1 gives 0) instead of 1. More generally, a point mass exactly on a break is pushed into the next bin.

Suggested fix: check u >= p_x before u <= p_xm1, and add a test with observations outside the sample range on both sides.

Found during a full review of the package (version 2.3.0.9000, main at 779d7d68).

Dominant language
R
Stars
67
Forks
24
Avg merge
1h 24m
Merged PRs (30d)
2

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

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.

More from epiforecasts/scoringutils

All issues in epiforecasts/scoringutils

Similar issues

More R issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.