☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Fluorite | Level 6

## Median difference using MannU and quantile regression

Hi, I am looking to determine whether two medians are not equal and attempt to estimate the median difference between the two. From my research, I have found this can be done by performing the Wilcoxon Mann u test and quantile regression. However, I am confused on interrupting the for results each. Below if my data, code for both, results, and interpretation.

I think I am in the right direction but: Having trouble with the median difference estimate interpretation as well as understanding why the discrepancy in significance results.

Happy to clarify anything that may have been unclear and appreciate the support.

Mann U (npar1way) median a median b median diff pval (kruskalW) hodgeL
Interpretation            601          642              41                 0.01 issue getting to load
Median A and Median B are considered to be significantly different (difference=41, p<.05) as determined by the mannU test
Quantile regression median a median b median diff                   pval
Interpretation             601            642           34 (-74 - 143.78)     0.524
Median A and Median B are not considered to be significantly different (difference= 34.5 (-74.7 - 143.78), p=.52) as determined by quantile regression

``````*Determine medians of the two groups;
proc means data=test_data median;
var y;
class x;
run;
*Perform W-Mann-U test using KW for results;
*HL for median difference not loading, useful?;
proc npar1way data=test wilcoxon median;
class x;
var y;
exact hl / maxtime=60;
run;
*Quantile regression to determine median difference estimate and signifiance difference;
proc quantreg data=test_data;
class x;
model y= x/ quantile=.5;
estimate x 1 -1 /CL;
run;``````

1 ACCEPTED SOLUTION

Accepted Solutions
Obsidian | Level 7

## Re: Median difference using MannU and quantile regression

The null hypothesis of Kruskal-Wallis test and Wilcoxon rank sum test is the mean ranks of two groups are the same, not the medians of two groups are equal. When the distributions of two samples are different, even they have equal median or mean, the two tests can still reject the null hypothesis, and conclude the two distributions are significantly different. So if you want to compare medians, the quantile regression or the CI of medians can be used as the link described given by @Rick_SAS.

Sorry I don't know much about Hodges-Lehmann CI of median, so cannot answer why the results from EXACT HL is different from the results of PROC QUANTREG.

2 REPLIES 2
SAS Super FREQ

## Re: Median difference using MannU and quantile regression

For experts who are wondering why PROC QUANTREG is being used, the OP appears to be using information and sample code from the blog post "Quantile estimates and the difference of medians in SAS."

Obsidian | Level 7

## Re: Median difference using MannU and quantile regression

The null hypothesis of Kruskal-Wallis test and Wilcoxon rank sum test is the mean ranks of two groups are the same, not the medians of two groups are equal. When the distributions of two samples are different, even they have equal median or mean, the two tests can still reject the null hypothesis, and conclude the two distributions are significantly different. So if you want to compare medians, the quantile regression or the CI of medians can be used as the link described given by @Rick_SAS.

Sorry I don't know much about Hodges-Lehmann CI of median, so cannot answer why the results from EXACT HL is different from the results of PROC QUANTREG.

Discussion stats
• 2 replies
• 798 views
• 2 likes
• 3 in conversation