I have a set of data with high variability and I want to use the median instead of mean to calculate the P value between conditions. So what test should I use and how to perform it ?

A common two-sample median test is Mood's median test. If there are more than two samples, it is sometimes called Brown-Mood median test. This test is available in R and SAS, and I think that's the median test that SPSS uses. It is also fairly easy to do by hand as well.

The non-parametric tests, Mann-Whitney for two independent samples or use Kruskal-Wallis test for three or more independent samples will be suitable for this situation.

Khalid Hassan , Asaad Yheia , the Wilcoxon-Mann-Whitney and Kruskal-Wallis tests are not tests of the median, except in special cases, as Pavlos Kolias suggests.

The median test does not compare medians. It measures a likely consequence of equality of medians, but it can be significant when the medians are the same.

Quantile regression tests for differences between medians.

It is correct as written, but notice the conditions it sets as an assumption: If the populations differ at all, they differ only with respect to their medians, then it tests a hypothesis about the medians. This is similar to the condition listed by Pavlos Kolias .

That may be a useful way to look at the WMW test in those conditions. But the general form of the test doesn't have those conditions. And I think in general, if we are using a nonparametric test, we probably aren't interested in imposing additional restrictions on the distributions of the populations.

Ronán Michael Conroy , good suggestion on quantile regression.

With "median test", are you talking about Mood's median test? I haven't seen the claim before that this test could turn a significant result if the medians are the same †. Do you have any references, examples, discussion to share?

__________

† Other than usual considerations of type 1 and type 2 errors.

The use of mean of median (i.e. parametric vs. non-parametric variables) should be tested first using normality tests, than if data did not follow normal distribution you can use non-parametric methods (Mann Whitney test, Kraskul Wallis test, etc)

@HayderFawzi , I would like to disagree with you on a few points.

First, there are no such things as parametric or nonparametric variables. It is the tests that are parametric or nonparametric, not the data.

Second, the process of choosing a test based on the results of a test for normality is a bad idea. In theory, making one test contingent on another distorts the p-value of the test. But practically, tests for normality are sensitive to sample size. So for large sample sizes, they are likely to return a significant result even if the deviations from normal are small. This process is definitely on the list of bad advice that has caused immense amounts of unnecessary distress for young researchers. See also: https://www.researchgate.net/publication/299497976_Silly_or_Pointless_Things_People_Do_When_Analyzing_Data_1_Testing_for_Normality_as_a_Precursor_to_a_t-test

Finally, Mann-Whitney and Kruskal-Wallis are not tests for the median. They really aren't, except in certain circumstances. The Handbook of Biological Statistics has an example of data where the medians of three groups are the same, and result in a significant Kruskal-Wallis test (http://www.biostathandbook.com/kruskalwallis.html). If that doesn't convince people, I don't know what will.