Understanding and debugging hierarchical forecast reconciliationAfter reconciling hierarchical forecasts, practitioners often need to answer questions like:
- How incoherent were my base forecasts? Did they significantly violate the hierarchical constraints?
- How much did reconciliation change the forecasts? Which levels were adjusted the most?
- Did reconciliation introduce problems? Such as negative values where they shouldnβt exist?
- Are the reconciled forecasts numerically coherent? Within acceptable tolerance?
HierarchicalReconciliation class provides an optional
diagnostics=True parameter that generates a comprehensive report
answering these questions. This notebook demonstrates the diagnostics
feature through three practical use cases.
You can run these experiments using CPU or GPU with Google Colab.
Setup
Load Data
Weβll use the TourismSmall dataset which has a 4-level hierarchy: - Country (1 node) - Country/Purpose (4 nodes) - Country/Purpose/State (28 nodes) - Country/Purpose/State/CityNonCity (56 nodes - bottom level)Generate Base Forecasts
Use Case 1: Verifying Reconciliation Quality
Scenario: Youβve just run reconciliation and want to verify that it worked correctly - that base forecasts were indeed incoherent and reconciliation fixed them. The diagnostics report answers: - Were the base forecasts incoherent? (coherence residuals before > 0) - Are the reconciled forecasts coherent? (coherence residuals after β 0) - Is numerical coherence satisfied within tolerance?
Interpretation: -
coherence_residual_mae_before > 0: Base
forecasts violated hierarchical constraints -
coherence_residual_mae_after β 0: Reconciliation fixed the
incoherence - is_coherent = 1.0: Reconciled forecasts satisfy
constraints within tolerance - coherence_max_violation: Maximum
deviation from perfect coherence (should be tiny)
Note that bottom-level series always have 0 coherence residual (they
define the hierarchy), while aggregate levels show how much they
deviated from the sum of their children.
Use Case 2: Comparing Reconciliation Methods
Scenario: You want to understand how different reconciliation methods affect your forecasts differently. Which method makes smaller adjustments? Which levels are most impacted? The diagnostics report helps compare: - Adjustment magnitude (MAE, RMSE, max) across methods - Which hierarchy levels each method adjusts the most
Key insights: - BottomUp only adjusts aggregate levels (bottom
level has 0 adjustment) - TopDown only adjusts bottom levels (top
level has 0 adjustment) - MinTrace methods distribute adjustments
across all levels, typically with smaller overall adjustments
This shows how each method distributes adjustments across hierarchy
levels. BottomUp concentrates changes at aggregate levels, TopDown at
bottom levels, and MinTrace spreads adjustments more evenly.
Use Case 3: Detecting Negative Value Issues
Scenario: Your forecasts represent quantities that cannot be negative (e.g., sales, visitors). You need to check if reconciliation introduced negative values. The diagnostics report tracks: -negative_count_before/after: Count of
negative values before and after reconciliation - negative_introduced:
Negatives created by reconciliation - negative_removed: Negatives
fixed by reconciliation
Interpretation: -
negative_count_before: Negatives in base
forecasts - negative_count_after: Negatives after reconciliation -
negative_introduced: New negatives created by reconciliation (bad!) -
negative_removed: Negatives fixed by reconciliation (good!)
Notice how MinTrace with nonnegative=True eliminates all negative
values.
This shows that BottomUp propagates negatives from bottom to aggregate
levels, while standard MinTrace may spread negatives further. The
nonnegative MinTrace variant addresses this.
Exporting Diagnostics
The diagnostics DataFrame can be exported to CSV for CI pipelines, benchmarks, or sharing with stakeholders.Summary of Diagnostic Metrics
References
- Hyndman, R.J., & Athanasopoulos, G. (2021). βForecasting: principles and practice, 3rd edition: Chapter 11: Forecasting hierarchical and grouped series.β
- Wickramasuriya, S. L., Athanasopoulos, G., & Hyndman, R. J. (2019). Optimal forecast reconciliation for hierarchical and grouped time series through trace minimization.

