Biostatistics Study NotesFrom concepts and derivations to interpretation

CHAPTER 08 · TOPIC 03

Kruskal–Wallis Test

Compare three or more independent groups with pooled ranks, a chi-square approximation, tie correction, and post hoc procedures.

On this page
  1. Study Design and Hypotheses
  2. Pool and Rank All Observations
  3. Kruskal–Wallis Statistic
  4. Chi-square approximation and degrees of freedom
  5. Tie correction
  6. Post Hoc Comparisons after a Significant Test

The Kruskal–Wallis test is a rank-based method that compares three or more independent groups and is a rank-based analogue of one-way ANOVA. We combine and rank all observations and measure how far the group mean rank deviates from the common center.

Study Design and Hypotheses#

  • The outcome is at least ordinal
  • Observations between groups are independent and each observation belongs to only one group.
  • The test is not appropriate for repeated measurements
  • If interpreted as a median difference, the group distributions have approximately the same shape.
H0:F1=F2==FkH1:At least one group’s distribution is differentH_0:F_1=F_2=\cdots=F_k\qquad H_1:\text{At least one group's distribution is different}

Pool and Rank All Observations#

Total sample sizeN=i=1kniN=\sum_{i=1}^{k}n_i
rank sum for group iRi=j=1niRijR_i=\sum_{j=1}^{n_i}R_{ij}
mean rankRˉi=Rini\bar R_i=\frac{R_i}{n_i}

Assign the average of the occupied ranks to tied values. The sum of all ranks is N(N+1)/2, and their common center is (N+1)/2. Under H₀, each group’s mean rank should lie near this value.

sum of all ranks1+2++N=N(N+1)21+2+\cdots+N=\frac{N(N+1)}2
common centerRˉ=N+12\bar R_{\cdot}=\frac{N+1}{2}

Kruskal–Wallis Statistic#

mean-rank formH=12N(N+1)ini(RˉiN+12)2H=\frac{12}{N(N+1)}\sum_i n_i\left(\bar R_i-\frac{N+1}{2}\right)^2
rank-sum formH=12N(N+1)iRi2ni3(N+1)H=\frac{12}{N(N+1)}\sum_i\frac{R_i^2}{n_i}-3(N+1)

Chi-square approximation and degrees of freedom#

Hχk12H\overset{\cdot}{\sim}\chi^2_{k-1}

Because the total rank sum across k groups is fixed, only k−1 rank sums can vary freely. For small samples or severe imbalance, consider exact or permutation methods. Having roughly five observations per group is only a guideline for the chi-square approximation and is unrelated to the expected-cell-count rule used for contingency tables.

Tie correction#

correction factorC=1j(tj3tj)N3NC=1-\frac{\sum_j(t_j^3-t_j)}{N^3-N}
Correction HHcorrected=HCH_{\mathrm{corrected}}=\frac HC

Post Hoc Comparisons after a Significant Test#

The significance of the overall test only indicates that at least one group is different. Use Dunn’s test or planned rank contrasts, and adjust multiplicity using Holm, Bonferroni, etc.

  1. Perform the overall Kruskal–Wallis test
  2. If significant, perform Dunn’s test or planned rank contrasts
  3. Adjust for multiple comparisons
  4. Report each group’s n, median, IQR, and mean rank, together with H, df, p value, and an effect size
ItemOne-way ANOVAKruskal–Wallis
InputRaw valuesPooled ranks
ComparisonMeansMean ranks / distributions
StatisticFH
Reference distributionFχ²(k−1)
Post hocTukey and related methodsDunn and related methods