Kruskal-Wallis H Test Calculator

StatisticsLast updated: August 22, 2026

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.

Write all values of a group on a single line. You may label a line as "Name: values". At least 2 groups are required, and the groups need not be the same size.
Sets the false-positive risk. In the social sciences 5% is the usual choice.

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

  1. Write the data of each group on its own line; you can name a group by starting the line with "Name: values".
  2. The groups do not have to be the same size, but at least 5 observations per group is recommended for the chi-square approximation.
  3. Choose the significance level (α); the pairwise comparisons are judged against that level divided by the Bonferroni factor.
  4. Read H, the degrees of freedom, and the p-value, then confirm the decision by comparing H with the critical chi-square value.
  5. Look at the η² and ε² effect sizes: a significant p does not mean the difference matters in practice.
  6. 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

Frequently Asked Questions

When should I prefer the Kruskal-Wallis test over one-way ANOVA?
Kruskal-Wallis is the safer choice when the group distributions depart noticeably from normality, when outliers are present, when the groups are small, or when the data were collected on an ordinal scale. If the variances are unequal but the data are normal, Welch ANOVA is another option. When normality does hold, ANOVA is more powerful; Kruskal-Wallis then retains roughly 95% of its power.
H came out significant — how do I find which groups differ?
A significant H only says that at least one group separates from the others. The standard route is to run every pairwise comparison with the Mann-Whitney U test and correct the p-values with Bonferroni; this calculator produces those comparisons automatically in the notes section. Dunn's test is the alternative: it keeps the shared ranking and is therefore more consistent with Kruskal-Wallis, and it is what the SPSS 'pairwise comparisons' output reports.
How do tied (equal) values affect the result?
Equal observations receive the average rank, and H is corrected upward with the term Σ(t³ − t)/(N³ − N). Without the correction the p-value comes out too large and real differences can be missed. This calculator applies the correction automatically and also shows the uncorrected H; with Likert-type data the gap between the two can be noticeable.
Does Kruskal-Wallis compare medians?
Not directly. The null hypothesis is that "all groups come from the same distribution", and the test examines whether the mean ranks differ. To read the result as "the medians differ", the group distributions must have similar shapes. If the shapes differ substantially, a significant result may also stem from a difference in spread.
Should I report η² or ε² as the effect size?
Either is acceptable. η²_H = (H − k + 1)/(N − k) is interpreted much like the ANOVA η², but sampling error can push it below zero, in which case it is taken as zero. ε² = H/(N − 1) always stays between 0 and 1, which is why some sources prefer it. The thresholds are the same for both: 0.01 small, 0.06 medium, 0.14 large.
How do I get the same result in SPSS and R?
In SPSS, follow Analyze → Nonparametric Tests → Independent Samples and choose the K-sample option; the output gives the tie-corrected H and the asymptotic p. In R, kruskal.test(value ~ group) produces the same H, df, and p, and applies the tie correction by default. Excel has no built-in function; you have to build the ranks with RANK.AVG and write the formula out by hand.
Can I run Kruskal-Wallis with two groups?
Technically yes, and the result is consistent with the Mann-Whitney U test: with two groups H approaches the square of the U test's z value and the p-values coincide. Even so, the convention in the literature for a two-group comparison is to report the Mann-Whitney U test, which gives the direction of the difference and the effect size directly. Kruskal-Wallis earns its place with three or more groups.