liveBook · Manning

Kruskal-wallis test

As explained in Effective Data Analysis

The Kruskal-Wallis test is a rank-based non-parametric statistical test for comparing three or more independent groups.

The Kruskal-Wallis test compares two or more independent groups using the ranks of continuous or ordinal observations. It is a non-parametric alternative to a one-way ANOVA when the data are not normally distributed, or when scores are ordinal. section 5.2.1

The test combines rank sums across groups, accounting for group size, to produce an H-statistic. H indicates the magnitude of a group difference, not which group has higher scores. Unlike a one-way ANOVA, the test does not assume a particular underlying distribution shape, but it has lower statistical power. section 5.2.1

Choose and interpret the test in context:

  • For two independent groups, the Mann-Whitney U test is another option; for three or more dependent groups, use a test suited to dependent samples, such as the Friedman test. section 5.2.1 section 5.4
  • A significant result across three or more groups does not identify the differing pairs. Follow it with corrected post hoc comparisons to limit false positives. section 5.2.1 section 5.4

Comparing assessment scores

Given three groups of assessment scores with different distribution shapes, plot their histograms, consider whether transformations make ANOVA appropriate, and run a Kruskal-Wallis test. Then examine which group scores highest and how changing sample sizes affects the result; use post hoc tests when pairwise conclusions are needed. section 5.2.2

H = st.kruskal(X1, X2, X3)
print(H)

This short SciPy listing shows the test call for three independent score arrays; its returned result must still be interpreted alongside the distributions and any needed post hoc comparisons. section 5.2.2

How Effective Data Analysis covers it

How deep it goes
Explains rank sums, group-size weighting, the H-statistic, limitations, and follow-up comparisons, without deriving a formula in the supplied passage.
Examples
Uses simulated skewed groups and a three-group assessment exercise with histograms, sample-size changes, and Python test calls.
What it assumes
Assumes familiarity with groups, p-values, and Python for the exercises; introduces non-parametric group comparisons in plain terms.
What you can do after
Apply it via SciPy to compare independent groups, then use corrected post hoc tests when significant multi-group results need pairwise interpretation.
How it connects
Relates the test to one-way ANOVA, the Mann-Whitney U test, the Friedman test, and post hoc comparisons.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Effective Data Analysis. The section links point to the parts of the book it draws on.