这是indexloc提供的服务,不要输入任何密码
Skip to content

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

josef-pkt
Copy link
Member

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)

@josef-pkt
Copy link
Member Author

module has a few old flake (import redefinition) and pep-8 style failures

@josef-pkt josef-pkt requested a review from Copilot July 22, 2025 07:30
Copy link

@Copilot Copilot AI left a 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 with power() and solve_power() methods
  • Uses normalized noncentrality parameter (noncentrality divided by sample size) as effect size

Comment on lines +1653 to +1654
standardized effect size, according to Cohen's definition.
see :func:`statsmodels.stats.gof.chisquare_effectsize`
Copy link
Preview

Copilot AI Jul 22, 2025

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.

Suggested change
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.

Comment on lines +1670 to +1672

'''

Copy link
Preview

Copilot AI Jul 22, 2025

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 ' '''

Suggested change
'''
'''

Copilot uses AI. Check for mistakes.

Comment on lines +1691 to +1692
standardized effect size, according to Cohen's definition.
see :func:`statsmodels.stats.gof.chisquare_effectsize`
Copy link
Preview

Copilot AI Jul 22, 2025

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.

Suggested change
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.

Comment on lines +1625 to +1628
References
----------
...

Copy link
Preview

Copilot AI Jul 22, 2025

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.

Suggested change
References
----------
...

Copilot uses AI. Check for mistakes.

@josef-pkt
Copy link
Member Author

I tried out github copilot code review for the first time.
No comments on actual function code, but mistake or ambiguous definition in docstring.

It's possible that Cohen's effect size is the same as normalized noncentrality in the chisquare case.
(I'm not sure I remember correctly.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant