# Mann-Whitney Exact Test

Based on the relationship between the Mann-Whitney Test and the Wilcoxon Rank-Sum Test, we can modify the exact test described in Wilcoxon Rank-Sum Exact Test to provide an exact test for Mann-Whitney.

The one-tail Wilcoxon Rank-Sum exact test is as follows:

p-value = PERMDIST(W, n1, n2, TRUE)

T-crit = PERMINV(α, n1, n2)

This turns into the one-tail Mann-Whitney exact test is as follows:

p-value = PERM2DIST(COMBIN(MIN(n1, n2)+1,2)+U, n1, n2, TRUE)

U-crit = PERM2INV(α, n1, n2)-COMBIN(MIN(n1, n2)+1, 2)

The two-tail Wilcoxon Rank-Sum exact test is as follows:

p-value = 2 * PERMDIST(W, n1, n2, TRUE)

T-crit = PERMINV(α/2, n1, n2)

This turns into the two-tail Mann-Whitney exact test is as follows:

p-value = 2 * PERM2DIST(COMBIN(MIN(n1, n2)+1,2)+U, n1, n2, TRUE)

U-crit = PERM2INV(α/2, n1, n2)-COMBIN(MIN(n1, n2)+1, 2)

The p-values for the two-tailed test are correct as long as the p-value for the one-tailed test is at most .5.

Real Statistics Functions: The Real Statistics Resource Pack contains the following functions which implement the process described above.

MANNDIST(xn1, n2, tails) = value of the Mann-Whitney distribution at x based on n1 and n2 elements, where tails = 1 (default) or 2; i.e. the p-value as defined above

MANNINV(pn1, n2, tails) = inverse of the Mann-Whitney distribution at p; i.e. the least value of   such that MANNDIST(xn1, n2, tails) ≥ p, where tails = 1 (default) or 2; i.e. U-crit as defined above

MANN_EXACT(R1, R2, tails) = p-value of the Mann-Whitney exact test on the data in ranges R1 and R2, where tails = 1 or 2 (default)

Thus for the two-tailed test for Example 1 of Mann-Whitney Test, we have

MANNDIST(H11,H5,I5,2) = .117928

MANNINV(.05,H5,I5,2) = 34

MANN_EXACT(A6:A17,B6:B16,2) = .117928

Observation: These functions are quite computationally intensive. Depending on the power of your computer they compute quite quickly for values of n = n1 + n2 up to about 24 or 25. Between 26 and 28 they slow down noticeably and after about 28 the time taken elongates rapidly.

As a result, the MANNDIST and MANNINV functions will give a warning message if n1 + n2 exceeds 28. Similarly, MANN_EXACT function will give a warning message if the size of range R1 plus the size of range R2 exceeds 28.

If you want to exceed this limit, you can add a fourth argument to the MANN_EXACT function or fifth argument to MANNDIST or MANNINV which describes how much you want to increase the limit. E.g. if you want to use the Mann Whitney exact test for n = 31, then you can use the formula =MANN_EXACT(A1:A15,B1:B16,,1.2). The 1.2 specifies that you have increased the limit from n = 28 to n = 28 × 1.2 = 33. Since 31 < 33, the function will run, although it will take longer.

### 3 Responses to Mann-Whitney Exact Test

1. Sonja says:

Dear Charles,

could you please explain me why you multiply the PERM2DIST by two to obtain the p-value for the two-tail Mann-Whitney exact test?
–> p-value = 2 * PERM2DIST(COMBIN(MIN(n1, n2)+1,2)+U, n1, n2, TRUE)

Does that have something to do with the test being two-tailed? I’m currently writing my thesis and in my text book I have the following data: μ = 12; standard deviation = 4,59; the calculated U-value = 11. In the text book they then calculate the normal distribution of these values and multiply the obtained value by 2 to get the p-value (0,828), but unfortunately they don’t explain why they do it. If you draw a quick sketch of the distribution, you see that the U is left of the μ and if you want to calculate the area from -infinity to U, I wouldn’t multiply it by two – could you please explain me why you do that? Thanks a lot.

Best regards from Austria,
Sonja

• Charles says:

Sonja,
For a symmetric distribution the two-tailed p-value is double the one-tailed p-value.
Charles

• Sonja says:

Thanks a lot, Charles!