Skip to contents

Evaluates fable models by expanding-window time-series cross-validation: from eval_start_date, models are refit at each origin and forecast h steps ahead, then scored by weighted interval score (WIS) and interval coverage via hubEvals. The ranking is reused by get_fcast.

Usage

get_cv(x, eval_start_date, h = 4, models = default_models(), step = h)

Arguments

x

An accidda_ncast (get_ncast) or accidda_data (check_data / get_data).

eval_start_date

Date (or string coercible to one). First origin evaluated; must lie within the data window. All observations before it form the initial training window.

h

Integer. Forecast horizon, in reporting-interval steps (weeks for weekly data, days for daily). Default 4.

models

Named list of fable models. Defaults to default_models; compose with c(default_models(), list(...)) to extend. Each element must reference observation. See the fabletools extension vignette for custom models.

step

Integer. Number of reporting-interval steps the training window advances between successive CV origins. Defaults to h (non-overlapping evaluation blocks).

Value

An accidda_cv object:

forecasts

Per-origin, per-model forecasts (model_out_tbl).

oracle

Observed truth (oracle_output).

score

Model ranking by WIS with interval coverage.

models

The evaluated model specifications.

meta

eval_start_date, h, location, target, interval.

data

Revision-collapsed input, reused by get_fcast.

Examples

if (FALSE) { # \dontrun{
cv <- get_data("covid", "ny", revisions = TRUE) |>
  get_ncast() |>
  get_cv(eval_start_date = "2025-01-01", h = 4)

cv$score
} # }