Mood's median test: compare medians with outliers present
Mood's median test compares the medians of two or more independent groups. It finds the median of all the data combined, counts how many values in each group fall above it and how many at or below it, and runs a chi-square test on that table. Because it only looks at which side of the grand median each value falls on, a wild outlier counts the same as any other value above the median. That makes it very robust, at the cost of some power.
When to use it
- Comparing typical values of several groups when the data contain outliers or very long tails that would distort means.
- Data with values censored at a limit (such as "more than 120 minutes"), where only the side of the median is certain.
- A quick, easy-to-explain comparison of medians, for example in a report for people who are not statisticians.
- When the data are cleaner, the Kruskal–Wallis test uses the full ranks and is usually more powerful.
How it works
With k groups:
- H₀: all groups have the same population median.
- H₁: at least one median differs.
Steps:
- Pool all N values and find the grand median M.
- For each group, count the values above M and the values at or below M. (Conventions for values exactly equal to M differ: some put them with "at or below", as here, and some drop them. When the grand median falls between two data values, as in the example, the question does not arise.)
- This gives a 2 × k table of counts. Under H₀, each group should have about half its values on each side.
- Run the Pearson chi-square test on the table:
χ² = Σ (Oᵢⱼ − Eᵢⱼ)² / Eᵢⱼ, Eᵢⱼ = (row total × column total) / N, df = k − 1The p-value is the upper tail of the chi-square distribution with k − 1 degrees of freedom. The usual chi-square rule applies: expected counts should be at least about 5, so each group needs roughly 10 or more values.
Assumptions: independent observations within and between groups; the groups' distributions have similar shapes if you want to read the result strictly as a statement about medians.
Example
A chemical plant filters each batch of a pigment slurry on a filter press. Filtration time drives the plant's throughput. Engineers trial three filter cloths, A, B and C, over 12 batches each, recording minutes to filter:
| Cloth | Filtration time (min) | Median |
|---|---|---|
| A | 42, 38, 45, 51, 40, 36, 47, 39, 44, 95, 43, 48 | 43.5 |
| B | 48, 55, 52, 46, 61, 50, 58, 49, 53, 57, 44, 51 | 51.5 |
| C | 41, 37, 43, 49, 39, 35, 52, 40, 38, 42, 36, 118 | 40.5 |
Two batches, 95 minutes on cloth A and 118 minutes on cloth C, had an unusual amount of fine particles that blinded the cloth. They are real results, but they say more about the slurry than about the cloths.
- Grand median of all 36 times: 45.5 minutes (between the 18th and 19th values).
- Counts:
| Cloth | At or below 45.5 | Above 45.5 |
|---|---|---|
| A | 8 | 4 |
| B | 1 | 11 |
| C | 9 | 3 |
| Total | 18 | 18 |
- Every expected count is 12 × 18 / 36 = 6.
- χ² = (8 − 6)²/6 + (4 − 6)²/6 + (1 − 6)²/6 + (11 − 6)²/6 + (9 − 6)²/6 + (3 − 6)²/6 = 12.67, with 3 − 1 = 2 df.
- p-value = 0.0018.
For comparison, a one-way ANOVA on the same data gives p = 0.73. The two long batches raise the means of cloths A and C to 47.3 and 47.5 minutes, close to cloth B's 52.0, and inflate the within-group variation. Kruskal–Wallis gives p = 0.0034.
How to read the results
- The p-value of 0.0018 says the cloths do not share one median filtration time.
- The table shows how. Cloth B puts 11 of its 12 batches above the grand median; cloths A and C put most of theirs below. Cloth B is the slow one, with a median about 8 to 11 minutes longer than the others.
- In plant terms, 8 to 11 extra minutes on a cycle of about 40 to 44 minutes means roughly 20 to 27% more press time per batch. Cloths A and C look equivalent on this evidence; the choice between them can rest on price and cloth life.
- Do not lose the outliers. The 95- and 118-minute batches point to a slurry problem (fines from an upstream step), which costs more than the cloth choice. Track it separately.
Common mistakes
- Using it when the data are well behaved. Mood's test throws away most of the information in the values. With few outliers, Kruskal–Wallis or ANOVA will detect smaller differences.
- Ignoring small expected counts. With fewer than about 10 values per group, some expected counts fall below 5 and the chi-square p-value becomes unreliable.
- Forgetting how values at the median were handled. Different conventions can change the counts when many values equal the grand median. Say which one you used.
- Reading equal medians as equal processes. Two cloths with the same median can differ greatly in their tails. Look at the boxplot as well.
Frequently asked questions
What is the difference between Mood's median test and Kruskal–Wallis?
Both compare several groups without assuming normal data. Kruskal–Wallis uses the ranks of all values; Mood's test only uses whether each value is above or below the grand median. Kruskal–Wallis is usually more powerful, while Mood's test is more resistant to extreme outliers and easier to explain.
Why is Mood's median test so robust to outliers?
Because an outlier only counts as one value above (or below) the median, no matter how extreme it is. A batch that took 118 minutes has the same effect as one that took 47.
Can I use Mood's median test with two groups?
Yes. It then becomes a chi-square test on a 2 × 2 table, an alternative to the Mann–Whitney test when outliers are severe.
Does it give confidence intervals?
A good tool reports each group's median with a confidence interval from the order statistics, as the sign test does. Here, for example, cloth B's median of 51.5 minutes has a 96% interval from 48 to 57 minutes.