Optimal combination reconciliation

This module provides functions for optimal (least-squares) forecast combination, with support for both cross-sectional and temporal frameworks.

Two main reconciliation functions are included:

  • csres(): For hierarchically, grouped, or otherwise linearly constrained series observed at the same frequency.

  • teres(): For temporal hierarchies, where the same time series can be aggregated or linearly combined at multiple frequencies (e.g., monthly, quarterly, yearly).

csrec(base: Array, agg_mat: Array = None, cons_mat: Array = None, params: cstools = None, comb: str = 'ols', res: Array = None, cov_mat: Array = None, approach: str = 'proj', solver: str = 'default', tol: float = 1e-06, nn: bool = False, immutable: array = None, **kwargs)[source]

Optimal combination cross-sectional reconciliation

This function performs optimal (in least squares sense) combination cross-sectional forecast reconciliation for a linearly constrained (e.g., hierarchical/grouped) multiple time series (Wickramasuriya et al., 2019, Panagiotelis et al., 2022, Girolimetto and Di Fonzo, 2023). The reconciled forecasts are calculated using either a projection approach (Byron, 1978, 1979) or the equivalent structural approach by Hyndman et al. (2011).

Parameters

base: ndarray

A \((h \times n)\) numeric matrix containing the base forecasts to be reconciled; \(h\) is the forecast horizon, and \(n\) is the total number of time series (\(n = n_a + n_b\)).

agg_mat: ndarray

A \((n_a \times n_b)\) numeric matrix representing the cross-sectional aggregation matrix (alternative to cons_mat and params). It maps the \(n_b\) bottom-level (free) variables into the \(n_a\) upper (constrained) variables.

cons_mat: ndarray

A \((n_a \times n)\) numeric matrix representing the cross-sectional zero constraints (alternative to agg_mat and params).

params: cstools

A cstools object (alternative to agg_mat and cons_mat).

comb: str, default ols

A string specifying the reconciliation method. For a complete list, see cscov()

res: ndarray

An \((N \times n)\) optional numeric matrix containing the residuals. This matrix is used to compute some covariance matrices.

cov_mat: jnp.ndarray

An \((n \times n)\) covariance matrix (alternative to comb).

approach: str, default proj

A string specifying the approach used to compute the reconciled forecasts. Options include:

  • proj: Projection approach according to Byron (1978, 1979).

  • strc: Structural approach as proposed by Hyndman et al. (2011).

  • proj_tol, strc_tol: implementation using the sparse matrix approach. These methods cannot ensure identical results to the non-sparse version.

solver: str, default default

Linear solvers: default and linearx.

tol: float

Tolerance value for some linear solvers.

immutable: jnp.array | None

Column indices of the base forecasts (the base parameter) to keep fixed. This option is only available when approach is set to proj.

nn: bool

If True, enforces non-negativity on reconciled forecasts using the heuristic “set-negative-to-zero” (Di Fonzo and Girolimetto, 2023). Default is False.

**kwargs: Arguments passed on to cscov().

Returns

A \((h \times n)\) numeric matrix of cross-sectional reconciled forecasts.

References

  • Byron, R.P. (1978), The estimation of large social account matrices, Journal of the Royal Statistical Society, Series A, 141, 3, 359-367. 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. DOI:10.2307/2982515

  • Di Fonzo, T. and Girolimetto, D. (2023), Spatio-temporal reconciliation of solar forecasts, Solar Energy, 251, 13-29. DOI:10.1016/j.solener.2023.01.003

  • Girolimetto, D. and Di Fonzo, T. (2023), Point and probabilistic forecast reconciliation for general linearly constrained multiple time series, Statistical Methods & Applications, 33, 581-607. DOI:10.1007/s10260-023-00738-6

  • 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. DOI:10.1016/j.csda.2011.03.006

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

  • Wickramasuriya, S.L., Athanasopoulos, G. and Hyndman, R.J. (2019), Optimal forecast reconciliation for hierarchical and grouped time series through trace minimization, Journal of the American Statistical Association, 114, 526, 804-819. DOI:10.1080/01621459.2018.1448825

