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.

Free tutorialPro practiceAbout 5 minutes7 practice questions

Quick answer: How do you run a Kruskal-Wallis test in SPSS?

  1. Click Analyze › Nonparametric Tests › Legacy Dialogs › K Independent Samples.
  2. Move the outcome into Test Variable List and the group variable into Grouping Variable.
  3. 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.

Last updated November 2026 · Not sure this is the right test? Try the Which statistical test? tool.

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

Kruskal-Wallis H

The nonparametric version of one-way ANOVA. Use it for three or more independent groups when your data are ordinal or not normal.

Tests for Several Independent Samples
Variables
Participant ID [id]
Age in years [age]
▶
Test Variable List:1
Stress rating [stress]
▶
Grouping Variable:
year(1 3)
Define Range…2
Exact…Options…
✓Kruskal-Wallis H3
Median
Jonckheere-Terpstra
OKPasteResetCancelHelp
  1. 1
    Test Variable ListThe outcome, such as a stress rating from 1 to 10.
  2. 2
    Define Range…Enter the lowest and highest group codes: Minimum 1, Maximum 3.
  3. 3
    Kruskal-Wallis HTicked by default. Found under Legacy Dialogs › K Independent Samples.

Reading Kruskal-Wallis output

Same idea as Mann-Whitney: ranks first, then the test.

Output1 [Document1] – SPSS Statistics Viewer
FileEditViewDataTransformAnalyzeGraphsUtilitiesExtensionsWindowHelp
Output
Log
NPar Tests
Kruskal-Wallis Test
Ranks
Test Statistics
Ranks · stress
yearNMean Rank1
Year 11515.50
Year 21522.23
Final year1531.27
Total45
Test Statistics
stress
Kruskal-Wallis H11.1502
df2
Asymp. Sig..0043

Grouping Variable: year · Medians: Year 1 = 4, Year 2 = 6, Final year = 7

  1. 1
    Mean RankStress rises from Year 1 to Final year.
  2. 2
    Kruskal-Wallis HThe test statistic, reported with df = groups − 1.
  3. 3
    Asymp. Sig..004 is below .05, so at least one group differs. Follow-up tests tell you which.

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.

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.

More in Categories and non-parametrics