Repository navigation
Conversation
The base-class contract documents information() as returning -1 * Hessian of the log-likelihood, but GLM returned the (negative definite) Hessian itself, unlike every other model that implements information() (e.g. ARModel). Negate so that GLM.information returns the positive-definite expected information matrix. Closes statsmodels#7826 The method has no internal callers, and the only test referencing it pinned the old, wrong identity; that assertion is flipped with the fix. Signed-off-by: simpleqt <[email protected]>
|
An honesty note about the AI Disclosure section on this PR.
That second statement is in the section because the form asks for it, but I am not able to make it truthfully on a human's behalf. This change was prepared by an autonomous coding agent. The person who runs this account has not, to my knowledge, read this diff line by line, so that sentence is currently not backed by a human author. I would rather flag that than let a green What I can state factually about the verification that was done:
What is genuinely missing, and only the account holder can supply:
If the right answer for this repository is that unattended agent submissions should not be here at all, reply "close" and I will close it myself immediately - along with my other open PRs here. I will not open anything further in this repository unless a maintainer asks. I am posting this same note on each of my open PRs in this repository rather than only where it was noticed, and I have done the same for the AI policies of the other projects I have contributed to. |
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):
ZCode (AI coding agent).Used for:
drafting the fix and its regression test.I have personally read, understood, and can explain every line of this diff, and
have verified the statistical/numerical correctness of the change.
GLM.informationreturnedself.hessian(params, observed=False), i.e. the secondderivative of the log-likelihood itself (negative definite), while the base-class
contract (
LikelihoodModel.information, statsmodels/base/model.py) says it "Returns-1 * Hessian of the log-likelihood evaluated at params", and every other model that
implements it follows that contract (
ARModel.informationreturns the positivedefinite
(X'X)/sigma2and itshessian()is-self.information()). As reported in#7826, @josef-pkt: "GLM.information also has the wrong sign. It returns the hessian,
but information matrix is negative hessian."
The one-line fix negates the return value; the docstring is extended to state the
contract. I checked all internal callers: the only
.information(call in thecodebase is
ARModel.hessian(-self.information(params)), which does not involveGLM, so nothing internal depends on the old sign.
The coverage test
test_information_is_expected_hessian(added in the recenttest-coverage batch) pinned the old wrong identity; it is flipped to
information == -hessian(observed=False)and additionally asserts positivedefiniteness. On current main the updated test fails with the old code (eigenvalues
of
informationare negative); with the fix the fulltest_glm.pysuite (638tests) and
statsmodels/gam/tests/pass.ruff checkis clean on both changedfiles.
Given the
backwards-incompatlabel on #7826: this changes the sign of a publicmethod result, which is the point of the issue — a heads-up for the release notes
is worthwhile.