library(scoringutils)
library(ggplot2)
library(dplyr)
library(DT)
library(knitr)
library(covidHubUtils)
library(lubridate)
library(data.table)
knitr::opts_chunk$set(echo = FALSE, 
                      message = FALSE, 
                      warning = FALSE)

include_ranking <- TRUE
include_forecast_plot <- TRUE
include_avail_forecasts <- FALSE
include_ranks_over_time <- FALSE

include_countries <- include_forecast_plot || 
  include_forecast_plot || 
  include_avail_forecasts || 
  include_ranks_over_time
data <- params$data

horizons <- data %>% 
  filter(!is.na(true_value), !is.na(horizon)) %>% 
  .$horizon %>% 
  unique

horizons <- horizons[as.integer(horizons) < 5]
horizons <- horizons[order(as.integer(horizons))]

summarise_by = c("model", "target_variable")

target_variables <- c(Cases = "inc case", Deaths = "inc death")

Overall performance {.tabset .tabset-fade}

The following table shows scores averaged across all locations, for all models that make forecasts for more than half of countries in the Hub. For country-by-country evaluation of performance of all models, select one of the countries in the drop-down list above.

out <- NULL

for (variable in names(target_variables)) {
  out = c(out, paste("\n\n##", variable, "{.tabset .tabset-fade}\n\n"))
  for (this_horizon in horizons) {
    filter_list = list(paste0("target_variable == '", target_variables[[variable]], "'"),
                       "!(is.na(quantile))",
                       paste0("horizon == ", this_horizon))
    horizon_string <- paste0(this_horizon, " week", if_else(this_horizon > 1, "s", ""), " ahead")
    out = c(out, paste("\n\n###", horizon_string, "\n\n"))
    out = c(out, knit_child(here::here("reports", "evaluation",
                                       "template-ranking-table.Rmd"),
                            quiet = TRUE))
  }
}

r paste(if (include_ranking) knit(text = out, quiet = TRUE), collapse = '\n\n')

{.unlisted .unnumbered}


Evaluation metrics

{.unlisted .unnumbered}



epiforecasts/europe-covid-forecast documentation built on Jan. 15, 2025, 8:57 p.m.