1
$\begingroup$

One way to obtain a (1-alpha)% confidence interval for the difference in medians for two samples is to use bootstrapping. Generate 10,000 bootstrap samples of both group's samples and find the difference in medians of each, forming a bootstrap distribution for the difference in medians. However, I am looking for a formula that would not require bootstrapping.

For example, the confidence interval for the difference in means (under appropriate assumptions) is (xbar1-xbar2) +/- t_0.025 * se , is there a similar formula for the difference in medians? Maybe a non-parametric test, but there has to be something, no?

$\endgroup$

1 Answer 1

1
$\begingroup$

There is a median test, based on a chi-square test. It breaks each group up into cases above and below the individual medians, and determines whether the frequencies of those groups differ from what would be predicted if all the data came from the same distribution. "[I]t only considers the position of each observation relative to the overall median," so it doesn't have much power to distinguish true differences in medians.

You will sometimes find the Wilcoxon-Mann-Whitney (WMW) test cited as a test for medians, but that is not a test for medians if the distributions being compared differ in symmetry or scale parameters. So although it's not a parametric test per se, you have to make some assumptions about the underlying distributions to use it as a test on medians.

And neither of those tests can provide confidence intervals (CI) for the difference in medians. With the WMW test, for example, what you can get with a 2-sample test, according to the manual page for wilcox.test, is:

a nonparametric confidence interval and an estimator... for the difference of the location parameters x - y ... the estimator for the difference in location parameters does not estimate the difference in medians (a common misconception) but rather the median of the difference between a sample from x and a sample from y.

That's why bootstrapping is so useful in situations like this: it doesn't require any assumptions about the underlying distributions, although in some cases it does require some care in finding the most reliable estimate of the CI. I understand some reluctance to approach bootstrapping if you haven't had any experience with it, but it's well worth your while to become familiar with it as it's useful in so many applications.

$\endgroup$
4
  • $\begingroup$ It's not that I do not trust bootstrapping, it's that I have a situation where I need to emulate the results of bootstrapping without using it (obviously some small tolerance is warranted due to the random nature of a bootstrap sampling.) $\endgroup$ Commented Aug 28, 2020 at 15:02
  • $\begingroup$ @StevenSarasin getting CI requires having a distribution function from which to get the desired limits. That distribution function is of an assumed form in parametric tests or empirical in bootstrapping. It's hard to think of a situation where you have the data and can't use bootstrapping. You might find some suitable hints on the page I linked for the Wilcoxon-Mann-Whitney test, for example a t-test based on data transformed to ranks. $\endgroup$
    – EdM
    Commented Aug 28, 2020 at 15:12
  • $\begingroup$ Both those tests can provide confidence intervals, e.g. for a shift alternative (though it won't necessarily be a ci for the desired difference in medians). Indeed the shift-parameter CI corresponding to the Wilcoxon-Mann-Whitney is available in many packages (R does it, simply by setting the relevant argument in the call). $\endgroup$
    – Glen_b
    Commented Aug 29, 2020 at 6:21
  • $\begingroup$ @Glen_b thanks, I've clarified in the answer what you can get with respect to CI for the WMW test. $\endgroup$
    – EdM
    Commented Aug 29, 2020 at 14:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.