Repository navigation
TST: Follow up #10713 (lag polynomial products in the ARIMA GLS whitening) - #10717
Merged
Merged
Conversation
Follow up statsmodels#10713, which made gls use the reduced (product) AR and MA lag polynomials when whitening. Its tests each had a single factor, so replacing the product by the sum of the non-seasonal and seasonal polynomials (losing the cross terms) was not detected, and nothing had differencing. Add test_gls_whitening_polynomial_products: models with a non-seasonal and a seasonal factor, a sparse non-seasonal lag with a seasonal AR, D=1 and d=1 models, for innovations_mle and statespace, and sparse lags with the hannan_rissanen estimator. The reference does not use the innovations algorithm: it differences endog and exog itself, multiplies the lag polynomials built from the estimated parameters with np.convolve, takes the autocovariances from arma_acovf and solves the GLS normal equations with np.linalg.solve (agreement to 1e-8). Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Follow up statsmodels#10713. Add the missing PR reference to the release note, drop the blank line after the bullet and say which calls are affected: statsmodels.tsa.arima.estimators.gls.gls and ARIMA.fit for a model with exog or a trend when the method is not "statespace" or gls=True. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
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.
Follow up to #10713 (ARIMA GLS whitening with the reduced AR and MA lag polynomials). Its review left the items below. The code does not change, so the new tests pass on main as well; they pin the behaviour that #10713 fixed.
NumPy's guide.
Changes
TST:The 12 cases oftest_gls_whitening_lagseach have a single factor, so the product of the non-seasonal and the seasonal polynomial, the reason forreduced_ar_polyandreduced_ma_poly, was not tested: replacing the products by the sum of the two polynomials (losing the cross terms, for example lag 5 of(1, 0, 0)x(1, 0, 0, 4)) passed all 22 tests of the file. The newtest_gls_whitening_polynomial_products(15 cases, about 3 s) has:(1,0,0)x(1,0,0,4),(0,0,1)x(0,0,1,4),(1,0,1)x(1,0,1,4)and([2],0,0)x(1,0,0,3);D=1with(0,0,0)x(0,1,1,4)and(1,0,0)x(0,1,1,4), andd=1with(1,1,0)x(0,0,1,4);innovations_mleandstatespace, and one case witharma_estimator="hannan_rissanen"and the sparse lags([2], 0, [2]), which was affected as well (it was about 0.12 off the exact GLS before BUG: Preserve seasonal and sparse lags in ARIMA GLS whitening #10713).endogandexogitself (differencing is not part of the whitening polynomials), multiplies the lag polynomials built from the parameters that the estimator found withnp.convolve, takes the autocovariances fromarma_acovf, and solves the GLS normal equations withnp.linalg.solve; the coefficients agree tortol=atol=1e-8. The simulated data usenp.random.default_rng(13579),nobs=80, two regressors, all ARMA coefficients nonzero.DOC:The release note of BUG: Preserve seasonal and sparse lags in ARIMA GLS whitening #10713 now has:pr:10713``, no blank line after the bullet (the other bullets of the list have none) and says who is affected:statsmodels.tsa.arima.estimators.gls.glsand `ARIMA.fit` for a model with `exog` or a trend that is estimated with a `method` other than "statespace", or with `method="statespace"` and `gls=True`, and that the estimates of such models with seasonal terms or non-consecutive lags change. The entry points were checked by spying on `estimate_gls` while fitting `ARIMA(endog, exog, (1, 0, 0), trend="n")`: `innovations_mle`, `hannan_rissanen`, `yule_walker`, `burg` and `statespace` with `gls=True` call it; the default `statespace` does not; with no `exog`, `trend="c"` calls it and `trend="n"` does not.Mutations of
gls.pythat the new test must catch (each applied to a copy of the source, and undone):p_arma.ar_params,p_arma.ma_paramsagain (the code before BUG: Preserve seasonal and sparse lags in ARIMA GLS whitening #10713): all 15 fail;Not changed
arima(..., fixed=..., transform.pars=FALSE, method="ML")returns the same coefficients to 1e-8 for the fixed ARMA parameters) and a case withn_iter > 1, which the review mentioned as optional.glsabout the reduced polynomials: DOC: Follow up #10711 (constants and trends in the ARIMA GLS notes) #10716 changes the Notes of the same docstring.Tests
test_gls.py: 37 passed (22 before) on Python 3.13 with NumPy 2.5.4 and SciPy 1.18.1, and on Python 3.10 with NumPy 1.23.5 and SciPy 1.8.1; the wholestatsmodels/tsa/arimadirectory: 223 passed, 3 xfailed (Python 3.13).ruff checkpasses andgit diff --checkis clean. The documentation was not built with Sphinx.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 Sonnet 5.5).
Used for: reviewing BUG: Preserve seasonal and sparse lags in ARIMA GLS whitening #10713, and writing the tests and the release-note text.
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