Is there a difference between two paired samples?

Yes, there is a difference between two paired samples. This difference is measured by the difference between the means of the two samples. This difference can be used to determine the significance of the difference between the two samples.


The  is the non-parametric version of . It is used to test whether or not there is a significant difference between two population means when the distribution of the differences between the two samples cannot be assumed to be normal.

This tutorial explains how to conduct a Wilcoxon Signed-Rank Test in R.

Example: Wilcoxon Signed-Rank Test in R

Suppose a basketball coach want to know if a certain training program increases the number of free throws made by his players. To test this, he has 15 players shoot 20 free throws each before and after the training program.

Since each player can be “paired” with themselves, the coach had planned on using a paired t-test to determine if there was a significant difference between the mean number of free throws made before and after the training program. However, the distribution of the differences turns out to be non-normal, so the coach instead uses a Wilcoxon Signed-Rank Test.

The following table shows the number of free throws made (out of 20 attempts) by each of the 15 players, both before and after the training program:

Example dataset for Wilcoxon Signed Rank test

To perform the Wilcoxon Signed-Rank Test on this data in R, we can use the wilcox.test() function, which uses the following syntax:

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

where:

  • x, y: two vectors of data values
  • paired: setting this to TRUE tells R that our two vectors contained paired data

The following code illustrates how to use this function to perform the Wilcoxon Signed-Rank Test on this data:

#create the two vectors of data
before <- c(14, 17, 12, 15, 15, 9, 12, 13, 13, 15, 19, 17, 14, 14, 16)
after <- c(15, 17, 15, 15, 17, 14, 9, 14, 11, 16, 18, 20, 20, 10, 17)

#perform Wilcoxon Signed-Rank Test
wilcox.test(before, after, paired=TRUE)

	Wilcoxon signed rank test with continuity correction

data:  before and after
V = 29.5, p-value = 0.275
alternative hypothesis: true location shift is not equal to 0

The test statistic is 29.5 and the corresponding p-value is 0.275. Since this p-value is not less than 0.05, we fail to reject the null hypothesis. There is not a statistically significant difference in the number of free throws before and after players participate in the training program.

By default, this function performs a two-sided Wilcoxon Signed-Rank Test but you can specify a left-tailed test or right-tailed test by using the alternative argument:

#perform left-tailed Wilcoxon Signed-Rank Test
wilcox.test(before, after, paired=TRUE, alternative="less")

	Wilcoxon signed rank test with continuity correction

data:  before and after
V = 29.5, p-value = 0.1375
alternative hypothesis: true location shift is less than 0

#perform right-tailed Wilcoxon Signed-Rank Test
wilcox.test(before, after, paired=TRUE, alternative="greater")

	Wilcoxon signed rank test with continuity correction

data:  before and after
V = 29.5, p-value = 0.8774
alternative hypothesis: true location shift is greater than 0

x