Skip to content

TST: Restore Brockwell-Davis Example 6.6.3 GLS test - #11196

Open
fcarvajalbrown wants to merge 1 commit into
statsmodels:mainfrom
fcarvajalbrown:tst/gls-brockwell-davis-663
Open

fcarvajalbrown wants to merge 1 commit into
statsmodels:mainfrom
fcarvajalbrown:tst/gls-brockwell-davis-663

Conversation

@fcarvajalbrown

Copy link
Copy Markdown

Part of #6159, the GLS item "Fix the following test and put it back into the GLS test suite".

The test in #6159 was never going to pass, and not because of gls.

  1. It differences the series by hand and then calls gls(..., order=(0, 0, 12)). No integration in the order means include_constant defaults to True, so exog_params picks up a constant the book never fits. The restored test passes include_constant=False.
  2. Two numbers were copied wrong from the book. Page 191 of Brockwell and Davis (2016) prints -0.028 at lag 10 (the test had -0.28) and -0.627 at lag 12 (the test had -0.672).

Fix those and gls converges in 53 iterations, close to the book: every MA coefficient within 0.016, the level shift at -321.99 against -328.45 (0.13 of the book's standard error of 49.41), sigma2 at 12559 against 12581. The book's values come from ITSM's MLE, and gls actually does a hair better: log-likelihood -668.565 against -668.595. So the old TODO was right. The test checks those tolerances and asserts gls is at least as good as the book.

Checks: the 46 tests in test_gls.py pass, the new one passes under -W error and fails if include_constant is left at its default, ruff is clean.

  • tests added / passed.
  • code/documentation is well formatted.

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): Claude Code.
    Used for: reproducing the failure, comparing log-likelihoods, reading the values off the book page, drafting the test and this description.
    I have personally read, understood, and can explain every line of this diff, and
    have verified the statistical/numerical correctness of the change.

Fit the seat-belt regression with MA(12) errors without an added
constant and compare against the values printed on p. 191 of
Brockwell and Davis (2016). The book's estimates come from ITSM's
MLE, and gls reaches a slightly higher log-likelihood, so the test
checks closeness within tolerance and that gls is at least as good.
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.

1 participant