### Wilcoxon Signed-Ranks Test for Paired Samples

When the requirements for the t-test for two paired samples are not satisfied, the Wilcoxon Signed-Rank Test for Paired Samples non-parametric test can often be used.

In particular, we assume *n* subjects from a given population with two observations *x _{i} *and y

*for each subject*

_{i}*i.*This results in two paired samples {

*x*

_{1}, …,

*x*} and {y

_{n}_{1 },…, y

*} as described in Paired Sample t Test. The requirements for the Wilcoxon Signed-Rank Tests for Paired Samples where*

_{n}*z*= y

_{i}*–*

_{i}*x*for all

_{i}*i*= 1, … ,

*n*, are as follows:

- the
*z*are independent_{i} *x*and y_{i}are interval data (and so a ranking can be applied and differences can be taken)_{i}

For this test we use the following null hypothesis:

H_{0}: the distribution of difference scores in the population is symmetric about zero

I.e. any differences are due to chance. We show how to apply this test via a couple of examples.

**Example 1**: A researcher wanted to determine whether people’s ability to identify objects with their right eye differs from their ability with their left eye. 16 subjects were presented with a series of images and were scored on their abilities to identify objects which each eye. The results tabulated in Figure 1. Based on this data determine use the Wilcoxon Signed-Ranks Test to whether there is a difference between the two eyes.

We perform a two-tailed Wilcoxon Signed-Ranks Test for Paired Samples with *α* = .05 to test the following null hypothesis:

H_{0}: any differences between the two eyes is due to chance (essentially based on the median of the differences)

The scores for the two eyes are presented in columns B and C. Column D contains the differences between the scores for each subject. Column E contains the absolute value of these differences, eliminating any zero differences from further consideration. Column F contains the adjusted rankings of the non-zero values in column E. Column G reports the values in column F where the difference in column D is positive. Column H reports the values in column F where the difference in column D is negative.

Columns G and H are summed (in cells G19 and H19) to obtain *T+* of 69.5 and *T-* of 35.5. The smaller of these values is the test statistic *T* = 35.5 (in cell K7).

The critical value for the *T* statistic is given in the Wilcoxon Signed-Ranks Table. Here we use *α* = .05 and *n* = 14 (i.e. the 15 subjects less the 1 subject where the difference value in column D is zero). From the table we find that *T _{crit} *= 21 (two-tail test). Since

*T*= 21 < 35.5 =

_{crit}*T*, we can’t reject the null hypothesis (i.e.

*p*≥ .05), and conclude there is no significant difference between the two eyes.

**Observation**: Generally for *n* > 25, an estimate using the normal distribution can be made (as seen in the next example). The actual threshold of 25 is not universally accepted and can be lowered to around 15 or raised to about 50.

**Property 1**: For *n* is sufficiently large, the *T* statistic (or even *T+* or *T-*) has an approximately normal distribution *N*(*μ, σ*) where

Click here for a proof of Property 1.

**Example 2**: A study is made to determine whether there is a difference between husbands and wives attitudes towards politics. A questionnaire measuring this was given to 30 couples with the results summarized in Figure 2.

The table above is similar to that in Figure 1. Since *T* = 90 < 98 = *T _{crit}* (two-tail test), we conclude there is a significant difference between husbands and their wives regarding politics, Alternatively, we can conduct the analysis using the normal distribution approximation, as we did in Example 2 of Mann-Whitney Test. This time, we calculate a mean of 203 (cell N8), variance of 1928.5 (cell N9) and standard deviation of 43.9 (cell N10). From these we calculate a z-score of 2.57, which yields a p-value of .005 (one-tail test), which is less than α = .05, and so once again we reject the null hypothesis.

**Real Statistics Excel Functions**: The following functions are provided in the Real Statistics Pack:

**SRankPair**(R1) = *T* for a pair of samples contained in range R1, where R1 consists of two columns, one for each paired sample. R1 must contain only numeric values.

**SRTESTPair**(R1) = p-value for Signed-Ranks Test using the normal distribution approximation for the pair of samples contained in range R1, where R1 consists of two columns, one for each paired sample. R1 must contain only numeric values.

**SRankCRIT**(*n, α, t*) = critical value of the Signed-Ranks Test for samples of size *n* for the given value of alpha and *t* = 1 (one tail) or 2 (two tails).

There are also two argument versions of SRankPair and SRTEST, namely:

**SRankPair**(R1, R2) = *T* for a pair of samples contained in ranges R1 and R2, where both R1 and R2 have only one column, one for each paired sample. R1 and R2 must contain only numeric values and they must have the same number of elements.

**SRTESTPair**(R1, R2) = p-value for Signed-Ranks test using the normal distribution approximation for the pair of samples contained in range R1 and R2, where both R1 and R2 have only one column, one for each paired sample. R1 and R2 must contain only numeric values and they must have the same number of elements.

These functions ignore any empty or non-numeric cells.

SRTESTPair returns the one-tail version of the Wilcoxon Signed-Ranks test. Simply double the p-value generated to obtain the two-tail test.

**Observation**: In Example 1, we can use the supplemental function to arrive at the same value for *T*, namely SRankPair(B4:C18) = 35.5.

Similarly in Example 2 we can use the supplemental function to arrive at the same value for *T*, namely SRankPair(B4:C33) = 90, as well as the same p-value (assuming a normal approximation), namely SRTESTPair(B4:C33) = 0.005039.

We can also use the two argument versions of these functions to get the same results, namely SRankPair(B4:B33, C4:C33) = 90 and SRTESTPair(B4:B33, C4:C33) = 0.005039.

**Observation**: As for the Wilcoxon test for independent samples, we can use the correlation coefficient *r* as a measure of effect size where

