# How to choose the test statistic in Mann-Whitney test?

Reading about the Mann-Whitney test for simple random and independent samples I encountered a small issue. According to the book "Introductory Statistics" by Weiss, the test statistic is obtained using

$M = \text{sum of the ranks for sample data from population 1}$

As usual, we use this test statistic to decide whether we reject the null hypothesis or not.

But this was a bit confusing because it seems arbitrary to choose a given sample as the first one. However, trying to clarifiy this, I found that there are other so-called test statistic $U$, and sometimes we are supposed to choose $\min(U_{1}, U_{2})$ or the opposite $\max(U_{1}, U_{2})$.

For example, in this tutorial, this statistic is used:

$U_{1} = R_{1} - \frac{n_{1}(n_{1} + 1)}{2}$

where $R_{1}$ is the sum of ranks in population $1$ as above.

Note that it doesn't matter which of the two samples is considered sample 1. The smaller value of U1 and U2 is the one used when consulting significance tables.

But this procedure doesn't seem to be used in Weiss' book.

Which one is the correct procedure? Maybe I'm just confusing different tests with similar names.

• Because the two samples of known sizes are combined first and then ranked (and the overall sum of ranks of is therefore fixed), it makes then no difference whether you base the test on min() or max(). – ttnphns Nov 17 '13 at 7:58
• Could you elaborate a bit more? Obviously there are two test statistic to choose from and those have different values depending on sum of ranks and possibly sample size, so why using min() or max() makes no difference? – Robert Smith Nov 17 '13 at 8:08
• Because since you know the sum of ranks, U1+U2, then if you get to know U1 you automatically know U2, and vice versa. – ttnphns Nov 17 '13 at 8:11
• A single answer to your confusion cannot be done because different programs (implementations) differ in details. The fact is that whether to rely on U1 or U2, there always a due move is done to compute the unique correct Z or the exact p-value. Don't bother your brains. – ttnphns Nov 17 '13 at 8:25
• All of the statistics mentioned are equally correct statistics, yielding equivalent tests. As long as you're clear which one you're using, and use the corresponding tables for that statistic, they all reject or fail to reject the same cases. There's a little bit of relevant discussion in this answer. – Glen_b -Reinstate Monica Nov 17 '13 at 14:28

For the Normal distribution test in the Mann Whitney U Test, note that the distribution that both $$U1$$ and $$U2$$ follow is a Normal distribution with mean equal to $$n_{1}n_{2}/2$$. But since $$U_{1} + U_{2} = n_{1}n_{2}$$, this means the null hypothesis distribution is Normal with a mean equal to the average of $$U_{1}$$ and $$U_{2}$$.
In particular, this means that both $$U_{1}$$ and $$U_{2}$$ are equally distant from the mean of the distribution (they are both exactly $$[max(U_{1}, U_{2}) - min(U_{1}, U_{2})] / 2$$ units away from the center of the null hypothesis distribution, by definition). Since they are equally distant and the distribution is symmetric about its mean, then both $$U_{1}$$ and $$U_{2}$$ must generate identical z-scores (up to a sign difference) in that distribution, and thus also identical p-values.
Also, if you calculate the z-score based on $$U_{min}$$, it is guaranteed to be along the left tail of the null hypothesis distribution. Call $$z_{min}$$ this z-score. Then the p-value generally of interest will simply be $$2 * normCDF(z_{min})$$, because $$z_{min}$$ is already negative on the left tail and you're measuring the probability of a value smaller than what was observed. Doubling it also accounts for the other tail where you care about $$P(z > z_{max})$$, since by the argument mentioned above, $$z_{max} = |z_{min}|$$.
If you base it off of $$z_{max}$$ directly, you'd need the ever so slightly more complicated calculation of $$2 * (1 - normCDF(z_{max}))$$, which has a track record of confusing the heck out of people.