Repository navigation
DOC: Say which end each caller passes to _check_dynamic - #11165
Merged
bashtage merged 3 commits intoNov 24, 2026
Merged
Conversation
The docstring of `FilterResults.predict` said that "the last prediction will be at end", but `end` is excluded, as the end of a slice: for a model with 20 observations, `predict(start=2, end=5)` returns the 3 predictions for periods 2, 3 and 4, `predict()` (whose default `end` is the number of observations) returns the 20 in-sample predictions, and `predict(start=18, end=22)` returns 2 in-sample predictions and 2 out-of-sample forecasts. The `end` parameter and attribute of `PredictionResults`, which receive this `end`, and the private `_check_dynamic` had the same mistake. Changes - The `end` parameter of `FilterResults.predict` says that it is excluded, with its default. - The same for the `end` parameter and attribute of `PredictionResults`, and for `end` of `_check_dynamic`. Not changed - The code. (`nforecast` of `PredictionResults` is documented as the number of in-sample forecasts, but statsmodels#11028 already fixes that.)
_check_dynamic is called by FilterResults.predict and by STLForecastResults. statsmodels#11117 changed the description of its `end` from the location of the final forecast (inclusive) to the location after it (exclusive), which is what FilterResults.predict passes (for example 48 for in-sample predictions that end at observation 47 of 48, and 51 with three out-of-sample forecasts). STLForecastResults passes the location of the final in-sample forecast (inclusive), 47 in both cases, and does not use the returned number of dynamic forecasts (which is one short for it). Changes - The `end` of _check_dynamic says what each caller passes, and that dynamic prediction beginning after `end` has no effect. - ndynamic is the number of in-sample dynamic forecasts for an exclusive `end`, min(end, nobs) - dynamic. - The comment in FilterResults.predict describes the ranges [0, end) and [start, end), as `end` is excluded. Not changed - Any behavior.
This was referenced Nov 24, 2026
bashtage
marked this pull request as ready for review
November 24, 2026 14:50
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.
Stacked on #11117, merge that first (its commits are the first ones here; this PR adds one commit). It rewrites the line of _check_dynamic that #11117 changes. Merges cleanly with the other open kalman_filter.py PRs (#11035, #11036, #11037, #11116, #11141, #11152, #11159). No release note: the docstring of a private function and a comment.
DOC: Say that the end of FilterResults.predict is excluded
The docstring of
FilterResults.predictsaid that "the last predictionwill be at end", but
endis excluded, as the end of a slice: for amodel with 20 observations,
predict(start=2, end=5)returns the 3predictions for periods 2, 3 and 4,
predict()(whose defaultendis thenumber of observations) returns the 20 in-sample predictions, and
predict(start=18, end=22)returns 2 in-sample predictions and 2out-of-sample forecasts. The
endparameter and attribute ofPredictionResults, which receive thisend, and the private_check_dynamichad the same mistake.Changes
endparameter ofFilterResults.predictsays that it is excluded,with its default.
endparameter and attribute ofPredictionResults,and for
endof_check_dynamic.Not changed
nforecastofPredictionResultsis documented as thenumber of in-sample forecasts, but TST: Cover the statespace representation, Kalman filter and initialization #11028 already fixes that.)
DOC: Say which end each caller passes to _check_dynamic
_check_dynamic is called by FilterResults.predict and by
STLForecastResults. #11117 changed the description of its
endfrom thelocation of the final forecast (inclusive) to the location after it
(exclusive), which is what FilterResults.predict passes (for example 48
for in-sample predictions that end at observation 47 of 48, and 51 with
three out-of-sample forecasts). STLForecastResults passes the location of
the final in-sample forecast (inclusive), 47 in both cases, and does not
use the returned number of dynamic forecasts (which is one short for it).
Changes
endof _check_dynamic says what each caller passes, and thatdynamic prediction beginning after
endhas no effect.end, min(end, nobs) - dynamic.[start, end), as
endis excluded.Not changed
Any behavior.
tests added / passed.
code/documentation is well formatted.
properly formatted commit message. See
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: checking which end each caller passes and writing the docstring.
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