Here we provide a collection of methods designed to provide hierarchically coherent probabilistic distributions, which means that they generate samples of multivariate time series with hierarchical linear constraints.

We designed these methods to extend the core.HierarchicalForecast capabilities class. Check their usage example here.

1. Normality


source

Normality

 Normality (S:numpy.ndarray, P:numpy.ndarray, y_hat:numpy.ndarray,
            sigmah:numpy.ndarray, W:numpy.ndarray, seed:int=0)

*Normality Probabilistic Reconciliation Class.

The Normality method leverages the Gaussian Distribution linearity, to generate hierarchically coherent prediction distributions. This class is meant to be used as the sampler input as other HierarchicalForecast reconciliation classes.

Given base forecasts under a normal distribution: y^h‚ąľN(őľ^,W^h)\hat{y}_{h} \sim \mathrm{N}(\hat{\boldsymbol{\mu}}, \hat{\mathbf{W}}_{h})

The reconciled forecasts are also normally distributed:

y~h‚ąľN(SPőľ^,SPW^hP‚äļS‚äļ) \tilde{y}_{h} \sim \mathrm{N}(\mathbf{S}\mathbf{P}\hat{\boldsymbol{\mu}}, \mathbf{S}\mathbf{P}\hat{\mathbf{W}}_{h} \mathbf{P}^{\intercal} \mathbf{S}^{\intercal})

Parameters:
S: np.array, summing matrix of size (base, bottom).
P: np.array, reconciliation matrix of size (bottom, base).
y_hat: Point forecasts values of size (base, horizon).
W: np.array, hierarchical covariance matrix of size (base, base).
sigmah: np.array, forecast standard dev. of size (base, horizon).
num_samples: int, number of bootstraped samples generated.
seed: int, random seed for numpy generator’s replicability.

References:
- Panagiotelis A., Gamakumara P. Athanasopoulos G., and Hyndman R. J. (2022). ‚ÄúProbabilistic forecast reconciliation: Properties, evaluation and score optimisation‚ÄĚ. European Journal of Operational Research.*


source

Normality.get_samples

 Normality.get_samples (num_samples:int=None)

*Normality Coherent Samples.

Obtains coherent samples under the Normality assumptions.

Parameters:
num_samples: int, number of samples generated from coherent distribution.

Returns:
samples: Coherent samples of size (base, horizon, num_samples).*

2. Bootstrap


source

Bootstrap

 Bootstrap (S:numpy.ndarray, P:numpy.ndarray, y_hat:numpy.ndarray,
            y_insample:numpy.ndarray, y_hat_insample:numpy.ndarray,
            num_samples:int=100, seed:int=0, W:numpy.ndarray=None)

*Bootstrap Probabilistic Reconciliation Class.

This method goes beyond the normality assumption for the base forecasts, the technique simulates future sample paths and uses them to generate base sample paths that are latered reconciled. This clever idea and its simplicity allows to generate coherent bootstraped prediction intervals for any reconciliation strategy. This class is meant to be used as the sampler input as other HierarchicalForecast reconciliation classes.

Given a boostraped set of simulated sample paths: (y^ŌĄ[1],‚Ķ,y^ŌĄ[B])(\hat{\mathbf{y}}^{[1]}_{\tau}, \dots ,\hat{\mathbf{y}}^{[B]}_{\tau})

The reconciled sample paths allow for reconciled distributional forecasts: (SPy^ŌĄ[1],‚Ķ,SPy^ŌĄ[B])(\mathbf{S}\mathbf{P}\hat{\mathbf{y}}^{[1]}_{\tau}, \dots ,\mathbf{S}\mathbf{P}\hat{\mathbf{y}}^{[B]}_{\tau})

Parameters:
S: np.array, summing matrix of size (base, bottom).
P: np.array, reconciliation matrix of size (bottom, base).
y_hat: Point forecasts values of size (base, horizon).
y_insample: Insample values of size (base, insample_size).
y_hat_insample: Insample point forecasts of size (base, insample_size).
num_samples: int, number of bootstraped samples generated.
seed: int, random seed for numpy generator’s replicability.

References:
- Puwasala Gamakumara Ph. D. dissertation. Monash University, Econometrics and Business Statistics (2020). ‚ÄúProbabilistic Forecast Reconciliation‚ÄĚ - Panagiotelis A., Gamakumara P. Athanasopoulos G., and Hyndman R. J. (2022). ‚ÄúProbabilistic forecast reconciliation: Properties, evaluation and score optimisation‚ÄĚ. European Journal of Operational Research.*


source

Bootstrap.get_samples

 Bootstrap.get_samples (num_samples:int=None)

*Bootstrap Sample Reconciliation Method.

Applies Bootstrap sample reconciliation method as defined by Gamakumara 2020. Generating independent sample paths and reconciling them with Bootstrap.

Parameters:
num_samples: int, number of samples generated from coherent distribution.

Returns:
samples: Coherent samples of size (base, horizon, num_samples).*

3. PERMBU


source

PERMBU

 PERMBU (S:numpy.ndarray, tags:Dict[str,numpy.ndarray],
         y_hat:numpy.ndarray, y_insample:numpy.ndarray,
         y_hat_insample:numpy.ndarray, sigmah:numpy.ndarray,
         num_samples:int=None, seed:int=0, P:numpy.ndarray=None)

*PERMBU Probabilistic Reconciliation Class.

The PERMBU method leverages empirical bottom-level marginal distributions with empirical copula functions (describing bottom-level dependencies) to generate the distribution of aggregate-level distributions using BottomUp reconciliation. The sample reordering technique in the PERMBU method reinjects multivariate dependencies into independent bottom-level samples.

Algorithm:
1.   For all series compute conditional marginals distributions.
2.   Compute residuals $\hat{\epsilon}_{i,t}$ and obtain rank permutations.
2.   Obtain K-sample from the bottom-level series predictions.
3.   Apply recursively through the hierarchical structure:<br/>
    3.1.   For a given aggregate series $i$ and its children series:<br/>
    3.2.   Obtain children's empirical joint using sample reordering copula.<br/>
    3.2.   From the children's joint obtain the aggregate series's samples.    

Parameters:
S: np.array, summing matrix of size (base, bottom).
tags: Each key is a level and each value its S indices.
y_insample: Insample values of size (base, insample_size).
y_hat_insample: Insample point forecasts of size (base, insample_size).
sigmah: np.array, forecast standard dev. of size (base, horizon).
num_samples: int, number of normal prediction samples generated.
seed: int, random seed for numpy generator’s replicability.

References:
- Taieb, Souhaib Ben and Taylor, James W and Hyndman, Rob J. (2017). Coherent probabilistic forecasts for hierarchical time series. International conference on machine learning ICML.*


source

PERMBU.get_samples

 PERMBU.get_samples (num_samples:int=None)

*PERMBU Sample Reconciliation Method.

Applies PERMBU reconciliation method as defined by Taieb et. al 2017. Generating independent base prediction samples, restoring its multivariate dependence using estimated copula with reordering and applying the BottomUp aggregation to the new samples.

Parameters:
num_samples: int, number of samples generated from coherent distribution.

Returns:
samples: Coherent samples of size (base, horizon, num_samples).*

References