Repository navigation
BUG: Accept a dataset in news for a univariate model with longer exog - #11273
Merged
bashtage merged 2 commits intoNov 27, 2026
Merged
Conversation
Stacked on statsmodels#11254. When the comparison passed to `MLEResults.news` is a dataset and `exog` has more periods than it, `_get_previous_updated` extends the dataset with missing values and wraps it in a DataFrame whose columns are `self.model.endog_names`. For a univariate model `endog_names` is a str such as "y", which pandas rejects, so `SARIMAX(endog[:15], exog=exog[:15], order=(1, 0, 0)).smooth(params) .news(endog, exog=exog[:17], impact_date=16)` raised `TypeError: Index(...) must be called with a collection of some kind, 'y' was passed`, for an ndarray, a list or a Series. Passing the equivalent updated results object worked. Changes - The columns are `np.atleast_1d(self.model.endog_names)`, so a univariate model gets one column named after its endog. - A versionchanged note for `comparison`. Not changed - Multivariate models, comparisons that are results objects, and comparisons whose length matches `exog`. Tests - `test_news_univariate_comparison_with_longer_exog`, for a 1-d array, an (n, 1) column, a list and a Series: for a regression with AR(1) errors and fixed parameters, the previous and updated forecasts of the impact date and the total impact equal the closed forms `beta * x[16] + phi**2 * u[14]` and `beta * x[16] + phi * u[15]` with `u = y - beta * x`, and the news equals the news computed from the updated results object. All four cases fail on the base with the TypeError and pass here. `test_mlemodel.py` and `test_news.py` pass on the oldest, mid and latest dependency sets.
bashtage
marked this pull request as ready for review
November 27, 2026 20:06
bashtage
added a commit
to bashtage/statsmodels
that referenced
this pull request
Nov 27, 2026
statsmodels#11273 made MLEResults.news accept a comparison dataset shorter than exog for a univariate model. Add a test for the cases its test does not cover: a VAR(1) with exog besides the regression with AR(1) errors, the total impact compared with its closed form, and the news compared with the news from results for the dataset extended by hand. Tests - For a regression with AR(1) errors and a VAR(1) with exog, the total impact of observing y_10 on the forecast of y_11 equals the closed form (phi (u_10 - phi u_9) and A (y_10 - A y_9 - B x_10)), the columns are the endog names, and the news equals the news from results for the dataset extended by hand with missing values.
4 of 5 tasks
bashtage
added a commit
to bashtage/statsmodels
that referenced
this pull request
Nov 28, 2026
statsmodels#11273 made MLEResults.news accept a comparison dataset shorter than exog for a univariate model. Add a test for the cases its test does not cover: a VAR(1) with exog besides the regression with AR(1) errors, the total impact compared with its closed form, and the news compared with the news from results for the dataset extended by hand. Tests - For a regression with AR(1) errors and a VAR(1) with exog, the total impact of observing y_10 on the forecast of y_11 equals the closed form (phi (u_10 - phi u_9) and A (y_10 - A y_9 - B x_10)), the columns are the endog names, and the news equals the news from results for the dataset extended by hand with missing values.
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 #11254.
When the comparison passed to
MLEResults.newsis a dataset andexoghas more periods than it,
_get_previous_updatedextends the datasetwith missing values and wraps it in a DataFrame whose columns are
self.model.endog_names. For a univariate modelendog_namesis a strsuch as "y", which pandas rejects, so
SARIMAX(endog[:15], exog=exog[:15], order=(1, 0, 0)).smooth(params) .news(endog, exog=exog[:17], impact_date=16)raisedTypeError: Index(...) must be called with a collection of some kind, 'y' was passed, for an ndarray, a list or a Series. Passing the equivalentupdated results object worked.
Changes
np.atleast_1d(self.model.endog_names), so aunivariate model gets one column named after its endog.
comparison.Not changed
comparisons whose length matches
exog.Tests
test_news_univariate_comparison_with_longer_exog, for a 1-d array,an (n, 1) column, a list and a Series: for a regression with AR(1)
errors and fixed parameters, the previous and updated forecasts of the
impact date and the total impact equal the closed forms
beta * x[16] + phi**2 * u[14]andbeta * x[16] + phi * u[15]withu = y - beta * x, and the news equals the news computed from theupdated results object. All four cases fail on the base with the
TypeError and pass here.
test_mlemodel.pyandtest_news.pypass onthe oldest, mid and latest dependency sets.
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 while sweeping input validation, writing the fix and its tests, and checking them (tests failing on main, three NumPy/pandas versions).
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