Statistics
Textbooks
Boundless Statistics
Other Hypothesis Tests
Tests for Ranked Data
Statistics Textbooks Boundless Statistics Other Hypothesis Tests Tests for Ranked Data
Statistics Textbooks Boundless Statistics Other Hypothesis Tests
Statistics Textbooks Boundless Statistics
Statistics Textbooks
Statistics
Concept Version 6
Created by Boundless

Kruskal-Wallis H-Test

The Kruskal–Wallis one-way analysis of variance by ranks is a non-parametric method for testing whether samples originate from the same distribution.

Learning Objective

  • Summarize the Kruskal-Wallis one-way analysis of variance and outline its methodology


Key Points

    • The Kruskal-Wallis test is used for comparing more than two samples that are independent, or not related.
    • When the Kruskal-Wallis test leads to significant results, then at least one of the samples is different from the other samples.
    • The test does not identify where the differences occur or how many differences actually occur.
    • Since it is a non-parametric method, the Kruskal–Wallis test does not assume a normal distribution, unlike the analogous one-way analysis of variance.
    • The test does assume an identically shaped and scaled distribution for each group, except for any difference in medians.
    • Kruskal–Wallis is also used when the examined groups are of unequal size (different number of participants).

Terms

  • Kruskal-Wallis test

    A non-parametric method for testing whether samples originate from the same distribution.

  • Type I error

    An error occurring when the null hypothesis ($H_0$) is true, but is rejected.

  • chi-squared distribution

    A distribution with $k$ degrees of freedom is the distribution of a sum of the squares of $k$ independent standard normal random variables.


Full Text

The Kruskal–Wallis one-way analysis of variance by ranks (named after William Kruskal and W. Allen Wallis) is a non-parametric method for testing whether samples originate from the same distribution. It is used for comparing more than two samples that are independent, or not related. The parametric equivalent of the Kruskal-Wallis test is the one-way analysis of variance (ANOVA). When the Kruskal-Wallis test leads to significant results, then at least one of the samples is different from the other samples. The test does not identify where the differences occur, nor how many differences actually occur. It is an extension of the Mann–Whitney $U$ test to 3 or more groups. The Mann-Whitney would help analyze the specific sample pairs for significant differences.

Since it is a non-parametric method, the Kruskal–Wallis test does not assume a normal distribution, unlike the analogous one-way analysis of variance. However, the test does assume an identically shaped and scaled distribution for each group, except for any difference in medians.

Kruskal–Wallis is also used when the examined groups are of unequal size (different number of participants).

Method

1. Rank all data from all groups together; i.e., rank the data from $1$ to $N$ ignoring group membership. Assign any tied values the average of the ranks would have received had they not been tied.

2. The test statistic is given by:

$\displaystyle{K=(N-1) \frac{\displaystyle{\sum_{i=1}^gn_i(\bar{r}_{i\cdot} - \bar{r})^2}}{\displaystyle{\sum_{i=1}^g \sum_{j=1}^{n_i} (r_{ij}-\bar{r})^2}}}$where

$\displaystyle{\bar{r}_{i\cdot}= \frac{\sum_{j=1}^{n_i}r_{ij}}{n_i}}$

and where $\bar{r} = \frac{1}{2} (N+1)$ and is the average of all values of $r_{ij}$, $n_i$ is the number of observations in group $i$, $r_{ij}$ is the rank (among all observations) of observation $j$ from group $i$, and $N$ is the total number of observations across all groups.

3. If the data contain no ties, the denominator of the expression for $K$ is exactly

$\dfrac{(N-1)N(N+1)}{12}$

and 

$\bar{r}=\dfrac{N+1}{2}$

Therefore:

$\begin{aligned} K &= \frac{12}{N(N+1)} \cdot \sum_{i=1}^g n_i \left( \bar{r}_{i \cdot} - \dfrac{N+1}{2}\right)^2 \\ &= \frac{12}{N(N+1)} \cdot \sum_{i=1}^g n_i \bar{r}_{i\cdot}^2 - 3 (N+1) \end{aligned}$

Note that the second line contains only the squares of the average ranks.

4. A correction for ties if using the shortcut formula described in the previous point can be made by dividing $K$ by the following:

$1-\frac{\displaystyle{\sum_{i=1}^G (t_i^3 - t_i)}}{\displaystyle{N^3-N}}$

where $G$ is the number of groupings of different tied ranks, and $t_i$ is the number of tied values within group $i$ that are tied at a particular value. This correction usually makes little difference in the value of $K$ unless there are a large number of ties.

5. Finally, the p-value is approximated by:

$Pr\left( { \chi }_{ g-1 }^{ 2 }\ge K \right)$

If some $n_i$ values are small (i.e., less than 5) the probability distribution of $K$ can be quite different from this chi-squared distribution. If a table of the chi-squared probability distribution is available, the critical value of chi-squared, ${ \chi }_{ \alpha ,g-1' }^{ 2 }$, can be found by entering the table at $g − 1$ degrees of freedom and looking under the desired significance or alpha level. The null hypothesis of equal population medians would then be rejected if $K\ge { \chi }_{ \alpha ,g-1 }^{ 2 }$. Appropriate multiple comparisons would then be performed on the group medians.

6. If the statistic is not significant, then there is no evidence of differences between the samples. However, if the test is significant then a difference exists between at least two of the samples. Therefore, a researcher might use sample contrasts between individual sample pairs, or post hoc tests, to determine which of the sample pairs are significantly different. When performing multiple sample contrasts, the type I error rate tends to become inflated.

[ edit ]
Edit this content
Prev Concept
Wilcoxon t-Test
Distribution-Free Tests
Next Concept
Subjects
  • Accounting
  • Algebra
  • Art History
  • Biology
  • Business
  • Calculus
  • Chemistry
  • Communications
  • Economics
  • Finance
  • Management
  • Marketing
  • Microbiology
  • Physics
  • Physiology
  • Political Science
  • Psychology
  • Sociology
  • Statistics
  • U.S. History
  • World History
  • Writing

Except where noted, content and user contributions on this site are licensed under CC BY-SA 4.0 with attribution required.