Skip to content
This repository has been archived by the owner on Nov 19, 2020. It is now read-only.

Mann-Whitney-U Test producing strange results #857

Closed
hkoestin opened this issue Sep 11, 2017 · 6 comments
Closed

Mann-Whitney-U Test producing strange results #857

hkoestin opened this issue Sep 11, 2017 · 6 comments

Comments

@hkoestin
Copy link

hkoestin commented Sep 11, 2017

Dear @cesarsouza

I just found out, that the MannWhitneyWilcoxonTest class may be buggy.

Given the following sample vector, when I pass it in as sample one and sample two vector, the Accord.NET implementation shows a p-Value of 0.41 or the like.
According to R, for the given vector, the p-Value should be 1 (exactly).

a <- c(250,200,450,400,250,250,350,0,200,400,300,600,200,200,
       550,100,300,250,350,200,550,200,450,400,200,400,450,
       200,400,400,500,450,300,250,200)
b <- c(250,200,450,400,250,250,350,0,200,400,300,600,200,200,
       550,100,300,250,350,200,550,200,450,400,200,400,450,
       200,400,400,500,450,300,250,200)

wilcox.test(a, b)

Gives the following output:

	Wilcoxon rank sum test with continuity correction

data:  a and b
W = 612.5, p-value = 1
alternative hypothesis: true location shift is not equal to 0

Warning message:
In wilcox.test.default(a, b) : cannot compute exact p-value with ties

I have other sample vectors, which show the same behavior. R always shows p-Value of 1 for them.

Thanks in advance,
Harald

@hkoestin
Copy link
Author

I searched the code base a little.
Found the following "issues":

@cesarsouza
Copy link
Member

Hi @hkoestin,

Many thanks for opening the issue and for the observations regarding the unused variables. I will be committing a fix for those and for the original issue in the next minutes.

Regards,
Cesar

cesarsouza added a commit that referenced this issue Sep 11, 2017
…hitney-Wilcoxon;

Updating Mann-Whitney-Wilcoxon to fall back to a non-exact test in case ties are present in the samples;

 - Updates GH-857: Mann-Whitney-U Test producing strange results
@cesarsouza
Copy link
Member

Hi @hkoestin,

I am uploading new pre-release packages (3.7.1-alpha) to NuGet with the latest corrections. They should be available soon.

Regards,
Cesar

@hkoestin
Copy link
Author

Hi @cesarsouza

thanks for committing the fix and providing the new alpha version.
I just tested it, and the results seem to be much closer to R than before.

So: works fine for me now! Thank you!

Regards
Harald

@hkoestin hkoestin reopened this Sep 12, 2017
@hkoestin
Copy link
Author

Oops. Pressed the wrong button

@cesarsouza
Copy link
Member

Fixed in 3.8.0.

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

No branches or pull requests

2 participants