BUG: use rank-adjusted df in wald_test_terms for rank-deficient models - #9907
Open
genrichez wants to merge 2 commits into
Open
BUG: use rank-adjusted df in wald_test_terms for rank-deficient models#9907genrichez wants to merge 2 commits into
genrichez wants to merge 2 commits into
Conversation
bashtage
force-pushed
the
fix/wald-test-terms-df-rank
branch
from
August 10, 2026 06:26
0801877 to
0390b0c
Compare
|
Thanks, the AI Disclosure section looks complete. |
added 2 commits
August 10, 2026 18:38
wald_test_terms was reporting df_constraint as the number of rows in the constraint matrix. For rank-deficient models this is wrong because some constraints are redundant. The wald_test method already computes the effective rank internally, so we now use that value instead. Closes statsmodels#9686
bashtage
force-pushed
the
fix/wald-test-terms-df-rank
branch
from
August 10, 2026 17:38
0390b0c to
275e4a4
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.
Fixes #9686.
wald_test_termswas reportingdf_constraintas the number of rows in the constraint matrix (constraint.shape[0]). For rank-deficient models (e.g. over-parameterized with zero columns via_fit_collinear), this is wrong because some constraints are redundant.The
wald_testmethod already computes the matrix rank of the constraint covariance and adjusts the degrees of freedom internally. This PR uses that rank-adjusted value inwald_test_termsinstead of the nominal row count.Also updated
compare_waldresin the tests to check against the effective df, and added a regression test with a rank-deficient interaction model.AI Disclosure
Tool(s):
Claude.Used for:
drafting the implementation and tests.I have personally read, understood, and can explain every line of this diff, and have verified the statistical/numerical correctness of the change.