StatsCalculators.com

Kruskal-Wallis Test

The Kruskal-Wallis Test Calculator helps you perform non-parametric analysis of variance to compare three or more independent groups. It determines whether samples originate from the same distribution by analyzing the ranks of the data rather than the raw values. This makes it particularly useful when your data violates the assumptions of one-way ANOVA, such as normality or equal variances. Common applications include comparing patient outcomes across multiple treatment groups, analyzing survey responses, or evaluating differences in performance metrics across departments. Click here to populate the sample data for a quick example.

Calculator

1. Load Your Data

2. Select Columns & Options

Learn More

Kruskal-Wallis Test

Definition

Kruskal-Wallis Test is a non-parametric method for testing whether samples originate from the same distribution. It's used to determine if there are statistically significant differences between two or more groups of an independent variable on a continuous or ordinal dependent variable. It extends the Mann–Whitney U test, which is used for comparing only two groups. The parametric equivalent of the Kruskal–Wallis test is the one-way analysis of variance(ANOVA).

A significant result indicates that at least one group differs from the others, but it doesn't identify which group is different. Post-hoc tests such as Dunn's test or pairwise Mann-Whitney U test with Bonferroni correction are often used to determine which groups are significantly different.

Test Statistic

H=12N(N+1)i=1kRi2ni3(N+1)H = \frac{12}{N(N+1)}\sum_{i=1}^k \frac{R_i^2}{n_i} - 3(N+1)

Where:

  • NN = total number of observations
  • nin_i = number of observations in group ii
  • RiR_i = sum of ranks for group ii
  • kk = number of groups

Tie Correction

T=1j(tj3tj)N3NT = 1 - \frac{\sum_{j}(t_j^3 - t_j)}{N^3 - N}

where tjt_j is the number of tied observations at rank jj.

The corrected test statistic is then calculated as:

Hcorrected=HTH_{\text{corrected}} = \frac{H}{T}

Key Assumptions

Independent Samples: Groups must be independent
Ordinal Data: Variable should be ordinal or continuous
Similar Shape: Distributions should have similar shapes

Practical Example

Step 1: State the Data

Test scores from three groups:

  • Group 1: 7,8,6,57, 8, 6, 5
  • Group 2: 9,10,6,89, 10, 6, 8
  • Group 3: 10,9,810, 9, 8
Step 2: State Hypotheses
  • H0H_0: The distributions are the same across groups
  • HaH_a: At least one group differs in distribution
  • α=0.05\alpha = 0.05
Step 3: Calculate Ranks
ValueRankRank (Adjusted for ties)Group
511Group 1
622.5Group 1
632.5Group 2
744Group 1
856Group 1
866Group 2
876Group 3
988.5Group 2
998.5Group 3
101010.5Group 2
101110.5Group 3
Step 4: Calculate Rank Sums
  • Group 1: R1=13.5 (n1=4)R_1 = 13.5\ (n_1 = 4)
  • Group 2: R2=27.5 (n2=4)R_2 = 27.5\ (n_2 = 4)
  • Group 3: R3=25 (n3=3)R_3 = 25\ (n_3 = 3)
  • Total number of observations: N=11N = 11
Step 5: Calculate H Statistic
H=1211(12)(13.524+27.524+2523)3(12)=4.269H = \frac{12}{11(12)}\left(\frac{13.5^2}{4} + \frac{27.5^2}{4} + \frac{25^2}{3}\right) - 3(12) = 4.269Here, tied ranks are:
  • t2=2t_2 = 2 (the tie occurs at rank 2)
  • t6=3t_6 = 3
  • t8=2t_8 = 2
  • t10=2t_{10} = 2
The tie correction is:T=1(232)+(333)+(232)+(232)11311=0.968T = 1 - \frac{(2^3 - 2) + (3^3 - 3) + (2^3 - 2) + (2^3 - 2)}{11^3 - 11} = 0.968The corrected test statistic is:Hcorrected=4.2690.968=4.4092H_{\text{corrected}} = \frac{4.269}{0.968} = 4.4092
Step 6: Draw Conclusion

Referring to the Chi-square distribution table, the critical value for χ2\chi^2 with df=2df = 2 degrees of freedom at a significance level of α=0.05\alpha = 0.05 is 5.9915.991.

The p-value can be found using the Chi-square Distribution Calculator with df=2df = 2 and χ2=4.4092\chi^2 = 4.4092, which gives p=0.1103p = 0.1103.

Since H=4.4092<5.991H = 4.4092 < 5.991 (critical value), we fail to reject H0H_0. There is insufficient evidence to conclude that the distributions differ significantly across groups.

Effect Size

Eta-squared (η2\eta^2) measures the proportion of variability in ranks explained by groups:

η2=Hk+1nk\eta^2 = \frac{H - k + 1}{n - k}

Where:

  • HH = Kruskal-Wallis HH statistic
  • kk = number of groups
  • nn = total sample size

Interpretation guidelines:

  • Small effect: η20.010.06\text{Small effect: }\eta^2 \approx 0.01 - 0.06
  • Medium effect: η20.060.14\text{Medium effect: }\eta^2 \approx 0.06 - 0.14
  • Large effect: η2>0.14\text{Large effect: }\eta^2 > 0.14

For our example:

η2=4.40923+1113=2.40928=0.301\eta^2 = \frac{4.4092 - 3 + 1}{11 - 3} = \frac{2.4092}{8} = 0.301

This indicates a large effect size, suggesting substantial practical significance in the differences between groups, even though the result was not statistically significant.

Verification

Related Calculators