Kruskal-Wallis H test for 2 to 10 independent groups from pasted values, with the tie correction, an exact p-value for small samples and Dunn's pairwise comparisons.
Kruskal-Wallis Test Calculator - H, Exact p and Dunn Test
Kruskal-Wallis H test for 2 to 10 independent groups from pasted values, with the tie correction, an exact p-value for small samples and Dunn's pairwise comparisons.
Parameters
Enter data for calculations
💡 Fill in all required fields to unlock the calculate button
Kruskal-Wallis H test on ranks, with an exact p-value for small groups
A rank-based comparison of 2 to 10 independent groups, for data where an ANOVA is on shaky ground: skewed measurements, a stray extreme value, ratings on a 1 to 5 scale. Paste one group per line and the calculator ranks the pooled values, gives H with the correction for ties, the p-value, the effect size η²H and a Dunn test for every pair of groups. When the groups are small enough for the number of possible splits to stay under 300,000, it also counts every split and reports the exact p, which can differ from the textbook chi-square approximation almost ninefold.
One mistyped value: the same data before and after
Three groups of six. In the second version a single value in group C was typed as 95 instead of 14. Nothing else changed.
One-way ANOVA: F = 13, p = 0.0005
Kruskal-Wallis: H = 10.7126, p = 0.0047
Both say the groups differ.
One-way ANOVA: F = 0.9181, p = 0.4206
Kruskal-Wallis: H = 8.4941, p = 0.0143
The ANOVA verdict flips; the rank test barely moves.
The reason is simple. To ANOVA, 95 is 81 units away from 14 and multiplies the variance of group C from 2 to 1,095.5. To a rank test, 95 is just the largest value, rank 18 instead of rank 8. A rank test hands over some sensitivity when the data really are normal, and in return a single wild value cannot rewrite its conclusion.
Two things to fill in
- Values of each group - one group per line, separated by spaces, commas, semicolons or tabs, with a dot for decimals. Measurements or ratings both work: Ad A: 3 4 4 5 3 4. A name before the colon labels the group in the tables. Up to 2,000 values per group.
- Significance level - 0.05, 0.01 or 0.10. It applies to H and to the adjusted p of every pair in the Dunn table.
- Read the result - H and its degrees of freedom, the exact or approximate p, η²H, the critical chi-square, the number of tie sets and the H before the tie correction, the median, rank sum and mean rank of every group, and for three or more groups the Dunn comparisons with Bonferroni-adjusted p-values.
Chi-square shortcut against the exact count
Textbooks and most spreadsheets read the p-value of H from a chi-square distribution with k - 1 degrees of freedom. It is an approximation, and with small groups it can miss in either direction. The exact p asks a plainer question: of all the ways to deal the observed ranks into groups of these sizes, how many give an H at least as large as yours?
| Data | H | Splits counted | Chi-square p | Exact p |
|---|---|---|---|---|
| 1 2 / 3 4 / 5 6 / 7 8 | 6.6667 | 2,520 | 0.0833 | 0.0095 |
| Ranks 1-9 in three groups of three | 7.2 | 1,680 | 0.0273 | 0.0036 |
| Groups of 5, 5 and 4, no ties | 9.0257 | 252,252 | 0.0110 | 0.0028 |
| 1 2 2 3 / 2 3 3 4 / 4 5 5 6, with ties | 8.2799 | 34,650 | 0.0159 | 0.0045 |
| Two groups: 1 3 5 / 2 4 6 | 0.4286 | 20 | 0.5127 | 0.7000 |
In the first row the shortcut says "not significant at 0.05" and the exact count says "significant at 0.01". The last row errs the other way. The exact p for two groups of three, 0.7, is the same as the exact two-sided Mann-Whitney p for those data.
What you gain and what you give up by ranking
Critical values of chi-square for H
With large groups, H is compared with the chi-square distribution with k - 1 degrees of freedom: H is significant when it exceeds the value in the table. These values are the ones printed in the NIST/SEMATECH e-Handbook, and the calculator reproduces all 27 cells.
| Groups (df) | α = 0.10 | α = 0.05 | α = 0.01 |
|---|---|---|---|
| 2 (1) | 2.706 | 3.841 | 6.635 |
| 3 (2) | 4.605 | 5.991 | 9.210 |
| 4 (3) | 6.251 | 7.815 | 11.345 |
| 5 (4) | 7.779 | 9.488 | 13.277 |
| 6 (5) | 9.236 | 11.070 | 15.086 |
| 8 (7) | 12.017 | 14.067 | 18.475 |
| 10 (9) | 14.684 | 16.919 | 21.666 |
Corn yields, checked against NCSS
The fertilizer data from the NCSS one-way ANOVA chapter, 13, 16 and 14 plots, give rank sums 229.5, 279 and 437.5, H = 11.2674 before and 11.2708 after the correction for four sets of ties, and p = 0.0036. The Dunn z values are 0.0462 for A against B, 2.8117 for A against C and 3.0063 for B against C, the same as the NCSS report. With three pairs the Bonferroni threshold is z = 2.394, so C differs from both A and B, and A and B do not differ from each other. η²H = (H - k + 1) / (N - k), the formula given by Tomczak and Tomczak, comes to 0.232.
Rank test questions, answered with the numbers
Related tools
Tukey HSD Calculator
Which pairs of group means differ after the ANOVA, with simultaneous intervals - See the calculator
ANOVA Calculator
The parametric counterpart, with Welch's version for unequal variances - See the calculator
Wilcoxon Test Calculator
The rank-sum test for two groups and the signed-rank test for paired data - See the calculator
Chi-Square Calculator
For counts in categories rather than values on a scale - See the calculator
P-Value Calculator
A p-value from an H read off a printout, through its chi-square distribution - See the calculator
Percentile Calculator
Medians, quartiles and percentile ranks of each group, by several methods - See the calculator
Skewness Calculator
Checks how lopsided a group is before you choose between ANOVA and ranks - See the calculator
Interquartile Range Calculator
Flags the outliers that push a data set toward a rank test - See the calculator