-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
BUG: adds warning to scipy.stats.brunnermunzel #15847
Conversation
scipy.stats.brunnermunzel returns a p-value of nan in some cases, because the numerator and denominator of the t-distribution were 0. It is not clear why nan is returned, especially when it appears that p should be 0 (when effect sizes are large). Now, a warning is emitted when p is nan, and an alternative is suggested Fixes scipy#15843
Thanks. If the suggestions above look OK to you, I'll push them, but there's one more thing needed before merge. Can you add your example as a test in |
@mdhaber will do, thanks for the review and changes! |
Co-authored-by: Matt Haberland <mhaberla@calpoly.edu>
Co-authored-by: Matt Haberland <mhaberla@calpoly.edu>
tests check if warning is emitted, and also that p=0 when normal distribution is used
@mdhaber thanks for the suggestions. added your changes, and also added two tests which check for warning and correct p when using a normal distribution. i verified that those two tests pass locally. |
Thanks! I'd suggest finding an option in your IDE that removes trailing spaces when it saves. Helps avoid PEP8 issues. |
thank you! fyi i had to disable my autoformatter (black) because it changed everything else in the file. also the imports are in a non pep8 order in some of the modules so i had to disable |
Thank you for doing that! |
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.
I'll merge when tests finish.
Thanks for the bug report and fix @sg-s! The Main Windows Python310 seems to have hung, as it frequently does, so I'll merge now. |
@mdhaber i have a dataset with relatively small n (3-10) where in some cases there was clearly a difference by eye, and t-tests were saying it wasn't different. turns out my data isn't normal, and also is heteroskedastic and what i should have done is a permutation test (which is what i used eventually). but brunnermunzel was one of the things i tried because it seemed to have lower restrictions. |
Great! Did you use |
yup, ended up using |
Reference issue
closes #15843
What does this implement/fix?
emits a warning when
scipy.stats.brunnermunzel
cannot compute p-valuebecause both numerator and denominator are 0, and therefore p-value is nan
also suggests an alternative (using distribution="normal")
This change does not change any output/no code is changed. The only changeis emitting a warning in some cases where output p-value is nan
also add two tests:
test_brunnermunzel_return_nan
tests that the correct warning is raised when using a t-distributiontest_brunnermunzel_normal_dist
tests that p=0 when using a normal dist with the problematic dataset