Repository navigation
BUG: Begin RecursiveLS dynamic prediction at a dynamic date - #11104
Merged
bashtage merged 6 commits intoNov 24, 2026
Merged
Conversation
4 of 5 tasks
bashtage
force-pushed
the
wip-recursivels-dynamic-date
branch
2 times, most recently
from
November 23, 2026 21:51
430943c to
2462a6e
Compare
This was referenced Nov 24, 2026
A `dynamic` date key that matches several dates of a DatetimeIndex, such as "2001-04" for daily data, gives a slice of locations, which raised "TypeError: unsupported operand type(s) for -=: 'slice' and 'int'" in `AutoReg.predict` (and so `ARDL.predict`), `MLEResults.get_prediction` (SARIMAX, ARIMA, UnobservedComponents, ...), `STLForecastResults`, `ETSResults` and `RecursiveLSResults.get_prediction`. Dynamic prediction now begins at the first date of the key, as `MLEResults.simulate` already does for a multi-date `anchor`.
Covers the branch of the new slice check where a date string matches a single date, so that its location is used unchanged.
Since statsmodels#10975 merged, ETSModel.fit, fit_constrained and smooth warn when param_index is not given (the default changes from "integer" to "names" after statsmodels 0.17). The tests this PR adds called them without it, so they leaked that FutureWarning. Pass param_index="integer", as the existing tests do; results are unchanged.
RecursiveLSResults.get_prediction (and so predict) used the location of a dynamic date string as an offset relative to start. With start=10, dynamic="2001-04-01" began dynamic prediction on 2001-04-11, silently. The shared docstring says that a date is not interpreted as an offset, and MLEResults.get_prediction converts it to an offset by subtracting start. A dynamic Timestamp or datetime raised "TypeError: Addition/subtraction of integers and integer-arrays with Timestamp is no longer supported". Changes - A dynamic date string, Timestamp or datetime is converted to its location and then to an offset relative to start, as in MLEResults.get_prediction, so dynamic prediction begins at that date. Results change when start is not the first observation. - The docstring notes the change in a versionchanged directive. Not changed - An integer or bool dynamic, which is an offset relative to start. - A dynamic date when start is the first observation (the default). - The check that raises NotImplementedError for dynamic prediction in a model with constraints. As for an integer offset of 0, a dynamic date equal to start is not caught by it. Tests - With start=10 or start="2000-01-11", a dynamic date string, month string, Timestamp or datetime gives the predictions from the coefficients estimated through the previous period up to the date, and from those estimated through the period before the date after it, and the same predictions and variances as the integer offset. All eight cases fail on main.
bashtage
force-pushed
the
wip-recursivels-dynamic-date
branch
from
November 24, 2026 16:17
2462a6e to
aff784e
Compare
bashtage
marked this pull request as ready for review
November 24, 2026 18:31
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 #10940, merge that first (its commits are the first ones here; this PR adds one commit). Both change the lines that convert
dynamicinRecursiveLSResults.get_prediction.BUG: Accept dynamic date keys that cover several dates
A
dynamicdate key that matches several dates of a DatetimeIndex, suchas "2001-04" for daily data, gives a slice of locations, which raised
"TypeError: unsupported operand type(s) for -=: 'slice' and 'int'" in
AutoReg.predict(and soARDL.predict),MLEResults.get_prediction(SARIMAX, ARIMA, UnobservedComponents, ...),
STLForecastResults,ETSResultsandRecursiveLSResults.get_prediction. Dynamic predictionnow begins at the first date of the key, as
MLEResults.simulatealreadydoes for a multi-date
anchor.TST: Check a single-date dynamic key of RecursiveLS
Covers the branch of the new slice check where a date string matches a
single date, so that its location is used unchanged.
BUG: Begin RecursiveLS dynamic prediction at a dynamic date
RecursiveLSResults.get_prediction (and so predict) used the location of a
dynamic date string as an offset relative to start. With start=10,
dynamic="2001-04-01" began dynamic prediction on 2001-04-11, silently. The
shared docstring says that a date is not interpreted as an offset, and
MLEResults.get_prediction converts it to an offset by subtracting start. A
dynamic Timestamp or datetime raised "TypeError: Addition/subtraction of
integers and integer-arrays with Timestamp is no longer supported".
Changes
location and then to an offset relative to start, as in
MLEResults.get_prediction, so dynamic prediction begins at that date.
Results change when start is not the first observation.
Not changed
model with constraints. As for an integer offset of 0, a dynamic date
equal to start is not caught by it.
Tests
With start=10 or start="2000-01-11", a dynamic date string, month string,
Timestamp or datetime gives the predictions from the coefficients
estimated through the previous period up to the date, and from those
estimated through the period before the date after it, and the same
predictions and variances as the integer offset. All eight cases fail on
main.
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: finding the bug in a coverage audit of the time series models, 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