Skip to Main Content

MASH : Maths and Stats Help

Mann-Whitney U-Test

Introduction

A Mann-Whitney U-Test compares the means between two unrelated groups, such as comparing the difference in heights between Cats and Yorkshire Terriers.

It is considered a non-parametric test and therefore is suitable for non-parametric data. To check if your data is parametric, please check our dedicated guide: Parametric or Not Guide (PDF)

If your data is parametric you should consider using an Independent-Samples t-Test

 

Test Procedure

The Mann-Whitney U test is also known as the Wilcoxon rank sum test and will be displayed as such in the R output. It is different from the Wilcoxon signed rank test, which is a test for paired samples. Both types of tests fall under the wilcox.test() function in R, with a “paired” argument denoting which of the two tests are run (FALSE/TRUE). By default, the argument is FALSE, meaning that the function will run a Mann-Whitney U.

 

Formula method

This is used for when the data is structured using a grouping variable. A grouping variable is a categorical variable indicating which scores belong to different groups.

Data:

 

The first argument entered in the wilcox.test() function is a formula that takes the following structure:

dependent variable ~ independent variable

The second argument is the data frame.

wilcox.test(Height ~ Species, pet_height1)
## Warning in wilcox.test.default(x = DATA[[1L]], y = DATA[[2L]], ...): cannot
## compute exact p-value with ties
## 
##  Wilcoxon rank sum test with continuity correction
## 
## data:  Height by Species
## W = 35.5, p-value = 0.1012
## alternative hypothesis: true location shift is not equal to 0
 
Variables method

This method is used when your data is structured into two separate variables. Both of your variables should be numeric.

Data:

Put both of your variables in the wilcox.test() function in any order. If you have your variables stored in a data frame, use the following structure to indicate the variable: data_frame$variable_name

wilcox.test(pet_height2$cat_height, pet_height2$york_height)
## Warning in wilcox.test.default(pet_height2$cat_height,
## pet_height2$york_height): cannot compute exact p-value with ties
## 
##  Wilcoxon rank sum test with continuity correction
## 
## data:  pet_height2$cat_height and pet_height2$york_height
## W = 35.5, p-value = 0.1012
## alternative hypothesis: true location shift is not equal to 0

 

R will generate largely the same output for both formula and variables methods.

Descriptive Statistics by group

The results of the tests will not include any descriptive statistics. As medians and inter-quartile ranges are commonly reported, please check our guide on descriptive statistics.

Test Statistics

The table output shows the Mann-Whitney U statistic (W) and the p-value.

Reporting the Results in APA Formatting

Heights of Cats and Yorkshire Terriers were compared. On average the Yorkshire Terriers (Mdn = 29.27) were taller than the Cats (Mdn = 28.00) however a Mann-Whitney U test indicated that this difference was not statistically significant, (NCats=11, NTerriers=11) = 35.5, = .101.