Here 2*n* = the number of observations, including the cases where the difference is 0. For Example 2

which represents a medium-sized effect.

**Real Statistics Data Analysis Tool**: The Real Statistics Resource Pack also provides a data analysis tool which performs the Wilcoxon signed-ranks test for paired samples, automatically calculating the medians, *T* test statistic, z-score, p-value and effect size *r*.

For example, to use this data analysis tool for Example 2, enter **Ctrl-m** and choose **T Tests and Non-parametric Equivalents** for the menu. A dialog box will appear as in Figure 3 in Mann-Whitney Test for Independent Sample. Enter B3:C33 in the **Input Range**, check **Column headings included with data**,** **choose the **Paired samples** and **Non-parametric** options and click on **OK**. The output is shown in Figure 3.

### Wilcoxon Signed-Ranks Test for a Single Sample

We can also use the Wilcoxon Signed-Ranks Test to test the following null hypothesis:

H_{0}: the median of the population is some given value ν

The approach we use is to apply the Wilcoxon Signed-Ranks test for paired samples, as described above, on a single sample {*x*_{1}, …, *x _{n}*} where we assume the second sample consists of

*n*values all of which are ν. We demonstrate approach this in Example 3 using the following supplemental functions.

**Real Statistics Excel Functions**: The following functions are provided in the Real Statistics Pack:

**SRank**(R1, *n*) = *T* for a single sample contained in range R1 less *n*, where R1 can be of any size and shape but must contain only numeric values. If the second argument is omitted it defaults to zero.

**SRTEST**(R1, *n*) = p-value for the Signed-Ranks test using the normal distribution approximation for the sample contained in range R1 less *n*, where R1 can be of any size and shape but must contain only numeric values. If the second argument is omitted it defaults to zero.

**SRankCRIT**(*n, α, t*) = critical value of the Signed-Ranks test for a sample of size *n* for the given value of alpha and *t* = 1 (one tail) or 2 (two tails). This is the same function that was described above for the paired samples case.

These functions ignore any empty or non-numeric cells.

SRTEST returns the one-tail version of the Wilcoxon Signed-Ranks test. Simply double the p-value generated to obtain the two-tail test.

**Example 3**: Determine whether the memory loss program described in Example 1 of the Sign Test is effective using the Wilcoxon Signed-Ranks Test.

We repeat the data from this example in Figure 4.

This time we compare the data from the single sample with the hypothetical median of 20%. We calculate *T* to be 40.5 using the formula SRank(D4:D18). We find the critical value for *T* when *n* = 14 to be 21 (two-tail test) from the Wilcoxon Signed-Ranks Table. Since 40.5 > 21, we cannot reject the null hypothesis and conclude again that there is no significant difference between the median of the data and 20%.

Using the normal distribution approximation, we see that SRTEST(B4:B18,20) = SRTEST(D4:D18) = .225629 > .05 = *α*, and so again conclude there is no significant difference between the median of the data and 20% (one-tail test).

Note that one way to calculate that *n* = 14 is to use the formula:

=COUNTIF(B4:B18,”<>”&20).

**Real Statistics Data Analysis Tool**: The Real Statistics Resource Pack also provides a data analysis tool which performs the Wilcoxon signed-ranks test for one sample, automatically calculating the median, *T* test statistic, z-score, p-value and effect size *r*.

For example, to use this data analysis tool for Example 3, enter **Ctrl-m** and choose **T Tests and Non-parametric Equivalents** for the menu. A dialog box will appear as in Figure 3 in Mann-Whitney Test for Independent Sample. Enter B3:B18 in the **Input Range**, check **Column headings included with data** and enter 20 for the **Hypothetical Mean/Mean**. Next choose the **One sample** and **Non-parametric** options and click on **OK**. The output is shown in Figure 5.

Hi,

I have downloaded your functions which are very helpul and thanks a lot for this.

The problem lies in SRankPair()which does not calculate.

Pls let me know whether you plan to fix the bug.

Much appreciating your assistance.

Hi Dinos,

I am pleased that you found the functions useful. I am sorry that the SRankPair function didn’t work. I will test the function tonight and see what the problem is. Sorry for any delay, but I am moving house and so things are a bit delayed.

Charles

Dinos,

I just tested the SRankPair() function and I found that it works just fine on my computer. Please make sure that you give the function one argument, consisting of a range with two columns. For example to calculate the value of the function for two samples in ranges E1:E10 and F1:F10 use the function SRankPair(E1:F10) and not SRankPair(E1:E10,F1:F10). The two samples must be contained in two contiguous columns of the same size starting in the same rows. I will introduce a two argument version of the function in a future release.

If this doesn’t address your problem, please send me the data that you used and range where the data was entered and I will try to duplicate the problem.

Charles

Update(20 July 2013): The new release of the Real Statistics Resource Pack, R1.4, now removes the restriction that the two ranges be contiguous. You can use the function SRankPai(R1, R2) where R1 and R2 are not contiguous.Hi Charles,

Thank you very much for putting all this information up for free – its all really useful. I have data very similar to that in Example 1. Would you be able to walk me through how to get the results as shown in columns F and K? I am assuming I use the SRankPair function for column F (inputting the data from columns A and B), but how do I get column K?

Thanks in advance,

Robin

Hi Robin,

Column F is calculated using the RANK.AVG function in Excel 2010/2013 (or the RANK_SUM supplemental function with earlier versions of Excel).

Cell K6 uses the formula =COUNT(E4:E18), cell K7 uses the formula =MIN(G19:H19), cell K8 uses the supplemental formula =SRankCRIT(K6,K4,K5) (or you can look up the value in the Wilcoxon Signed Rank Table).

You can check all of this out by downloading the Real Statistics Examples Workbook, which contains the worksheets for all the examples in the website.

Charles