Kruskal-Wallis test
Shown in the app as kruskal_wallis. Part of the method reference, under Comparing groups.
When to use
3+ independent groups, continuous/ordinal outcome, non-normal.
What you provide
- Outcome: one numeric column.
- Group: one categorical column.
Options
Missing data
- Complete case (listwise deletion)
- Mean imputation (single)
- Median imputation (single)
Multiple comparisons
- Holm
- Benjamini-Hochberg (false discovery rate)
- Bonferroni
- None (unadjusted)
Confidence level
Every interval in the result is reported at the level you choose:
- 90%
- 95%
- 99%
Related methods
Alternatives that take the same inputs:
Other methods under Comparing groups:
- Welch's t-test
- Student's t-test
- Paired t-test
- Mann-Whitney U test
- Wilcoxon signed-rank test
- Repeated-measures ANOVA (Greenhouse-Geisser)
- ANCOVA (analysis of covariance)
- Two-way ANOVA (factorial)
Guides that discuss this method
- How to choose a statistical test for your data
- Multiple comparisons: Bonferroni, Holm, or BH
- One-way ANOVA, Welch ANOVA or Kruskal-Wallis?
- Reproducible statistical analysis: the rerun test
How to read the output
These methods compare one outcome across three or more independent groups, for example crop yield under four irrigation schedules, or test scores across several schools.
The overall test. The p-value answers one question: is there any difference among the groups? A small p-value does not say which groups differ or by how much. One-way ANOVA assumes equal variances across groups; Welch’s ANOVA does not; the Kruskal-Wallis test works on ranks and does not assume normality.
Effect size. For the two ANOVAs, eta-squared is the proportion of the outcome’s variation that lies between the groups, from 0 to 1. For Kruskal-Wallis, epsilon-squared plays the same role on ranks. Both come with a two-sided confidence interval; the epsilon-squared interval is a seeded bootstrap, so the same data always give the same interval. The reproducible script recomputes the effect size and its interval too.
Groups coded as numbers. A group column stored as numbers (1, 2, 3) is still treated as a set of labels, never as a measurement. When missing values are filled with a mean or median, a missing group code is not filled, because the mean of two codes is not a group; that row is left out instead.
Which groups differ. With three or more groups, Celeus adds pairwise comparisons, each corrected for making several comparisons at once: Tukey’s honestly significant difference after one-way ANOVA, the Games-Howell procedure after Welch’s ANOVA (it does not assume equal variances either), and Dunn’s test after Kruskal-Wallis, where you choose the correction (Holm by default). Read each pair’s adjusted p-value and its effect size together; a pair can differ reliably by a trivial amount.
Options. Every interval of a run (the effect size, the Tukey intervals and each pair’s effect size) uses one confidence level: 90%, 95% (the default) or 99%. The overall test has no one-sided version: it asks whether any group differs, which has no direction.
Sources: Tukey JW (1949), Biometrics 5(2):99-114, doi:10.2307/3001913. Games PA, Howell JF (1976), Journal of Educational Statistics 1(2):113-125, doi:10.3102/10769986001002113. Dunn OJ (1964), Technometrics 6(3):241-252, doi:10.1080/00401706.1964.10490181.
Worked examples
Celeus's result on a published or illustrative dataset, next to an independent computation and, where one exists, a published value. The data themselves are not reproduced here.
datasets::ToothGrowth
- Source: Published dataset distributed with an R package
- Licence: base R (GPL)
- Reference: Crampton (1947)
| Quantity | Celeus | Independent computation | Published value | Agrees |
|---|---|---|---|---|
| p-value | 1.47521e-09 | 1.47521e-09 | - | Yes |
| Effect size | 0.689304 | 0.689304 | - | Yes |
datasets::InsectSprays
- Source: Published dataset distributed with an R package
- Licence: base R (GPL)
- Reference: Beall (1942), Biometrika 32(3/4):243-262 (the data); independent computation
| Quantity | Celeus | Independent computation | Published value | Agrees |
|---|---|---|---|---|
| Test statistic | 54.6913 | 54.6913 | - | Yes |
| Degrees of freedom | 5 | 5 | - | Yes |
| p-value | 1.51084e-10 | 1.51084e-10 | - | Yes |
| Effect size | 0.770301 | 0.770301 | - | Yes |
| Multiplicity correction for the pairwise comparisons | bonferroni | bonferroni | - | Yes |
datasets::airquality (Ozone by Month)
- Source: Published dataset distributed with an R package
- Licence: base R (GPL)
- Reference: Chambers et al. (1983), Graphical Methods for Data Analysis (the data); independent computation
| Quantity | Celeus | Independent computation | Published value | Agrees |
|---|---|---|---|---|
| Test statistic | 29.2666 | 29.2666 | - | Yes |
| Degrees of freedom | 4 | 4 | - | Yes |
| p-value | 6.90071e-06 | 6.90071e-06 | - | Yes |
| Number of observations | 116 | 116 | - | Yes |
| Effect size | 0.254492 | 0.254492 | - | Yes |
datasets::warpbreaks (breaks by tension)
- Source: Published dataset distributed with an R package
- Licence: base R (GPL)
- Reference: Tippett (1950), Technological Applications of Statistics (the data); independent computation
| Quantity | Celeus | Independent computation | Published value | Agrees |
|---|---|---|---|---|
| Test statistic | 10.8093 | 10.8093 | - | Yes |
| Degrees of freedom | 2 | 2 | - | Yes |
| p-value | 0.00449571 | 0.00449571 | - | Yes |
| Effect size | 0.203948 | 0.203948 | - | Yes |
| Confidence level of the effect size interval | 0.9 | 0.9 | - | Yes |
References
- Kruskal, W. H., Wallis, W. A. (1952). Use of ranks in one-criterion variance analysis. Journal of the American Statistical Association 47: 583-621. doi:10.1080/01621459.1952.10483441 doi:10.1080/01621459.1952.10483441