Repository navigation
DOC: Follow up #10711 (constants and trends in the ARIMA GLS notes) - #10716
Merged
Merged
Conversation
…d models Follow up statsmodels#10711, which addressed statsmodels#6159. Checked by running gls on simulated AR(1) data with drift: - exog description: an integrated model without exog fails for every value of include_constant, so say the model must not include integration when exog is omitted. - A constant column in exog is removed by differencing like the include_constant column and makes the regression singular, but is not rejected. - A trend in exog becomes a constant after one (regular or seasonal) difference and its coefficient is the drift per unit of the column; after a second difference the column is zero and cannot be estimated. - State why the ARMA step does not demean: the regression absorbs all deterministic terms and the estimators receive its residuals. Docstring only; the code is unchanged. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Follow up statsmodels#10711, which addressed statsmodels#6159. Add the PR role, move the bullet to the end of the Documentation section (entries are appended in merge order), drop the blank line after it and state that numerical behavior is unchanged, like the neighbouring bullets. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
4 of 5 tasks
bashtage
marked this pull request as ready for review
November 10, 2026 13:30
6 of 15 tasks
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 #10711 (documentation of the deterministic terms of the ARIMA GLS estimator, #6159). Its review left the items below; none of them changes the code, and #6159 stays open for its other items.
NumPy's guide.
Changes
DOC:The Notes ofglssaid that a linear trend inexog"becomes a constant after first differencing and can represent drift", which is true but silent about when it is not. Each case was run on simulated data (an I(1) series with drift 0.5 and AR(1) errors on the differences, n=200,np.random.default_rng(12345)):exog=twithorder=(1, 1, 0)gives 0.5126 andexog=t/ngives 102.52 (n times as large). With only seasonal differencing (order=(1, 0, 0),seasonal_order=(0, 1, 0, 4), a seasonal random walk with slope 0.5)exog=tgives 0.482, andexog=t/ngives 96.46.order=(1, 2, 0), ororder=(1, 1, 0)withseasonal_order=(0, 1, 0, 4)) the column is zero:glsreturnsexog_paramsequal to[0.]with twoSingularMatrixWarning, and no error.DOC:A constant column that the user puts inexogis eliminated by differencing like theinclude_constantcolumn, but it is not rejected:gls(y, exog=np.ones(n), order=(1, 1, 0))returns[0.]andexog=np.c_[np.ones(n), t]returns[0., 0.5126], both withSingularMatrixWarning; onlyinclude_constant=Trueraises "Cannot include a constant in an integrated model". One sentence says so.DOC:Theexogdescription said "If not included, theninclude_constantmust be True", which cannot be satisfied for an integrated model:gls(y, order=(1, 1, 0))raisesValueError: diff requires input that is at least one dimensionalforinclude_constantNoneandFalse, and the "Cannot include a constant"ValueErrorforTrue. It now says that the model must not include integration whenexogis omitted.DOC:The "why" of the item in ENH: Improvements to new ARIMA-type estimators #6159: the regression absorbs every deterministic term, so the ARMA estimator receives the regression residuals and must not demean them again. In the code,include_constantis applied toexogbefore the regression, every ARMA estimator is called withdemean=Falseand the state space estimator withinclude_constant=False.DOC:Release note: added:pr:10711``, moved the bullet to the end of "Documentation" (the section is appended in order of merging) and removed the blank line after it, and added "Numerical behavior is unchanged." like the neighbouring bullet.Not changed
exoghas no valid call togls(the errors above; with only seasonal differencing it is anIndexError: too many indices for array;include_constant=Falsewithout exog fails for a non-integrated model too, with aValueErrorabout the dimensions in a concatenation). The messages are not helpful. This is a code defect, not a documentation one, and is not changed here.glsis not in the Sphinx API documentation, so the changes are visible throughhelp()and the source only.Tests
gls.pywith the docstrings removed is identical to main. Rendered with numpydoc 1.10.0 and docutils 0.22.4, the docstring gives the same messages as on main (the three about thearma_estimatorbullet list that are already there, and the "Unknown directive" artifact of rendering without Sphinx).ruff checkandgit diff --checkpass;test_gls.pypasses (22). 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 DOC: Clarify deterministic terms in ARIMA GLS estimation #10711, and writing and checking the docstring and release-note changes.
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