Kruskal-Wallis H Test Calculator
The Kruskal-Wallis H test compares the distribution locations of three or more independent groups using rank numbers. It is the nonparametric counterpart of one-way ANOVA: it requires neither normality nor homogeneity of variance, and it works with ordinal data and small samples.
Paste one group of data per line and this calculator ranks all observations together, builds the H statistic from the group rank sums, applies the correction for tied observations, and reads the p-value from the chi-square distribution. The output covers H, the degrees of freedom, the critical chi-square, the η² and ε² effect sizes, a summary table of group medians and mean ranks, a multi-group box plot, and — when the result is significant — Bonferroni-corrected pairwise comparisons.
Kruskal-Wallis H Test Formulas
Ranking: All N observations are ranked together; ties get the average rank Test statistic: H = [12 / (N(N+1))] · Σ (Rᵢ² / nᵢ) − 3(N + 1) Tie correction: H_corr = H / [ 1 − Σ(t³ − t) / (N³ − N) ] Deg. of freedom: df = k − 1 p-value: p = P(χ²_df > H) Effect size: η²_H = (H − k + 1) / (N − k) Effect size: ε² = H / (N − 1) Mean rank: R̄ᵢ = Rᵢ / nᵢ , expected R̄ = (N + 1)/2
H measures how far the group mean ranks deviate from the overall mean rank, and in large samples it approaches a chi-square distribution with k − 1 degrees of freedom. At least 5 observations per group are recommended; smaller groups call for an exact test. When equal values are present the tie correction raises H, making the test slightly more sensitive.
How to Calculate
- Write the data of each group on its own line; you can name a group by starting the line with "Name: values".
- The groups do not have to be the same size, but at least 5 observations per group is recommended for the chi-square approximation.
- Choose the significance level (α); the pairwise comparisons are judged against that level divided by the Bonferroni factor.
- Read H, the degrees of freedom, and the p-value, then confirm the decision by comparing H with the critical chi-square value.
- Look at the η² and ε² effect sizes: a significant p does not mean the difference matters in practice.
- When the result is significant, use the Bonferroni-corrected pairwise Mann-Whitney comparisons in the notes together with the box plot to identify which groups separate.
Worked Examples
Comparing three teaching methods
The mean ranks of the three groups separate clearly at 4.50, 12.56, and 20.44. With the tie correction H(2) = 20.348 (20.321 uncorrected); p < 0.001 makes the difference significant, and with η² = 0.874 and ε² = 0.885 the effect is large. All three Bonferroni-corrected pairwise comparisons are significant (p = 0.002 for the first-second and first-third pairs, p = 0.003 for the second-third pair); the confidence interval for the median gap between the two extreme groups runs from 11 to 17 points.
H test statistic: 20.348 · Degrees of freedom (df): 2 · p-value: p < 0.001
Three branches with no difference
The mean ranks are almost identical at 10.36, 11.50, and 11.14, with rank sums of 72.5, 80.5, and 78.0. Since H(2) = 0.125 and p = 0.940, no difference is detected between the groups. With η² = 0.000 and ε² = 0.006 the effect is negligible, and the box plot shows the three distributions overlapping almost entirely.
H test statistic: 0.125 · Degrees of freedom (df): 2 · p-value: p = 0.940
Four dose levels, unbalanced group sizes, and tied values
The group sizes are unbalanced at 6, 5, 7, and 4, and the ordinal scale produces many tied values, so the correction Σ(t³ − t) = 204 is applied: the uncorrected H = 18.056 becomes a corrected H = 18.409. With df = 3 and p < 0.001 the doses differ significantly, and η² = 0.856 marks a large effect. After the Bonferroni correction only the placebo-medium dose pair (p = 0.014) and the low dose-medium dose pair (p = 0.045) remain significant.
H test statistic: 18.409 · Degrees of freedom (df): 3 · p-value: p < 0.001