Data and statistics · cheat sheet

Kruskal-Wallis test

A test of whether three or more independent groups differ, using ranks instead of averages: the rank-based version of one-way ANOVA.

Common practice
4 steps
Used by Process Improvement Specialist

What it is

Kruskal-Wallis ranks all values from several groups together and tests whether the groups' average ranks differ.

When to use it

When comparing several groups with skewed or ordinal data.

Why it works

It's the ANOVA alternative for skewed data.

Do

  • Box plots show which group differs.

Don't

  • Using it on related groups (use Friedman).
  • Forgetting to say which group is different.

Step by step

  1. Rank all
  2. Average rank per group
  3. H statistic
  4. p-value Chi-square, groups − 1.
Also called: Rank test for several groupsPrint the blank template ↗

Worked example

The situation. Waiting times (minutes) at three clinics, 6 patients each.

  1. Medians 24.5, 34 and 25.5.

The result. Clinic 2 was understaffed at lunch.

Kruskal-Wallis worksheet Print blank
PartValue
H10.41
Degrees of freedom2
p-value0.005

Filled in for: Waiting times (minutes) at three clinics, 6 patients each.

ValueGroupRank

Copy this structure, or print the blank version and fill it in by hand. Average rank per group ______ H ______ p ______

Before you use it: check these

CheckIf it fails
Independent groupsUse the Friedman test when the same blocks appear in every group
At least about 5 values per groupCombine groups or collect more

How to do it with real data

The full calculation, as it happens in the story: the data, every step, how to read the result, and the spreadsheet functions to do it yourself.

Worked example with real data

Checking the Monday effect without assuming normal data

From Day 32: Checking with ranks and medians of the Process Improvement Specialist story

The same 60 waits by day, tested on ranks and on medians instead of averages.

Waits by the day of the first request010203040Monday: median 14, quartiles 11.25 and 20, n = 1814MondayTuesday: median 5, quartiles 3 and 6.25, n = 125TuesdayWednesday: median 10.5, quartiles 5 and 14.75, n = 1010.5WednesdayThursday: median 6, quartiles 4.25 and 9.25, n = 106ThursdayFriday: median 8, quartiles 5.5 and 11.75, n = 108Friday

Step by step

  1. Kruskal-Wallis: rank everythingrank all 60 waits from 1 to 60, ties sharing the average rank
  2. Compare average ranksdo the days' average ranks differ more than chance would give?= H = 19.66
  3. Kruskal-Wallis: p-valuechi-square with 4 degrees of freedom= 0.0006
  4. Mood's median: overall medianmedian of all 60= 10 days
  5. Count above and belowMonday: 15 above, 3 at or below · Tuesday: 2 and 10 · Wednesday: 5 and 5 · Thursday: 1 and 9 · Friday: 4 and 6
  6. Mood's median: p-valuechi-square on that table= 0.0006
RequestDay of first requestWait (days)
R01Friday12
R02Wednesday13
R03Monday12
R04Monday28
R05Friday11
R06Monday12
R07Thursday16
R08Thursday7
R09Tuesday3
R10Monday4
R11Tuesday4
R12Tuesday10
R13Wednesday4
R14Tuesday17
R15Tuesday5
R16Wednesday8
R17Thursday5
R18Tuesday5
R19Friday5
R20Monday20
R21Thursday3
R22Wednesday15
R23Wednesday5
R24Friday9
R25Tuesday5
R26Wednesday5
R27Wednesday15
R28Monday15
R29Wednesday14
R30Friday13
R31Monday18
R32Friday16
R33Tuesday3
R34Wednesday5
R35Monday10
R36Friday7
R37Thursday6
R38Thursday10
R39Thursday10
R40Tuesday5
R41Friday5
R42Thursday4
R43Friday5
R44Thursday6
R45Friday7
R46Monday11
R47Monday11
R48Tuesday3
R49Monday13
R50Monday26
R51Monday12
R52Monday22
R53Monday27
R54Wednesday18
R55Thursday4
R56Tuesday14
R57Monday20
R58Tuesday3
R59Monday6
R60Monday19

How to read the result

Both tests agree with ANOVA: Monday requests wait longer. Kruskal-Wallis uses ranks, Mood's median only counts above or below the median, so it's less powerful but very robust to extreme values.

What it led to

Root cause confirmed: Monday demand (30% of the week's requests) meets the same capacity as any other day.

Do it in a spreadsheet

Ranks=RANK.AVG(C2,$C$2:$C$61,1)
Average rank by day=AVERAGEIFS(D2:D61,B2:B61,"Monday")
Mood's table=COUNTIFS(B2:B61,"Monday",C2:C61,">10")
Chi-square p-value=CHISQ.TEST(observed,expected)
Try it yourself: Which of the two tests would you trust more if a few waits were extremely long (say 80 days)?

Mood's median: it only asks whether each value is above or below the median, so extreme values can't pull it. Kruskal-Wallis is also robust but uses more information.

In the roles

How a Process Improvement Specialist uses it

Waits by weekday: H = 19.66, p = 0.0006.

Questions people ask

Kruskal-Wallis or Mood's median?

Kruskal-Wallis is more powerful; Mood's is more robust to extreme values.

Related techniques

← All techniques and tools