# One sample Wilcoxon signed-rank test

This page offers all the basic information you need about the one sample wilcoxon signed-rank test. It is part of Statkat’s wiki module, containing similarly structured info pages for many different statistical methods. The info pages give information about null and alternative hypotheses, assumptions, test statistics and confidence intervals, how to find p values, SPSS how-to’s and more.

To compare the one sample wilcoxon signed-rank test with other statistical methods, go to Statkat's or practice with the one sample wilcoxon signed-rank test at Statkat's

##### When to use?

Deciding which statistical method to use to analyze your data can be a challenging task. Whether a statistical method is appropriate for your data is partly determined by the measurement level of your variables. The one sample wilcoxon signed-rank test requires one variable of the following type:

 One of ordinal level

Note that theoretically, it is always possible to 'downgrade' the measurement level of a variable. For instance, a test that can be performed on a variable of ordinal measurement level can also be performed on a variable of interval measurement level, in which case the interval variable is downgraded to an ordinal variable. However, downgrading the measurement level of variables is generally a bad idea since it means you are throwing away important information in your data (an exception is the downgrade from ratio to interval level, which is generally irrelevant in data analysis).

If you are not sure which method you should use, you might like the assistance of our method selection tool or our method selection table.

##### Null hypothesis

The one sample wilcoxon signed-rank test tests the following null hypothesis (H0):

H0: $m = m_0$

Here $m$ is the population median, and $m_0$ is the population median according to the null hypothesis.
##### Alternative hypothesis

The one sample wilcoxon signed-rank test tests the above null hypothesis against the following alternative hypothesis (H1 or Ha):

H1 two sided: $m \neq m_0$
H1 right sided: $m > m_0$
H1 left sided: $m < m_0$
##### Assumptions

Statistical tests always make assumptions about the sampling procedure that was used to obtain the sample data. So called parametric tests also make assumptions about how data are distributed in the population. Non-parametric tests are more 'robust' and make no or less strict assumptions about population distributions, but are generally less powerful. Violation of assumptions may render the outcome of statistical tests useless, although violation of some assumptions (e.g. independence assumptions) are generally more problematic than violation of other assumptions (e.g. normality assumptions in combination with large samples).

The one sample wilcoxon signed-rank test makes the following assumptions:

• The population distribution of the scores is symmetric
• Sample is a simple random sample from the population. That is, observations are independent of one another
##### Test statistic

The one sample wilcoxon signed-rank test is based on the following test statistic:

Two different types of test statistics can be used, but both will result in the same test outcome. We will denote the first option the $W_1$ statistic (also known as the $T$ statistic), and the second option the $W_2$ statistic. In order to compute each of the test statistics, follow the steps below:
1. For each subject, compute the sign of the difference score $\mbox{sign}_d = \mbox{sgn}(\mbox{score} - m_0)$. The sign is 1 if the difference is larger than zero, -1 if the diffence is smaller than zero, and 0 if the difference is equal to zero.
2. For each subject, compute the absolute value of the difference score $|\mbox{score} - m_0|$.
3. Exclude subjects with a difference score of zero. This leaves us with a remaining number of difference scores equal to $N_r$.
4. Assign ranks $R_d$ to the $N_r$ remaining absolute difference scores. The smallest absolute difference score corresponds to a rank score of 1, and the largest absolute difference score corresponds to a rank score of $N_r$. If there are ties, assign them the average of the ranks they occupy.
Then compute the test statistic:

• $W_1 = \sum\, R_d^{+}$
or
$W_1 = \sum\, R_d^{-}$
That is, sum all ranks corresponding to a positive difference or sum all ranks corresponding to a negative difference. Theoratically, both definitions will result in the same test outcome. However:
• Tables with critical values for $W_1$ are usually based on the smaller of $\sum\, R_d^{+}$ and $\sum\, R_d^{-}$. So if you are using such a table, pick the smaller one.
• If you are using the normal approximation to find the $p$ value, it makes things most straightforward if you use $W_1 = \sum\, R_d^{+}$ (if you use $W_1 = \sum\, R_d^{-}$, the right and left sided alternative hypotheses 'flip').
• $W_2 = \sum\, \mbox{sign}_d \times R_d$
That is, for each remaining difference score, multiply the rank of the absolute difference score by the sign of the difference score, and then sum all of the products.
##### Sampling distribution

Sampling distribution of $W_1$ and of $W_2$ if H0 were true:

Sampling distribution of $W_1$:
If $N_r$ is large, $W_1$ is approximately normally distributed with mean $\mu_{W_1}$ and standard deviation $\sigma_{W_1}$ if the null hypothesis were true. Here $$\mu_{W_1} = \frac{N_r(N_r + 1)}{4}$$ $$\sigma_{W_1} = \sqrt{\frac{N_r(N_r + 1)(2N_r + 1)}{24}}$$ Hence, if $N_r$ is large, the standardized test statistic $$z = \frac{W_1 - \mu_{W_1}}{\sigma_{W_1}}$$ follows approximately the standard normal distribution if the null hypothesis were true.

Sampling distribution of $W_2$:
If $N_r$ is large, $W_2$ is approximately normally distributed with mean $0$ and standard deviation $\sigma_{W_2}$ if the null hypothesis were true. Here $$\sigma_{W_2} = \sqrt{\frac{N_r(N_r + 1)(2N_r + 1)}{6}}$$ Hence, if $N_r$ is large, the standardized test statistic $$z = \frac{W_2}{\sigma_{W_2}}$$ follows approximately the standard normal distribution if the null hypothesis were true.

If $N_r$ is small, the exact distribution of $W_1$ or $W_2$ should be used.

Note: if ties are present in the data, the formula for the standard deviations $\sigma_{W_1}$ and $\sigma_{W_2}$ is more complicated.
##### Significant?

This is how you find out if your test result is significant:

For large samples, the table for standard normal probabilities can be used:
Two sided:
Right sided:
Left sided:
##### Example context

The one sample wilcoxon signed-rank test could for instance be used to answer the question:

Is the median mental health score of office workers different from $m_0 = 50$?
##### SPSS

How to perform the one sample wilcoxon signed-rank test in SPSS:

Specify the measurement level of your variable on the Variable View tab, in the column named Measure. Then go to:

Analyze > Nonparametric Tests > One Sample...
• On the Objective tab, choose Customize Analysis
• On the Fields tab, specify the variable for which you want to compute the Wilcoxon signed-rank test
• On the Settings tab, choose Customize tests and check the box for 'Compare median to hypothesized (Wilcoxon signed-rank test)'. Fill in your $m_0$ in the box next to Hypothesized median
• Click Run
• Double click on the output table to see the full results
##### Jamovi

How to perform the one sample wilcoxon signed-rank test in jamovi:

T-Tests > One Sample T-Test
• Put your variable in the box below Dependent Variables
• Under Tests, select Wilcoxon rank
• Under Hypothesis, fill in the value for $m_0$ in the box next to Test Value, and select your alternative hypothesis