Several methods are provided to convert external forecasts given as a data.frame into predictions_cards objects compatible with the various evaluation and plotting functions.

as.predictions_cards(x, ...)

# S3 method for predictions_cards
as.predictions_cards(x, ...)

# S3 method for data.frame
as.predictions_cards(
  x,
  forecaster = "forecaster",
  forecast_date = lubridate::today(),
  incidence_period = c("epiweek", "day"),
  data_source = "data_source",
  signal = "signal",
  target_end_date = NULL
)

Arguments

x

Object to be converted. See Methods section below for details on formatting of each input type.

...

Additional arguments passed to methods.

forecaster

The name of the forecaster that produced this data.

forecast_date

Date object or string of the form "YYYY-MM-DD", indicating date on which forecasts will be made about some period (e.g., epiweek). For example, if forecast_date = "2020-05-11", incidence_period = "day", and ahead = 3, then, we'd be making forecasts for "2020-05-14".

incidence_period

String indicating the incidence period, either "epiweek" or "day".

data_source

The name of the data_source for the forecast target.

signal

The name of the signal for the forecast target.

target_end_date

The date the forecast target is observed (combines forecast_date, ahead, and incidence_period). This is determined automatically if NULL (the default).

Value

Long data frame of forecasts with a class of predictions_cards. The first 4 columns are the same as those returned by the forecaster. The remainder specify the prediction task, 10 columns in total: ahead, geo_value, quantile, value, forecaster, forecast_date, data_source, signal, target_end_date, and incidence_period. Here data_source and signal correspond to the response variable only.

Methods (by class)

  • predictions_cards: Simply returns the predictions_cards object unchanged.

  • data.frame: The input data frame x must contain the columns ahead, geo_value, quantile and value. Addional columns forecaster forecast_date, incidence_period, data_source, signal, and target_end_date will be created if missing. Other columns will be preserved as-is.