-
Notifications
You must be signed in to change notification settings - Fork 1
/
template-plot-forecasts.Rmd
44 lines (33 loc) · 1.9 KB
/
template-plot-forecasts.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
```{r prediction-plots, echo = FALSE, results='asis', fig.width = 10, fig.height=10}
for (forecast_date in forecast_dates) {
cat(paste0("\n\n## ", forecast_date, "{.tabset} \n\n"))
#, "{.tabset}\n\n")
# plot_df <- dplyr::left_join(tidyr::expand(data = data, target_type, true_value, location_name, model),
# data)
for (location in locations) {
cat("\n\n###", location, "{.tabset} \n\n")
for (target_type in target_types) {
cat("\n\n####", target_type, "\n\n")
filter_both <- list(paste0("target_type %in% '", target_type, "'"),
paste0("location_name %in% '", location, "'"))
filter_truth <- list(paste0("target_end_date > '", as.Date(forecast_date) - 7 * 10, "'"),
paste0("target_end_date <= '", as.Date(forecast_date) + 7 * 4, "'"))
filter_forecasts <- list(paste0("forecast_date == '", as.Date(forecast_date), "'"))
plot <- scoringutils::plot_predictions(data,
x = "target_end_date",
filter_both = filter_both,
filter_truth = filter_truth,
filter_forecasts = filter_forecasts,
facet_formula = ~ model,
# facet_formula = model ~ target_type + location_name,
# facet_wrap_or_grid = "facet",
allow_truth_without_pred = FALSE,
scales = "free") +
# ggplot2::ggtitle(paste0("Predictions for incident ", target_type, "s")) +
ggplot2::theme(legend.position = "bottom",
strip.placement = "outside")
print(plot)
}
}
}
```