Unit 5 · Categories and non-parametrics
How to run a Kruskal-Wallis test in SPSS
Run a Kruskal-Wallis H test in SPSS with Bonferroni-corrected follow-up tests.
Quick answer: How do you run a Kruskal-Wallis test in SPSS?
- Click Analyze › Nonparametric Tests › Legacy Dialogs › K Independent Samples.
- Move the outcome into Test Variable List and the group variable into Grouping Variable.
- Click Define Range and enter the lowest and highest group codes, then click OK.
Report it in APA style: Stress differed across year groups, H(2) = 11.15, p = .004.
What is the Kruskal-Wallis test?
The Kruskal-Wallis H test is the non-parametric alternative to one-way ANOVA. It compares three or more independent groups using ranks.
When to use it
- Three or more independent groups.
- An ordinal outcome, or Scale data that clearly break ANOVA’s assumptions.
How it works
All scores are ranked together, then H tests whether the mean ranks differ more than chance would allow. Degrees of freedom are groups − 1. Like ANOVA, it only says that some difference exists; follow up with Mann-Whitney tests using a Bonferroni-corrected α (.05 ÷ number of comparisons).
Assumptions
- Independent groups and observations.
- Ordinal or Scale outcome.
- Similar distribution shapes if you interpret it as a difference in medians.
Worked example
Stress differed across year groups, H(2) = 11.15, p = .004. Follow-up tests (α = .017) showed final-year students were more stressed than first-years (p = .001).
Key terms
- H statistic
- Kruskal-Wallis test statistic, compared with a chi-square distribution.
- Bonferroni correction
- Dividing α by the number of comparisons.
Common mistakes
- Running follow-up Mann-Whitney tests without correcting α.
- Reporting means instead of medians.
How to do it in SPSS
The SPSS syntax
Prefer typing to clicking? Open File › New › Syntax, paste this in, select it and choose Run › Selection. Every dialog's Paste button writes the same kind of code.
NPAR TESTS
/K-W=stress BY year(1 3)
/STATISTICS=QUARTILES.
* Follow-up: compare two years at a time, then use alpha = .05 / 3 = .017.
NPAR TESTS /M-W=stress BY year(1 3).Practice data
Download the file used in this lesson and run it yourself in SPSS. Your results will closely match the screens above, though a few numbers may differ slightly.
- year_stress.savStress ratings by year of study (N = 45)
Now practise it interactively →
Reading is only half of it. Tap through the real SPSS menus, read the output and pick the right write-up in 7 quick questions, with instant feedback on every answer.
Practice for this lesson is part of Pro, with every unit, unlimited hearts and saved progress.