# Statistic of Wilcoxon-Mann-Whitney test with two-sided alternative hypothesis

I am learning about some non-parametric tests. In my textbook (the one that my teachers drafted), it is said that "The Wilcoxon,Mann-Whitney test does not allow testing the two-sided alternative hypothesis". But it is weird to me because in R, we can see the option "alternative=two.sided" in the command wilcox.test. And I also see many sources on the Internet that show how to build this test with two-tailed. The first two sources that I found:

But these two sources used different statistic. One took the minimum rank-sum of the samples and the other took the maximum rank-sum of the samples.

So does the MWW allow testing the two-sided alternative hypothesis? And if yes, what is the statistic for this test?

Edit:

In my textbook, the hypothesis are: $$H_0: F=G$$ against $$H_1: F\ge G$$, where $$F,G$$ are the cdfs of two samples $$X,Y$$ respectively.

The statistic is defined by: $$MW_{X,Y}=\sum_i \sum_j 1_{Y_j>X_i}$$

I have just noticed that in the $$H_1$$, there is also the equality symbol. Is it weird or it is a typo of my textbook?

• What statistic does your textbook use? It would be useful to be able to discuss how to do a two sided test with it in an answer. Commented Sep 22, 2018 at 1:07
• Thank you so much for your answer. In my textbook, the alternative hypothesis is as follow: $H_1: F \ge G$, where F and G are cdfs of X,Y respectively, and the statistic is $MW=\sum_{i} \sum_{j} 1_{Y_j>X_i}$. Commented Sep 22, 2018 at 7:20
• And in my textbook, the $H_1$ also has a $"="$ as you can see above, is it weird? I never saw any alternative hypothesis that has $"="$. I am sorry, I cannot edit my comment above anymore. I will edit my question soon. Commented Sep 22, 2018 at 7:33
• Thanks for that information. Yes, they shouldn't have the "=" in the alternative. I'll make an edit that shows that this statistic is definitely useable two sided. (Might not be right away.) Commented Sep 22, 2018 at 7:48

The test has several different-but-equivalent forms, where equivalent means you'll always reject the same possible samples under the same null, alternative and significance level. This dates right back (at least!) to the first two papers by Wilcoxon (1945, 1947), because the second paper used a different form of statistic to the first. In fact many nonparametric tests have this property; it's a feature of permutation tests more generally.

Every form I have seen allows for two sided tests, including Wilcoxon's original 1945 paper. This paper assumed equal sample sizes and used the smaller sum of ranks, and was thereby (automatically) considering differences in both directions (i.e. two sided), since it picks out the smaller of the two possible one-sided sum-of-rank statistics. Indeed the significance levels he offered in his initial table were all for a two sided alternative.

The statistic you mention is more often termed $$U$$; when the continuous random variable point-null $$P(X_i is true, the distribution of $$U$$ is symmetric about $$mn/2$$. For example, here's the probability of each value of $$U$$ when $$m=5$$ and $$n=7$$:

If $$P(X_i\frac12$$ then the statistic will tend to be larger than this, while if $$P(X_i then the statistic will tend to be smaller than this.

Which is to say, it will pick up both sides of the alternative.

Or looking at it another way -- if you interchange the $$X$$'s and $$Y$$'s the statistic has the same distribution under the null (i.e. if $$m=7$$ and $$n=5$$ the plot would look the same as above, but the two tails are "flipped" (what was in the high tail one way around is in the low tail the other way around).

Practically speaking, the WMW test allows for a two-sided test.

It's difficult to assess the mentioned material without seeing the whole context. I imagine the test is being presented in a way that is akin to "The way the test itself is conducted is actually one-sided, but by the end of the explanation you will see how we use it as a two-sided test."

Let's say one group is called X and the other is called Y. And the statistic for X is called F, and the statistic for Y is called G.

If we define the test as H1: F > G, then the test is in fact a one-sided test in one direction. Of course, if we define the test as H1: G > F, then the test is one-sided in the other direction.

However, if we call Q the greater of either F or G, and use Q as our test statistic, then it will be a two-sided test. In this case we are essentially testing H1: F > G or G > F.

So, in my example, the test itself is really one-sided. But we can use it as a two sided test, by making our test statistic either the maximum of F or G, or the minimum of F or G (depending on how the subsequent math or statistics are conducted).

It will depend on the people involved and the situation, but likely your teacher will appreciate feedback on the text if there is something you found confusing. Or an error, as in the equality in the alternative hypothesis. I don't have any great advice about how you go about this, for example if it's something you want to bring up as you go along, or if you want to keep a document of everything until the end of the course.

• Thank you for your answer and your advice :)) I have not asked my teacher about these problems because she has not taught it in the class yet. I just would like to self-study and learn more about the related things that are not in the textbook. Commented Sep 22, 2018 at 19:46