Skip to contents

Fit models to the full series and forecast the next h reporting intervals.

Usage

get_fcast(
  x,
  models = default_models(),
  h = 4,
  top_n = 3,
  ensemble = c("linear_pool", "quantile_average"),
  quantiles = c(0.025, 0.25, 0.5, 0.75, 0.975)
)

Arguments

x

An insightcast_* object.

models

Named list of ordinary fable or joint insight.cast model specifications, such as HHH4. Defaults to default_models. When x is an insightcast_cv object, leave unset to forecast its models and use the top-ranked models for the ensemble, or provide a custom set of models to forecast and combine.

h

Forecast horizon in reporting intervals. Defaults to 4, or the cross-validation horizon when x is an insightcast_cv object.

top_n

Integer giving the number of top-ranked models to combine into the ensemble for each series. Used only when x is an insightcast_cv object and models is not provided. Defaults to 3.

ensemble

Method used to combine the models into the ENSEMBLE forecast. "linear_pool" (default) mixes the models' predictive distributions with equal weights. "quantile_average" takes, at each quantile level, the median of the models' quantiles using simple_ensemble

quantiles

Numeric vector of quantiles to extract. Defaults to c(0.025, 0.25, 0.5, 0.75, 0.975) and these default will be included regardless of any additional custom quantiles passed here.

Value

An insightcast_fcast object containing:

hub

Hub-format forecasts containing model_out_tbl and oracle_output.

score

Cross-validation model performance scores, or NULL.

meta

Forecast settings including models, model selection, ensemble method, horizon, series keys, target, reporting interval, nowcast information, and evaluation date.

Details

When provided with an insightcast_cv object, the function forecasts every successfully evaluated model and uses the cross-validation results to select the best-performing models for each series for the equal-weight ensemble. For insightcast_data or insightcast_ncast objects, all models in models are fitted, forecast, and combined.

If the input contains nowcast uncertainty from get_ncast, this uncertainty is incorporated into the forecast intervals.

Author

Cyril Geismar

Examples

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

get_fcast(cv, top_n = 3) # use cross-validation rankings
get_fcast(cv, models = default_models()) # use custom models
get_fcast(ncast) # forecast directly from nowcast data
} # }