Level conditional coherent reconciliation for temporal hierarchies
Level conditional coherent reconciliation for temporal hierarchies
This function implements a forecast reconciliation procedure inspired by the original proposal by Hollyman et al. (2021) for temporal hierarchies. Level conditional coherent reconciled forecasts are conditional on (i.e., constrained by) the base forecasts of a specific upper level in the hierarchy (exogenous constraints). It also allows handling the linear constraints linking the variables endogenously (Di Fonzo and Girolimetto, 2022). The function can calculate Combined Conditional Coherent (CCC) forecasts as simple averages of Level-Conditional Coherent (LCC) and bottom-up reconciled forecasts, with either endogenous or exogenous constraints.
telcc(base, agg_order, comb ="ols", res =NULL, CCC =TRUE, const ="exogenous", hfts =NULL, tew ="sum", approach ="proj", nn =NULL, settings =NULL,...)
Arguments
base: A (h(k∗+m)×1) numeric vector containing base forecasts to be reconciled ordered from the lowest frequency to the highest frequency; m
is the max aggregation order, k∗ is the sum of (a subset of) (p−1) factors of m, excluding m, and h is the forecast horizon for the lowest frequency time series.
agg_order: Highest available sampling frequency per seasonal cycle (max. order of temporal aggregation, m), or a vector representing a subset of p factors of m.
comb: A string specifying the reconciliation method. For a complete list, see tecov .
res: A (N(k∗+m)×1) optional numeric vector containing the in-sample residuals at all the temporal frequencies ordered from the lowest frequency to the highest frequency. This vector is used to compute come covariance matrices.
CCC: A logical value indicating whether the Combined Conditional Coherent reconciled forecasts reconciliation should include bottom-up forecasts (TRUE, default), or not.
const: A string specifying the reconciliation constraints:
"exogenous" (default): Fixes the top level of each sub-hierarchy.
"endogenous": Coherently revises both the top and bottom levels.
hfts: A (mh×1) numeric vector containing high frequency base forecasts defined by the user. This parameter can be omitted if only base forecasts in base are used (see Di Fonzo and Girolimetto, 2024).
tew: A string specifying the type of temporal aggregation. Options include: "sum" (simple summation, default), "avg" (average), "first" (first value of the period), and "last" (last value of the period).
approach: A string specifying the approach used to compute the reconciled forecasts. Options include:
"proj" (default): Projection approach according to Byron (1978, 1979).
"strc": Structural approach as proposed by Hyndman et al. (2011).
"proj_osqp": Numerical solution using list("osqp")
for projection approach.
"strc_osqp": Numerical solution using list("osqp")
for structural approach.
nn: A string specifying the algorithm to compute non-negative reconciled forecasts:
"sntz": heuristic "set-negative-to-zero" (Di Fonzo and Girolimetto, 2023).
settings: An object of class osqpSettings specifying settings for the list("osqp") solver. For details, refer to the c("list("osqp")", " documentation") (Stellato et al., 2020).
...: Arguments passed on to tecov
mse: If TRUE (default) the residuals used to compute the covariance matrix are not mean-corrected.
shrink_fun: Shrinkage function of the covariance matrix, shrink_estim (default)
Returns
A (h(k∗+m)×1) numeric vector of temporal reconciled forecasts.
Examples
set.seed(123)# (7 x 1) base forecasts vector (simulated), agg_order = 4base <- rnorm(7, rep(c(20,10,5), c(1,2,4)))# (70 x 1) in-sample residuals vector (simulated)res <- rnorm(70)# (4 x 1) Naive high frequency base forecasts vector: all forecasts are set equal to 2.5naive <- rep(2.5,4)## EXOGENOUS CONSTRAINTS# Level Conditional Coherent (LCC) reconciled forecastsexo_LC <- telcc(base = base, agg_order =4, comb ="wlsh", hfts = naive, res = res, nodes ="auto", CCC =FALSE)# Combined Conditional Coherent (CCC) reconciled forecastsexo_CCC <- telcc(base = base, agg_order =4, comb ="wlsh", hfts = naive, res = res, nodes ="auto", CCC =TRUE)# Results detailed by level:info_exo <- recoinfo(exo_CCC, verbose =FALSE)# info_exo$lcc## ENDOGENOUS CONSTRAINTS# Level Conditional Coherent (LCC) reconciled forecastsendo_LC <- telcc(base = base, agg_order =4, comb ="wlsh", res = res, nodes ="auto", CCC =FALSE, const ="endogenous")# Combined Conditional Coherent (CCC) reconciled forecastsendo_CCC <- telcc(base = base, agg_order =4, comb ="wlsh", res = res, nodes ="auto", CCC =TRUE, const ="endogenous")# Results detailed by level:info_endo <- recoinfo(endo_CCC, verbose =FALSE)# info_endo$lcc
References
Byron, R.P. (1978), The estimation of large social account matrices, Journal of the Royal Statistical Society, Series A, 141, 3, 359-367. tools:::Rd_expr_doi("10.2307/2344807")
Byron, R.P. (1979), Corrigenda: The estimation of large social account matrices, Journal of the Royal Statistical Society, Series A, 142(3), 405. tools:::Rd_expr_doi("10.2307/2982515")
Di Fonzo, T. and Girolimetto, D. (2024), Forecast combination-based forecast reconciliation: Insights and extensions, International Journal of Forecasting, 40(2), 490–514. tools:::Rd_expr_doi("10.1016/j.ijforecast.2022.07.001")
Di Fonzo, T. and Girolimetto, D. (2023b) Spatio-temporal reconciliation of solar forecasts. Solar Energy 251, 13–29. tools:::Rd_expr_doi("10.1016/j.solener.2023.01.003")
Hyndman, R.J., Ahmed, R.A., Athanasopoulos, G. and Shang, H.L. (2011), Optimal combination forecasts for hierarchical time series, Computational Statistics & Data Analysis, 55, 9, 2579-2589. tools:::Rd_expr_doi("10.1016/j.csda.2011.03.006")
Hollyman, R., Petropoulos, F. and Tipping, M.E. (2021), Understanding forecast reconciliation. European Journal of Operational Research, 294, 149–160. tools:::Rd_expr_doi("10.1016/j.ejor.2021.01.017")
Stellato, B., Banjac, G., Goulart, P., Bemporad, A. and Boyd, S. (2020), OSQP: An Operator Splitting solver for Quadratic Programs, Mathematical Programming Computation, 12, 4, 637-672. tools:::Rd_expr_doi("10.1007/s12532-020-00179-2")