See Also

cstools cscov

terec(base: Array, agg_order: list = None, params: tetools = None, comb: str = 'ols', res: Array = None, cov_mat: Array = None, tew: str = 'sum', approach: str = 'proj', solver: str = 'default', tol: float = 1e-06, nn: bool = False, immutable: Array = None, **kwargs)[source]

Optimal combination temporal reconciliation

This function performs forecast reconciliation for a single time series using temporal hierarchies (Athanasopoulos et al., 2017). The reconciled forecasts can be computed using either a projection approach (Byron, 1978, 1979) or the equivalent structural approach by Hyndman et al. (2011).

Parameters

base: ndarray

A \([N(k^\ast + m) \times 1]\) numeric vector containing the base forecasts to be reconciled, ordered from lowest to highest frequency; \(m\) is the maximum aggregation order, \(k^\ast\) is the sum of a chosen subset of the \(p - 1\) factors of \(m\) (excluding \(m\) itself) and \(h\) is the forecast horizon for the lowest frequency time series.

agg_order: list

Highest available sampling frequency per seasonal cycle (max. order of temporal aggregation, \(m\)), or a list representing a subset of \(p\) factors of \(m\).

params: tetools

A tetools object (alternative to agg_order).

comb: str, default ols

A string specifying the reconciliation method. For a complete list, see tecov()

res: ndarray

A \([N(k^\ast+m) \times 1]\) optional numeric vector containing the residuals ordered from the lowest frequency to the highest frequency. This vector is used to compute some covariance matrices.

cov_mat: jnp.ndarray

An \([(k^\ast+m) \times (k^\ast+m)]\) covariance matrix (alternative to comb).

tew: str, default sum

Temporal aggregation weighting scheme applied within each high-to-low block when building the aggregation matrix:

  • sum: sum over the block.

  • avg: arithmetic average over the block.

  • last: take the last element in the block.

  • first: take the first element in the block.

approach: str, default proj

A string specifying the approach used to compute the reconciled forecasts. Options include:

  • proj: Projection approach according to Byron (1978, 1979).

  • strc: Structural approach as proposed by Hyndman et al. (2011).

  • proj_tol, strc_tol: implementation using the sparse matrix approach. These methods cannot ensure identical results to the non-sparse version.

solver: str, default default

Linear solvers: default and linearx.

tol: float

Tolerance value for some linear solvers.

nn: bool

If True, enforces non-negativity on reconciled forecasts using the heuristic “set-negative-to-zero” (Di Fonzo and Girolimetto, 2023). Default is False.

immutable: jnp.ndarray | None

Matrix where each row is a pair \([k, j]\):

  • k: temporal aggregation order (\(k = m, ..., 1\)).

  • j: temporal forecast horizon (\(j = 1, ..., m / k\)).

Examples (quarterly series, \(m = 4\)):

  • np.array([[4, 1]]) — fix the one-step-ahead annual forecast.

  • np.array([[1, 2]]) — fix the two-step-ahead quarterly forecast.

This option is only available when approach is set to proj.

**kwargs: Arguments passed on to tecov().

Returns

A \([h(k^\ast+m) \times 1]\) numeric vector of temporal reconciled forecasts.

References

  • Athanasopoulos, G., Hyndman, R.J., Kourentzes, N. and Petropoulos, F. (2017), Forecasting with Temporal Hierarchies, European Journal of Operational Research, 262, 1, 60-74. DOI:10.1016/j.ejor.2017.02.046

  • Byron, R.P. (1978), The estimation of large social account matrices, Journal of the Royal Statistical Society, Series A, 141, 3, 359-367. 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. DOI:10.2307/2982515

  • Di Fonzo, T. and Girolimetto, D. (2023), Spatio-temporal reconciliation of solar forecasts, Solar Energy, 251, 13-29. 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. DOI:10.1016/j.csda.2011.03.006

See Also

tetools tecov