# Kruskal-Wallis-Test

## What is the Kruskal-Wallis test

The Kruskal-Wallis test (H-test) is a hypothesis test for multiple independent samples, which is used when the assumptions for a one factor analysis of variance are not met.

Since the Kruskal-Wallis test is a nonparametric test (also called a distribution-free test), the data used do not have to be normally distributed, in contrast to analysis of variance. The only requirement is that the data be ordinal scale.

In the Kruskal-Wallis test, ordinal variables are sufficient, since non-parametric tests do not use the differences of the values, but the ranks (which value is larger, which is smaller). Therefore, the Kruskal-Wallis test is also often called "Kruskal-Wallis one-way ANOVA by ranks test".

## 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 test whether a drug XY has an influence on body weight. For this purpose, the drug is administered to 20 test persons, 20 test persons receive a placebo and 20 test persons receive no drug or placebo.

### Social science example:

Do 3 age groups differ in terms of daily television consumption?

## Research Question and Hypotheses

The research question for the Kruskal-Wallis test may be: Is there a difference in the central tendency of several independent samples? This question position then results in the null and alternative hypothesis.

### Null hypothesis

The independent samples all have the same central tendency and therefore come from the same population.

### Null hypothesis

At least one of the independent samples does not have the same central tendency as the other samples and therefore originates from a different population.

## Assumptions for the Kruskal-Wallis test

To compute a Kruskal-Wallis test, only several independent random samples with at least ordinally scaled characteristics must be available. The variables do not have to satisfy a distribution curve.

If you have a dependent sample, then you just use the Friedman test.

## Calculate Kruskal-Wallis-Test

The calculation of the Kruskal and Wallis rank variance analysis is similar to that of the Mann-Whitney-U-Test, which is the nonparametric counterpart of the t-test for independent samples.

Let's say the null hypothesis is true and thus there is no difference between the independent samples. Then high and low ranks are randomly distributed across the samples and should be equally distributed across the groups. Therefore, the probability that a rank is assigned to a group is the same for all 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 variable *H* is calculated. The H
value corresponds to the χ2 value. The *H* value results from:

The critical H value can be read from the table of critical χ2 values.

## Calculation with example data

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 we calculate the rank sum and the mean rank sum.

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 quantity 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 maintained and there is no difference in reaction time in 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 of the groups differed; a post-hoc test is required for this.

For this purpose, the Dunn test is the appropriate nonparametric test for the pairwise multiple comparison.

### 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
*y _{i}= W_{A}-W_{B}*
is the difference of the mean rank sums. The standard error is given by

Where *N* is the number of all cases, *r* is the number of connected
ranks, and *τ _{s} * is the number of cases at that rank.

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, the calculated p-value is multiplied by the number of 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.

DATAtab automatically outputs the Dunn-Bonferroni test when calculating a Kruskal-Wallis test.

## Calculate Kruskal-Wallis test online with DATAtab

Calculate the example directly with DATAtab for free:

Kruskal-Wallis-Test load data setOf course you can calculate the Kruskal-Wallis test online with DATAtab. 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 uncheck "Parametric test".

DATAtab then gives you 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 retained, 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 retained and it is assumed that there is no difference between the different groups in terms of reaction time.

## Kruskal-Wallis test reporting

How are the results from a Kruskal-Wallis test reported?

A Kruskal-Wallis test was calculated to test whether groups A, B, and C have an effect on reaction time. The Kruskal-Wallis test revealed that there is no significant difference between categories A, B, and C of the independent variable with respect to the dependent variable reaction time, 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 251 pages
**Only 6.99 €**

*"Super simple written"*

*"It could not be simpler"*

*"So many helpful examples"*