Repository navigation
Conversation
4 of 5 tasks
bashtage
force-pushed
the
wip-ss-smoother-output-flags
branch
from
November 27, 2026 23:06
f4cb22b to
a2dbce9
Compare
The smoother output can be limited with smooth(smoother_output=...) or the smoother_output option of the model, but: - Some output is computed from other output that the Cython smoother only computes when it is requested too. Without it the values were wrong: the state autocovariances need N_t, which is only computed with the state covariances (or disturbance covariances); the disturbance covariances are only computed with the disturbances; and the classical smoother computes r_t (N_t) from the smoothed state (state covariance) of the next period, so its disturbances need the smoothed state and its disturbance covariances the state covariances. For example, SMOOTHER_STATE_AUTOCOV alone gave autocovariances off by 0.23. - SmootherResults took the output flags from the options of the model, not from the smoother. smooth(smoother_output=SMOOTHER_STATE) on a model with the default output reported all output, with stale values from an earlier run (or uninitialized memory) for the output that was not computed. - SmootherResults.smoother_output was always None. Changes: - _initialize_smoother adds the output that the requested output depends on before it is passed to the smoother (for the classical smoother when SMOOTH_CLASSICAL is set). - update_smoother sets smoother_output and the smoother_* flags from the smoother, so the results contain the computed output and None for the rest. The presample scaled smoothed estimators are set only if the scaled smoothed estimator (covariance) is computed, as before. - With a concentrated scale, only the computed output is rescaled (it raised a TypeError for output that is now None). Not changed: the default output (SMOOTHER_ALL) and its values, and the smoother_output option of the model (the dependencies are added only to what is passed to the smoother). Tests (appended to test_smoothing.py): - For the conventional, alternative, classical and univariate smoothers, with a known and an exact diffuse initialization and missing data, every subset of the smoother output (including none), set by the argument and by the option, agrees with the full run; the results report the requested output and its dependencies in smoother_output and the flags, and have None for the other output (the presample estimators are not set). - With a concentrated scale, every subset agrees with the model with that scale (not concentrated), including the rescaled covariances, scaled smoothed estimators and smoothing error.
bashtage
force-pushed
the
wip-ss-smoother-output-flags
branch
from
November 28, 2026 21:36
a2dbce9 to
e9ffa18
Compare
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.
Based on main; #11025 (the C9b coverage chunk) changes docstrings of the same files and appends to the same test files, so whichever merges second needs a rebase. With #11025: only
test_smoothing.py, keep both blocks (the names differ from #11025'stest_smoother_output_subset, and the presample estimators stay unset when they are not computed, as that test checks). The other C9F-B PRs that append totest_smoothing.py(smooth arguments, smoother output, autocovariance cache, smoother unreachable code) conflict there too: keep every appended block and the union of the imports.The smoother output can be limited with smooth(smoother_output=...) or the
smoother_output option of the model, but:
computes when it is requested too. Without it the values were wrong:
the state autocovariances need N_t, which is only computed with the
state covariances (or disturbance covariances); the disturbance
covariances are only computed with the disturbances; and the classical
smoother computes r_t (N_t) from the smoothed state (state covariance)
of the next period, so its disturbances need the smoothed state and its
disturbance covariances the state covariances. For example,
SMOOTHER_STATE_AUTOCOV alone gave autocovariances off by 0.23.
from the smoother. smooth(smoother_output=SMOOTHER_STATE) on a model with
the default output reported all output, with stale values from an
earlier run (or uninitialized memory) for the output that was not
computed.
Changes:
on before it is passed to the smoother (for the classical smoother when
SMOOTH_CLASSICAL is set).
smoother, so the results contain the computed output and None for the
rest. The presample scaled smoothed estimators are set only if the
scaled smoothed estimator (covariance) is computed, as before.
raised a TypeError for output that is now None).
Not changed: the default output (SMOOTHER_ALL) and its values, and the
smoother_output option of the model (the dependencies are added only to
what is passed to the smoother).
Tests (appended to test_smoothing.py):
For the conventional, alternative, classical and univariate smoothers,
with a known and an exact diffuse initialization and missing data,
every subset of the smoother output (including none), set by the
argument and by the option, agrees with the full run; the results report
the requested output and its dependencies in smoother_output and the
flags, and have None for the other output (the presample estimators are
not set).
With a concentrated scale, every subset agrees with the model with that
scale (not concentrated), including the rescaled covariances, scaled
smoothed estimators and smoothing error.
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.
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