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

    2 to 10 lines, a name before a colon is optional

    Applies to H and to the pairwise table

    Form progress0 / 2 fields

    💡 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.

    Before: 12 14 13 15 11 13 / 16 18 17 15 19 17 / 14 13 15 12 16 14
    One-way ANOVA: F = 13, p = 0.0005
    Kruskal-Wallis: H = 10.7126, p = 0.0047
    Both say the groups differ.
    After: the last value of C is 95
    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

    1. 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.
    2. 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.
    3. 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 86.66672,5200.08330.0095
    Ranks 1-9 in three groups of three7.21,6800.02730.0036
    Groups of 5, 5 and 4, no ties9.0257252,2520.01100.0028
    1 2 2 3 / 2 3 3 4 / 4 5 5 6, with ties8.279934,6500.01590.0045
    Two groups: 1 3 5 / 2 4 60.4286200.51270.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

    Gained: ordinal data become usable. Ratings, scores and grades have an order but no reliable distances; ranks need only the order. Three ad versions rated 3 4 4 5 3 4, 2 3 2 3 3 2 and 4 5 5 4 5 5 give H = 12.1849, p = 0.0023, and the Dunn table places the difference between the second and third versions (adjusted p 0.0016).
    Gained: skewed data stop misleading. Measurements from three sites with one large value each in sites 1 and 2: ANOVA gives p = 0.1843, Kruskal-Wallis gives H = 12.4603, p = 0.0020, with site 2 above site 3 (adjusted p 0.0013).
    Given up: a statement about means. The test compares where the values of each group tend to lie. Reading it as a test of medians is fair only when the groups have distributions of similar shape, which NCSS lists among the assumptions: the distributions should be identical except for location.
    Not a fix for unequal spreads. NCSS states that the Kruskal-Wallis test assumes equal variances, so with normal data and very different spreads Welch's ANOVA is the better tool.

    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.7063.8416.635
    3 (2)4.6055.9919.210
    4 (3)6.2517.81511.345
    5 (4)7.7799.48813.277
    6 (5)9.23611.07015.086
    8 (7)12.01714.06718.475
    10 (9)14.68416.91921.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

    How do I report a Kruskal-Wallis result?
    H with its degrees of freedom, the sample size, the p-value and an effect size, for the corn data: H(2) = 11.27, p = .004, η²H = .23, followed by the medians of the groups and the pairs the Dunn test found, with the correction you used.
    Why is the exact p not shown for my data?
    The number of splits grows very fast. Three groups of five give 756,756 splits, which is above the limit, so the chi-square p is shown. When at least one group has fewer than five values and the exact count is out of reach, the result also carries a warning to treat a p near the threshold with care.
    What does the tie correction do?
    Tied values share their average rank, which shrinks the spread of the ranks. H is divided by C = 1 - Σ(t³ - t) / (N³ - N) to make up for it. With rating scales the correction matters: for the three ad versions above, H rises from 11.3801 to 12.1849.
    Can H be significant while no pair in the Dunn table is?
    Yes. In the 1 2 / 3 4 / 5 6 / 7 8 data the exact p is 0.0095, yet with six pairs and groups of two even the most distant pair reaches an adjusted p of only 0.0858. The overall test pools the evidence from all groups; each pair has to stand on four values. NCSS notes that the Dunn test needs at least five values per group, and preferably more.

    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

    Similar calculators from this section