Skip to Main Content

MASH : Maths and Stats Help

Wilcoxon Signed-Rank Test

Introduction

 

A Wilcoxon test, sometimes called a Wilcoxon Signed-Rank Test, compares the means between two related groups, such as comparing the difference between pre-intervention and post-intervention test results.

It is considered a non-parametric test and therefore it 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 a Paired-Samples t-Test

 

Test Procedure

 

The Wilcoxon signed rank test is often referred to as simply the Wilcoxon test. It is different from the Wilcoxon rank sum test (also known as the Mann-Whitney U test), which is a test for independent 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 test if we do not specify paired = TRUE.

 

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.

The third argument needs to be “paired = TRUE”. The wilcox.test() function runs a Mann-Whitney U test by default, this is why we need to specify the option in order for it to run a Wilcoxon test.

wilcox.test(Score ~ Time, pre_post1, paired = TRUE)
## 
##  Wilcoxon signed rank test with continuity correction
## 
## data:  Score by Time
## V = 2858, p-value = 0.04329
## 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

The third argument needs to be “paired = TRUE”. The wilcox.test() function runs a Mann-Whitney U test by default, this is why we need to specify the option in order for it to run a Wilcoxon test.

wilcox.test(pre_post2$Before, pre_post2$After, paired = TRUE)
## 
##  Wilcoxon signed rank test with continuity correction
## 
## data:  pre_post2$Before and pre_post2$After
## V = 2858, p-value = 0.04329
## 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 Wilcoxon signed-rank statistic (V) and the p-value.

Reporting the Results in APA Formatting

Students’ test results were compared before and after the intervention workshop. On average, students performed better (Mdn = 73.00) after the intervention than before (Mdn = 72.00). A Wilcoxon Test indicated that this improvement, was statistically significant, = 2858, p = .043.

Downloads