Skip to content

BUG: Make GEE cov_type case-insensitive and fix the constraint guard - #10791

Merged
bashtage merged 4 commits into
statsmodels:mainfrom
ChenyangLi4288:bug/gee-cov-type-case
Nov 19, 2026
Merged

bashtage merged 4 commits into
statsmodels:mainfrom
ChenyangLi4288:bug/gee-cov-type-case

Conversation

@ChenyangLi4288

Copy link
Copy Markdown
Contributor

Two small GEE fixes from the #10781 review:

  • cov_type is case-insensitive. A mixed-case value such as "Bias_Reduced" or "Kauermann_Carroll" raised UnboundLocalError in GEE, OrdinalGEE and NominalGEE. fit and the results class now lowercase it.
  • Constraint guard checked the wrong variable. After expanding the bias-reduced covariance under a constraint, fit checked x, which is never None, instead of y. It now checks y, and the Kauermann-Carroll path gets the same check.

The new tests fail on main and pass here.

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 (Claude Code).
    Used for: drafting the first fix, 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.

Mixed-case values such as "Kauermann_Carroll" raised UnboundLocalError.
The guard tested x, which is never None, instead of y; KC gets the same guard.
@ChenyangLi4288

ChenyangLi4288 commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor Author

Heads-up: this PR and #10792 both add a bullet at the end of the GLM bug-fix list in docs/source/release/version0.15.1.rst, so whichever is merged second will conflict there. I can rebase that one as soon as the other is merged.

@bashtage
bashtage merged commit b8346a0 into statsmodels:main Nov 19, 2026
9 of 10 checks passed
@bashtage

Copy link
Copy Markdown
Member

Thanks for the work on GEE.

bashtage added a commit to bashtage/statsmodels that referenced this pull request Nov 19, 2026
test_constraint_small_sample_cov_fails (statsmodels#10791) made the third call of
GEE._handle_constraint fail by counting calls, so it passed or failed
for the wrong reason if fit changed the number of calls. The wrapper now
fails only for the call that receives the matrix returned by _bc_covmat,
and the test checks that this call was reached.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
bashtage added a commit to bashtage/statsmodels that referenced this pull request Nov 19, 2026
…riance

The release note of statsmodels#10791 mentioned only the case-insensitive cov_type.
When the expansion of the bias_reduced or kauermann_carroll covariance of
a constrained fit failed, fit continued and returned results whose
covariance raised a ValueError when used; it now returns None with a
ConvergenceWarning.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
bashtage added a commit to bashtage/statsmodels that referenced this pull request Nov 19, 2026
test_constraint_small_sample_cov_fails (statsmodels#10791) made the third call of
GEE._handle_constraint fail by counting calls, so it passed or failed
for the wrong reason if fit changed the number of calls. The wrapper now
fails only for the call that receives the matrix returned by _bc_covmat,
and the test checks that this call was reached.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
bashtage added a commit to bashtage/statsmodels that referenced this pull request Nov 19, 2026
…riance

The release note of statsmodels#10791 mentioned only the case-insensitive cov_type.
When the expansion of the bias_reduced or kauermann_carroll covariance of
a constrained fit failed, fit continued and returned results whose
covariance raised a ValueError when used; it now returns None with a
ConvergenceWarning.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
bashtage added a commit to bashtage/statsmodels that referenced this pull request Nov 20, 2026
test_constraint_small_sample_cov_fails (statsmodels#10791) made the third call of
GEE._handle_constraint fail by counting calls, so it passed or failed
for the wrong reason if fit changed the number of calls. The wrapper now
fails only for the call that receives the matrix returned by _bc_covmat,
and the test checks that this call was reached.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
bashtage added a commit to bashtage/statsmodels that referenced this pull request Nov 20, 2026
…riance

The release note of statsmodels#10791 mentioned only the case-insensitive cov_type.
When the expansion of the bias_reduced or kauermann_carroll covariance of
a constrained fit failed, fit continued and returned results whose
covariance raised a ValueError when used; it now returns None with a
ConvergenceWarning.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
bashtage added a commit to bashtage/statsmodels that referenced this pull request Nov 20, 2026
test_constraint_small_sample_cov_fails (statsmodels#10791) made the third call of
GEE._handle_constraint fail by counting calls, so it passed or failed
for the wrong reason if fit changed the number of calls. The wrapper now
fails only for the call that receives the matrix returned by _bc_covmat,
and the test checks that this call was reached.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
bashtage added a commit to bashtage/statsmodels that referenced this pull request Nov 20, 2026
…riance

The release note of statsmodels#10791 mentioned only the case-insensitive cov_type.
When the expansion of the bias_reduced or kauermann_carroll covariance of
a constrained fit failed, fit continued and returned results whose
covariance raised a ValueError when used; it now returns None with a
ConvergenceWarning.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
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.

2 participants