thief_ensemble: Temporal hierarchy reconciliation of ensemble univariate...

Description Usage Arguments Details Value References See Also Examples

View source: R/thief_ensemble.R

Description

This function fits ensemble univariate forecast models on all levels of temporal aggregation for a multivariate xts timeseries object

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
thief_ensemble(
  y,
  k = 1,
  lambda = NULL,
  frequency = 52,
  horizon = NULL,
  cores = parallel::detectCores() - 1,
  max_agg = NULL,
  discrete = FALSE
)

Arguments

y

xts matrix. The outcome series to be modelled. NAs are currently not supported

k

integer specifying the length of the forecast horizon in multiples of frequency. Default is 1, meaning that a final forecast of frequency horizons will be returned

lambda

numeric. The Box Cox power transformation parameter for all series. Must be between -1 and 2 inclusive

frequency

integer. The seasonal frequency in y

horizon

integer. The horizon to forecast. Defaults to frequency

cores

integer. The number of cores to use. This is used to initialize the states of each series using ets_modelspec

max_agg

(optional) integer specifying the maximum number of temporal aggregation levels to use when reconciling, via the structural scaling method. Useful if higher levels of aggregation are unlikely to have 'seen' recent changes in series dynamics and will likely then result in poor forecasts as a result. Default is NULL, meaning that all levels of aggregation are used

discrete

logical Is the series in y discrete? If TRUE, use a copula-based method relying on the Probability Integral Transform to map the series to an approximate Gaussian distribution prior to modelling. Forecasts are then back-transformed to the estimated discrete distribution that best fits y. Default is FALSE

Details

Series in y are aggregated at all possible levels up to annual using tsaggregates. ensemble_base is used on all levels of aggregation to find a weighted ensemble of six univariate forecast models that minimises mean absolute scaled error. Forecasts are then reconciled using reconcilethief and are optionally constrained using non-negative optimisation if there are no negative values in y. Adjustments to the original unaggregated forecast are incorporated and a distribution of 1000 sample paths for each series' forecast are returned

Value

A list containing the reconciled forecast distributions for each series in y. Each element in the list is a horizon x 1000 matrix of forecast predictions

References

Athanasopoulos, G., Hyndman, R., Kourentzes, N., and Petropoulos, F. Forecasting with temporal hierarchies. (2017) European Journal of Operational Research 262(1) 60–74

See Also

ensemble_base, forecast, reconcilethief

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
library(mvforecast)
data("ixodes_vets_dat")

#Fit a thief_ensemble model
mod1 <- thief_ensemble(y = ixodes_vets_dat$y_train,
frequency = 52, lambda = 1, k = 1,
cores = parallel::detectCores() - 1)

#Calculate the out-of-sample CRPS
calc_crps(mod1, y_test = ixodes_vets_dat$y_test)

Plot simulation results for one of the plots in the NEON dataset
plot_mvforecast(simulation = mod1[[4]])
points(as.vector(ixodes_vets_dat$y_test[,4]))

nicholasjclark/mvforecast documentation built on Dec. 22, 2021, 2:11 a.m.