# How is median of the difference calculated in Mann Whitney U test (TOST)?

I'm running wilcox_TOST in R and below is the result. If Mann Whitney U test is equal to Wilcoxon Rank Sum Test and considering what this test does (e.g., ranking the data and summing the ranks etc.,) there's no median of the difference used or reported anywhere. I'm wondering:

1- what the median of the difference is showing here? median of what difference? and 2- why is 95% CI reported for it and not an interquartile range that is usually reported for medians?

Wilcoxon rank sum test with continuity correction

The equivalence test was non-significant W = 252.500, p = 9.41e-01
The null hypothesis test was significant W = 284.000, p = 1.85e-02

NHST: reject null significance hypothesis that the effect is equal to zero
TOST: don't reject null equivalence hypothesis

TOST Results
Test Statistic p.value
NHST                284.0   0.018
TOST Lower          317.0 < 0.001
TOST Upper          252.5   0.941

Effect Sizes
Estimate            C.I. Conf. Level
Median of Differences       1.2500     [0.4999, 2]         0.9
Rank-Biserial Correlation   0.4753 [0.183, 0.6904]         0.9

• median of differences of every cross-sample pair, $A_i-B_j$. Commented Feb 2 at 21:23

The median of the differences is also called the Hodges-Lehmann statistic, or pseudomedian in the single-sample case. Its calculation is quite straightforward: for each observation in one sample, calculate the difference (i.e. subtract) from all observations in the other sample. The HL statistic is then the median of all these values.

TOSTER::wilcox_TOST just calls stats::wilcox.test internally, you can easily verify by hand as well:

set.seed(1)
x <- runif(5, min=.2, max=.5)
y <- runif(5, min=.4, max=.7)

median(outer(x, y, "-"))
> -0.2866022

## Verify against wilcox.test
wilcox.test(x, y, conf.int=TRUE)
> difference in location
>             -0.2866022


The calculation of the confidence interval is quite a bit more involved - you can have a look at wilcox.test if you want to know more - but the reason it's being returned here is because you are performing inference on the (difference in) location of your sample(s), and not describing the population distribution as a whole.

An interquartile range tells you: between which values do I expect half of my population to be? Glossing over the intricacies of what a frequentist confidence interval means exactly, it roughly answers: how precisely have I estimated this particular parameter? As your sample size increases the width of the former should stay just about the same, whereas the width of the latter goes to zero. This is akin to the difference between a standard deviation and a standard error of the mean: they are answers to different questions.