What is a Kruskal Wallis test?
Use the Kruskal-Wallis test to determine whether the medians of two or more groups differ when you have data that are not symmetric, such as skewed data.
The Kruskal-Wallis test is a non-parametric statistical technique and is an alternative to one-factor ANOVA. This test assumes that we have one continuous dependent variable (e.g. anxiety level, stress level, etc.) and one categorical variable with three or more groups (e.g. marital status, education level, etc.).
When Should a Kruskal Wallis be Used?
The Kruskal-Wallis test is a nonparametric alternative to a one-way ANOVA. Non-parametric means that the test doesn’t assume your data comes from a particular distribution. The test doesn’t require the data to be normal but instead uses the rank of the data values instead of the actual data values for the analysis.
An Example Of the Kruskal Wallis Test
For example, Suppose a researcher wants to examine whether there are differences in test scores based on where a student was born. Therefore, we have one independent categorical variable country with three categories (USA, Australia, Europe) and one continuous dependent variable (exam score).
What are the use of null and alternative hypothesis for the Kruskal Wallis Test?
Therefore, we test the following hypotheses:
Null hypothesis: There is no significant effect of the country where students were born (USA, Australia, Europe) on exam scores.
Alternative hypothesis: There is a significant effect of the country where students were born (USA, Australia, Europe) on exam scores.
R function to Compute Kruskal Wallis Test
The code to run a Kruskal Wallis Test using R is as follows:
kruskal.test(DV~ IV, var.equal=TRUE, data = dataframe)
DV: dependent variable
IV: Independent variable