Skip to contents

Summarise model forecasting scores

Usage

summarise_scores(scores, variables = NULL, sel_scores = NULL)

Arguments

scores

A dataframe of model scores as produced by score_model

variables

A character vector of variables names to group over. By default score type and model is grouped over if present.

sel_scores

A character vector indicating which scores to return information on. Defaults to all scores

Value

A dataframe of summarised scores in a tidy format.

Examples

if (FALSE) {
## Example cases
cases <- EpiSoon::example_obs_cases %>%
  dplyr::mutate(timeseries = "Region 1") %>%
  dplyr::bind_rows(EpiSoon::example_obs_cases %>%
    dplyr::mutate(timeseries = "Region 2"))


## Example Rts
rts <- EpiSoon::example_obs_rts %>%
  dplyr::mutate(timeseries = "Region 1") %>%
  dplyr::bind_rows(EpiSoon::example_obs_rts %>%
    dplyr::mutate(timeseries = "Region 2"))

## List of forecasting bsts models wrapped in functions.
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)
          }, ...
      )
    }
)


## Compare models
evaluations <- compare_timeseries(rts, cases, models,
  horizon = 7, samples = 10,
  serial_interval = example_serial_interval
)



## Score across the default groups
summarise_scores(evaluations$rt_scores)


## Also summarise across time horizon
summarise_scores(evaluations$rt_scores, "horizon", sel_scores = "crps")

## Instead summarise across region and summarise case scores
summarise_scores(evaluations$case_scores, "timeseries", sel_scores = "logs")
}