stats: report perfectly separated data as significant instead of an all-NaN "not significant" - #34
Open
ChrisW09 wants to merge 1 commit into
Open
stats: report perfectly separated data as significant instead of an all-NaN "not significant"#34ChrisW09 wants to merge 1 commit into
ChrisW09 wants to merge 1 commit into
Conversation
With zero residual variance (the factors fully determine the verdicts), statsmodels' Type-II ANOVA returns an all-NaN table (0/0 F), which fit_effects translated into p=None / significant=False — reporting the strongest possible effect as 'no significant effect'. The repo's own test (test_fit_effects_detects_real_effect) pins the correct behavior and fails on a fresh install with statsmodels 0.14.6. Detect ss_resid == 0 and report per-factor one-way ANOVAs instead (F=inf, p=0, partial eta^2=1 under perfect separation) with an explicit warning that the full ANOVA's F-tests are undefined and interactions are not estimable. Also fix the same function's interaction fallback: it recomputed the table from a fresh main-effects OLS without reassigning , so res.residuals/res.fitted described the abandoned interaction model rather than the reported one. Fixes #4 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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 #4.
Bug 1: on zero-residual data (a factor fully determines the verdicts — e.g. always-5 vs always-2), statsmodels' Type-II ANOVA returns an all-NaN table, and
fit_effectsreported the term asp: None, significant: False. The repo's owntest_fit_effects_detects_real_effectpins the correct behavior and fails on a fresh install (statsmodels 0.14.6 satisfies the>=0.14pin); with no test-running CI workflow this was invisible. The fix detectsss_resid == 0and reports per-factor one-way ANOVAs (F=inf, p=0, partial η²=1 under perfect separation) with an explicit warning that the full ANOVA's F-tests are undefined (0/0) and interactions are not estimable. Sample output:Bug 2 (same function): the interaction→main-effects fallback recomputed the ANOVA table from a fresh OLS fit without reassigning
fit, sores.residuals/res.fitteddescribed the abandoned interaction model rather than the reported one.fitis now reassigned beforeanova_lm.Test: full cafe-core suite — 109 passed, 2 skipped, 0 failed (previously 1 failed). A test-running CI workflow would be a worthwhile follow-up so regressions like this surface on push.
🤖 Generated with Claude Code