Português

Kruskal-Wallis test

Ranks (nonparametric) · Three or more independent groups · reference distribution: χ²(k−1)

When to use it

Compare three or more independent groups without assuming normality: it is the ANOVA done on ranks.

Null hypothesis

All groups come from the same distribution.

Assumptions

Test statistic

H = \dfrac{12}{N(N+1)} \sum_j \dfrac{R_j^2}{n_j} - 3(N+1)

Effect size

ε²: the rank version of η².

\varepsilon^2 = \dfrac{H}{N - 1}

How to report it

H(2) = 8.43, p = .015, ε² = .19

In R and Python

R
kruskal.test(y ~ group, data = df)
Python
stats.kruskal(a, b, c)

In Python, stats is scipy.stats and np is numpy.

Variants and alternatives

Where it sits in the catalog

Ranks (nonparametric). Nonparametric tests assume no distribution for the data. They replace each value by its rank, its position in order (1st, 2nd, 3rd…), which protects them from extreme values and makes them fit ordinal data.

Three or more independent groups. Several groups of different individuals, tested at once: one test per pair would inflate the type I error.

In the decision tree

  1. What do you want to do? Compare groups, or one group with a reference value
  2. What kind of response did you measure? Numeric: a measurement, such as weight, time or score
  3. How many groups or measurements? Three or more groups
  4. Are the groups made of different individuals or the same individuals? Different individuals (independent)
  5. Are the residuals approximately normal? No, or the response is ordinal

Open the decision tree