Skip to contents

Score a case forecast

Usage

score_case_forecast(pred_cases, obs_cases, scores = "all")

Arguments

pred_cases

Dataframe of predicted cases with the following variables: sample, date, cases and forecast horizon. As produced by forecast_cases.

obs_cases

Dataframe of observed cases with the following variables: date and cases.

scores

Character vector defaulting to "all". Select which scores to return, default is all scores but any subset can be returned.

Value

A dataframe containing the following scores per forecast timepoint: dss, crps, logs, bias, and sharpness as well as the forecast date and time horizon.

Examples

if (FALSE) {
## Fit a model (using a subset of observations)
samples <- forecast_rt(EpiSoon::example_obs_rts[1:10, ],
  model = function(...) {
    EpiSoon::bsts_model(
      model =
        function(ss, y) {
          bsts::AddSemilocalLinearTrend(ss, y = y)
        }, ...
    )
  },
  horizon = 7, samples = 10
)

pred_cases <- forecast_cases(
  EpiSoon::example_obs_cases,
  samples, EpiSoon::example_serial_interval
)

## Score the model fit (with observations during the time horizon of the forecast)
score_case_forecast(pred_cases, EpiSoon::example_obs_cases)


## Score the model fit (with observations during the time horizon of the forecast)
score_case_forecast(pred_cases, EpiSoon::example_obs_cases, scores = c("crps", "sharpness", "bias"))
}