The Kruskal-Wallis test
Another non-parametric test we will now discuss is the Kruskal-Wallis test. It is an alternative to the one-way ANOVA test when the normality assumption is not satisfied. It uses the medians instead of the means to test whether there are statistically significant differences between two or more independent groups. Let us consider a generic example of three independent groups:
group1 = [8, 13, 13, 15, 12, 10, 6, 15, 13, 9] group2 = [16, 17, 14, 14, 15, 12, 9, 12, 11, 9] group3 = [7, 8, 9, 9, 4, 15, 13, 9, 11, 9]
The null and alternative hypotheses are stated as follows.
H 0 : The medians are equal among these three groups
H a : The medians are not equal among these three groups
In Python, it is easy to implement by using the scipy.stats.kruskal
function. The documentation can be found at the following link:
https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.kruskal.html
from scipy import stats group1 = [8, 13, 13,...