Statistics made easy
8th revised edition (March 2026) - many illustrative examples - only €8.99
Kruskal-Wallis-Test
Author: Dr. Hannah Volk-Jesussek
Updated:
What is the Kruskal-Wallis test?
The Kruskal-Wallis test (also called H-test) is a non-parametric statistical test used to compare three or more independent groups to determine whether their distributions differ. The Kruskal-Wallis test extends the Mann-Whitney U test to more than two independent groups.
The Kruskal-Wallis test is used when the assumptions for a one-way analysis of variance are not met. Because the Kruskal-Wallis test is a non-parametric test, the data used do not have to be normally distributed.
The data must at least have an ordinal scale level and the samples must be independent.
In the Kruskal-Wallis test, ordinal variables are sufficient, since non-parametric tests analyze the ranks of the data rather than the raw values.
Key Characteristics:
- Non-parametric: It does not assume a normal distribution of the data, making it suitable for non-normally distributed data.
- Ordinal or Continuous Data: It can be used with ordinal data or continuous data that has been converted to ranks.
- Independent Groups: The test is used for comparing independent groups, meaning the observations in each group are not related.
Examples for the Kruskal-Wallis test
For the Kruskal-Wallis test, of course, the same examples can be used as for the single factor analysis of variance, but with the addition that the data need not be normally distributed.
Medical example:
For a pharmaceutical company, you want to compare body weight among three groups. Drug XY is administered to 20 participants, 20 participants receive a placebo, and 20 participants receive no drug or placebo.
Social science example:
Do 3 age groups differ in terms of daily television consumption?
Research Questions and Hypotheses
The research question for the Kruskal-Wallis test may be: Do the distributions of several independent groups differ? This question results in the null and alternative hypothesis.
Null hypothesis
The outcome has the same distribution in all groups.
Alternative hypothesis
The outcome distribution differs for at least one group.
Median vs. Rank Sums
The Kruskal-Wallis test actually tests for differences in the rank sums of the groups, not directly the medians. The distinction is important and worth clarifying:
Rank Sums
The Kruskal-Wallis test ranks all the data from all groups together. Each value is replaced by its rank in the combined dataset; tied values receive their average rank. The test then sums these ranks for each group. It detects differences in the distributions through differences in the groups' ranks. This is different from saying that the medians are equal, although there is a relationship between the two.
Median
While the test is often used as an indicator of differences in medians (especially when the distributions are similar), strictly speaking, it does not directly test the medians. The rationale is that if the distributions are similar, differences in mean ranks imply differences in medians.
Summary
In summary, the Kruskal-Wallis test is a non-parametric method for testing whether samples originate from the same distribution. It tests whether the mean ranks are the same across groups, which is often interpreted as a test of differences in medians, especially when the shapes of the distributions are similar across groups.
Assumptions for the Kruskal-Wallis test
To compute a Kruskal-Wallis test, the observations must be independent within and between groups, and the outcome must be at least ordinal. Ideally, the groups are random samples or are formed through random assignment. The outcome does not have to be normally distributed. If the result is interpreted specifically as a difference in medians, the group distributions should have a similar shape and spread.
If you have a dependent sample, then you just use the Friedman test.
Calculation for the Kruskal-Wallis test
The calculation of the Kruskal-Wallis rank-based analysis of variance is similar to that of the Mann-Whitney U-Test, which is the nonparametric counterpart of the t-test for independent samples.
Suppose the null hypothesis is true and the outcome has the same distribution in all groups. Then high and low ranks should be distributed similarly across the groups.
If there is no difference between the groups, the mean value of the ranks should also be the same in all groups. The expected value of the ranks for each group is then given by
Each sample has the same expected value of the ranks, which corresponds to the expected value of the population. Furthermore, the variance of the ranks is needed, the variance can be calculated with the following formula:
In the Kruskal-Wallis test, the test statistic H is calculated. For sufficiently large samples, its null distribution is approximated by a χ2 distribution with the number of groups minus one degree of freedom. The H value results from:
The critical H value can be read from the table of critical χ2 values.
Let's say you have measured the reaction time of three groups and you want to know if there is a difference between them. To find out, you now use the H-test (Kruskal-Wallis test)
First, we assign a rank to each person, then calculate the rank sum and mean rank for each group. Tied observations receive their average rank, and the test statistic should be corrected for ties.
We measured reaction time in twelve people, so the number of cases is twelve. The degrees of freedom are given by the number of groups minus one, so we have two degrees of freedom.
Now we have calculated all values to calculate the test statistic H.
After the H-value or the chi-square value has been calculated, the critical chi-square value can be read from the table of critical chi-square values.
At a significance level of 5%, the critical chi-square value is therefore 5.991. This critical value is therefore greater than the calculated chi-square or H value. Thus, the null hypothesis is not rejected. The sample does not provide sufficient evidence of a difference in the reaction-time distributions of the three groups.
Post-hoc-Test
The Kruskal-Wallis test can be used to determine whether at least two groups differ from each other. The Kruskal-Wallis test does not provide an answer to the question of which groups differ; if the overall test is significant, post-hoc comparisons are required for this.
Dunn's test is a common nonparametric method for these pairwise comparisons.
Dunn-Bonferroni-Tests
To find out which of the pairs differ, the individual groups can be compared pairwise. Dunn's test is used to calculate the p-value of each pair. To compare group A and B, the z-value is calculated using the following formula.
where i is one of the groups and yi= WA-WB is the difference of the mean rank sums. The standard error is given by
where N is the total number of cases, r is the number of tied-rank groups, and τs is the number of cases in tied-rank group s.
The calculated p-value can then be adjusted using the Bonferroni correction. The Bonferroni correction is the simplest method to counteract the problem of multiple comparisons. Here, each calculated p-value is multiplied by the number of pairwise comparisons, which is k(k − 1)/2 for k groups.
If the adjusted p-value in a pairwise comparison is smaller than the significance level (usually 0.05), the null hypothesis that there is no difference is rejected. So, if the adjusted p-value is smaller than 0.05, it is assumed that the respective two groups differ.
numiqo automatically outputs the Dunn-Bonferroni test when calculating a Kruskal-Wallis test.
Calculate Kruskal-Wallis test online with numiqo
Reaction time example dataOf course you can calculate the Kruskal-Wallis test online with numiqo. Just go to the statistics calculator, copy your data into the table in the statistics calculator and select the tab "Hypothesis tests". Then you just have to select the variables you want to analyze and select "Kruskal-Wallis Test".
numiqo then provides you with the results, including interpretation in the following form:
Kruskal-Wallis test interpretation
As with any statistical hypothesis test, the calculated p-value is of interest at the end. The question is whether the calculated p-value is smaller or larger than the significance level usually set at 0.05. If the p-value is larger, the null hypothesis is not rejected, otherwise it is rejected.
In the example above, the p-value is 0.779 and thus greater than 0.05. The null hypothesis is thus not rejected. The sample does not provide sufficient evidence that the reaction-time distributions differ between the groups.
Kruskal-Wallis test reporting
How are the results from a Kruskal-Wallis test reported?
A Kruskal-Wallis test was calculated to test whether the reaction-time distributions differ among groups A, B, and C. The test found no statistically significant difference in reaction time among the three groups, p=0.779. Thus, with the available data, the null hypothesis is not rejected.
Statistics made easy
- many illustrative examples
- ideal for exams and theses
- statistics made easy on 464 pages
- 8th revised edition (March 2026)
Only €8.99
Free sample
"Super simple written"
"It could not be simpler"
"So many helpful examples"