-
Notifications
You must be signed in to change notification settings - Fork 3.3k
ENH/DOC: add chisquare power based on normalized noncentrality #9432
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
module has a few old flake (import redefinition) and pep-8 style failures |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds power and sample size computation capabilities for chi-square tests using normalized noncentrality parameters. The implementation provides both a standalone function and a class-based interface following the existing patterns in the statsmodels power module for OLS, GLM, and generic MLE applications.
- Introduces
chisquare_power_noncent()
function for direct power calculations - Adds
ChisquareNoncentPower
class withpower()
andsolve_power()
methods - Uses normalized noncentrality parameter (noncentrality divided by sample size) as effect size
standardized effect size, according to Cohen's definition. | ||
see :func:`statsmodels.stats.gof.chisquare_effectsize` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The docstring incorrectly references Cohen's definition for effect size. The effect_size parameter is described as normalized noncentrality (nc / nobs) in the class docstring, not Cohen's standardized effect size.
standardized effect size, according to Cohen's definition. | |
see :func:`statsmodels.stats.gof.chisquare_effectsize` | |
Normalized noncentrality parameter, defined as `nc / nobs`. | |
This is the deviation from the null hypothesis scaled by the | |
sample size. See :func:`chisquare_power_noncent` for details. |
Copilot uses AI. Check for mistakes.
|
||
''' | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing space in the docstring closing. Should be ' '''
''' | |
''' |
Copilot uses AI. Check for mistakes.
standardized effect size, according to Cohen's definition. | ||
see :func:`statsmodels.stats.gof.chisquare_effectsize` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same issue as in the power() method - the docstring incorrectly references Cohen's definition when it should describe the normalized noncentrality parameter.
standardized effect size, according to Cohen's definition. | |
see :func:`statsmodels.stats.gof.chisquare_effectsize` | |
Normalized noncentrality parameter, representing the standardized | |
difference between the observed and expected values under the null hypothesis. |
Copilot uses AI. Check for mistakes.
References | ||
---------- | ||
... | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The References section contains only '...' placeholder text. Either provide actual references or remove this section.
References | |
---------- | |
... |
Copilot uses AI. Check for mistakes.
I tried out github copilot code review for the first time. It's possible that Cohen's effect size is the same as normalized noncentrality in the chisquare case. |
see #9414
objective here is to add initial power and sample size computation for OLS, GLM and for generic mle.
This initial version uses noncentrality for local alternatives, variance is assumed to be (asymptotically) the same under the null and alternative.
Refined versions that distinguish cov_null and cov_alternative will or might follow later.
We might be able to add separate variances more easily following existing patterns for the normal case (simple hypothesis with asymptotic normality)