feat: chi-square goodness-of-fit (closes last infer vignette gap)#17
Merged
Conversation
The one infer example the port lacked. Add a one-variable goodness-of-fit test:
- hypothesize(null="point", p=...) now accepts a {level: probability} mapping.
- calculate(stat="Chisq") with no explanatory variable computes the GOF statistic
(observed counts vs n * p[level]); validates that p sums to 1 and covers every
observed level.
- generate(type="draw") (alias "simulate") samples each replicate's categories
from the hypothesized proportions for the null distribution.
- chisq_test(data, response=, p=) is the one-line GOF wrapper (theoretical
p-value); chisq_stat() works for it too.
Docs: GOF example in the hypothesis-testing guide; CHANGELOG. Tests: observed
stat matches scipy.stats.chisquare, null+p-value, wrapper parity, observe()
shortcut, and the error paths. 248 tests, 100% coverage, ruff clean, docs -W clean.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017CTL1QSTg1DmDUpqYuPEog
Welcome to Codecov 🎉Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests. Thanks for integrating Codecov - We've got you covered ☂️ |
Codify the infer 'Full pipeline examples' vignette as a pytest test that runs every calculate(stat=) form against gss (incl. the new goodness-of-fit), plus representative null/p-value, bootstrap-CI, theory (assume), and wrapper flows. Catches behavioral gaps in CI rather than only on manual vignette review; complements the structural parity-drift tooling. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017CTL1QSTg1DmDUpqYuPEog
ismayc
added a commit
that referenced
this pull request
Jun 20, 2026
Now that chi-square goodness-of-fit is implemented (merged via #17), the infer-examples page documents it as a working example instead of a gap: a new "One categorical variable (3+ levels): chi-square goodness-of-fit" section, and the two "not yet supported" notes removed. Merges main; HTML rebuilt. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017CTL1QSTg1DmDUpqYuPEog
ismayc
added a commit
that referenced
this pull request
Jun 20, 2026
* docs: add infer "stat menu" page; array-API + split model-plot examples - New guide guides/infer-examples.md mirroring infer's observed_stat_examples vignette: the calculate(stat=) forms by variable type, on gss, with null/CI/ theoretical pipelines. Honestly notes the one gap (chi-square goodness-of-fit is not yet supported) rather than claiming exhaustiveness. - Regression guide: add an array-API models example (sm.OLS(y, X).fit()), and split the stacked "Visualizing models" cell so each plot actually renders. All example cells execute; docs build warning-free under -W. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017CTL1QSTg1DmDUpqYuPEog * docs: turn the GOF "not supported" notes into a real example Now that chi-square goodness-of-fit is implemented (merged via #17), the infer-examples page documents it as a working example instead of a gap: a new "One categorical variable (3+ levels): chi-square goodness-of-fit" section, and the two "not yet supported" notes removed. Merges main; HTML rebuilt. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017CTL1QSTg1DmDUpqYuPEog --------- Co-authored-by: Claude Opus 4.8 <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.
Implements the one example from the R
infervignettes the port was missing — the chi-square goodness-of-fit test — so the infer pipeline coverage is now genuinely complete.What's new
hypothesize(null="point", p=...)accepts a{level: probability}mapping (in addition to a scalar proportion).calculate(stat="Chisq")on a single categorical variable computes the goodness-of-fit statistic (observed counts vsn * p[level]), validating thatpsums to 1 and covers every observed level.generate(type="draw")(alias"simulate") samples each replicate's categories from the hypothesized proportions to build the null distribution.chisq_test(data, response=, p=)is the one-line GOF wrapper (theoretical p-value viascipy.stats.chisquare);chisq_stat()works for it too.Tests & docs
scipy.stats.chisquare; null distribution + p-value; wrapper/pipeline parity;observe()shortcut; and the error paths (nopdict,pnot summing to 1, missing level, wrapper without explanatory/p).-W..claude/settings.Follow-up
PR #16 (docs examples) currently notes GOF as "not yet supported". Once this merges, I'll flip that note into a real example (the new
infer-examples.mdpage).🤖 Generated with Claude Code