The **Mood’s Median Test**, essentially a two sample version of the Sign Test, is used to determine whether the median of two independent samples are equal. To perform this test, you need to execute the following steps:

- Calculate the total median
*m*of the combination of the two samples. - Create a 2 × 2 contingency table whose first row consists of the number of elements in each sample that are greater than
*m*and whose second row consists of the number of elements in each sample that are less than or equal to*m* - Perform a chi-square test of independence
- If p-value <
*α*then the medians of the populations from which the two samples are derived are unequal; otherwise they are equal

**Example 1**: Repeat Example 2 of Two Sample t-Test with Equal Variance to determine whether the Drug and Control groups have the same median based on the data in Figure 1.

**Figure 1 – Data for Example 1**

As can be seen in Wilcoxon Ranked Sum Test when we repeat this example using the Wilcoxon ranked sum test, this data is not normally distributed and so we need to use a non-parametric test.

We execute the steps in Mood’s Median Test as shown in Figure 2. Column I shows the formulas used in column F.

**Figure 2 – Mood’s Median Tests for two samples**

Since p-value = .0405 < .05 = *α*, we reject the null-hypothesis, and conclude there is a significant difference between the two population medians.

**Observation**: Generally the Wilcoxon Rank Sum or Mann-Whitney test is used instead of Mood’s Median Test since they provide more accurate results.

**Real Statistics Functions**: The Real Statistics Pack provides the following functions:

**MOODS_STAT**(R1) = the chi-square test statistic for Mood’s Median test where R1 contains the sample data.

**MOODS_TEST**(R1) = the p-value statistic for Mood’s Median test where R1 contains the sample data.

For Example 1, MOODS_STAT(B4:C15) = 4.196 and MOODS_TEST(B4:C15) = .0405.

**Observation**: Mood’s Median Test can also be applied to more than two samples and can be viewed as a weak version of the Kruskal-Wallis test.

Hi Charles,

Very many thanks for all of the fantastic info on your site.

I am trying to replicate the example you have here in R and am failing to get the same p-value as yourself. If I use the exact method based on Fisher I get a p-value = 0.0995. I can get to this value by either using this code:

control = c(11,15,9,4,34,17,18,14,12,13,26,31)

drug = c(34,31,35,29,28,12,18,30,14,22,10,29)

data = c(control, drug)

label = gl(2, 12, labels = c(“Control”,”Drug”))

mood.medtest(data~label, exact = TRUE)

or by using this function:

median.test <- function(x, y){

z <- c(x, y)

g <- rep(1:2, c(length(x), length(y)))

m <- median(z)

fisher.test(z < m, g)$p.value

}

median.test(drug,control)

If I set exact in the first example to FALSE, which then uses a chi-squared test with a Yates continuity correction, I get a p-value of 0.1013, and if I try the following on the contingency table you give above:

a = matrix(data = c(3,8,9,4), nrow=2, ncol=2, byrow=TRUE)

chisq.test(a)

I also get a p-value of 0.1013

Can you shed some light on what might be happening here?

Thanks again for the really great resource you've created here.

Phil

Phil,

Thanks for the clarification. It is difficult for me to comment since I don’t use R and so don’t know what assumptions are being made. Did you see a specific error in what I wrote?

Charles

Charles,

I want to know which statistical test has to be used to compare medians among 3 groups i.e which is the analogous test similar to repeated measures ANOVA i.e median scores compared for same group at 3 time intervals (baseline, 3 months and 6 months)

Madhu,

The usual nonparametric test is Friedman’s Test.

Charles

Hi Charles,

I still do not understand Mood”s median test (for two samples), does it work for two samples with two different sample size? If so, I just use SAS did, proc code as following:

proc npar1way mood median data=expensediff;

var difference;

class group_cd;

run;

and the outputs for this step include median scores, median two_sample test, frequency above and below the overall median, and mood scores, Mood Two-Sample Test, distribution of mood scores.

but I am still confusing about the purpose for Mood’s Median Test, because I did not learn anything about it when I was in university.

Yang,

Mood’s median test can be used with samples of different sizes.

Usually there are other tests that can be used instead which have more power, which is probably why you didn’t learn about it when you were in university.

Charles

Hey Charles,

Very many thanks for the fantastic info about the Test and your Excel Add-on.

I have one Question. How is it possible, or is it possible to use the Mood’s Median-Test for a one side test ? Respectively to evaluate which sample has the smaller values.

Maximillian,

I am not aware of a one-sided version of Mood’s Median Test.

If the test shows a significant difference between the medians, then it is safe to say that the group with the smaller sample median is the one with the smaller population median (with 100xalpha degree of confidence).

Charles

Tank you very much, for your answer.

Maximilian

Hi Charles,

From this test, is it possible to tell whether or not two samples came from the same population?

K

No. This test doesn’t go that far.

Charles

thank you very much Mr Charles.

i just need a clarification. i compared survival rates between two fly groups using both mood’s median test and Mann whitney. all were not significant, i wish to know wich one is best to report on and possibly why.

Best regards

Bertrand

You need to tell me more about the nature of your data before I am able to answer your question.

Charles

