core.HierarchicalForecast
capabilities class. Check their usage example
here.
1. Normality
Normality
sampler input as other HierarchicalForecast reconciliation classes.
Given base forecasts under a normal distribution:
The reconciled forecasts are also normally distributed:
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
S | Union[ndarray, spmatrix] | Summing matrix of size (base, bottom). | required |
P | Union[ndarray, spmatrix] | Reconciliation matrix of size (bottom, base). | required |
y_hat | ndarray | Point forecasts values of size (base, horizon). | required |
sigmah | ndarray | Forecast standard dev. of size (base, horizon). | required |
W | Union[ndarray, spmatrix] | Hierarchical covariance matrix of size (base, base). Required when covariance_type='diagonal' (default). Ignored when covariance_type is 'full' or 'shrink' (covariance is computed from residuals instead). Default is None. | None |
seed | int | Random seed for numpy generatorβs replicability. Default is 0. | 0 |
covariance_type | Union[str, CovarianceType] | Type of covariance estimator. Can be a string or CovarianceType enum. Options are: - 'diagonal' / CovarianceType.DIAGONAL: Uses the W matrix diagonal with correlation scaling (default, backward compatible). W is required. - 'full' / CovarianceType.FULL: Uses full empirical covariance from residuals. W is ignored. Warning: may be non-positive-definite if n_series > n_observations. - 'shrink' / CovarianceType.SHRINK: Uses SchΓ€fer-Strimmer shrinkage estimator. W is ignored. Recommended for numerical stability with many series.Default is 'diagonal'. | βdiagonalβ |
residuals | ndarray | Insample residuals of size (base, obs). Required when covariance_type is 'full' or 'shrink'. Default is None. | None |
shrinkage_ridge | float | Ridge parameter for shrinkage covariance estimator. Only used when covariance_type='shrink'. A warning is issued if provided with other covariance types. Default is 2e-8. | _DEFAULT_SHRINKAGE_RIDGE |
| Type | Description |
|---|---|
ValueError | If covariance_type is invalid. |
ValueError | If covariance_type='diagonal' and W is None. |
ValueError | If covariance_type is 'full' or 'shrink' and residuals is None. |
ValueError | If residuals shape doesnβt match expected (base, obs). |
ValueError | If residuals has fewer than 2 observations. |
ValueError | If residuals is empty. |
ValueError | If any series in residuals has all NaN values. |
| Type | Description |
|---|---|
UserWarning | If shrinkage_ridge is provided but covariance_type is not 'shrink'. |
UserWarning | If W is provided but covariance_type is not 'diagonal' (W is ignored). |
UserWarning | If any series has zero or near-zero variance (may affect correlation estimates). |
UserWarning | If covariance_type='full' and n_series > n_observations (non-PSD risk). |
Normality.get_samples
| Name | Type | Description | Default |
|---|---|---|---|
num_samples | int | number of samples generated from coherent distribution. | required |
| Name | Type | Description |
|---|---|---|
samples | ndarray | Coherent samples of size (base, horizon, num_samples). |
2. Bootstrap
Bootstrap
sampler
input as other HierarchicalForecast reconciliation classes.
Given a boostraped set of simulated sample paths:
The reconciled sample paths allow for reconciled distributional forecasts:
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
S | ndarray | spmatrix | np.array, summing matrix of size (base, bottom). | required |
P | ndarray | spmatrix | np.array, reconciliation matrix of size (bottom, base). | required |
y_hat | ndarray | Point forecasts values of size (base, horizon). | required |
y_insample | ndarray | Insample values of size (base, insample_size). | required |
y_hat_insample | ndarray | Insample point forecasts of size (base, insample_size). | required |
num_samples | int | int, number of bootstraped samples generated. | 100 |
seed | int | int, random seed for numpy generatorβs replicability. | 0 |
Bootstrap.get_samples
| Name | Type | Description | Default |
|---|---|---|---|
num_samples | int | int, number of samples generated from coherent distribution. | required |
| Name | Type | Description |
|---|---|---|
samples | Coherent samples of size (base, horizon, num_samples). |
3. PERMBU
PERMBU
- For all series compute conditional marginals distributions.
- Compute
residualsand obtain rank permutations. - Obtain K-sample from the bottom-level series predictions.
- Apply recursively through the hierarchical structure:
- For a given aggregate series and its children series:
- Obtain childrenβs empirical joint using sample reordering copula.
- From the childrenβs joint obtain the aggregate seriesβs samples.
| Name | Type | Description | Default |
|---|---|---|---|
S | array | summing matrix of size (base, bottom). | required |
tags | dict[str, ndarray] | Each key is a level and each value its S indices. | required |
y_insample | array | Insample values of size (base, insample_size). | required |
y_hat_insample | array | Insample point forecasts of size (base, insample_size). | required |
sigmah | array | forecast standard dev. of size (base, horizon). | required |
num_samples | int | number of normal prediction samples generated. Default is None | None |
seed | int | random seed for numpy generatorβs replicability. Default is 0. | 0 |
PERMBU.get_samples
| Name | Type | Description | Default |
|---|---|---|---|
num_samples | int | number of samples generated from coherent distribution. | None |
| Name | Type | Description |
|---|---|---|
samples | ndarray | Coherent samples of size (base, horizon, num_samples). |
References
- Rob J. Hyndman and George Athanasopoulos (2018). βForecasting principles and practice, Reconciled distributional forecastsβ.
- 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.
- 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.

