t-Test, Chi-Square, ANOVA, Regression, Correlation... (2024)

What is the Kruskal-Wallis test?

The Kruskal-Wallis test is a non-parametric statistical test used to compare three or more independent groups to determine if there are statistically significant differences between them. It is an extension of the Mann-Whitney U test, which is used for comparing two groups.

The Kruskal-Wallis test is used when the assumptions for a one way analysis of variance are not met. Since the Kruskal-Wallis test is a nonparametric testthe data used do not have to be normally distributed. The only requirement is that the data be ordinal scale.

t-Test, Chi-Square, ANOVA, Regression, Correlation... (1)

In the Kruskal-Wallis test, ordinal variables are sufficient, since non-parametric tests do not use the differences of the values, but the ranks.

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 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 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.

Alternative 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.

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. The test then sums these ranks for each group. The null hypothesis of the Kruskal-Wallis test is that the mean rank of the groups is the same. This is a bit 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, only several independent random samples with at least ordinally scaled characteristics must be available. The variables do not have to satisfy a distribution curve.

t-Test, Chi-Square, ANOVA, Regression, Correlation... (2)

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

t-Test, Chi-Square, ANOVA, Regression, Correlation... (3)

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:

t-Test, Chi-Square, ANOVA, Regression, Correlation... (4)

In the Kruskal-Wallis test, the test variable H is calculated. The H value corresponds to the χ2 value. The H value results from:

t-Test, Chi-Square, ANOVA, Regression, Correlation... (5)

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.

t-Test, Chi-Square, ANOVA, Regression, Correlation... (6)

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.

t-Test, Chi-Square, ANOVA, Regression, Correlation... (7)

Now we have calculated all values to calculate the test quantity H.

t-Test, Chi-Square, ANOVA, Regression, Correlation... (8)

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.

t-Test, Chi-Square, ANOVA, Regression, Correlation... (9)

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.

t-Test, Chi-Square, ANOVA, Regression, Correlation... (10)

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

t-Test, Chi-Square, ANOVA, Regression, Correlation... (11)

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:

Load data set

Of 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".

t-Test, Chi-Square, ANOVA, Regression, Correlation... (12)

DATAtab then gives you the results including interpretation in the following form:

t-Test, Chi-Square, ANOVA, Regression, Correlation... (13)

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 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.

t-Test, Chi-Square, ANOVA, Regression, Correlation... (2024)

References

Top Articles
Latest Posts
Article information

Author: Madonna Wisozk

Last Updated:

Views: 5460

Rating: 4.8 / 5 (68 voted)

Reviews: 91% of readers found this page helpful

Author information

Name: Madonna Wisozk

Birthday: 2001-02-23

Address: 656 Gerhold Summit, Sidneyberg, FL 78179-2512

Phone: +6742282696652

Job: Customer Banking Liaison

Hobby: Flower arranging, Yo-yoing, Tai chi, Rowing, Macrame, Urban exploration, Knife making

Introduction: My name is Madonna Wisozk, I am a attractive, healthy, thoughtful, faithful, open, vivacious, zany person who loves writing and wants to share my knowledge and understanding with you.