Hello Charles,

I can’t find the =chi_stat, or =chi_test formulas on excel.

Do I need an add-in?

Thank you in advance,

Pablo

Pablo,

Yes, you need the Real Statistics add-in.

Charles

Can any one tell me the formula of The Median test for four samples??

Zanish,

See the following webpage:

Mood’s Median Test

Charles

Dear Charles,

I tested your two sample example of your site (median = 18, x^2 = 4.195, p = 0.0405) with the corresponding median test calculator of IFA (http://www.fon.hum.uva.nl/Service/Statistics/Median_Test.html) and I obtain the following results : median = 18, p = 0.0995 but without the corresponding numerical result for x^2.

Dear Charles,

I would strongly appreciate if you could give me a “scientific” explanation about this discrepancy.

Yours faithfully,

Alcibiades (B.C. 450 – B.C. 404)

In comparing your results with the corresponding ones from IFA (Holland) site, I found :

yours : p =

Alcibiades,

Thanks for your question. It forced me to relook at Mood’s Median test. The version that I explain on the Real Statistics website is based on a chi-square test for independence, which is reasonably accurate for larger samples, especially when none of the cells is less than 5. Since z is normally distributed if and only z^2 has a chi-square distribution, probably the approximation described on the referenced website that you provided is equivalent for large samples (or at least similar). I hedge because the site doesn’t say that it is using the Mood’s test, although it probably is.

Since I don’t have the data you used, I looked at the data on the website that you referenced. The samples there are small (9 and 12) and so they didn’t use the normal approximation, but used a permutation test instead. This is probably similar to the Fisher exact test, although I can’t say for sure, especially since they said that they would carry out the calculations favoring the null hypothesis. They came up with a result of p = .0484.

When I carried out the Mood Median test using the Real Statistics software I got p-value = .00372. This is based on a chi-square test where one of the four cells has a value of 1. This is not a good fit for the chi-square test. When I used the Fisher Exact Test, I got p-value = .00752.

I then noted that one of the values in sample 2 is 774, the exact same value as the overall median. In this case, we can optionally change the cell with value 1 to 2 (thereby favoring the null hypothesis). In this case, Fisher’s Exact Test yields the value .0300, which is still not the same as the value obtained on the referenced website, but much closer to that value.

I haven’t invested much effort into Mood’s Median test, simply because it is usually not used since other tests are more powerful. I any case, I plan to add the option to use the Fisher Exact Test version for small samples.

Charles

Thank you for explanation.

Mood’s median test is same as median test ?

if different then how they are different ?

I presume that they are the same, although perhaps there is another median test that I am not aware of.

Charles

Dear Charles

i am Tariq Hussain, Ph.D. scholor.

i read that Mood’s Median test is more Robust to outliers as compared to Krushkall wallis test. But i did not knew how to prove it?

Help me plz….

Tariq,

That may be true, I can’t say for sure, but since Kruskal-Wallis uses ranks it should be pretty robust to outliers.

Charles

Hi Charles,

I thought of another test you could add if you think it would be worthwhile – I decided to comment here since it compares the medians of two groups, much the same as Moods Median Test, but it is a parametric approach that should be more accurate. It’s called the Fligner-Policello test. In case you’re not familiar with it I’ll describe the procedure as succinctly as possible.

1) Arrange the values from the 2 groups in ascending numerical order.

2) For each value in group 1, figure out how many values in group 2 are greater than this value, and call this number x. Increase x by 0.5 for each tie found in group 2.

3) Add up all the x values, including the additions for ties if needed, and divide by the number of observations in group 1. This is x-bar.

4) Calculate the sum of the squared differences between each value in group 1 and x-bar.

5) Repeat steps 2-4 using the second group – find out how many values in group 1 are greater than each value in group 2, calculating x-bar and the sum of the squared differences as before.

6) The numerator of our test statistic is (Group 1 size*Group 1 x-bar) – (Group 2 size*Group 2 x-bar).

7) For the denominator of the test statistic, add together the sums of the squared differences for both groups, add to that the product of the two x-bars, then take the square root, and finally double the result.

8) Evaluate this against a z-score for the normal distribution with 2 tails; at an alpha of 0.05 in 2 tails this corresponds to +/- 1.96. So if the test statistic is more than 1.96 or less than -1.96 we can say that the null hypothesis of equal medians for the two groups is false.

If you need a written example, I’ll be happy to email you one. Perhaps you might find this to be an interesting alternative for a parametric approach. Thanks!

Sorry, but I made an error above. Apparently the FP test is in fact nonparametric in nature, but it should be more robust than Moods Test.

hi Charles

I was running a one sided hypothesis testing of comparing medians between two groups … serial measurements of a pain score(0-10) were taken 2 hours apart for 12 hours ie at 0 hour ,2 hour,4hour,6hour,8 hour,10 hour and 12 hour.. median score at o hour, 2 hour and 4 hour is same …but p value by mann-whitney u test is <0.05…..is mood's median test better in this case?

Why is a p-value from the Mann-Whitney test a problem? Mood’s median test doesn’t take the rankings into account and so I don’t have any reason to think that that test is better.

Charles