← All resources

WORKED EXAMPLE · ORDINAL OUTCOMES ACROSS THREE GROUPS

Kruskal–Wallis and Dunn Worked Example: Ordinal Scores Across Three Independent Groups

Follow tied ordinal pain-interference scores through a rank-based three-group comparison, tie correction, Holm-adjusted Dunn follow-ups, interpretation, and BioTabular setup.

Published by BioTabularLast reviewed: November 1, 2026

This worked example uses synthetic data created for teaching. Imagine a randomized three-arm study in which each participant is assigned to control, a standard program, or an intensive program. At week 6, each participant reports pain interference on an ordered scale from 0 to 10, where lower values indicate less interference. Every participant contributes one score.

Define the design and the rank-based question

Observational unit
One independently randomized participant.
Groups
Control, standard program, or intensive program; each participant belongs to one group only.
Outcome
Week-6 pain-interference score from 0 to 10, treated as an ordered outcome.
Primary question
Are the population score distributions equal across all three groups?
Follow-up question
Which group pairs differ after accounting for the three pairwise comparisons?
Starting method
A tie-corrected Kruskal–Wallis test followed by two-sided Dunn comparisons with Holm adjustment.

The null hypothesis is that the three population distributions are equal. The alternative is that at least one differs. This is a rank-distribution question—not the same estimand as the mean comparison in one-way ANOVA. A location or median interpretation requires additional context about the shapes and spreads of the group distributions.

Inspect the synthetic participant-level data

The file contains 36 complete observations, with 12 independent participants in each group. Scores repeat because this integer scale has eleven possible categories—0 through 10 inclusive. That count is unrelated to the test’s degrees of freedom. BioTabular assigns average ranks to tied observations and applies the standard tie correction.

ParticipantProgramPain-interference score
C01Control8
C02Control7
C03Control9
C04Control6
C05Control8
C06Control7
C07Control9
C08Control8
C09Control6
C10Control7
C11Control8
C12Control9
S01Standard program6
S02Standard program5
S03Standard program7
S04Standard program6
S05Standard program5
S06Standard program6
S07Standard program7
S08Standard program5
S09Standard program6
S10Standard program4
S11Standard program7
S12Standard program6
I01Intensive program5
I02Intensive program4
I03Intensive program6
I04Intensive program5
I05Intensive program3
I06Intensive program4
I07Intensive program6
I08Intensive program5
I09Intensive program4
I10Intensive program3
I11Intensive program5
I12Intensive program6

Describe the observed score distributions

Control
n = 12; median = 8; IQR = 1.25; mean rank = 28.9583
Standard program
n = 12; median = 6; IQR = 1.25; mean rank = 17.2083
Intensive program
n = 12; median = 5; IQR = 1.25; mean rank = 9.3333
Complete observations
36 included; 0 omitted
Observed scores
3 through 9, with ties at every value
Direction
Lower ranks correspond to less pain interference
Dot plot of pain-interference scores in control, standard-program, and intensive-program groups. Control scores are generally highest, intensive-program scores are lowest, and adjacent groups overlap.
Show the individual ordinal scores, their overlap, and the group medians. The plotted separation supports a location-oriented description for this teaching dataset, but the test calculation uses pooled ranks.

Calculate the tie-corrected Kruskal–Wallis statistic

All 36 scores are pooled and ranked from smallest to largest. Tied scores receive their average rank. The test compares each group’s rank sum with what would be expected if the group distributions were equal, then corrects the statistic for ties.

A mean rank is the sum of a group’s pooled ranks divided by that group’s sample size. For example, the two scores of 3 occupy pooled ranks 1 and 2, so each receives rank 1.5. The four scores of 4 occupy ranks 3 through 6, so each receives rank 4.5. The complete pooled ranking is:

Observed scorePooled countAverage rank assigned
321.5
444.5
5710.0
61018.5
7626.5
8431.5
9335.0

The control participants’ ranks sum to 347.5, so their mean rank is 347.5 ÷ 12 = 28.9583. The standard-program rank sum is 206.5, giving 17.2083. The intensive-program rank sum is 112.0, giving 9.3333. Because lower scores receive lower ranks, the intensive group has the lowest mean rank. These are summaries of pooled ranks, not means of the original 0–10 scores.

H = tie-corrected contrast among the three group rank sumsH(2) = 21.8803; p = 0.0000177

