Skip to content
Related Articles

Related Articles

Improve Article

Kruskal Wallis Test

  • Last Updated : 26 Nov, 2020

Kruskal Wallis Test: It is a nonparametric test. It is sometimes referred to as One-Way ANOVA on ranks. It is a nonparametric alternative to One-Way ANOVA. It is an extension of the Man-Whitney Test to situations where more than two levels/populations are involved. This test falls under the family of Rank Sum tests. It depends on the ranks of the sample observations.

Non-Parametric Test:  It is a test which does not follow normal distribution.

Elements of a Kruskal Wallis Test

  • One independent variable with two or more levels. This independent variable is Categorical.
  • One dependent variable which can be in Ordinal, Interval or Ratio level of measurement.

Assumptions of Kruskal Wallis Test

  • Independence of Observations – Each observation can belong to only one level.
  • No assumption of normality.
  • Additional Assumption – The distributions of the dependent variable for all levels of the independent variable must have similar shapes. We can male use of Histograms or Boxplots to determine if the distributions have similar shapes. If this assumption is met it allows you to interpret the results of the Kruskal Wallis Test in terms of medians and not just mean ranks.

Null Hypothesis of Kruskal Wallis Test



The Kruskal Wallis Test has one Null Hypothesis i.e. – The distributions are Equal.

H Statistics of Kruskal Wallis Test

H=\left[\frac{12}{n(n+1)} \sum \frac{R_{i}^{2}}{n_{i}}\right]-3(n+1)
ni = number of items in sample i
Ri = sum of ranks of all items in sample i
K = total number of samples
n = n1 + n2 + ...... +nK ; Total number of observations in all samples.

Steps to perform Kruskal Wallis Test

Let us take an example to understand how to perform this test.

Example:- The score of a sample of 20 students in their university examination are arranged according to the method used in their training : 1) Video Lectures 2) Books and Articles 3) Class Room Training. Evaluate the Effectiveness of these training methods at 0.10 level of significance.

Video LectureBooks and ArticlesClass Room Training
768070
908085
846752
955993
579186
729479
 6880

Step 1: Identify Independent and Dependent variables

Here,
Independent variable – method of training. It has three levels.
Dependent variable – examination scores.



Step 2: State the Hypothesis

H0 = The mean examination scores of students trained by each of the three methods are equal. u1=u2=u3.

H1 = At least one of the mean examination scores is not equal.

Step 3: Sort the data for all groups in ascending order and allot them ranks. If more than one entry has the same score then take the average of the ranks and allot the same rank to each of those entries.

Rank ScoreTraining MethodRank ScoreTraining Method
152CR1180BA
257VL1180CR
359BA1384VL
467BA1485CR
568BA1586CR
670CR1690VL
772VL1791BA
876VL1893CR
979CR1994BA
1180BA2095VL

In this the score 80 had three ranks 10, 11 and 12. So we took the average of these ranks which was 11.

Step 4: Arrange back according to the levels an calculate the sum of ranks for each level.

Video Lecture RankBooks and ArticlesRankClass Room TrainingRank
572593521
727674706
768685799
841380118011
901680118514
952091178615
  94199318
 ∑=66 ∑=70 ∑=74

Step 5: Calculate H Statistics

H=\frac{12}{20(20+1)}\left[\frac{66^{2}}{6}+\frac{70^{2}}{7}+\frac{74^{2}}{7}\right]-3(20+1)

H = 0.0938

Step 6: Find the critical chi-square value



  • The chi-square distribution can be used when all the sample sizes are at least 5.

Degree of freedom = K-1 => 3-1=2 
Alpha = 0.10

Use this chi-square table to find the value.

X2 = 4.605

Step 7: Compare H value and Critical Chi- Square value

  • If H calc < X2 ; Accept the Null Hypothesis
  • If H calc > X2 ; Reject the Null Hypothesis

Here, 0.0938 < 4.605.

Since, Hcalc < X2 . We accept the Null Hypothesis. We can say that there is no difference in the result obtained by using the three training methods.

This is all about the Kruskal Wallis Test. For any queries do leave a comment down below.

Attention reader! Don’t stop learning now. Get hold of all the important Machine Learning Concepts with the Machine Learning Foundation Course at a student-friendly price and become industry ready.




My Personal Notes arrow_drop_up
Recommended Articles
Page :