Mann-Whitney test

By Data Tricks, 28 July 2020

What is a Mann-Whitney test?

The Mann-Whitney test is a non-parametric test that allows two unpaired samples to be compared without making the assumption that values are normally distributed.

The null hypothesis of a Mann-Whitney test is that the medians of the two samples are identical.

The Mann–Whitney test is also referred to as the Mann-Whitney U test, Mann–Whitney–Wilcoxon, Wilcoxon rank-sum test or Wilcoxon–Mann–Whitney test.

Example in R

First, simulate some data to which we will apply the test:

set.seed(150)
data <- data.frame(sampleA = sample(c(0:100), 100, replace = TRUE),
                   sampleB = sample(c(0:100), 100, replace = TRUE))

We can perform a Mann-Whitney test using the wilcox.test function (see above where the Mann-Whitney test is also called the Wilcoxon rank-sun test):

test <- wilcox.test(x = data$sampleA, y = data$sampleB, alternative = "two.sided", paired = FALSE)

Analyse the result:

> test

       Wilcoxon rank sum test with continuity correction

data: data$sampleA and data$sampleB
W = 4727, p-value = 0.5055
alternative hypothesis: true location shift is not equal to 0

p-value

The p value is 0.5, which is above the 5% significance level, therefore the null hypothesis, which is that the medians of the two samples are equal, cannot be rejected.

Is Mann-Whitney the right test?

Use our interactive tool to help you choose the right statistical test or read our article on how to choose the right statistical test.

Tags: ,

Leave a Reply

Your email address will not be published. Required fields are marked *

Please note that your first comment on this site will be moderated, after which you will be able to comment freely.