Skip to content

Mitokic/10312026/hts blank bug - #300

Open
Mike Tokic (mitokic) wants to merge 7 commits into
mainfrom
mitokic/10312026/hts-blank-bug
Open

Mike Tokic (mitokic) wants to merge 7 commits into
mainfrom
mitokic/10312026/hts-blank-bug

Conversation

@mitokic

@mitokic Mike Tokic (mitokic) commented Oct 31, 2026 •

Copy link
Copy Markdown
Collaborator

This pull request updates the handling of missing and ambiguous combo variable values in hierarchical forecasting, improves the reliability of hierarchical series naming, and adds comprehensive tests to ensure correct behavior. The changes make hierarchical forecasts more robust to missing values, prevent silent merging of series with ambiguous names, and ensure external regressors are correctly mapped to all bottom-level series, including those with numeric or special names.

Hierarchical combo value handling and naming:

  • Missing combo values in hierarchical forecasts now form an "NA" label, consistent with prep_data() and other naming conventions, instead of causing errors. This ensures that grouped hierarchical forecasts reconcile correctly even when combo variables have missing values. [1] [2] [3] [4] [5] [6]
  • A new helper function hts_node_names() ensures that all hierarchy series names are syntactic, unique, and consistent across the package. It raises an explicit error if two series would map to the same name after cleanup (e.g., "A.B" vs. "A_B"), preventing silent data merging. [1] [2]

External regressor and series compatibility:

  • Hierarchy-level external regressors now correctly reach bottom series whose names start with a digit (e.g., numeric cost centers), fixing a previous issue where these series received missing regressor values. [1] [2] [3]

Error handling and validation:

  • Hierarchical preparation now stops with a clear error if two series map to the same name after cleanup, instead of merging them silently. [1] [2] [3] [4]
  • Validation for combo variable values is improved: only blank or nonfinite values are now rejected, while missing values are handled as "NA". [1] [2] [3]

Testing and documentation:

  • Added and updated tests to verify that missing combo values are handled as "NA", that ambiguous or colliding series names are detected early, and that regressor mapping works for all valid series names. [1] [2] [3]
  • Documentation and NEWS are updated to reflect these changes and clarify the new behaviors. [1] [2] [3]

Version bump:

  • The package version is incremented to 0.7.0.9020 to reflect these improvements and bug fixes. [1] [2]

These changes improve the reliability and clarity of hierarchical forecasting, especially in the presence of missing or ambiguous combo values.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Missing values and literal "NA" silently merge distinct groups before collision checks, requiring per-column ambiguity validation in preparation and hierarchy detection plus regression coverage.

1 open issue
1 file not reviewed
  • man/detect_hierarchy.Rd: Generated file
What changed in this PR

This PR improves FinnTS hierarchical forecasting by handling missing combo labels and aligning series names across target aggregation and external-regressor joins.

Changes:

  • Represent missing grouped labels as "NA" and update hierarchy detection.
  • Centralize series-name cleanup, reject cleanup collisions, and fix regressor joins for digit-prefixed series.
  • Add regression coverage, update documentation, and advance the development version to 0.7.0.9020.
File Description
vignettes/​hierarchical-forecasting.Rmd Explain missing labels and naming collisions.
tests/​testthat/​test-hierarchical.R Cover missing-label grouping and reconciliation.
tests/​testthat/​test-hierarchical-xreg.R Test numeric labels, regressor joins, and collisions.
tests/​testthat/​test-detect-hierarchy.R Update missing and invalid label expectations.
tests/​testthat/​test-agent-hierarchy-compatibility.R Align detector expectations for missing labels.
R/​hierarchy.R Normalize missing groups and centralize series naming.
R/​detect_hierarchy.R Allow missing labels while rejecting blanks and nonfinite values.
NEWS.md Document fixes and restart guidance.
man/​detect_hierarchy.Rd Update public label-handling documentation.
DESCRIPTION Bump the development version.

Review effort: Balanced

Comment thread R/hierarchy.R Resolved

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants