Skip to content

BUG: Raise a clear error for smoothed predictions without smoother output - #11060

Draft
bashtage wants to merge 2 commits into
statsmodels:mainfrom
bashtage:wip-mlemodel-smoothed-low-memory
Draft

bashtage wants to merge 2 commits into
statsmodels:mainfrom
bashtage:wip-mlemodel-smoothed-low-memory

Conversation

@bashtage

Copy link
Copy Markdown
Member

#11029 (the C10 coverage chunk) appends tests to the same test file, so whichever merges second needs a rebase (keep both test blocks). The other C10F PRs and #11043 also append to test_mlemodel.py: keep every appended block.

get_prediction(information_set="smoothed") (and predict) of state space
results needs the output of the Kalman smoother. The results of filter,
with or without low_memory=True, and of fit with low_memory=True, do not
have it, and the call raised "AttributeError: 'NoneType' object has no
attribute 'shape'".

Changes

  • A ValueError says that smoothed predictions require the output of the
    Kalman smoother, and to use the results of smooth, or of fit without
    low_memory=True.

Not changed

  • Results that have the smoother output, and the other information sets
    (with low_memory, their unavailable output is still NaN).

Tests

  • The ValueError for the results of filter, with and without low_memory,
    for the observations and for the signal; these fail on main.

  • Smoothed predictions of a zero-mean AR(1) from smooth equal the
    smoothed state, and the predicted ones of the results of filter equal
    phi y_{t-1}.

  • 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.

  • No AI tools were used to develop this pull request.
  • AI tools were used.
    Tool(s): Claude Code (Claude Opus 5.5).
    Used for: finding the bug in a contract audit, writing the fix and its tests, and checking them (tests failing on main, mutation check).
    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

@bashtage
bashtage force-pushed the wip-mlemodel-smoothed-low-memory branch 6 times, most recently from 356024c to 6b97f25 Compare November 27, 2026 23:06
…tput

get_prediction(information_set="smoothed") (and predict) of state space
results needs the output of the Kalman smoother. The results of filter,
with or without low_memory=True, and of fit with low_memory=True, do not
have it, and the call raised "AttributeError: 'NoneType' object has no
attribute 'shape'".

Changes
- A ValueError says that smoothed predictions require the output of the
  Kalman smoother, and to use the results of smooth, or of fit without
  low_memory=True.

Not changed
- Results that have the smoother output, and the other information sets
  (with low_memory, their unavailable output is still NaN).

Tests
- The ValueError for the results of filter, with and without low_memory,
  for the observations and for the signal; these fail on main.
- Smoothed predictions of a zero-mean AR(1) from smooth equal the
  smoothed state, and the predicted ones of the results of filter equal
  phi y_{t-1}.
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