tdrec: Top-down forecast reconciliation for genuine...

View source: R/tdrec.R

tdrecR Documentation

Top-down forecast reconciliation for genuine hierarchical/grouped time series

Description

\loadmathjax

Top-down forecast reconciliation for genuine hierarchical/grouped time series, where the forecast of a ‘Total’ (top-level series, expected to be positive) is disaggregated according to a proportional scheme given by a vector of proportions (weights). Besides the fulfillment of any aggregation constraint, the top-down reconciled forecasts should respect two main properties:

  • the top-level value remains unchanged;

  • all the bottom time series reconciled forecasts are non-negative.

The top-down procedure is extended to deal with both temporal and cross-temporal cases. Since this is a post-forecasting function, the vector of weights must be given in input by the user, and is not calculated automatically (see Examples).

Usage

tdrec(topf, C, m, weights)

Arguments

topf

(\mjseqnh \times 1) vector of the top-level base forecast to be disaggregated; \mjseqnh is the forecast horizon (for the lowest temporal aggregation order in temporal and cross-temporal cases).

C

(\mjseqnn_a \times n_b) cross-sectional (contemporaneous) matrix mapping the \mjseqnn_b bottom level series into the \mjseqnn_a higher level ones.

m

Highest available sampling frequency per seasonal cycle (max. order of temporal aggregation, \mjseqnm), or a subset of the \mjseqnp factors of \mjseqnm.

weights

vector of weights to be used to disaggregate topf: (\mjseqnn_b \times h) matrix in the cross-sectional framework; (\mjseqnm \times h) matrix in the temporal framework; (\mjseqnn_b m \times h) matrix in the cross-temporal framework.

Details

Fix \mjseqnh = 1, then \mjsdeqn\widetilde\mathbfy = \mathbfS\mathbfw\widehata_1 where \mjseqn\widetilde\mathbfy is the vector of reconciled forecasts, \mjseqn\mathbfS is the summing matrix (whose pattern depends on which type of reconciliation is being performed), \mjseqn\mathbfw is the vector of weights, and \mjseqn\widehata_1 is the top-level value to be disaggregated.

Value

The function returns an (\mjseqnh \times n) matrix of cross-sectionally reconciled forecasts, or an (\mjseqnh(k^\ast + m) \times 1) vector of top-down temporally reconciled forecasts, or an (\mjseqnn \times h (k^\ast + m)) matrix of top-down cross-temporally reconciled forecasts.

References

Athanasopoulos, G., Ahmed, R.A., Hyndman, R.J. (2009), Hierarchical forecasts for Australian domestic tourism, International Journal of Forecasting, 25, 1, 146–166.

See Also

Other reconciliation procedures: cstrec(), ctbu(), htsrec(), iterec(), lccrec(), octrec(), tcsrec(), thfrec()

Examples

data(FoReco_data)
### CROSS-SECTIONAL TOP-DOWN RECONCILIATION
# Cross sectional aggregation matrix
C <- FoReco_data$C
# monthly base forecasts
mbase <- FoReco2matrix(FoReco_data$base, m = 12)$k1
obs_1 <- FoReco_data$obs$k1
# average historical proportions
props <- colMeans(obs_1[1:168,-c(1:3)]/obs_1[1:168,1])
cs_td <- tdrec(topf = mbase[,1], C = C, weights = props)

### TEMPORAL TOP-DOWN RECONCILIATION
# top ts base forecasts ([lowest_freq' ...  highest_freq']')
top_obs12 <- FoReco_data$obs$k12[1:14,1]
bts_obs1 <- FoReco_data$obs$k1[1:168,1]
# average historical proportions
props <- colMeans(matrix(bts_obs1, ncol = 12, byrow = TRUE)/top_obs12)
topbase <- FoReco_data$base[1, 1]
t_td <- tdrec(topf = topbase, m = 12, weights = props)

### CROSS-TEMPORAL TOP-DOWN RECONCILIATION
top_obs <- FoReco_data$obs$k12[1:14,1]
bts_obs <- FoReco_data$obs$k1[1:168,-c(1:3)]
bts_obs <- lapply(1:5, function(x) matrix(bts_obs[,x], nrow=14, byrow = TRUE))
bts_obs <- do.call(cbind, bts_obs)
# average historical proportions
props <- colMeans(bts_obs/top_obs)
ct_td <- tdrec(topf = topbase, m = 12, C = C, weights = props)


FoReco documentation built on May 31, 2023, 5:17 p.m.