Skip to content

BUG: Preserve seasonal and sparse lags in ARIMA GLS whitening - #10713

Merged
bashtage merged 1 commit into
statsmodels:mainfrom
Mohammed-AB:fix/gls-seasonal-whitening
Nov 10, 2026
Merged

bashtage merged 1 commit into
statsmodels:mainfrom
Mohammed-AB:fix/gls-seasonal-whitening

Conversation

@Mohammed-AB

Copy link
Copy Markdown

The ARIMA GLS estimator passed compact, nonseasonal coefficient arrays to the innovations whitening step. Seasonal AR/MA terms were omitted, and nonconsecutive lags were interpreted as consecutive. This can produce incorrect regression coefficient estimates even when the ARMA error parameters are estimated correctly.

Use the reduced AR and MA lag polynomials for whitening so missing lags are represented by zeros and seasonal factors are included. The compact parameter arrays remain unchanged for result storage and optimizer warm starts.

For example, in the sparse MA regression case in the new tests, the old slope is approximately 0.92744 while the independent matrix GLS calculation gives approximately 0.76720. The corrected result agrees with the matrix calculation.

Validation:

  • Added 12 parametrized regression cases covering AR and MA processes, lag 1 controls, sparse lag 2, seasonal lag 4, and both innovations_mle and statespace estimators.
  • Expected coefficients use closed-form AR/MA autocovariances and the GLS normal equations, independently of innovations whitening.
  • Before the fix: 8 new cases failed and 4 controls passed. After the fix: all 12 passed.
  • pytest statsmodels/tsa/arima -q --cov=statsmodels.tsa.arima.estimators.gls: 208 passed, 3 xfailed; the changed whitening code is covered.
  • Repository-wide ruff check . and git diff --check passed.
  • Tested with Python 3.12.7, NumPy 2.5.4, SciPy 1.18.1, and pandas 3.1.1. The full statsmodels test suite was not run.

A release note is included.

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.

  • No AI tools were used to develop this pull request.
  • AI tools were used.
    Tool(s): OpenAI Codex.
    Used for: investigating the GLS lag handling, drafting the fix and regression tests, running validation, and preparing the PR.
    I have personally read, understood, and can explain every line of this diff, and
    have verified the statistical/numerical correctness of the change.

@bashtage
bashtage merged commit 764d2bd into statsmodels:main Nov 10, 2026
11 of 13 checks passed
@bashtage

Copy link
Copy Markdown
Member

Thanks.

bashtage added a commit that referenced this pull request Nov 10, 2026
Follow up #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]>
bashtage added a commit that referenced this pull request Nov 10, 2026
Follow up #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]>
bashtage added a commit that referenced this pull request Nov 10, 2026
TST: Follow up #10713 (lag polynomial products in the ARIMA GLS whitening)
bashtage added a commit that referenced this pull request Nov 16, 2026
Move the bullet of #10742 to the end of the "Time series analysis" bug
fix list, add its :pr: role, and say what users see: loglike now equals
loglikeobs().sum(), llf and the fixed_scale value, also for
conserve_memory settings; values and fitted parameters change when the
diffuse periods contain finite innovations (several observed series with
one diffuse state, a diffuse state observed only later), and single
series models without such innovations (local level, local linear
trend, SARIMAX with concentrate_scale) are unchanged. The bullet stays
under Bug Fixes, as the neighbouring merged #10713 bullet.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants