BookmarkSubscribeRSS Feed
msecic
Calcite | Level 5

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

9 REPLIES 9
Rick_SAS
SAS Super FREQ

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.

msecic
Calcite | Level 5

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

msecic
Calcite | Level 5

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

Reeza
Super User

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

data_null__
Jade | Level 19

@msecic wrote:

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


Look again.

GMartel
Fluorite | Level 6

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!

Rick_SAS
SAS Super FREQ

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.

GMartel
Fluorite | Level 6

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.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

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