`wis(na.rm = TRUE)`: components do not sum to WIS when an interval is incomplete

Open Beginner friendly
#1,265 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
76/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
r
Domain
data

Research direction

Read wis() in R/metrics-quantile.R alongside interval_score() in R/metrics-interval-range.R to trace how missing interval bounds affect the component averages. Add a regression test that checks the components sum to wis with na.rm = TRUE, then run the relevant package tests. Done means the component total matches wis for incomplete intervals.

Written by the indexing model from the issue text.

Description

CLAUDE: With an incomplete prediction interval (or an NA prediction) and na.rm = TRUE, the over- and underprediction components include a term for the half interval, while wis and dispersion do not. The components then no longer sum to wis. The error message of wis() recommends na.rm = TRUE for exactly this situation.

library(scoringutils)
r <- wis(0, matrix(c(1, 2, 3, 4), 1), c(0.1, 0.25, 0.5, 0.75),
         separate_results = TRUE, na.rm = TRUE)
unlist(r)
#>  wis 2.667  dispersion 0.333  underprediction 0  overprediction 1.8
r$dispersion + r$underprediction + r$overprediction
#> 2.133      (overprediction should be 2.333)

Location: wis() in R/metrics-quantile.R (weighted.mean(..., na.rm = TRUE) drops NAs column by column) together with interval_score() in R/metrics-interval-range.R (the penalty for a half interval is not NA).

Suggested fix: drop intervals with a missing bound from all four columns before averaging, and test that the components sum to wis under na.rm = TRUE.

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.