Repository navigation
Conversation
bashtage
force-pushed
the
wip-mlemodel-oim-params
branch
6 times, most recently
from
November 27, 2026 23:06
1df57e8 to
4220c01
Compare
4 of 5 tasks
MLEModel.observed_information_matrix replaced params by the constrained parameter vector (with the fixed parameters included) and then passed that vector to the numerical derivatives, together with the caller's transformed and includes_fixed flags. - With transformed=False, the derivatives transformed the already constrained parameters a second time, while the base point of the differences was the correct one. For SARIMAX(1, 0, 0) with a trend on the macrodata inflation series, at params [1, 0.5, 4], the diagonal was [4.7e16, 1.9e17, 2.9e15] instead of J' I(p) J = [0.2525, 2.767, 0.5], and [0.249, 3.371, 1.999] with approx_centered=True. - With fixed parameters (fix_params) and includes_fixed=False, it raised "ValueError: shape mismatch: value array of shape (3,) could not be broadcast to indexing result of shape (2,)", and so did hessian(params, method="oim"). Changes - The numerical derivatives are taken with respect to params as given, so with transformed=False the information matrix is with respect to the untransformed parameters, J' I(p) J, and with fixed parameters it is the matrix of the free parameters. - The docstring says so, with a versionchanged note. Not changed - transformed=True without fixed parameters, or with includes_fixed=True. - hessian(..., transformed=False, method="oim"), which uses the chain rule and does not reach this path. Tests - With transformed=False, forward and centered differences match J' I(p) J, with I(p) by complex step and J by centered differences of transform_params, for an AR(1) and an AR(2) (whose transformation is not diagonal). Main is off by a factor of 1e16 (forward) or up to 4 (centered). - With fixed parameters, transformed True and False, the matrix equals that of the model without fixed parameters at the same values, restricted to the free parameters; hessian(method="oim") likewise. These raise on main.
bashtage
force-pushed
the
wip-mlemodel-oim-params
branch
from
November 28, 2026 21:36
4220c01 to
f67565f
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.
#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.MLEModel.observed_information_matrix replaced params by the constrained
parameter vector (with the fixed parameters included) and then passed that
vector to the numerical derivatives, together with the caller's
transformed and includes_fixed flags.
constrained parameters a second time, while the base point of the
differences was the correct one. For SARIMAX(1, 0, 0) with a trend on
the macrodata inflation series, at params [1, 0.5, 4], the diagonal was
[4.7e16, 1.9e17, 2.9e15] instead of J' I(p) J = [0.2525, 2.767, 0.5],
and [0.249, 3.371, 1.999] with approx_centered=True.
"ValueError: shape mismatch: value array of shape (3,) could not be
broadcast to indexing result of shape (2,)", and so did
hessian(params, method="oim").
Changes
so with transformed=False the information matrix is with respect to the
untransformed parameters, J' I(p) J, and with fixed parameters it is the
matrix of the free parameters.
Not changed
and does not reach this path.
Tests
With transformed=False, forward and centered differences match
J' I(p) J, with I(p) by complex step and J by centered differences of
transform_params, for an AR(1) and an AR(2) (whose transformation is not
diagonal). Main is off by a factor of 1e16 (forward) or up to 4
(centered).
With fixed parameters, transformed True and False, the matrix equals
that of the model without fixed parameters at the same values,
restricted to the free parameters; hessian(method="oim") likewise. These
raise on main.
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