# 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

- 1. When to use
- 2. Null hypothesis
- 3. Alternative hypothesis
- 4. Assumptions
- 5. Test statistic
- 6. Sampling distribution
- 7. Significant?
- 8. Example context
- 9. SPSS
- 10. Jamovi

##### 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:

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 (H_{0}):

- H
_{0}: the population medians for the $I$ groups are equal

Formulation 1:

- H
_{0}: the population scores in any of the $I$ groups are not systematically higher or lower than the population scores in any of the other groups

- H
_{0}: P(an observation from population $g$ exceeds an observation from population $h$) = P(an observation from population $h$ exceeds an observation from population $g$), for each pair of groups.

##### Alternative hypothesis

The kruskal-wallis test tests the above null hypothesis against the following alternative hypothesis (H_{1} or H_{a}):

- H
_{1}: not all of the population medians for the $I$ groups are equal

Formulation 1:

- H
_{1}: the poplation scores in some groups are systematically higher or lower than the population scores in other groups

- H
_{1}: for at least one pair of groups:

P(an observation from population $g$ exceeds an observation from population $h$) $\neq$ P(an observation from population $h$ exceeds an observation from population $g$)

##### Assumptions

Statistical tests always make assumptions about the sampling procedure that was 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:

- Group 1 sample is a simple random sample (SRS) from population 1, group 2 sample is an independent SRS from population 2, $\ldots$, group $I$ sample is an independent SRS from population $I$. That is, within and between groups, observations are independent of one another

##### 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)$.

##### Sampling distribution

Sampling distribution of $H$ if H_{0}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$:- Check if $X^2$ observed in sample is equal to or larger than critical value $X^{2*}$ or
- Find $p$ value corresponding to observed $X^2$ and check if it is equal to or smaller than $\alpha$

##### 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...- Put your dependent variable in the box below Test Variable List and your independent (grouping) variable in the box below Grouping Variable
- Click on the Define Range... button. If you can't click on it, first click on the grouping variable so its background turns yellow
- Fill in the smallest value you have used to indicate your groups in the box next to Minimum, and the largest value you have used to indicate your groups in the box next to Maximum
- Continue and click OK

##### Jamovi

How to perform the kruskal-wallis test in jamovi:

ANOVA > One Way ANOVA - Kruskal-Wallis- Put your dependent variable in the box below Dependent Variables and your independent (grouping) variable in the box below Grouping Variable