Summary plots to compare timeseries and forecast models
plot_compare_timeseries.Rd
Summary plots to compare timeseries and forecast models
Arguments
- compare_timeseries_output
A named list of dataframes produced by
compare_timeseries
- type
Type(s) of summary plot to be produced for Rt and case observations for each model in n
compare_timeseries_output
."summary_score"
provides a plot of model fit scores for the 0-7 and 8-14 day horizons. If desired, a subset of scores can be specified using thescore
argument."horizon_score"
provides a plot of scores (CRPS, Calibration, Sharpness, Median, IQR, CI, Bias) across horizons."region_score"
provides a plot of scores (CRPS, Calibration, Sharpness, Bias, Median, IQR) by region for the 0-7 and 8-14 day horizons.- score
(Optional) One or more of
c("Bias","CRPS","Sharpness","Calibration","Median","IQR","CI")
whentype="summary_score"
is used.
Examples
if (FALSE) {
obs_rts <- EpiSoon::example_obs_rts %>%
dplyr::mutate(timeseries = "Region 1") %>%
dplyr::bind_rows(EpiSoon::example_obs_rts %>%
dplyr::mutate(timeseries = "Region 2"))
obs_cases <- EpiSoon::example_obs_cases %>%
dplyr::mutate(timeseries = "Region 1") %>%
dplyr::bind_rows(EpiSoon::example_obs_cases %>%
dplyr::mutate(timeseries = "Region 2"))
models <- list(
"AR 3" = function(...) {
EpiSoon::bsts_model(model = function(ss, y) {
bsts::AddAr(ss, y = y, lags = 3)
}, ...)
},
"Semi-local linear trend" = function(...) {
EpiSoon::bsts_model(model = function(ss, y) {
bsts::AddSemilocalLinearTrend(ss, y = y)
}, ...)
}
)
forecast_eval <-
compare_timeseries(obs_rts, obs_cases, models,
horizon = 10, samples = 10,
serial_interval = EpiSoon::example_serial_interval
)
## Produce all plots
plot_compare_timeseries(forecast_eval)
## Produce subsets of plots
plot_compare_timeseries(forecast_eval, type = "summary_score")
plot_compare_timeseries(forecast_eval,
type = "summary_score",
score = "Bias"
)
plot_compare_timeseries(forecast_eval, type = "horizon_score")
plot_compare_timeseries(forecast_eval, type = "region_score")
plot_compare_timeseries(forecast_eval,
type = c("horizon_score", "region_score")
)
}