-
Notifications
You must be signed in to change notification settings - Fork 88
fix pvalue > 1 in MannWhitneyUTest (#126) #243
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
Conversation
|
Ready for a review @andreasnoack @nalimilan |
nalimilan
left a comment
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.
Thanks. It's kind of weird that we have to clamp the value like that, but that's less surprising if other software do that. Anyway PValue throws an error for values above 1 and we probably shouldn't change that.
Do we need the same fix for other Mann-Whitney tests?
test/mann_whitney.jl
Outdated
| @test abs(pvalue(ExactMannWhitneyUTest(Float32[1:10;], Float32[2:11;])) - 0.5096) <= 1e-4 | ||
| end | ||
|
|
||
| @testset "Issue #126" begin |
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.
Say what this issue is about?
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.
Added.
Co-authored-by: Milan Bouchet-Valat <nalimilan@club.fr>
|
I fixed all the ocurrences of I'm sure there are more cases of bad p-values but we can tackle those more slowly in a slew of smaller PRs as they are discovered. |
|
Thanks for the review. This can be merged. |
|
Bumping this @andreasnoack. Can I get a review / merge? |
|
@devmotion Have your comments been addressed? |
devmotion
left a comment
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.
It seems the type instability was fixed 👍 I think two things should be improved:
- Can you add a test for the type stability of
pvalue(::ApproximateMannWhitneyTest)? It can be provoked on the master branch with basically any standard example and you can just changepvalueto@inferred(pvalue(...)). - Can you add a test for
pvalue(::ApproximateMannWhitneyUTest; tail=:both) <= 1? Currently both tests just check theExactMannWhitneyUTest. Unfortunately, the second example already works on the master branch for the approximate version so one needs different data to provoke a p-value > 1.
| A = [12,10,7,6,3,1] | ||
| B = [11,9,8,5,4,2] | ||
|
|
||
| m = MannWhitneyUTest(A,B) |
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.
This will also be an ExactMannWhitneyUTest, so the changes for the p-value and type stability in the ApproximateWhitneyUTest are not tested.
I wanted to suggest changing this to
m = ApproximateMannWhitneyUTest(A,B)but unfortunately the p-value is already 1 for this example so it can only be used for testing type stability of pvalue.
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 can't find inputs to get the p-value above 1 here. But I did fix an inference issue, which is nice.
Added
Added a test, which is really just testing inference. |
|
Thanks, let me know if you have more comments. |
devmotion
left a comment
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.
Looks good to me now, thank you @pdeffebach for taking into account all comments!
Codecov Report
@@ Coverage Diff @@
## master #243 +/- ##
=======================================
Coverage 93.64% 93.65%
=======================================
Files 28 28
Lines 1715 1717 +2
=======================================
+ Hits 1606 1608 +2
Misses 109 109
Continue to review full report at Codecov.
|
|
Seems Julia 1.7 broke the tests, probably due to the RNG changes. In general, equality checks of random results with fixed seeds seem very brittle and not reliable since different Julia versions are not guaranteed to yield the same random numbers (as happened now) - IMO ideally they should be replaced with some more stable tests. But of course this is not something you should have to deal with in this PR... |
|
@andreasnoack can this be merged? Test failures unrelated. |
|
Let's get tests green before merging. I've opened #252 as a minimal PR to make tests green again. |
|
Will we merge #252 and then rebase? |
|
Now that #252 is merged, what is the next course of action? |
|
Update the PR so that tests pass, i.e., either merge the master branch or rebase the PR 🙂 |
Co-authored-by: Milan Bouchet-Valat <nalimilan@club.fr>
…pothesisTests.jl into fix_pvalue_too_big
|
Okay I rebased Then I changed the base branch back and forth on the github UI so the changes look good. I think we should run the workflow. |
nalimilan
left a comment
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.
@devmotion Merge?
|
Thank you @pdeffebach 🙂 |
Fix taken from here in the R source code.
Tests seem to fail for FischerExactTest for unrelated reasons.