Repository navigation
BUG: Simulate a single in-sample step in ETS get_prediction - #10930
Merged
Merged
Conversation
bashtage
force-pushed
the
wip-ets-simulated-one-step
branch
from
November 21, 2026 21:40
f476837 to
27b5a4c
Compare
4 of 5 tasks
With `method="simulated"` (the default for models with multiplicative components), `ETSResults.get_prediction` simulates each in-sample prediction one step ahead and the out-of-sample predictions from the end of the sample. The one-step simulations ran only `if nsmooth > 1`, so a prediction with exactly one in-sample period skipped it: - with no out-of-sample periods, for example `get_prediction(start=10, end=10, method="simulated")`, there was no simulation at all and it raised "ValueError: need at least one array to concatenate"; - with out-of-sample periods, for example a multiplicative model's `get_prediction(start=nobs - 1, end=nobs + 3)`, the simulations started one period late, so `pred_int()` and `summary_frame()` raised "Shape of passed values is (4, 2), indices imply (5, 2)" and `var_pred_mean` had 4 values for 5 predictions. Changes: - The one-step simulations run for any number of in-sample periods (`if nsmooth > 0`). Results that were returned before do not change: predictions with two or more in-sample periods, or none, take the same path as before. `var_pred_mean` in the second case above now has a value for every prediction. Tests: `test_get_prediction_simulated_one_step` covers a single in-sample period at the start of the sample (simulated from the initial states) and in the middle, and one in-sample period followed by four forecasts for an additive and a multiplicative model. It checks the summary frame against the one-step prediction plus the simulated errors, drawn from the same generator, and against `simulate` from the end of the sample for the forecasts. All four cases fail on main.
bashtage
force-pushed
the
wip-ets-simulated-one-step
branch
from
November 22, 2026 14:04
27b5a4c to
6fcf444
Compare
bashtage
marked this pull request as ready for review
November 22, 2026 19:01
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.
With
method="simulated"(the default for models with multiplicativecomponents),
ETSResults.get_predictionsimulates each in-sampleprediction one step ahead and the out-of-sample predictions from the end
of the sample. The one-step simulations ran only
if nsmooth > 1, so aprediction with exactly one in-sample period skipped it:
get_prediction(start=10, end=10, method="simulated"), there was nosimulation at all and it raised "ValueError: need at least one array
to concatenate";
get_prediction(start=nobs - 1, end=nobs + 3), the simulationsstarted one period late, so
pred_int()andsummary_frame()raised"Shape of passed values is (4, 2), indices imply (5, 2)" and
var_pred_meanhad 4 values for 5 predictions.Changes:
(
if nsmooth > 0).Results that were returned before do not change: predictions with two
or more in-sample periods, or none, take the same path as before.
var_pred_meanin the second case above now has a value for everyprediction.
Tests:
test_get_prediction_simulated_one_stepcovers a single in-sampleperiod at the start of the sample (simulated from the initial states)
and in the middle, and one in-sample period followed by four forecasts
for an additive and a multiplicative model. It checks the summary frame
against the one-step prediction plus the simulated errors, drawn from
the same generator, and against
simulatefrom the end of the samplefor the forecasts. All four cases fail on main.
NumPy's guide.
AI Disclosure
Contributions must comply with the statsmodels AI Policy.
Tick exactly one of the following. If AI tools were used, replace the
<...>placeholders in the second option with the tool name(s) and how the tool's output was
used.
Tool(s): Claude Code (Claude Opus 5.5).
Used for: finding the bug in a contract audit, writing the fix and its tests, and checking them (tests failing on main, mutation check).
I have personally read, understood, and can explain every line of this diff, and
have verified the statistical/numerical correctness of the change.
🤖 Generated with Claude Code