The degrees of freedom are the number of groups minus one: 3 − 1 = 2. At α = .05, the result provides evidence that at least one population score distribution differs. It does not identify which pair differs, prove that all pairs differ, or estimate a mean difference. The low p-value also does not measure clinical importance.

Follow the omnibus result with Holm-adjusted Dunn comparisons

Dunn comparisons use differences in mean ranks and the same tie-aware rank variance as the overall analysis. Holm adjustment controls the family-wise error rate across the three pairwise tests without assuming that an unadjusted p-value can be read in isolation. The contrast is the second named group minus the first, so negative z values indicate lower ranks in the program group.

ContrastzRaw pHolm-adjusted p
Standard program − Control−2.78260.005390.01079
Intensive program − Control−4.64750.000003360.0000101
Intensive program − Standard program−1.86490.062190.06219

Assumptions and design checks

  1. Independent observations: each participant contributes one score to one group. Repeated, matched, family-clustered, or site-clustered observations need a method that represents that dependence.
  2. Ordered outcome: larger values consistently mean more pain interference, so ranking is meaningful.
  3. Comparable measurement: all groups use the same scale, timing, instructions, and scoring rule.
  4. Distributional interpretation: Kruskal–Wallis tests equality of distributions. Describing a location shift or median difference requires that the shapes and spreads make that interpretation reasonable.
  5. Ties: repeated ordinal scores are expected. The calculation must use average ranks and a tie correction.
  6. Planned multiplicity control: pairwise questions and the Holm adjustment should be chosen from the analysis plan, not selected after viewing favorable comparisons.

Reproduce the result in BioTabular

  1. Download the synthetic CSV and open the Kruskal–Wallis calculator.
  2. Import the file. Keep Participant_ID as the identifier, Program as categorical, and Pain_Interference_Score as numeric or ordinal.
  3. Review the group order as Control, Standard program, Intensive program, then confirm the variable roles.
  4. Choose outcome-plus-grouping-column format. Select Pain_Interference_Score as the outcome and Program as the grouping column.
  5. Keep Holm adjustment and select “Show adjusted Dunn p-values.”
  6. Run the analysis. Confirm 36 included observations, no omissions, mean ranks 28.958, 17.208, and 9.333, and H(2) = 21.880 with p < .001.
  7. Confirm adjusted p-values of .011, < .001, and .062 in the stated contrast order, then use Plot Studio to inspect a grouped box or violin plot with observations.

Interpret and report the result

The synthetic randomized design supports comparing the assigned groups at week 6, but the analysis remains an unadjusted single-time-point comparison. The data support lower score distributions in each program group than in control. They do not establish that intensive is better than standard, quantify a clinically important difference, or show how scores changed from baseline.

“Week-6 pain-interference score distributions differed among control (median 8, IQR 1.25), standard program (median 6, IQR 1.25), and intensive program (median 5, IQR 1.25), Kruskal–Wallis H(2) = 21.88, p < .001. Holm-adjusted Dunn comparisons supported lower ranks for standard versus control (z = −2.78, adjusted p = .011) and intensive versus control (z = −4.65, adjusted p < .001), but not intensive versus standard (z = −1.86, adjusted p = .062).”

Common mistakes this example avoids

  • Calling Kruskal–Wallis a variance-free ANOVA that tests exactly the same mean estimand.
  • Reporting a significant result automatically as a difference in medians.
  • Claiming every pair differs because the omnibus test is significant.
  • Running three unadjusted rank-sum tests after the overall analysis.
  • Ignoring ties from an ordinal scale.
  • Reading adjusted p = .062 as proof of equivalence.
  • Using an independent-groups test for repeated or matched scores.

Limits of this worked example

The dataset is small, balanced, complete, synthetic, and deliberately follows similarly shaped group distributions. It contains one week-6 outcome, no baseline adjustment, covariates, clustering, repeated follow-up, or missing data. A real ordinal outcome may call for an ordinal regression model, a longitudinal ordinal model, prespecified covariate adjustment, cluster-aware inference, or an estimand that directly expresses a clinically meaningful probability or threshold.

Related resources

Compare this rank-based analysis with the one-way ANOVA worked example, which targets mean differences across three independent groups. Read T-test vs. ANOVA for the broader independent-group framework, or return to Which Statistical Test Should I Use? for other outcome structures.

References and further reading

BioTabular’s editorial approach and scope explain how these educational resources are prepared and what they do not replace.