# Is it possible to get a CI for the difference in median response between two groups via Dunn test?

Dunn test for two groups is equivalent to Kruskal-Wallis. The null is the absence of stochastic dominance, but if we impose some more restrictions we can assume that the null is the equality of medians, $H_0: M1 = M2$.

Apparently, the Dunn test statistic is assumed Normal, but it is computed in rank terms, not in terms of the original observations. Therefore, we can obtain p-value for $H_0$, but no explicit CI for $(M1 - M2)$.

1) Is it ok to assume that $(M1 - M2)$ is also Normal? If yes, we can use the point estimate and p-value to derive the s.e. and construct a confidence interval.

2) This question is not related to 1). I would like to get p-value for $H_0 : M1/M2 = 1$. Let's assume no ties. Then, using the fact that the Dunn p-value is invariant to a monotone transformation of the original response, $Y$, and that $log(median(Y)) = median(log(Y))$, it looks like the p-value for $M1/M2$ is exactly the same as for $M1 - M2$. Did I get that right?

• Why you want to use Dunn test? What is your task?
– zlon
Feb 12 '17 at 7:51
• Dunn's test is a post-hoc modification of Mann-Whitney. Why are you speaking of specifically Dunn in your context? Feb 12 '17 at 9:46
• Because the original problem has more than two groups. I need to produce the model p-value which is done by K-W and then contrast p-values which is done by Dunn. The contrast p-value should be the same as the model p-value in case of two groups. It seems to be the case if I use Dunn, but not M-W. On top of that, I need CI for the contrasts. Feb 13 '17 at 15:15
• Is it Ok for you if it will be 1 test for both N groups and 2 groups?
– zlon
Feb 18 '17 at 11:20

## 2 Answers

(Note by the way that the Kruskal-Wallis test for two samples is also identical to the asymptotic Wilcoxon-test. The Dunn-test is a multiple comparison procedure, but if you have only a single comparison --between group 1 and 2-- it simplifies to the Wilcoxon-test. This explains some comments.)

1) If it would be normally distributed, then the Dunn test would not have been used because it would not have been reasonable to "swallow" this distributional information by the ranks if it were true, i.e. you would leave the "nonparametric world" by assuming normality of the median difference.

However, there are procedures to calculate CIs for your case. For the "relative effect", i.e. the probability, that an observation from group 1 is larger than an observation from group 2 (or from all the groups in the multisample case), see the nparcomp package. It implements the Dunn-test, as well, so you should be able to reproduce all the results you already have with this package, but you can get matching simultaneous CI, too. See the references in the package documentation.

2) The p-values are the same. Monotonous transformations don't change the ranks. But the $log$ changes the hypothesis in terms of the original data form "no difference" to "ratio = 1".

• "The test statistic's distribution is often very different from the observation's distribution" - the difference or ratio of sample medians is also a test statistic. I didn't ask whether I can consider Y itself to be Normal. Feb 19 '17 at 5:32

You may calculate numerical F-statistic and It's confidence interval for 2 and N groups. Here described how to find p-values. But absolutely same approach may be used for CI's. Just calculate 95% (or whatever You wish) quantiles for null distributions. Code is attached in link above.

If you will describe Your problem more concretely We'll be able to help You better.

# Update

1) You may sample observations from X1 and X2 independently with replacement. For each sample you calculate $M=M1-M2$. Thus, you obtain non-parametric distribution of $M1-M2$

2) Similar to 1 You may obtain null-distribution $M=M1/M2$ and have it's CI's

3) If You want to test hypothesis then just sample Your grouping variable (which shows to which group belongs observation) without replacement. For each sample calculate statistic from step 1 or 2 (whatever you like more). So, you have observed statistic $S_{observed}$ and distribution of sampled statistic $S_{sample}$. Now you may calculate how many samples have higher $S_{sample}$ then $S_{observed}$. Let's say it will be $N$. Than the probability, that statistic under null-hypothesis (random grouping) is higher that $S_{observed}$ will be $N/(Number of Samples+1)$. You should add 1, as you observation is also inside null-distribution.

• Thank you, but I am not interested in resampling in this case. Feb 19 '17 at 2:57