Calcite | Level 5

## difference between two medians - 95% CI

how can I get the 95% confidence interval for the difference between two medians?

9 REPLIES 9
SAS Super FREQ

## Re: difference between two medians - 95% CI

The NPAR1WAY procedure uses nonparametric tests to compare independent distributions. You can use the WILCOXON option to test for difference in location and use the MEDIAN option to requests the median test for difference. An example is provided in the documentation of PROC NPAR1WAY.

Calcite | Level 5

## Re: difference between two medians - 95% CI

yes, but it does not provide the 95% confidence interval for the difference between the two medians.  do you know how to get that?

## Re: difference between two medians - 95% CI

Calcite | Level 5

## Re: difference between two medians - 95% CI

No, that is for paired.  My scenario is for unpaired.

Super User

## Re: difference between two medians - 95% CI

Isn't odd to use the 95% CI for medians? Isn't the IQR or a different non parametric estimate used instead?

## Re: difference between two medians - 95% CI

@msecic wrote:

No, that is for paired.  My scenario is for unpaired.

Look again.

Fluorite | Level 6

## Re: difference between two medians - 95% CI

When I look at this output, am I to understand that the location shift represents the median difference?

Can someone comment on the relative merit of the Hodges-Lehmann approach vs bootstrapping. I was advised to use bootstrapping. is there a coding model I could use?

Many thanks!

SAS Super FREQ

## Re: difference between two medians - 95% CI

It would take many pages to provide a complete answer to your question. Briefly,

- The H-L estimate is robust to extreme values b/c it is based on robust statistics.

- The CI for H-L is computed based on the asymptotic distribution of the H-L statistic under the null hypothesis (no difference between group locations)

- The bootstrap estimate is based on assuming that the population is well-represented by the sample. If your sample is small, contains rounded values, or contains a disproportional number of unusual observations, it might not be representative.

- In particular, a bootstrap analysis that involves medians of rounded values can lead to situations where the bootstrap distribution is not a good appr... to the actual distribution of the statistic. In those cases, you might need to use the smooth bootstrap.

- The bootstrap process gives you the approximate distribution of the statistic for the sample sizes w/o using any asymptotics.

If you choose to pursue bootstrapping, the answer should be close to the H-L estimates, so you have some basis for deciding whether your bootstrap analysis is correct. As for coding, you can start by reading "The Essential Guide to Bootstrapping in SAS,"

Although your advisor said to use bootstrapping, I think this problem is actually a "permutation test" rather than a bootstrap problem. You can see the article "Resampling and permutation tests in SAS," which computes a permutation test for the mean-difference problem. If you have SAS/IML, you can replace each call to the MEAN function with a call to the MEDIAN function.

Fluorite | Level 6

## Re: difference between two medians - 95% CI

This was very helpful thank you. I have also looked into using quantile regression. I have examined the dataset using HL, bootstrapping and quantile regression. The findings are essentially the same with each approach.

Discussion stats
• 9 replies
• 7011 views
• 5 likes
• 5 in conversation