I am trying to check a hypothesis using a WIlcoxon rank sum test on R. I have my data in two separate arrays, X and Y. My initial hypothesis is that X's mean value is greater than Y's and obviously my alternative hypothesis would be that Y's is greater. I'm a bit confused as to how alternative works in this type of test: what is the "shift" that the test's results refer to and how can I understand that better through my problem described above?

wilcox.test(X, Y, conf.level=0.01, 

Basically I'm looking to understand what would go in the ???? section.

EDIT: Just to clarify, I am working with a situation were I have to compare the damage a female game character does with that of a non-female character. I have saved the damage for women in X and that for other in Y. In either case I have 21 and 25 values for damage respectively.

I then run two tests: 1) to check whether the populations' distributions were normal (the women's seems to not be and the others' is iffy) and 2) check the variances for which the ratio came around 1.03. In the book I'm consulting about this it says that when distribution is not normal and I want to compare something common I need to conduct a Wilcoxon rank sum or Mann-Whitney test. An additional question would be whether I'm right to assume I can apply this test to my case, by having my initial assumption be "women's mean value of damage is higher than others'" and my alternative be "other's mean value of damage is higher than women's".

  • 1
    $\begingroup$ The shift refers to the difference in the median of two distributions. If the alternative is set to "greater", it tests whether X's median is greater than Y's, i.e., the positive shift of X's median from Y's. $\endgroup$ Commented Apr 30, 2022 at 14:47
  • $\begingroup$ I assume that the essence of the question lies in : My initial hypothesis is that X's mean value is greater than Y's and obviously my alternative hypothesis would be that Y's is greater. This isn't quite right. a) The null hypothesis might be that X and Y have equal means, and then the alternative is that they do not. This is a two-sided hypothesis test. b) The null hypothesis might be that X has a greater mean than Y. In this case, the alternative hypothesis is that the mean of X is less than or equal to that of Y. This is a one-sided test. $\endgroup$ Commented May 3, 2022 at 14:16
  • $\begingroup$ You'll need to sort out which null hypothesis you are interested in to determine what goes in to alternative = option. $\endgroup$ Commented May 3, 2022 at 14:18
  • 1
    $\begingroup$ But note that the Wilcoxon-Mann-Whitney test isn't a test of means. Or medians. $\endgroup$ Commented May 3, 2022 at 14:19
  • $\begingroup$ I am deleting my Answer, even though I believe it is correct. An improperly framed question in terms of means and confusing comments about $H_0$ have by now made it difficult to follow any answer. Several pages linked as 'Relevant' show the connection between useful hypotheses and corresponding use of alte in Wilcoxon tests. $\endgroup$
    – BruceET
    Commented May 3, 2022 at 16:09

2 Answers 2


The Wilcoxon test compares the rank sums between two samples. In terms of interpretation this means that it will reject the null hypothesis if there is evidence that one group produces systematically larger or smaller values than the other. Alternative "greater" means that the first group tends to produce larger values than the second, alternative "less" means that it tends to produce smaller values, "two.sided" means that it tends to produce either systematically smaller or larger values. (I have to say that the help page of wilcox.test doesn't explain this in the clearest possible way.)

Note that the term "location shift" is misleading, because it suggests that rejection of the null hypothesis means that there's evidence that the "distributional shape" of the two distributions is the same and that one is the other shifted to the right (or left, respectively). If this were indeed the case, it would be both a mean and a median "shift"; there's nothing in the Wilcoxon test that particularly refers to the median (two distributions can have equal median and the Wilcoxon test can still reject, for example if the lower 51% of observations are the same but one group has larger values on the upper 49%). In fact the alternative can be taken as generally one distribution to tend to produce systematically larger (or smaller, respectivaly) values than the other, measured in terms of rank sums. One does not need to be a "shift" of the other.

The only connection with the median (rather than the mean) is that the median, as rank sums, does not use the precise values of most or all observations, and will therefore give outliers very limited influence, as rank sums do, and as opposed to means. So generally Wilcoxon will in cases in which looking at mean and median differences give different results more often agree with the "message from the median". However, in most simple examples, all three, Wilcoxon, mean, and median differences will point in the same direction (sometimes mean differences will not be significant according to the t-test but will be according to Wilcoxon and medians, although there are also opposite situations).


Here's a reproducible example from the wilcox.test() help file illustrating a one sample test where the null hypothesis is x is less than or equal to y and the alternate hypothesis is x is greater than y.

For the study data below, we'd expect patients to have a lower score on the Hamilton depression scale factor after receiving a tranquilizer (y) than before the tranquilizer was administered (x).

## One-sample test.
## Hollander & Wolfe (1973), 29f.
## Hamilton depression scale factor 
## measurements in 9 patients with
##  mixed anxiety and depression, taken at 
## the first (x) and second
##  (y) visit after initiation of a therapy 
## (administration of a  tranquilizer).

x <- c(1.83,  0.50,  1.62,  2.48, 1.68, 
       1.88, 1.55, 3.06, 1.30)
y <- c(0.878, 0.647, 0.598, 2.05, 1.06, 
       1.29, 1.06, 3.14, 1.29)

# for this data, null hypothesis is x <= y
# alternate hypothesis is x > y, that the 
# treatment reduces depression scale
# factor measurements

wilcox.test(x, y, paired = TRUE, 

... and the output:

wilcox.test(x,y,paired = TRUE, 

    Wilcoxon signed rank exact test

data:  x and y
V = 40, p-value = 0.01953
alternative hypothesis: true location shift 
is greater than 0


Note that for a one tailed test, the entire rejection region is on one side of the Wilcoxon distribution, so the null hypothesis includes the area where y is significantly greater than x.

In the example data, the researchers wanted to know whether the tranquilizer reduced scores on the depression scale factor measurements. Since they knew the desired direction of the effect in advance of the treatment, they could use a one-tailed test rather than a two-tailed test.

NOTE: The original post did not include a minimal reproducible example and the most readily available data to me was a paired test. 'sidedness' works the same way for both paired and independent samples, so I used a paired test to illustrate how it works in the wilcox.test() function.

  • 2
    $\begingroup$ The OP speaks of a situation with independent samples, not paired ones. $\endgroup$
    – Michael M
    Commented Apr 30, 2022 at 16:39
  • $\begingroup$ @MichaelM. True and important to point that out. However, the discussion of 'sidedness` and the use of parameter alt is much the same. $\endgroup$
    – BruceET
    Commented Apr 30, 2022 at 19:31
  • $\begingroup$ @MichaelM. True and important to point that out. However, the discussion of 'sidedness` and the use of parameter alt is much the same. // For large sample sizes a normal approximation is used for this test. But the use of 'normal' in the next to last paragraph needs some explanation. $\endgroup$
    – BruceET
    Commented Apr 30, 2022 at 19:43
  • 1
    $\begingroup$ @BruceET - thanks, adjusted the paragraph to be more precise, referencing the Wilcoxon distribution. $\endgroup$
    – Len Greski
    Commented Apr 30, 2022 at 22:09
  • 1
    $\begingroup$ @SalMangiafico - yes, null is x <= y with the one sided test using the argument alternative = greater. Adjusted the comment accordingly. $\endgroup$
    – Len Greski
    Commented May 3, 2022 at 15:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.