What Is the Kruskal-Wallis Test?
Named for William Kruskal and W. Allen Wallis, who published it in 1952, the test works by replacing raw observations with their ranks within the combined dataset. Instead of asking "are the group means different?", it asks "are the rank distributions different?" That shift makes it useful for ordinal data, skewed distributions, and situations where small samples make normality assumptions difficult to verify.
One thing to keep in mind from the start: calling the Kruskal-Wallis test simply "the nonparametric ANOVA" is a common shorthand that can mislead. ANOVA compares means directly. The Kruskal-Wallis test compares rank distributions. A median interpretation is reasonable when the group distributions share a similar shape, but when shapes differ, a significant result may reflect a difference in spread or skewness rather than location. Parametric vs. nonparametric tests covers these distinctions in depth.
When to Use the Kruskal-Wallis Test
The Kruskal-Wallis test is appropriate when all of the following conditions point toward a rank-based approach:
The test is designed for three or more groups. For exactly two independent groups, the Mann-Whitney U test handles the same question. See the Mann-Whitney U test guide for that case.
The dependent variable must be at least ordinal so that ranking observations is meaningful. Likert-scale responses, satisfaction ratings, and clinical severity scores are typical examples.
Observations must be independent both within and between groups. If the same subjects appear in multiple groups, or measurements are matched or blocked, the Friedman test is more appropriate.
When data are skewed, contain outliers, or come from populations where normality cannot be reasonably assumed, a rank-based approach avoids reliance on the distributional assumptions underpinning one-way ANOVA.
For larger samples, one-way ANOVA is quite robust to moderate departures from normality due to the central limit theorem. With enough data and a continuous outcome that is only mildly skewed, ANOVA can be the better choice because it directly compares means with greater statistical power.
The Kruskal-Wallis test does not have a universal minimum sample size that guarantees validity. For small samples where the chi-square approximation may be imprecise, exact methods exist and some software implementations offer them. For most practical applications, a few observations per group is sufficient for the asymptotic approximation to perform adequately, but researchers should verify this for their specific situation.
Kruskal-Wallis Test Hypotheses
H₀: All groups come from the same distribution (under the conditions required for the intended interpretation). Hₐ: At least one group differs in its distribution from the others. Note: the alternative does not say every group differs from every other group.
The null hypothesis states that all groups share the same underlying distribution. When the distributions have similar shapes, this is equivalent to saying all groups have the same population median (or, more loosely, the same central tendency). The alternative states that at least one group differs, not that all groups are mutually distinct.
A significant Kruskal-Wallis result tells you that the groups do not all behave the same way statistically, but it does not tell you which ones differ. That requires post-hoc testing, covered below.
Kruskal-Wallis H Statistic Formula
After ranking all N observations across the combined dataset and calculating the rank sum Rᵢ for each group, the H statistic is:
k = number of groups
nᵢ = sample size of group i
Rᵢ = sum of ranks for group i
N = total observations (Σnᵢ)
The factor 12 / [N(N+1)] normalizes the rank sums so that H follows (approximately) a chi-square distribution with k−1 degrees of freedom when the null hypothesis is true and sample sizes are not extremely small. Larger H values indicate greater separation in the rank distributions across groups.
Tie Correction
When observations share the same value, they receive the average of the ranks they would occupy if they were distinct. This averaging reduces the variability of ranks and inflates H slightly relative to what the uncorrected formula gives. A tie correction factor C corrects for this:
tⱼ = number of observations in the j-th tied group
N = total observations
The tie correction has minimal effect when the proportion of tied observations is small. Most statistical software — including SPSS, R's kruskal.test(), and scipy.stats.kruskal in Python — applies the tie correction automatically. When ties are extensive, they can indicate that a different measurement approach (capturing more granular data) might be worth considering.
These are two different adjustments. The tie correction (shown above) accounts for tied ranks in the data. A continuity correction is sometimes used in other nonparametric tests to approximate a discrete distribution with a continuous one. Do not confuse them.
Degrees of Freedom and P-Value
The degrees of freedom for the Kruskal-Wallis test are:
For four groups, df = 3. The p-value is the probability of observing H ≥ h (or a more extreme value) under the null hypothesis, evaluated against the chi-square distribution with df = k−1. When p < α, reject H₀. When p ≥ α, there is not sufficient evidence to conclude that the groups differ. Failure to reject H₀ is not the same as proving that the groups are identical.
Worked Examples — Step-by-Step Manual Calculations
Each example below follows a consistent structure and shows every calculation. Data values are kept small enough for manual verification. The methodology follows the approach described by NIST.
Example 1 — Basic Three-Group Comparison
Problem: Three groups of students received different teaching methods (A, B, C). Their post-test scores are: A = {65, 72, 68}, B = {80, 85, 78}, C = {55, 60, 58}. Test at α = 0.05 whether the groups differ in their score distributions.
Hypotheses: H₀: All three groups come from the same distribution | Hₐ: At least one group differs
Combine and rank all 9 observations:
55(rank 1), 58(2), 60(3), 65(4), 68(5), 72(6), 78(7), 80(8), 85(9)
Group A scores: 65→4, 72→6, 68→5 | Group B: 80→8, 85→9, 78→7 | Group C: 55→1, 60→3, 58→2
Rank sums: RA = 4+6+5 = 15 | RB = 8+9+7 = 24 | RC = 1+3+2 = 6
Calculate H:
N = 9, nA = nB = nC = 3
H = [12/(9×10)] × [(15²/3) + (24²/3) + (6²/3)] − 3(10)
H = [12/90] × [75 + 192 + 12] − 30
H = 0.1333 × 279 − 30 = 37.2 − 30 = 7.2
Degrees of freedom: df = 3 − 1 = 2
P-value: H = 7.2 with df = 2 gives p ≈ 0.027. Since p < 0.05, reject H₀.
✅ Conclusion: H(2) = 7.20, p ≈ 0.027. There is sufficient evidence at the 5% level that at least one teaching method produces a different score distribution. Post-hoc testing is needed to identify which groups differ.
Example 2 — Four Groups with Tied Ranks
Problem: Four clinics report patient satisfaction scores (1–10 scale). Clinic A = {6, 7, 6}, B = {8, 9, 8}, C = {5, 5, 6}, D = {7, 8, 7}. Test at α = 0.05.
Hypotheses: H₀: All four clinics share the same distribution | Hₐ: At least one clinic differs
Rank all 12 observations (average ranks for ties):
Values sorted: 5,5,6,6,6,6,7,7,7,8,8,9
5,5 → ranks 1,2 → average = 1.5 (assigned to both 5s)
6,6,6,6 → ranks 3,4,5,6 → average = 4.5 (all four 6s)
7,7,7 → ranks 7,8,9 → average = 8 (all three 7s)
8,8 → ranks 10,11 → average = 10.5 (both 8s)
9 → rank 12
Assign ranks back to groups:
A: 6→4.5, 7→8, 6→4.5 | RA = 17
B: 8→10.5, 9→12, 8→10.5 | RB = 33
C: 5→1.5, 5→1.5, 6→4.5 | RC = 7.5
D: 7→8, 8→10.5, 7→8 | RD = 26.5
Uncorrected H:
N = 12, each nᵢ = 3
H = [12/(12×13)] × [(17²+33²+7.5²+26.5²)/3] − 3(13)
H = [12/156] × [(289+1089+56.25+702.25)/3] − 39
H = 0.07692 × 712.167 − 39 = 54.783 − 39 = 15.78
Tie correction:
Tied groups: two 5s (t=2), four 6s (t=4), three 7s (t=3), two 8s (t=2)
Σ(tⱼ³−tⱼ) = (8−2)+(64−4)+(27−3)+(8−2) = 6+60+24+6 = 96
N³−N = 1728−12 = 1716
C = 1 − (96/1716) = 1 − 0.05594 = 0.9441
Hcorrected = 15.78 / 0.9441 = 16.71
df = 3, p-value: H = 16.71 with df = 3 gives p ≈ 0.001 < 0.05 → Reject H₀
✅ Conclusion: H(3) = 16.71 (tie-corrected), p ≈ 0.001. Patient satisfaction distributions differ significantly across the four clinics. Post-hoc testing with Dunn's test is required to determine which specific pairs differ.
Example 3 — Unequal Sample Sizes
Problem: Three fertilizer treatments with different plot counts. Group 1 (n=2): {12, 15}; Group 2 (n=4): {20, 18, 22, 19}; Group 3 (n=3): {8, 10, 9}. Test at α = 0.05.
H₀: All three fertilizer treatments produce the same yield distribution
Rank all 9 values combined:
8(1), 9(2), 10(3), 12(4), 15(5), 18(6), 19(7), 20(8), 22(9)
Rank sums:
G1 (n=2): 12→4, 15→5 | R₁ = 9
G2 (n=4): 20→8, 18→6, 22→9, 19→7 | R₂ = 30
G3 (n=3): 8→1, 10→3, 9→2 | R₃ = 6
H calculation (N=9):
H = [12/(9×10)] × [(9²/2)+(30²/4)+(6²/3)] − 3(10)
H = 0.1333 × [40.5+225+12] − 30
H = 0.1333 × 277.5 − 30 = 37.0 − 30 = 7.0
df = 2, p ≈ 0.030 < 0.05 → Reject H₀
✅ Conclusion: H(2) = 7.0, p ≈ 0.030. Fertilizer treatment significantly affects yield distributions, even with unequal sample sizes. The Kruskal-Wallis test handles unequal group sizes naturally.
Example 4 — Non-Significant Result
Problem: Three groups of workers report hours of overtime per week. Group X = {3, 4, 5}, Group Y = {3, 5, 4}, Group Z = {4, 3, 5}. Test at α = 0.05.
Rank all 9 observations: 3,3,3 → tied at average rank (1+2+3)/3 = 2; 4,4,4 → ranks 4,5,6 → average 5; 5,5,5 → ranks 7,8,9 → average 8
Rank sums: Each group has one 3, one 4, one 5 → RX = RY = RZ = 2+5+8 = 15
H = 0. When rank sums are equal across groups, H = 0, giving p = 1.0.
✓ Conclusion: H(2) = 0, p = 1.0. There is no evidence that overtime distributions differ across the three groups. Failing to reject H₀ is not proof the groups are identical — it means the data do not provide sufficient evidence of a difference.
Example 5 — Medical Research Context
Problem: Three hospital wards record patient-reported pain levels (1–10) post-surgery. Ward A = {7, 8, 6, 9}, Ward B = {4, 3, 5, 4}, Ward C = {6, 5, 7, 6}. Test at α = 0.05.
H₀: Pain level distributions are the same across all three wards
Combined sorted values (N=12):
3(1), 4(2.5), 4(2.5), 5(4.5), 5(4.5), 6(7), 6(7), 6(7), 7(9.5), 7(9.5), 8(11), 9(12)
Rank sums per ward:
A: 9.5+11+7+12 = 39.5 (n=4)
B: 4+2.5+4.5+2.5 = 13.5 (n=4)
C: 7+4.5+9.5+7 = 28 (n=4)
H (uncorrected):
H = [12/(12×13)] × [(39.5²+13.5²+28²)/4] − 3(13)
H = 0.07692 × [(1560.25+182.25+784)/4] − 39
H = 0.07692 × 631.625 − 39 = 48.59 − 39 = 9.59
Tie correction: Tied groups: two 4s (t=2), two 5s (t=2), three 6s (t=3), two 7s (t=2)
Σ(tⱼ³−tⱼ) = 6+6+24+6 = 42 | C = 1 − (42/1716) = 0.9755
Hcorr = 9.59/0.9755 ≈ 9.83
df = 2, p ≈ 0.007 < 0.05 → Reject H₀
✅ Conclusion: H(2) = 9.83 (tie-corrected), p ≈ 0.007. Post-surgical pain levels differ significantly across the three wards. Dunn's test with Holm correction would identify which pairs account for the difference.
Kruskal-Wallis Test Calculator
Enter raw data values for each group (comma-separated). The calculator ranks all observations together, handles tied ranks with the tie correction, computes the H statistic, degrees of freedom, p-value, effect size (ε²), and optionally runs pairwise Dunn's test with Bonferroni or Holm correction.
Kruskal-Wallis Test Calculator
Calculations run entirely in your browser. No data is transmitted or stored.
Post-Hoc Testing After a Significant Kruskal-Wallis Test
A significant Kruskal-Wallis result answers one question: do the groups differ? It does not answer which groups differ. For that, pairwise post-hoc comparisons are necessary. Skipping post-hoc analysis and concluding "Group A and Group B are different" from a significant omnibus test alone is a common statistical error.
Dunn's Test
Dunn's test (Dunn, 1964) is the most widely recommended post-hoc procedure following a significant Kruskal-Wallis test. It computes pairwise z-statistics using the same rank information as the omnibus test, comparing each pair of groups:
R̄ᵢ = mean rank of group i
SEij = standard error accounting for N, nᵢ, nⱼ, and ties
Multiple-Comparison Correction
When making multiple pairwise comparisons simultaneously, the probability of a false positive increases with each comparison. For k groups, there are k(k−1)/2 pairs. A multiple-comparison correction controls the family-wise error rate or false discovery rate.
| Method | How It Works | Controls | When to Use |
|---|---|---|---|
| Bonferroni | Multiply each p-value by the number of comparisons (m): padj = p × m | Family-wise error rate (FWER) | Small number of planned comparisons; more conservative |
| Holm | Sort p-values; apply sequentially decreasing thresholds | Family-wise error rate (FWER) | All pairwise comparisons; less conservative than Bonferroni |
| Benjamini-Hochberg | Controls the expected proportion of false discoveries | False discovery rate (FDR) | Exploratory analyses; less conservative overall |
The Holm correction is generally preferred over Bonferroni because it is uniformly more powerful while providing the same FWER control. The choice between FWER-controlling and FDR-controlling methods depends on the research context and the consequences of false positives versus missed effects.
Effect Size for the Kruskal-Wallis Test
A statistically significant p-value tells you the result is unlikely under H₀. It does not tell you how large or practically meaningful the difference is. Effect size addresses that question.
Epsilon Squared (ε²)
One commonly used effect size estimator for the Kruskal-Wallis test is epsilon squared:
H = Kruskal-Wallis statistic
k = number of groups
N = total observations
Different sources use different formulas for rank-based effect sizes (eta squared, epsilon squared, rank-biserial variants). Always report the specific formula you used rather than citing generic thresholds as universal rules. A "small" vs. "large" effect is context-dependent and should be interpreted alongside the research question and practical consequences.
Regardless of which convention you apply, report the effect size alongside the p-value. A large sample can yield statistical significance for a trivially small group difference, and an effect-size measure helps readers judge practical importance.
Does the Kruskal-Wallis Test Compare Medians?
The Kruskal-Wallis test is fundamentally a test of rank distributions, not directly of medians. A median interpretation is appropriate when the group distributions have similar shapes and spread. When shapes differ (for example, one group is right-skewed and another is left-skewed), a significant result may reflect a difference in shape rather than location.
This distinction matters for reporting. Rather than routinely saying "the test compared medians," state that the test compared rank distributions, then note the distributional assumption required for a median interpretation. If group distributions do appear similarly shaped (something box plots or violin plots can help assess visually), the median interpretation is reasonable and should be supported by reporting medians as the descriptive summary.
Kruskal-Wallis vs. Other Statistical Tests
Kruskal-Wallis vs. One-Way ANOVA
| Feature | Kruskal-Wallis | One-Way ANOVA |
|---|---|---|
| Data approach | Rank-based (converts observations to ranks) | Raw numerical values |
| Parametric? | Nonparametric | Parametric |
| Outcome type | Ordinal or continuous | Continuous |
| Normality | Not required in the same way | Important for classical validity |
| Outlier sensitivity | Less sensitive (ranks bound extreme values) | Can be sensitive to extreme outliers |
| Test statistic | H (chi-square approximation) | F-ratio |
| Post-hoc methods | Dunn's test, Conover's test | Tukey HSD, Bonferroni, Scheffé |
| Interprets | Rank distribution differences | Mean differences |
| Statistical power | Generally lower when ANOVA assumptions hold | Higher when assumptions are met |
When ANOVA's assumptions hold, ANOVA has greater statistical power. When data are ordinal or clearly non-normal with smaller samples, the Kruskal-Wallis test is the more defensible choice. See the one-way ANOVA guide for the parametric approach.
Kruskal-Wallis vs. Mann-Whitney U
The Mann-Whitney U test is designed for exactly two independent groups. The Kruskal-Wallis test extends the rank-based comparison to three or more groups. Running multiple pairwise Mann-Whitney U tests in place of a Kruskal-Wallis omnibus test inflates the family-wise error rate and is generally not recommended as the primary analysis when comparing three or more groups simultaneously. After a significant Kruskal-Wallis result, Dunn's test (rather than raw Mann-Whitney comparisons) should be used for post-hoc pairwise testing.
Kruskal-Wallis vs. Friedman Test
| Feature | Kruskal-Wallis | Friedman Test |
|---|---|---|
| Study design | Independent groups | Related samples / repeated measures |
| Subjects | Different subjects in each group | Same subjects measured multiple times, or matched blocks |
| Parametric equivalent | One-way ANOVA | Repeated measures ANOVA |
| Ranks | Across all observations | Within each subject or block |
Confusing these two tests is a common error. If the same participants appear in each condition, or if observations are matched (for example, litters of animals, matched patient pairs, or multiple measurements from the same individual), the Friedman test is appropriate and the Kruskal-Wallis test is not.
Kruskal-Wallis Test in SPSS, R, and Python
SPSS
In SPSS, the Kruskal-Wallis test is found under Analyze → Nonparametric Tests → Legacy Dialogs → K Independent Samples. Set the test variable (your dependent/outcome variable) and the grouping variable, then define the range of group codes. Under "Test Type," ensure Kruskal-Wallis H is selected. In newer SPSS versions (Statistics 21+), the same test is also accessible through Analyze → Nonparametric Tests → Independent Samples with a more automated interface.
The SPSS output includes the H statistic, degrees of freedom, and asymptotic p-value. Post-hoc pairwise comparisons are available through the newer interface under "Compare Groups." Check the "Mean ranks" table to see which groups had higher or lower average ranks.
R
# Basic Kruskal-Wallis test result <- kruskal.test(score ~ group, data = mydata) print(result) # Returns: Kruskal-Wallis chi-squared, df, p-value # Post-hoc Dunn's test with Holm correction # Requires: install.packages("dunn.test") or rstatix library(dunn.test) dunn.test(mydata$score, mydata$group, method = "holm") # With rstatix (tidyverse-friendly) library(rstatix) mydata %>% kruskal_test(score ~ group) # omnibus mydata %>% dunn_test(score ~ group, p.adjust.method = "holm") # post-hoc # Effect size (epsilon squared) mydata %>% kruskal_effsize(score ~ group)
R's kruskal.test() applies the tie correction automatically. The result object contains the H statistic (labeled as statistic), degrees of freedom, and p-value. For full reproducibility, always report the R version and package versions used. Documentation for the base function is available from The R Foundation.
Python
from scipy import stats import scikit_posthocs as sp # pip install scikit-posthocs import numpy as np # Your group data as separate arrays group_a = [65, 72, 68] group_b = [80, 85, 78] group_c = [55, 60, 58] # Kruskal-Wallis test (tie correction applied automatically) H, p = stats.kruskal(group_a, group_b, group_c) print(f"H = {H:.4f}, p = {p:.4f}") # Degrees of freedom k = 3 # number of groups df = k - 1 # Epsilon squared effect size N = len(group_a) + len(group_b) + len(group_c) epsilon_sq = (H - k + 1) / (N - k) print(f"ε² = {epsilon_sq:.4f}") # Post-hoc Dunn's test with Holm correction data_all = [group_a, group_b, group_c] posthoc = sp.posthoc_dunn(data_all, p_adjust='holm') print(posthoc)
scipy.stats.kruskal accepts two or more array-like arguments and returns the tie-corrected H statistic and p-value. The scikit-posthocs library provides Dunn's test and several other post-hoc methods. Documentation for scipy.stats.kruskal is maintained at SciPy.org.
Excel
Excel does not include a built-in Kruskal-Wallis function. You can implement it manually using Excel's RANK.AVG function to assign average ranks to tied values, then apply the H formula with SUMPRODUCT. For regular use, dedicated statistical software (R, Python, SPSS, or JASP) is more practical and less error-prone. JASP is a free open-source alternative with a point-and-click interface that includes the Kruskal-Wallis test and Dunn's post-hoc analysis.
How to Report the Kruskal-Wallis Test
Report the H statistic with its degrees of freedom, the sample sizes per group, the p-value, and a measure of effect size. Include medians and interquartile ranges as descriptive statistics (rather than means and standard deviations) since the test is rank-based. If post-hoc comparisons were conducted, report those results with the correction method used.
APA-Style Reporting Templates
Significant Result
A Kruskal-Wallis test indicated that the three groups differed significantly in [outcome], H(2) = 7.20, p = .027, ε² = .58. Pairwise comparisons using Dunn's test with Holm correction revealed that Group B (Mdn = 80) scored significantly higher than Group C (Mdn = 58), padj = .029, but did not differ significantly from Group A (Mdn = 68), padj = .102.
Non-Significant Result
A Kruskal-Wallis test did not reveal sufficient evidence of a difference in [outcome] across the three conditions, H(2) = 1.44, p = .486, ε² = .07. Post-hoc comparisons were not conducted given the non-significant omnibus result.
Common Mistakes to Avoid
| Mistake | Incorrect Approach | Correct Approach |
|---|---|---|
| Skipping post-hoc tests | Concluding "Groups A and B differ" from a significant omnibus H | Run Dunn's test with multiple-comparison correction to identify specific pairs |
| Using KW for paired data | Applying Kruskal-Wallis to pre/post measurements from the same participants | Use the Friedman test for related or matched samples |
| Treating H as a median test unconditionally | "The test showed that median of Group A is different from Group B" | State it tests rank distributions; note a median interpretation requires similar distribution shapes |
| Ignoring effect size | Reporting only H(2) = 12.3, p = .002 | Also report ε² (or another effect size measure) and group descriptives |
| Running many Mann-Whitney tests instead | Comparing all pairs with separate Mann-Whitney tests at α = .05 each | Run the Kruskal-Wallis omnibus test first, then Dunn's test if significant |
| Misinterpreting a non-significant result | "The test proves the groups are equal" | "There was insufficient evidence to conclude the groups differ" |
| Ignoring ties | Applying the uncorrected formula when many tied ranks are present | Apply the tie correction (most software does this automatically) |
Real-World Applications
Medicine and Healthcare
Comparing patient-reported outcome measures across treatment arms when Likert-scale data, ceiling effects, or small samples make ANOVA assumptions questionable.
Psychology
Comparing anxiety scores, depression ratings, or cognitive test performance across diagnostic groups where ordinal scales are common.
Biology and Ecology
Comparing species counts, growth measurements, or behavioral scores across habitat types or experimental conditions with non-normal distributions.
Education
Comparing assessment scores across teaching methods, school types, or grade levels when score distributions are skewed or ordinal scales are used.
Business Analytics
Comparing customer satisfaction ratings, Net Promoter Scores, or product ratings across regions, demographic groups, or product lines.
Environmental Science
Comparing pollutant concentrations, biodiversity indices, or environmental quality ratings across geographic zones where data are skewed.
Practice Problems
Work through these problems to test your understanding. Answers follow each problem block.
Conceptual Questions
A researcher measures customer satisfaction (rated 1–5) across four store locations (n=8 per group). Which test is appropriate: one-way ANOVA or Kruskal-Wallis? Justify your choice.
True or False: A significant Kruskal-Wallis result (p = .02) means all groups are significantly different from each other. Explain.
A study measures blood glucose three times in the same patients under different diets. Should the researcher use Kruskal-Wallis or Friedman? Why?
What degrees of freedom would a Kruskal-Wallis test have if comparing five independent groups?
Under what distributional assumption is interpreting Kruskal-Wallis as a test of medians most appropriate?
Calculation Problems
Three groups: A={4,6,5}, B={8,7,9}, C={2,3,1}. Rank all observations, calculate rank sums, compute H, and interpret at α = 0.05 (df = 2, critical value ≈ 5.99).
Data with ties: A={5,5,7}, B={7,9,9}. Note this is only two groups — explain why Kruskal-Wallis is not the right test here and what you would use instead.
Four groups each with n=3. The H statistic (tie-corrected) is 10.5. State the degrees of freedom and determine whether the result is significant at α = 0.05 (chi-square critical value for df=3 at α=.05 is 7.815).
A researcher reports H(3) = 4.2, p = .240. What does this mean? Does it mean the four groups are equal?
Five groups, N = 50, H = 14.8. Calculate ε² using the formula ε² = (H − k + 1)/(N − k). What does this value suggest about the practical significance of the group differences?
Selected Answers
Answer: Kruskal-Wallis is more appropriate. Satisfaction rated 1–5 is ordinal, not continuous. The restricted scale and likely ceiling/floor effects make normality assumptions for ANOVA questionable, particularly with n=8 per group.
Answer: False. A significant omnibus result means at least one group differs from at least one other. It does not specify which pairs. Post-hoc testing is required to answer that question.
Answer: Friedman test. The same patients appear under each diet condition — these are related/repeated measures, which violates the independence assumption of Kruskal-Wallis.
Answer: df = k − 1 = 5 − 1 = 4
Answer: Sorted ranks: 1(1), 2(2), 3(3), 4(4), 5(5), 6(6), 7(7), 8(8), 9(9). RA=4+6+5=15, RB=8+7+9=24, RC=2+3+1=6. H = [12/90]×[(225+576+36)/3] − 30 = 0.1333×279 − 30 = 7.2. Since 7.2 > 5.99, reject H₀ at α = 0.05.
Answer: df = 4−1 = 3. H = 10.5 > 7.815 (critical value at α=.05, df=3). Reject H₀ — the four groups differ significantly.
Answer: ε² = (14.8 − 5 + 1)/(50 − 5) = 10.8/45 = 0.24. This is a moderate-to-large effect, suggesting the group differences are not trivially small in practical terms.
Frequently Asked Questions
The Kruskal-Wallis test determines whether three or more independent groups come from the same distribution. It is used when the outcome variable is ordinal or when the assumptions of one-way ANOVA (particularly normality) are questionable, making a rank-based nonparametric approach more appropriate.
Yes. The formula for H accommodates different group sizes through the nᵢ terms in the denominator of each rank sum squared term. No special adjustment is required — you simply use the actual sample size for each group when calculating.
Dunn's test is the most widely recommended post-hoc procedure after a significant Kruskal-Wallis result. It uses the same rank information as the omnibus test and is available with Holm, Bonferroni, or Benjamini-Hochberg multiple-comparison corrections. The Holm correction is generally preferred over Bonferroni because it provides the same family-wise error rate control with greater power.
The key difference is the study design. Kruskal-Wallis is for independent groups (different subjects in each group). The Friedman test is for related samples — where the same subjects are measured across multiple conditions, or where observations are matched or blocked. Using Kruskal-Wallis when Friedman is appropriate ignores the dependency in the data and reduces statistical validity.
Epsilon squared (ε²) is a commonly used rank-based effect size for the Kruskal-Wallis test, calculated as (H − k + 1)/(N − k). Eta squared (η² = H/(N−1)) is another option. Because formulas vary across sources, always state the formula you used rather than citing generic thresholds.
Tied observations receive the average of the ranks they would have occupied if distinct. A tie correction factor C is then applied: Hcorrected = H/C, where C = 1 − [Σ(tⱼ³ − tⱼ)/(N³ − N)]. Most statistical software applies this automatically. The correction is negligible when ties are rare but can matter when tied observations are common.
Yes, in many cases. Likert-scale data are ordinal, and the Kruskal-Wallis test requires only an ordinal outcome. Because the scale is bounded (for example, 1–5 or 1–7), it often exhibits ceiling or floor effects that violate normality, making rank-based methods a natural fit. Whether to treat averaged Likert scales as approximately continuous (and use ANOVA) is a longstanding methodological debate; for individual Likert items, a nonparametric approach is more defensible.
There is no single universal minimum. The chi-square approximation for the p-value becomes more accurate as sample sizes increase. For very small samples (fewer than 5 per group), exact methods exist and are available in some software. In practice, five or more observations per group generally provides a reasonable approximation, though this depends on the number of groups and the degree of tied observations.
Report in this format: H(df) = value, p = value, ε² = value. For example: "A Kruskal-Wallis test indicated that pain scores differed significantly across treatment groups, H(2) = 9.83, p = .007, ε² = .37." Include group medians and IQRs as descriptive statistics, and if post-hoc tests were conducted, report the method and adjusted p-values for each comparison.
Technically, the formula works with k = 2 groups, and in that case H equals the square of the Mann-Whitney U z-statistic. However, for exactly two independent groups, the Mann-Whitney U test is the standard choice. Kruskal-Wallis is specifically designed for three or more groups as the omnibus test.
Formula Reference Sheet
| Formula | Expression | Notes |
|---|---|---|
| H Statistic | H = [12/(N(N+1))] × Σ(Rᵢ²/nᵢ) − 3(N+1) | Core Kruskal-Wallis formula |
| Tie correction C | C = 1 − [Σ(tⱼ³−tⱼ)/(N³−N)] | tⱼ = count in j-th tied group |
| Corrected H | Hcorr = H / C | Applied when tied ranks are present |
| Degrees of Freedom | df = k − 1 | k = number of groups |
| Epsilon Squared ε² | ε² = (H − k + 1) / (N − k) | One common convention; verify source |
| Bonferroni adjustment | padj = min(p × m, 1) | m = number of pairwise comparisons |
| Number of pairs | m = k(k−1)/2 | Total pairwise comparisons |