# Wilcoxon signed-rank test can be a test for comparing means but not for comparing medians?

Wikipedia says that we can rewrite the hypotheses of the one-sample Wilcoxon signed-rank test in terms of expected value (as "a test for the location of the mean") if the following assumptions are met (below we have random iid sample $$(X_1,\ldots,X_n) \overset{\text{iid}}{\sim} F$$):

1. $$F$$ has unique median $$\mathrm{med}(X)$$ such that $$P(X = \mathrm{med}(X)) = 0$$;
2. $$F$$ is symmetric about $$\mathrm{med}(X)$$;
3. Expectation $$\mathrm{E}[X]$$ exists.

So, if these assumptions are met then $$\mathrm{med}(X) = \mathrm{E}[X]$$ and the hypotheses of the one-sample Wilcoxon signed-rank test are the following (for the two-sided alternative):

\quad\begin{aligned}H_0: ~\mathrm{med}(X) = 0 \\ H_1: ~\mathrm{med}(X) \neq 0 \end{aligned} \qquad \iff \qquad \begin{aligned}\widetilde{H_0}: ~\mathrm{E}[X] = 0 \\ \widetilde{H_1}: ~\mathrm{E}[X] \neq 0 \end{aligned}

Next, I tried to use the fact that paired Wilcoxon signed-rank test is just a special case of its one sample version (if we have paired samples $$(X_1,\ldots,X_n) \overset{\text{iid}}{\sim} F_1$$ and $$(Y_1, \ldots, Y_n) \overset{\text{iid}}{\sim} F_2$$, we just need to replace $$X$$ by difference $$X - Y$$ in the aforementioned formulas), and got the following.

Assumptions for the paired Wilcoxon signed-rank test:

1. Distribution of $$X - Y$$ has unique median $$\mathrm{med}(X-Y)$$ such that $$P(X - Y = \mathrm{med}(X-Y)) = 0$$;
2. Distribution of $$X - Y$$ is symmetric about $$\mathrm{med}(X-Y)$$;
3. Expectation $$\mathrm{E}[X-Y]$$ exists.

If these assumptions are met then $$\mathrm{med}(X-Y) = \mathrm{E}[X-Y]$$ and the hypotheses of the paired Wilcoxon signed-rank test are the following (for the two-sided alternative):

\quad\begin{aligned}H_0: ~\mathrm{med}(X-Y) = 0 \\ H_1: ~\mathrm{med}(X-Y) \neq 0 \end{aligned} \qquad \iff \qquad \begin{aligned}\widetilde{H_0}: ~\mathrm{E}[X-Y] = 0 \\ \widetilde{H_1}: ~\mathrm{E}[X-Y] \neq 0 \end{aligned}

This all seems fine but one thing confuses me: expectation is a linear operator, so we can rewrite $$\widetilde{H_0}$$ and $$\widetilde{H_1}$$ as $$\widetilde{H_0}: \mathrm{E}[X] = \mathrm{E}[Y]$$ and $$\widetilde{H_1}: \mathrm{E}[X] \neq \mathrm{E}[Y]$$ respectively. But population median is not a linear operator, hence we can't rewrite $$H_0$$ and $$H_1$$ as $$H_0: \mathrm{med}(X) = \mathrm{med}(Y)$$ and $$H_1: \mathrm{med}(X) \neq \mathrm{med}(Y)$$ respectively.
In other words, paired Wilcoxon signed-rank test (if the aforementioned assumptions are met) is a test for comparing the means of the paired samples, but it is not a test for comparing the medians of the paired samples. Is this conclusion right or wrong?

P.S. There is a post on SSE on similar topic, it claims that paired Wilcoxon signed-rank test can be a test of median difference (or mean difference) only if two fairly strict assumptions are met:

• The distribution of both groups must have the same shape.

• The variance of both groups must be equal.

These assumptions seem strange for me because, as far as I know, paired Wilcoxon signed-rank test is just a special case of its one-sample version. And I didn't met these two assumptions in other sources (I saw these assumptions in requirements for the Mann–Whitney U test but not for the Wilcoxon signed-rank test).

• In general it is not comparing medians but under the additional assumptions you made, it will be. Nov 18, 2021 at 0:00
• @Glen_b Does this mean that $\mathrm{med}(X-Y) = \mathrm{med}(X)-\mathrm{med}(Y)$ under these assumptions? If not, I still can't see how we can compare $\mathrm{med}(X)$ and $\mathrm{med}(Y)$ with each other. Nov 18, 2021 at 6:07

The one-sample signed-rank test is, precisely, a test for the median pairwise mean. That is, we can define pairwise means $$\Delta_{ij}=(X_i+X_j)/2$$, and the test statistic has its minimum value when the median of $$\Delta$$ is zero. As sample size increases, the test will eventually reject for any distribution where $$med[\Delta]\neq 0$$.
If the distribution is symmetric and the mean of $$X$$ exists, the median of $$\Delta$$ and the mean of $$X$$ and the median of $$X$$ are all the same; they are all the centre of symmetry. In that special case, the test is also a test for the median of $$X$$ and for the mean of $$X$$, because they are all the same. If the distribution is not symmetric, they are typically all different and the test is not a test for the mean of $$X$$ or the median of $$X$$.
Going on to paired tests, if $$X_i=Y_i-Z_i$$ then the test is still for the median pairwise difference fo $$X_i$$, and is for the mean or median of $$X$$ under the same assumptions as before. These are your second set of assumptions. Precisely because the median is not a linear functional, it takes additional assumptions for a test of the median to also be a test of the mean.
And finally, the situation for the Wilcoxon rank-sum test is very different. There is no one-sample summary statistic analogous to $$med(\Delta)$$ that the Wilcoxon rank-sum test is a test for (without additional assumptions). In fact, there is no ordering on all distributions that agrees with the Wilcoxon rank-sum test. It's possible to have three variables $$X$$, $$Y$$, $$Z$$ such that the Wilcoxon test thinks $$X$$ is bigger than $$Y$$, $$Y$$ is bigger than $$Z$$, and $$Z$$ is bigger than $$X$$.
• Thanks! But your statement "Precisely because the median is not a linear functional, it takes additional assumptions for a test of the median to also be a test of the mean." is slightly confusing - what is "the mean" here? Maybe you wanted to write "the medians (of $Y$ and $Z$)" instead? Nov 18, 2021 at 6:36