Kruskal-Wallis test

This page offers all the basic information you need about the kruskal-wallis test. It is part of Statkat’s wiki module, containing similarly structured info pages for many different statistical methods. The info pages give information about null and alternative hypotheses, assumptions, test statistics and confidence intervals, how to find p values, SPSS how-to’s and more.

To compare the kruskal-wallis test with other statistical methods, go to Statkat's or practice with the kruskal-wallis test at Statkat's

Contents

When to use?

Deciding which statistical method to use to analyze your data can be a challenging task. Whether a statistical method is appropriate for your data is partly determined by the measurement level of your variables. The kruskal-wallis test requires the following variable types:

Variable types required for the kruskal-wallis test :
Independent/grouping variable:
One categorical with $I$ independent groups ($I \geqslant 2$)
Dependent variable:
One of ordinal level

Note that theoretically, it is always possible to 'downgrade' the measurement level of a variable. For instance, a test that can be performed on a variable of ordinal measurement level can also be performed on a variable of interval measurement level, in which case the interval variable is downgraded to an ordinal variable. However, downgrading the measurement level of variables is generally a bad idea since it means you are throwing away important information in your data (an exception is the downgrade from ratio to interval level, which is generally irrelevant in data analysis).

If you are not sure which method you should use, you might like the assistance of our method selection tool or our method selection table.

Null hypothesis

The kruskal-wallis test tests the following null hypothesis (H0):

If the dependent variable is measured on a continuous scale and the shape of the distribution of the dependent variable is the same in all $I$ populations: Else:
Formulation 1: Formulation 2: Several different formulations of the null hypothesis can be found in the literature, and we do not agree with all of them. Make sure you (also) learn the one that is given in your text book or by your teacher.
Alternative hypothesis

The kruskal-wallis test tests the above null hypothesis against the following alternative hypothesis (H1 or Ha):

If the dependent variable is measured on a continuous scale and the shape of the distribution of the dependent variable is the same in all $I$ populations: Else:
Formulation 1: Formulation 2:
Assumptions

Statistical tests always make assumptions about the sampling procedure that's been used to obtain the sample data. So called parametric tests also make assumptions about how data are distributed in the population. Non-parametric tests are more 'robust' and make no or less strict assumptions about population distributions, but are generally less powerful. Violation of assumptions may render the outcome of statistical tests useless, although violation of some assumptions (e.g. independence assumptions) are generally more problematic than violation of other assumptions (e.g. normality assumptions in combination with large samples).

The kruskal-wallis test makes the following assumptions:

Test statistic

The kruskal-wallis test is based on the following test statistic:

$H = \dfrac{12}{N (N + 1)} \sum \dfrac{R^2_i}{n_i} - 3(N + 1)$

Here $N$ is the total sample size, $R_i$ is the sum of ranks in group $i$, and $n_i$ is the sample size of group $i$. Remember that multiplication precedes addition, so first compute $\frac{12}{N (N + 1)} \times \sum \frac{R^2_i}{n_i}$ and then subtract $3(N + 1)$.

Note: if ties are present in the data, the formula for $H$ is more complicated.
Sampling distribution

Sampling distribution of $H$ if H0 were true:

For large samples, approximately the chi-squared distribution with $I - 1$ degrees of freedom.

For small samples, the exact distribution of $H$ should be used.

Significant?

This is how you find out if your test result is significant:

For large samples, the table with critical $X^2$ values can be used. If we denote $X^2 = H$:
Example context

The kruskal-wallis test could for instance be used to answer the question:

Do people from different religions tend to score differently on social economic status?
SPSS

How to perform the kruskal-wallis test in SPSS:

Analyze > Nonparametric Tests > Legacy Dialogs > K Independent Samples...
Jamovi

How to perform the kruskal-wallis test in jamovi:

ANOVA > One Way ANOVA - Kruskal-Wallis