Skip to contents

Allows users to forecast using ensembles from the forecastHybrid package. Note that whilst weighted ensembles can be created this is not advised when samples > 1 as currently samples are derived assuming a normal distribution using the upper and lower confidence intervals of the ensemble. These confidence intervals are themselves either based on the unweighted mean of the ensembled models or the maximum/minimum from the candiate models. Note that forecastHybrid must be installed for this model wrapper to be functional.

Usage

forecastHybrid_model(
  y = NULL,
  samples = NULL,
  horizon = NULL,
  model_params = NULL,
  forecast_params = NULL
)

Arguments

y

Numeric vector of time points to forecast

samples

Numeric, number of samples to take.

horizon

Numeric, the time horizon over which to predict.

model_params

List of parameters to pass to forecastHybrid::hybridModel.

forecast_params

List of parameters to pass to forecastHybrid:::forecast.hybridModel.

Value

A dataframe of predictions (with columns representing the time horizon and rows representing samples).

Examples

if (FALSE) {

library(forecastHybrid)

## Used on its own
forecastHybrid_model(
  y = EpiSoon::example_obs_rts$rt,
  samples = 10, horizon = 7
)


## Used with non-default arguments
## Note that with the current sampling from maximal confidence intervals model
## Weighting using cross-validation will only have an impact when 1 sample is used.
forecastHybrid_model(
  y = EpiSoon::example_obs_rts$rt,
  samples = 1, horizon = 7,
  model_params = list(
    cvHorizon = 7, windowSize = 7,
    rolling = TRUE, models = "zeta"
  )
)


## Used for forecasting
forecast_rt(EpiSoon::example_obs_rts,
  model = EpiSoon::forecastHybrid_model,
  horizon = 7, samples = 1
)

## Used for forcasting with non-default arguments
forecast_rt(EpiSoon::example_obs_rts,
  model = function(...) {
    EpiSoon::forecastHybrid_model(
      model_params = list(models = "zte"),
      forecast_params = list(PI.combination = "mean"), ...
    )
  },
  horizon = 7, samples = 10
)
}