scoringutils drops forecasts with NA in any column, including covariates

Open
#197 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
42/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
r
Domain
data

Research direction

Start with R/process-score.R and trace how the trend column is passed to as_forecast_quantile(); then inspect process_data() for the planned explicit forecast_unit and covariate-window exclusion. Reproduce the dropped rows with the supplied scoringutils example and compare it with #187. Done means forecasts with complete predicted and observed values are excluded by the intended rule, rather than silently dropped because trend contains NA.

Written by the indexing model from the issue text.

Description

Note to think through before raising upstream in scoringutils.

What happens

  • R/process-score.R passes the observed data to as_forecast_quantile() with the trend column attached.
  • scoringutils (2.1.2) infers the forecast unit from every column other than predicted, observed and quantile_level, so trend becomes part of the forecast unit.
  • score() calls clean_forecast(na.omit = TRUE), which runs na.omit() row-wise over all columns.
  • trend is NA for each negative-count week (set to NA by download_obs()) and the three weeks after it. Every forecast targeting those four weeks is dropped from scoring, although its predicted and observed values are complete (apart from the negative week itself).
  • The only signal is the generic message "Some rows containing NA values may be removed. This is fine if not unexpected."

Example: FR cases has no scores for targets 2021-05-22 to 2021-06-12. In total there are 17 negative-count location-weeks (4 cases, 13 deaths).

Effect here: the primary (target-dated) exclusion of these forecasts happens through this side effect, not an explicit rule. See #187 and the handoff plan: pass forecast_unit explicitly in process-score.R and exclude on the covariate window in process_data().

Reprex

library(scoringutils)
library(data.table)
d <- data.table(
  model = "m", location = rep(c("A", "B"), each = 3),
  quantile_level = rep(c(0.25, 0.5, 0.75), 2),
  predicted = c(1, 2, 3, 1, 2, 3), observed = 2,
  trend = c(rep("Stable", 3), rep(NA, 3))  # covariate, not needed for scoring
)
fc <- as_forecast_quantile(d)
get_forecast_unit(fc)  # "model" "location" "trend"
nrow(score(fc))        # 1: location B dropped, though predicted and observed are complete
nrow(score(as_forecast_quantile(d, forecast_unit = c("model", "location"))))  # 2

Possible handling upstream (to think about)

NA in Option
observed Drop the whole forecast (all its quantiles), and report it
predicted Error or warn at the forecast level, naming the forecast, rather than dropping single quantile rows
A forecast-unit column Keep it (NA is a valid group label), or error naming the column. Not a silent drop

Related upstream issues

  • epiforecasts/scoringutils#537 (open): NA message should give counts and columns. About the message, not which columns trigger removal.
  • epiforecasts/scoringutils#1258 (open): row-wise NA removal splits or shrinks multivariate groups. Same mechanism.
  • epiforecasts/scoringutils#731 (closed): wis() now defaults to na.rm = FALSE.

None covers which columns should trigger removal, so a new upstream issue linking #537 and #1258 seems the right shape.

Scaffold for the upstream issue

Title: score() drops forecasts with NA in forecast-unit columns, not only predicted/observed

<!-- context: scoring EU hub forecasts with a covariate column attached -->
<!-- what happens: forecast unit inferred from all other columns; na.omit row-wise over all columns -->
<!-- consequence: complete forecasts excluded; only a generic message -->
<!-- reprex -->
<!-- proposal: table above -->
<!-- links: #537, #1258 -->
<!-- workaround: pass forecast_unit explicitly -->
Dominant language
R
Stars
6
Forks
0
Avg merge
7m
Merged PRs (30d)
1

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

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/eval-by-method

All issues in epiforecasts/eval-by-method

Similar issues

More R issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.