Calculate the Kruskal-Wallis H statistic, p-value and effect size from raw data. Enter each group on its own line and tied values are handled for you.

Put each group on its own line, with its values separated by spaces or commas. A name and a colon before the values is optional, such as A: 4.2 4.6 3.9.

0.05 is the usual choice. The result is called significant when the p-value is below this level.

Optional settings

Calculator Functions

The calculator runs the Kruskal-Wallis test on your raw data. It gives the H statistic, its p-value and degrees of freedom, the critical value, two effect sizes, and the rank sum, mean rank and median of each group.

FunctionUse it whenYou enter
Kruskal-Wallis testYou have two or more independent groups of measurements and want to know whether they differ, without assuming the data are normally distributedThe values of each group, one group per line

Separate the values with spaces or commas. Groups can have different sizes, and you can enter 2 to 20 of them. To name a group, type the name and a colon before its values, such as Control: 4.2 4.6 3.9. The significance level is 0.05 unless you choose 0.01 or 0.10. If you already have H and only need the effect size, use the Kruskal Wallis Effect Size Calculator.

Kruskal-Wallis Test Formulas

H = 12 ÷ (N × (N + 1)) ×
Σ(R² ÷ n) − 3 × (N + 1) [1]
HKruskal-Wallis test statistic
NTotal number of values in all groups
RSum of the ranks in one group
nNumber of values in that group
ΣAdd the term for every group

All values are pooled and ranked together, with 1 for the smallest and N for the largest [1]. Values that are equal share the average of the ranks they cover, so two values tied for ranks 4 and 5 each get 4.5 [2]. When every group has a similar mean rank, H is close to 0. The more the mean ranks differ, the larger H becomes [2].

Tie correction

C = 1 − Σ(t³ − t) ÷ (N³ − N)
Hcorrected = H ÷ C [3]

Here t is the number of values that share one tied value, and the sum runs over every set of ties. With no ties, C is 1 and H is unchanged. The calculator reports the corrected H as its main result, as statistical software does, and lists H before the correction whenever your data contain ties.

P-value and critical value

When the groups come from the same distribution, H follows approximately a chi-square distribution with k − 1 degrees of freedom, where k is the number of groups [1]. The p-value is the chance of a chi-square value at least as large as H [3]. The result is significant when the p-value is below your significance level, which is the same as H exceeding the critical value. A significant result says that at least one group tends to give higher or lower values than another. It does not say which one.

Effect size

ε² = H ÷ (N − 1)
η²H = (H − k + 1) ÷ (N − k) [4]

Both run from 0 to 1 and describe how much of the variation in the ranks goes with group membership. Eta squared can come out slightly below 0 for a very small H, and the calculator shows 0 in that case.

Worked example

Four groups of 4, 5, 5 and 5 values (N = 19) have rank sums of 65, 41.5, 17.5 and 66 [1]. Then Σ(R² ÷ n) = 65² ÷ 4 + 41.5² ÷ 5 + 17.5² ÷ 5 + 66² ÷ 5 = 2,333.15, and H = 12 ÷ (19 × 20) × 2,333.15 − 3 × 20 = 13.678. One pair of values is tied, so C = 1 − 6 ÷ (19³ − 19) = 0.99912 and the corrected H is 13.690. With 3 degrees of freedom the p-value is 0.0034, and the critical value at 0.05 is 7.815, so the groups differ.

Limits of This Estimate

  • The p-value uses the chi-square approximation, which needs groups that are not too small. A common rule is at least 5 values in every group [1]. The calculator warns you when a group is smaller, and an exact test is the better choice for very small samples [2].
  • The groups must be independent. Repeated measurements on the same subjects need a different test, such as the Friedman test [2].
  • The test compares whole distributions. It is a test of medians only when the groups have the same shape and spread [2].
  • The calculator does not run the pairwise comparisons that show which groups differ from each other.

Sources

  1. National Institute of Standards and Technology, Engineering Statistics Handbook, Section 7.4.1: H formula, ranking, degrees of freedom, sample size rule and the worked example
  2. U.S. Geological Survey, Statistical Methods in Water Resources (Techniques and Methods 4-A3), Chapter 7: what the test compares, shared ranks for ties, and when an exact test is needed
  3. R Core Team, R source code, kruskal.test: tie correction and chi-square p-value
  4. Tomczak and Tomczak, The need to report effect size estimates revisited, Trends in Sport Sciences 21(1), 2014: epsilon squared and eta squared from H