Repository navigation
Don't flatten decomposition models in model arithmetic - #443
Open
robjhyndman wants to merge 1 commit into
Open
robjhyndman wants to merge 1 commit into
robjhyndman wants to merge 1 commit into
Conversation
`.cj_parts()` unpacked any fit inheriting from `model_combination`, which includes `decomposition_model`. For a transformed decomposition (e.g. `STL(log(y))`) the components sum to the transformed response, and the back-transformation on the outer model was dropped, so combinations such as `(ets + stlf + arima)/3` gave forecasts on the wrong scale while `mean(ets, stlf, arima)` was correct. See https://github.com/orgs/OTexts/discussions/164 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reported in https://github.com/orgs/OTexts/discussions/164.
Problem
Combining models with arithmetic gave forecasts on the wrong scale when one of the models was a transformed
decomposition_model(), whilemean()gave the right answer:Cause
.cj_parts()unpacks any fit that inherits frommodel_combinationinto its components. Adecomposition_modelfit also inherits frommodel_combination, so+split STLF into ETS onseason_adjustplus SNAIVE onseason_year. Those components add up tolog(Turnover), and the back-transformation is stored on the outer STLF model, which was dropped.combination1ended up with four weights of 1/3 and averaged forecasts in dollars with forecasts in log-dollars. Without a transformation the split is harmless, which is why this went unnoticed.Fix
.cj_parts()no longer unpacks decomposition models; each one is kept as a single component. Added a regression test and a NEWS entry.Testing
combination1andcombination2.test-combination.Rfails without the fix and passes with it.🤖 Generated with Claude Code