Mood’s Median Test (for two samples)

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.

Two samples data

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.

Mood's two-sample test

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.

25 Responses to Mood’s Median Test (for two samples)

  1. Kevin Bluxome says:

    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!

    • Kevin Bluxome says:

      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.

  2. Tariq Hussain says:

    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….

  3. Geeta Shah says:

    Thank you for explanation.
    Mood’s median test is same as median test ?
    if different then how they are different ?

  4. Alcibiades GOUSIS says:

    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 ( 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 =

    • Charles says:


      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.


  5. Zanish says:

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

  6. Pablo says:

    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,

  7. ndzeshang bertrand says:

    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

  8. K says:

    Hi Charles,

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


  9. Maximilian says:

    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.

    • Charles says:

      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).

  10. Yang says:

    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;
    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.

    • Charles says:

      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.

  11. Madhu says:


    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)

  12. Phil says:

    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

    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)
    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.


    • Charles says:

      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?

Leave a Reply

Your email address will not be published. Required fields are marked *