Solved – Understanding the Wilcoxon rank-sum one-sided test

hypothesis testingrwilcoxon-mann-whitney-test

With a simple two sided test, the null hypothesis is often set as:

Hn: µ1- µ2 = 0

and if we get a p-value less than 0.05, we can reject the null hypothesis and accept the alternative. That is:

Ha: µ1 – µ2 != 0

But if we expect a difference, we can create a one-side test. Taking the example from here, we run a one-sided Wilcoxon rank-sum test test on the data.

set.seed(123)
Nj  <- c(20, 30)
DVa <- rnorm(Nj[1], mean= 95, sd=15)
DVb <- rnorm(Nj[2], mean=100, sd=15)
wIndDf <- data.frame(DV=c(DVa, DVb),
                     IV=factor(rep(1:2, Nj), labels=LETTERS[1:2]))

Not included on the original website, we can visualise the data

boxplot(DV ~ IV, data = wIndDf)

We also assess the levels of the data

levels(wIndDf$IV)

And we see that A will be compared to B. To run a one-side test, the code is as (direct from the website)

wilcox.test(DV ~ IV, alternative="less", conf.int=TRUE, data=wIndDf)

And we get a p-value < 0.05, so we can reject the null. But what was the null, and the alternative

From the alternative command, am I correct in saying the null is:

µA < µB

Best Answer

The IV variable is a factor with two ordered levels, A and B. The A is the referent level and the B is the comparitor. The difference in location is of a A - B form. It's easy to check this by giving B a much larger mean and testing the "greater" and "less" commands. The presentation of the estimate and its CI is also the same as a T-test. A more interesting question is what exactly is lesser or greater with the Wilcoxon. The Wilcoxon has been questioned extensively as far as interpretation and credibility of results. It is not a median nor is it a mean unless strong distributional assumptions are met.