thief_rfsrc: Temporal hierarchy reconciliation of multivariate Breiman...

Description Usage Arguments Details Value References See Also Examples

View source: R/thief_rfsrc.R

Description

This function fits multivariate Breiman random forests on a multivariate xts timeseries object and then uses ensemble univariate forecast models on all higher levels of temporal aggregation to reconcile the forecasts

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
thief_rfsrc(
  y,
  k = 1,
  lambda = NULL,
  frequency = 52,
  horizon = NULL,
  predict_quantiles = TRUE,
  tune_nodesize = FALSE,
  cores = parallel::detectCores() - 1,
  max_agg = NULL,
  discrete = F
)

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

frequency

integer. The seasonal frequency in y

horizon

integer. The horizon to forecast. Defaults to frequency

predict_quantiles

logical. If TRUE, a quantreg.rfsrc is used to train a second multivariate random forest using quantile loss to predict uncertainty intervals. If FALSE, the distribution of estimates from the 2000 original random forests is used to estimate uncertainties

tune_nodesize

logical. If TRUE, tune.nodesize is used to try and find the optimal nodesize tuning parameter for the multivariate random forest. This can be slow, so the default is FALSE and a nodesize of 10 is used

cores

integer. The number of cores to use

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. rfsrc is used on the unaggregated series, with regressors including exponentially weighted moving averages of each series as well as time features that can be extracted from the series. Run conditions are: ntree = 2000, nsplit = NULL, nodesize = 12. ensemble_base is used on all aggretated levels to find a weighted ensemble of eight 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, rfsrc, 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_rfsrc model
mod1 <- thief_rfsrc(y = ixodes_vets_dat$y_train,
frequency = 52, 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.