Repository navigation
BUG: Follow up #10790 on GEE marginal effects and small-sample covariances - #10792
Merged
bashtage merged 8 commits intoNov 19, 2026
Merged
Conversation
…ge 1 A group with leverage 1 raised a bare LinAlgError, or gave a meaningless covariance for Gaussian.
The eigenvalues of the full group leverage matrix cost about 50 times the solve for groups of 800.
The header had one entry for the two confidence interval columns, so summary() raised ValueError.
get_margeff ignored use_t and always used the normal distribution.
Contributor
Author
|
Heads-up: this PR and #10791 both add a bullet at the end of the GLM bug-fix list in |
5 of 6 tasks
Member
|
Thanks for the work on GEE. |
This was referenced Nov 19, 2026
bashtage
added a commit
to bashtage/statsmodels
that referenced
this pull request
Nov 19, 2026
The leverage check of statsmodels#10792 calls np.linalg.eigvals, which raises a bare LinAlgError when the covariance of the parameters contains NaN or inf, for example for a Poisson model with an exchangeable correlation and an observation with y = 0 and its own dummy variable. Before statsmodels#10792 the same fit returned NaN standard errors for cov_type="bias_reduced" and failed in sqrtm for "kauermann_carroll". Check that the covariance is finite first and raise a ValueError that says why the leverages cannot be computed. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
bashtage
added a commit
to bashtage/statsmodels
that referenced
this pull request
Nov 19, 2026
Add a Raises entry with a versionchanged directive to GEE.fit, and say that a leverage larger than 1 - 1e-8 counts as 1 (the tolerance of the check added in statsmodels#10792). Reword the release note of statsmodels#10792: main returned meaningless covariances for some families, not only Gaussian (Binomial bse about 9e15, Poisson NaN), and a non-finite covariance now raises the ValueError. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
bashtage
added a commit
to bashtage/statsmodels
that referenced
this pull request
Nov 19, 2026
The leverage test of statsmodels#10792 still passed if the p x p matrix was replaced by dmat.T @ dmat, if the message showed the position instead of the label of the group, or if the cov_type name in the message was wrong. Use string group labels and match the cov_type, compare the check with the eigenvalues of the full leverage matrix built in numpy for an exchangeable correlation (with dummies whose leverage is within and outside 1e-8 of 1), and add a case with a non-finite covariance. Import scipy.stats at module level. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
bashtage
added a commit
to bashtage/statsmodels
that referenced
this pull request
Nov 19, 2026
The leverage check of statsmodels#10792 calls np.linalg.eigvals, which raises a bare LinAlgError when the covariance of the parameters contains NaN or inf, for example for a Poisson model with an exchangeable correlation and an observation with y = 0 and its own dummy variable. Before statsmodels#10792 the same fit returned NaN standard errors for cov_type="bias_reduced" and failed in sqrtm for "kauermann_carroll". Check that the covariance is finite first and raise a ValueError that says why the leverages cannot be computed. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
bashtage
added a commit
to bashtage/statsmodels
that referenced
this pull request
Nov 19, 2026
Add a Raises entry with a versionchanged directive to GEE.fit, and say that a leverage larger than 1 - 1e-8 counts as 1 (the tolerance of the check added in statsmodels#10792). Reword the release note of statsmodels#10792: main returned meaningless covariances for some families, not only Gaussian (Binomial bse about 9e15, Poisson NaN), and a non-finite covariance now raises the ValueError. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
bashtage
added a commit
to bashtage/statsmodels
that referenced
this pull request
Nov 19, 2026
The leverage test of statsmodels#10792 still passed if the p x p matrix was replaced by dmat.T @ dmat, if the message showed the position instead of the label of the group, or if the cov_type name in the message was wrong. Use string group labels and match the cov_type, compare the check with the eigenvalues of the full leverage matrix built in numpy for an exchangeable correlation (with dummies whose leverage is within and outside 1e-8 of 1), and add a case with a non-finite covariance. Import scipy.stats at module level. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
bashtage
added a commit
that referenced
this pull request
Nov 19, 2026
BUG: Follow up #10792 on GEE small-sample covariances, docs and tests
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.
NumPy's guide.
Fixes the two GEE problems listed under "Not changed" in #10790 by @bashtage (the third, case-sensitive
cov_type, is #10791).get_margeffignoreduse_t. Withuse_t=True, the p-values and confidence intervals of the marginal effects now use the t distribution withdf_resid_inference, as the parameters do, and thesummary_framecolumns aret/Pr(>|t|). The default is unchanged.summary()raisedValueError. Its header had one entry for the two confidence interval columns. Found while testing the above.bias_reduced/kauermann_carroll. A group with leverage 1, e.g. a single observation with its own dummy, raised a bareLinAlgError(Poisson) or silently returned a meaningless covariance (Gaussian, where rounding hides the singularity). It now raises aValueErrorthat names the group. The leverages are checked on a p x p matrix with the same nonzero eigenvalues, so groups of 800 cost 0.13 s instead of 5.4 s for the full matrix.The new tests fail on
mainand pass here.Not changed:
NominalGEE.get_margeff()fails with 3 or more categories (a shape error), so theJ > 1branch of the margins summary is not reachable.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 (Claude Code).Used for:
drafting the fixes, tests and docs.I have personally read, understood, and can explain every line of this diff, and
have verified the statistical/numerical correctness of the change.