Home • SimpleStats • User Guide and Documentation

☰ Menu
We are updating all the pages, it will be complete soon!

Analyze/Stats: Kruskal-Wallis H-Test

The Kruskal-Wallis H-test is a non-parametric statistical method used to determine whether three or more independent groups originate from the same distribution. As the non-parametric alternative to one-way ANOVA, it’s particularly valuable when data violates normality assumptions or when working with ordinal variables.

Why Use This Test?

Unlike parametric ANOVA that compares group means, the Kruskal-Wallis test evaluates differences in median ranks across groups. This makes it good for:

  • Non-normal data distributions (doesn’t assume normality)
  • Ordinal data or continuous data that fails normality tests
  • Small sample sizes (though each group should have ≥5 observations)
  • Unequal group sizes (handles different sample sizes per group)

Common applications include clinical trials comparing multiple treatments, customer satisfaction surveys across regions, or any scenario comparing ≥3 independent groups with non-parametric data.

When Should You Use the Kruskal-Wallis Test?

  • You need to compare three or more independent groups
  • Your data is ordinal or continuous but non-normal
  • Sample sizes are unequal across groups
  • You want a non-parametric alternative to one-way ANOVA

Common Alternatives (When Kruskal-Wallis Isn’t the Best Fit)

How to Interpret the Results

The Kruskal-Wallis test returns two key numbers:

  1. H-statistic: Measures the degree of difference in group rankings (higher values indicate greater divergence)
  2. p-value: Determines statistical significance of observed differences
Kruskal-Wallis results, example
Kruskal-Wallis results, example

This is how you see the Kruskal-Wallis results with SimpliStats

Decision Rule:
  • p-value < 0.05: Reject null hypothesis (evidence that at least one group differs)
  • p-value ≥ 0.05: No significant evidence of group differences

Important Note: A significant result doesn’t indicate which groups differ – post hoc tests are needed for pairwise comparisons.

Example:

Suppose you compare customer satisfaction scores (1-10 scale) across three store locations:

Kruskal-Wallis data, example
  • H-statistic: 11.0623
  • P-value = 0.0039 (or p < 0.01)

Since 0.0039 < 0.05, you conclude:
“There are statistically significant differences in satisfaction scores between at least two store locations.”

How the function is called in the background

				
					from scipy.stats import kruskal

statistic, pvalue = kruskal(group1, group2, group3)
				
			

Input

  • *samples: Two or more 1D arrays of sample dataaxis:

Output

  • statistic: The Kruskal-Wallis H statistic
  • pvalue: The associated p-value

Conclusion

The Kruskal-Wallis test is a robust non-parametric method for comparing multiple independent groups. While it identifies whether differences exist, researchers should plan for post hoc tests to pinpoint specific group disparities. Its flexibility with non-normal data and unequal sample sizes makes it invaluable across scientific, business, and social research contexts.