Formula: Kruskal-Wallis H-Test Formula
- perGroupSampleSizeN: Per Group Sample Size N (n per group)
- group1RankSumR1: Group1 Rank Sum R1 (R₁)
- group2RankSumR2: Group2 Rank Sum R2 (R₂)
Compute Kruskal-Wallis H statistic, χ²(2) significance, and ε² / η²_H effect size.
Ranks 1 to N always add up to N(N + 1) / 2, so once you know two of the three sums the third is fixed. The page subtracts your two sums from that total and shows the result as the inferred Group 3 sum, 215 in the default. Check it against your own third sum, because a mismatch means a ranking error.
It is the upper 5% point of the chi-square distribution with 2 degrees of freedom. Under the null hypothesis, H approximately follows that distribution when groups are not too small. Because the page always has three groups, the degrees of freedom are always 2 and the threshold never changes. For a 1% test the cutoff would be higher.
No. It compares H with 5.991 and labels the result significant or not at the 5% level. For an exact p-value, look up H in a chi-square table with 2 degrees of freedom, or use the chi-square function in a spreadsheet. The default H of 9.29 corresponds to a p-value of roughly 0.01.
No. H is a scaled sum of squared distances between group mean ranks and the overall mean rank, so its smallest value is 0, reached when every group has the same mean rank. The page rejects rank sums that could not come from a real ranking, so it never reports a negative H. Rank sums of 145 and 155 at ten per group give H of 0.258.
Not directly. The page multiplies one group size by three to get N and divides every squared rank sum by that same size. With unequal groups, use the full formula: divide each squared rank sum by its own group size, add them, multiply by 12 over N(N + 1) and subtract 3(N + 1).
No. It assumes the groups are independent, with each subject appearing in only one group. If the same subjects are measured under three conditions, the Friedman test is the rank-based alternative. Using Kruskal-Wallis on repeated measures ignores the pairing and usually loses power.
Give H, the degrees of freedom, the p-value or significance level, the group sizes and an effect size. For the default that would read as H(2) = 9.29, p below 0.05, with ten per group and epsilon-squared of 0.32. Add mean or median ranks per group so readers can see the direction, and report any post hoc tests you ran.
At least one sum, possibly the inferred Group 3 sum, lies outside what n ranks can add to. For groups of 10 each sum must be at least 55, the total of ranks 1 to 10, and no more than the total of ranks 21 to 30. Sums of 95 and 95 fail because the implied third sum is too large. Recheck the ranking and the group size.
ANOVA compares means and assumes roughly normal data with similar variances in each group. Kruskal-Wallis works on ranks, so it copes better with skewed data, outliers and ordinal scales. When the ANOVA assumptions hold, ANOVA has a little more power. When they clearly fail, the rank test is the safer choice.
Not wrong, but slightly conservative. Ties reduce the variance of the ranks, and the standard tie correction divides H by a factor below 1, which raises it. The page leaves out the correction. With few ties the difference is negligible. With heavily tied data, such as rating scales, compute the corrected H in software before deciding.
About a third of the variation in the pooled ranks lines up with group membership. That indicates a substantial difference between at least some of the groups. It does not say which pair drives it. Use post hoc comparisons for that, and compare the effect with what earlier studies in your field have reported.
Report it as not significant at the 5% level and give the effect size alongside. A borderline H with a moderate epsilon-squared suggests the study may have been too small to detect a real difference. Apply the tie correction if your data has many ties, since it raises H, but do not change the test after looking at the result.
The default describes a study with three independent groups of ten. All thirty values have been pooled and ranked from 1 to 30. The ranks belonging to Group 1 add up to 95 and those in Group 2 to 155 in total. You do not enter the third sum. The page works it out from the fact that ranks 1 to 30 always add to the same total, and shows it as 215 on the card.
From those sums the page reports an H statistic of 9.29 with 2 degrees of freedom. The critical value of chi-square with 2 degrees of freedom at the 5% level is 5.991. H is above it, so the interpretation line marks the result significant at p below 0.05. The effect size, epsilon-squared, is 0.32.
In plain terms, Group 1 sits mostly in the low ranks, Group 3 mostly in the high ranks, and Group 2 in the middle. If the three groups came from the same distribution, a spread this wide would be unusual. The test does not say which pairs differ. It only says the three are unlikely to share one distribution.
The formula on the page squares each rank sum, but there is an equivalent form that is easier to do by hand. Divide each group's rank sum by its size to get the mean rank. For the default that gives 9.5, 15.5 and 21.5. The overall mean rank for thirty observations is (N + 1) / 2, which is 15.5.
Now take each group's distance from that overall mean: minus 6, 0 and plus 6. Square them and add: 36 + 0 + 36 is 72. Multiply by the group size, 10, and by 12, then divide by N times (N + 1). That is 12 times 10 times 72 divided by 30 times 31, which comes to 9.29. It matches the page.
Seen this way, H is a scaled measure of how far the group mean ranks sit from the middle. When all three groups have the same mean rank, H is exactly 0. Enter 155 for both Group 1 and Group 2 and the inferred third sum is also 155 exactly. The page then returns H of 0 and epsilon-squared of 0.
The degrees of freedom are always the number of groups minus one. This page is built for three groups, so df is fixed at 2 and the critical value at 5.991.
Small groups make the arithmetic easy to follow. Set the group size to 4, so N is 12, and enter rank sums of 15 and 26. The page infers the third sum as 37 and reports H of 4.654 with epsilon-squared of 0.423. That is below 5.991, so the result is not significant at the 5% level.
By hand, the mean ranks are 3.75, 6.5 and 9.25 around an overall mean of 6.5. The distances are minus 2.75, 0 and plus 2.75. Their squares add to 15.125. Then H is 12 times 4 times 15.125 divided by 12 times 13, which simplifies to 60.5 divided by 13, or 4.654.
Notice that the effect size here is larger than in the default, 0.423 against 0.32, yet the result is not significant. With only twelve observations, a fairly large shift in ranks can still arise by chance. Significance depends on sample size. Effect size does not, at least not directly.
With groups this small, the chi-square approximation behind the 5.991 threshold is rough. Exact critical values for the Kruskal-Wallis test with small groups are published in statistical tables and built into most statistics software. If each of your groups has only a handful of observations, use one of those instead of the threshold on this page.
For any group of n observations, the rank sum has hard limits. The smallest possible sum is n(n + 1) / 2, which happens when the group holds ranks 1 through n. For a group of 10 that is 55. The largest is the sum of the top n ranks, which for groups of 10 among thirty means ranks 21 to 30.
The page checks these limits for all three sums, including the Group 3 sum it infers. Enter 95 for both Group 1 and Group 2 with groups of 10, and the implied third sum would be larger than ranks 21 to 30 can add up to, so the page returns an error naming the allowed range instead of an H value. The group size must also be a whole number of at least 3.
The largest H possible with three equal groups of 10 comes from complete separation: Group 1 holding ranks 1 to 10, Group 2 ranks 11 to 20 and Group 3 the rest. Enter 55 and 155 and the page gives H of 25.807 and epsilon-squared of 0.89. That is the ceiling for this design.
The preset comparisons sit between that ceiling and zero. Rank sums of 145 and 155 imply 165 for Group 3, close to an even split, and H is only 0.258 with epsilon-squared of 0.009: no evidence of a difference. Sums of 70 and 160 imply 235, a strong split, and H rises to 17.613 with epsilon-squared of 0.607, far past the 5.991 line. The default, at 9.29, falls between them.
Epsilon-squared, the second supporting line, divides H by N minus 1. For the default that is 9.29 divided by 29, which is 0.32. It runs from 0, when the groups have identical mean ranks, to 1, when the groups are completely separated and nothing overlaps.
One way to read it is as the share of the variation in ranks that is explained by group membership. A value of 0.32 means about a third of the variation in where values fall in the pooled ranking lines up with which group they came from. That is a substantial effect in most fields.
The six-per-group example with rank sums of 40 and 55 shows a weaker case. The inferred third sum is 76, H is 3.825 and epsilon-squared is 0.225. Not significant, but not trivial either. If that came from a pilot study, the effect size is a better guide for planning the main study than the failed significance test.
Some software reports eta-squared based on H instead, which subtracts the degrees of freedom from H and divides by N minus the number of groups. For the default it comes out near 0.27, a little smaller. When you quote an effect size, name the formula so readers can compare like with like.
The Kruskal-Wallis test is an omnibus test. A significant result says at least one group tends to give higher or lower values than another. It does not say which. In the default, the mean ranks suggest Groups 1 and 3 are the furthest apart, but a formal answer needs follow-up comparisons.
The usual follow-up is Dunn's test, which compares mean ranks for each pair of groups using the same pooled ranking, with a correction for doing several comparisons. With three groups there are three pairs. A Bonferroni or Holm adjustment is common. Running three separate Mann-Whitney tests without any correction inflates the chance of a false positive.
It is also worth being careful with the wording. Kruskal-Wallis is often described as a test of medians, but that is only true if the groups have distributions of similar shape. Otherwise, a significant H may reflect differences in spread or skew as much as differences in the middle. Plot the data before you write it up.
The page assumes three groups of the same size and no ties. Real data often breaks both. When values tie, each gets the average of the ranks they would have occupied. That is fine for the rank sums, but H should then be divided by a tie correction, 1 minus the sum of (t cubed minus t) over all tied groups, divided by N cubed minus N, where t is the size of each tie. The correction always raises H, so ignoring it is conservative.
With few ties the correction is tiny. With many, such as Likert-scale responses where most answers are 3 or 4, it can matter enough to move a borderline result across the 5.991 line. Software applies it automatically. This page does not.
For unequal groups, the general formula divides each squared rank sum by its own group size before adding. The page only takes one group size, so with groups of 8, 10 and 12 you need to do the sum by hand or in a spreadsheet. With four or more groups, the degrees of freedom become the number of groups minus one and the critical value changes, so the threshold on this page no longer applies.
Pool every observation from all three groups into one list and sort it. Give the smallest value rank 1 and the largest rank N. Where values tie, give each the average of the ranks they span. Then add the ranks within each group to get the three sums.
Before entering anything, check that the three sums add up to N(N + 1) / 2. For thirty observations that is 30 times 31 divided by 2. If they do not, a rank has been missed or counted twice. The page cannot catch every slip of this kind, because it never sees your third sum; it only checks that the sum it infers is possible. It infers Group 3 from whatever you enter for Groups 1 and 2, so a typo in either one moves Group 3 by the same amount in the opposite direction.
The page will reject any sum outside the possible range for the group size, but a sum can be possible and still wrong, so the total check above matters more. If the default 95, 155 and 215 came from your data, all three are within range for groups of 10 and the H of 9.29 can be trusted, subject to the usual caveats about ties and the chi-square approximation.