thief_probreco: Probabilistic reconciliation of temporally reconciled grouped...

Description Usage Arguments Details Value References See Also Examples

View source: R/thief_probreco.R

Description

This function fits a specified thief model and then uses probabilistic reconciliation based on the supplied grouping structure to reconcile base forecast distributions

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
thief_probreco(
  y,
  k = 1,
  frequency = 52,
  lambda = NULL,
  model = "thief_ensemble",
  prob_train_horizon = 2,
  horizon = NULL,
  max_agg = NULL,
  groups,
  keep_total = TRUE,
  cores = parallel::detectCores() - 1,
  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

frequency

integer. The seasonal frequency in y

lambda

numeric. The Box Cox power transformation parameter for aggregate series. Must be between -1 and 2 inclusive. If y_series contains zeros, lambda will be set to max(c(0.7, lambda)) to ensure stability of forecasts

model

One of codec(thief_ensemble, thief_rfsrc, thief_vets)

prob_train_horizon

integer specifying the number of observations to holdout of y for training the probabilistic reconciliation weights. Models are first fitted to a subset of y that has removed the last prob_train_horizon observations, and these are used as cross-validation observations to train the reconciliation weights. Once trained, models are refitted to the full series in y and forecasts are used alongside reconciliation weights to formulate the reconciled forecast. Should be >1 to provide at least some variation to scoreopt. Default is 2

horizon

integer. The horizon to forecast. Defaults to frequency

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 #'@param 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

groups

Group matrix indicates the group structure, with one column for each series when completely disaggregated, and one row or each grouping of the time series. It allows either a numerical matrix or a matrix consisting of strings that can be used for labelling. See gts for more details

keep_total

logical. If TRUE, forecasts for the the top-level summed series (the total) will also be returned as the last element in the returned list of forecast distributions

cores

integer. The number of cores to use

...

Other arguments to be passed on to the specified thief model

Details

Series in y are aggregated at all possible levels up to annual using tsaggregates. The specified model is used on the unaggregated series, with forecasts reconciled using reconcilethief. Finally, the grouping structure is used in gts to create the group summing structure. Forecasts of the summed series, including the final total, are generated using thief_ensemble and the final base forecast distributions are reconciled using weights calculated through energy score optimisation using scoreopt

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

Panagiotelis, A., Gamakumara, P., Athanasopoulos, G., and Hyndman, R. Probabilistic Forecast Reconciliation: Propoerties, Evaluation and Score Optimisation. (2020) Monash EBS Working Paper 26/20

Panagiotelis, A., Athanasopoulos, G., Gamakumara, P., and Hyndman, R. (2021). Forecast reconciliation: A geometric view with new insights on bias correction. International Journal of Forecasting, 37(1), 343-359.

See Also

thief_ensemble, gts, reconcilethief, scoreopt

Examples

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

#Fit a probabilistic thief_ensemble model
groups <- ixodes_vets_dat$groups
mod1 <- thief_probreco(y = ixodes_vets_dat$y_train,
model = 'thief_ensemble',
frequency = 52,
prob_train_horizon = 12,
keep_total = FALSE,
groups = groups)

#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.