Repository navigation
Conversation
Member
|
Is this unique to Type I? If it affects other types, it could be good to cover those as well. |
Type I sums of squares assume a full-rank design. Reject unsupported singular designs before QR decomposition so redundant terms cannot receive arbitrary sums of squares. Related to statsmodelsGH-8506.
bashtage
force-pushed
the
fix/type1-anova-rank
branch
from
October 1, 2026 15:02
0f7df18 to
3232738
Compare
bashtage
reviewed
Oct 6, 2026
bashtage
left a comment
Member
There was a problem hiding this comment.
Please extend the PR to Type II and III which also have the same issue.
bashtage
requested changes
Oct 6, 2026
bashtage
left a comment
Member
There was a problem hiding this comment.
Sorry, should have been request changes to add proection for type II and III and tests.
6 of 7 tasks
Member
|
Thanks @dnncha for finding this and for the Type I guard and its tests. I have taken this over in #10622 to add the same protection for Type II and III, as requested in the review. Your two commits are kept unchanged at the start of that branch, so you remain their author. I will close this pull request when #10622 is merged. |
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.
Type I ANOVA maps QR effects back to formula terms under a full-rank design assumption. With an exact duplicate predictor, the model span and residual sum of squares are unchanged, but the duplicate can receive an arbitrary sum of squares and a significant p-value.
For a fixed 12-row example,
y ~ x + duplicatecurrently assigns the duplicatesum_sq=138.6197andp=0.02714, whiley ~ xgivesp=0.80229; the fitted values differ by less than9e-16. This change rejects rank-deficient single-model Type I ANOVA before the QR calculation. It does not implement nested ANOVA or change Type II/III behavior.Related to #8506.
Validation:
python -m pytest --cov=statsmodels.stats.anova --cov-report=term-missing statsmodels/stats/tests/test_anova.py -q: 22 passed.ruff check statsmodels/stats/anova.py statsmodels/stats/tests/test_anova.py: passed.anova_lmreplay: the rank-deficient model now raisesValueError; the full-rank control is unchanged.AI Disclosure
Contributions must comply with the statsmodels AI Policy.
Tool(s): OpenAI Codex (GPT-6).
Used for: reproducing the reported behavior, porting the guard and regression tests, running validation, and drafting this description.
The numerical behavior was checked against the unchanged model span and residual sum of squares. This submission has not undergone independent human scientific review.