hubverse-org / example-complex-forecast-hub

An example of a forecast hub with a complex set of modeling tasks
Creative Commons Zero v1.0 Universal
0 stars 2 forks source link

add sample output type to model outputs #28

Closed elray1 closed 6 months ago

elray1 commented 6 months ago

This PR would address the second item for issue #8. I suggest that this be reviewed and merged after #27 , which adds updates to the hub config files, and once functionality for validation sample submissions is in place in hubValidations. That will enable running validations on these submission files before merging them in.

I ended up just adding dependence across horizon (compound forecast unit = [location, reference_date]) for all models, rather than using different strategies for different models. Getting a realistic example with dependence across locations was going to be fiddly.

Here's code and a plot to show the trajectories for one of the submission files:

library(tidyverse)

df <- readr::read_csv("model-output/PSI-DICE/2022-11-19-PSI-DICE.csv")
ts <- readr::read_csv("target-data/time-series.csv") |>
  dplyr::filter(date >= "2022-10-01", date <= "2023-02-01")

ggplot() +
  geom_line(
    data = df |> filter(output_type == "sample"),
    mapping = aes(x = target_end_date, y = value, group = output_type_id),
    alpha = 0.5) +
  geom_line(
    data = ts,
    mapping = aes(x = date, y = observation),
    color = "orange", linetype = 2
  ) +
  facet_wrap( ~ location, scales = "free_y") +
  theme_bw()

image