Opens in a new tab

METHOD GUIDE

Kruskal-Wallis Test in R
Omnibus Test, Dunn Follow-Up and Adjusted p-Values

Base R stops at the omnibus statistic, so the pairwise step needs an add-on package, and packages differ in how they adjust p-values. Naming the package, its adjustment and the number of comparisons keeps the follow-up reproducible and its adjusted p-values interpretable.

IN SHORT

What the Omnibus Test Answers and What Must Follow It

The Kruskal-Wallis test compares three or more independent groups through the ranks of an ordinal or continuous outcome, and asks whether values in at least one group tend to be larger or smaller than in the others. To run the Kruskal-Wallis test in R, call kruskal.test() with the outcome and a grouping factor, read the chi-squared statistic with its degrees of freedom, then choose a pairwise method and an adjustment for the follow-up. It supports a statement about medians only when the group distributions have a similar shape. OnlineSPSS, a specialist statistical consultancy for academic, clinical and professional research, carries out and reviews this analysis through an in-house PhD-level statistician.

ANALYSIS SUPPORT

Analysis Support for This Method

The omnibus line in R is brief, and what follows it, which pairs to test and how to adjust, shapes what the report can claim, so the plan is made before the console is opened.

Kruskal-Wallis Test

The rank-based comparison of three or more independent groups, carried out in R or another program, with the follow-up, the adjustment and the reporting agreed for your data.

Explore Kruskal-Wallis Test
One-Way ANOVA

A comparison of three or more independent group means on a continuous outcome, for when the size of the differences between means is the quantity the study needs.

Explore One-Way ANOVA

BEFORE YOU RUN IT

Pairs, Claim and Adjustment Chosen First

The omnibus line alone rarely answers the question a study with several groups asks, so the pairs, the claim and the adjustment are settled while the data are still unseen.

Unrelated Groups Every case belongs to a single group and contributes one measurement. Repeated measurements on the same people need a different test, and clustered participants need a model that allows for the clustering.

Tendency or Median Claim Ranks support the statement that values in some groups tend to be larger. A statement about medians holds only when the distributions have a similar shape in every group.

Which Pairs Will Be Tested Decide whether every pair matters or only a few, because the number of comparisons sets the size of the adjustment. A reduced set chosen in advance is easier to defend than a selection made after the output.

Ties and Small Groups Ties are common on rating scales, and the chi-squared reference distribution is an approximation that is less dependable in very small groups. Group sizes and tied values are described in the report.

IN R

How to Run the Kruskal-Wallis Test in R

Base R ends at kruskal.test(). The Dunn step depends on the package chosen, and because adjustment defaults differ between packages, the package, its version and the adjustment are all named.

  1. Confirm the design: an ordinal or continuous outcome, three or more independent groups, one row per case.
  2. Convert the grouping variable with factor() and check the group sizes with table().
  3. Draw the outcome distribution for every group and compare shape and spread.
  4. Run kruskal.test(outcome ~ group, data = d) and read the chi-squared statistic, df and p.
  5. Run a Dunn follow-up, for example dunnTest() in FSA or dunn_test() in rstatix, with the adjustment set explicitly.
  6. Add an effect size, for example rank_epsilon_squared() in the effectsize package, and keep the plot.

READING THE OUTPUT

The Chi-Squared Line and the Dunn Comparison Table

Two different printouts carry the result, a three-line block for the omnibus test and a table of pairs for the follow-up, and the second one changes with the package.

Output element What it tells you What to check
Header line Kruskal-Wallis rank sum test, and the variable and grouping names That the grouping variable is a factor with the intended levels
Kruskal-Wallis chi-squared The H statistic, corrected for ties and referred to a chi-squared distribution That it is not described as a test of counts
df The number of groups minus 1 That it matches the number of groups in the design
p-value The asymptotic p for the omnibus hypothesis That a small group size is noted as a limit on the approximation
Dunn comparison table One row per pair with a z statistic, an unadjusted p and an adjusted p That the adjusted column is the one reported
Adjustment method Holm, Bonferroni or none, according to the package default or the argument That the method is named, since defaults differ between packages
Effect size output A rank-based effect size for the omnibus test, with an interval That the measure is named and the type of its interval is read from the package documentation

REPORTING

Wording the Omnibus Result and Its Follow-Up

The omnibus result takes one line, while the follow-up needs its method, its adjustment and the number of comparisons it covered.

Write H(df) = ___, p = ___, with the group sizes and a distribution summary for each group such as the median and interquartile range, and show the distributions. Add a rank-based effect size, for example epsilon squared = ___ with its 95% CI [___, ___], and name it. For the follow-up, state that Dunn comparisons were used, which adjustment was applied and over how many comparisons, then give each adjusted p alongside a plain statement of which group tended to score higher. Describe the result as a tendency toward larger values, and mention medians only when the shapes were similar. A non-significant pair is not evidence that two groups are alike, and the plain-language statement should say so where it matters.

Omnibus HGroup SummariesNamed AdjustmentAdjusted p ValuesRank Effect Size

COMMON MISTAKES

Follow-Up Choices That Weaken a Kruskal-Wallis Report

Most of these appear after the omnibus line, because the packages that run the pairwise step make choices that the write-up does not repeat.

Unadjusted Pairs Reported Some Dunn functions return unadjusted p-values unless an adjustment is requested. Quoting that column across many pairs inflates the chance of a false positive finding.

Adjustment Left Unnamed Holm, Bonferroni and Benjamini-Hochberg give different adjusted values and answer slightly different questions. The report names the method and the number of comparisons it covered.

One Effect Size for All Pairs A single rank effect size for the omnibus test says nothing about how far any two groups differ. For the pairs that matter, a two-group rank effect with its interval makes the follow-up interpretable.

Medians Over-Read A significant H is reported as a difference in medians, which holds only for similarly shaped distributions. Plots of the groups belong in the analysis before the sentence is written.

Pairs Tested After a Null Omnibus Pairwise tests run on a non-significant omnibus result and reported as findings are exploratory, and the text says so. A planned small set of contrasts is a separate analysis.

Related Cases Treated as Independent Repeated measurements or clustered cases make observations related while the test treats them as independent. The design shows this, and a repeated-measures or clustered method is the match.

Dunn comparisons in the write-up? Independent Statistical Review checks the omnibus line, the follow-up choice and the adjusted values you quote before you submit.

Request an Assessment

FREQUENTLY ASKED QUESTIONS

Questions About Dunn Tests and the H Statistic in R

Follow-up tables in R depend on the package that produced them, which is why two of the three method answers concern the pairwise step and not the omnibus line.

Their default adjustments differ. Documented defaults include no adjustment in dunn.test and Holm in FSA and rstatix, at the versions documented at the time of writing, so a table can look different with the same z statistics. Set the adjustment explicitly, name it in the report, and compare the unadjusted values to confirm the packages agree.

It runs a separate two-group rank test for each pair, ranking only those two groups, which is not the same procedure as Dunn’s comparisons based on the pooled ranks. It can be justified with a stated adjustment, but the report names the method used, and the two should not be mixed in one table.

No. The H statistic is computed from ranks and referred to a chi-squared distribution with the number of groups minus 1 degrees of freedom as an approximation. It is less dependable with very small groups, which the report mentions, and it is not related to a chi-squared test on a contingency table.

Yes. Which pairs answer your question is agreed with you first, and an in-house PhD-level statistician then sets the package and the adjustment before the follow-up runs and carries out or reviews the analysis on your data. Reporting the adjusted results afterward is the focus of Results Reporting & Interpretation. The substantive interpretation and the conclusions stay with you.

Your data and project details are handled confidentially, and project information is not published. Researcher names and institutions are not used publicly without permission. An NDA is available where required and can be arranged before sensitive materials are shared. Read more about confidentiality and data security.

You share your research question, design and relevant materials, such as the dataset or the output you have, and a statistically trained Research Coordinator reviews the request and responds the same day. The analysis, deliverables, timeline and one fixed project fee are then confirmed before any work begins, so the timeline follows from the agreed scope.

Still have a question? Find more answers in our full FAQ.

View All FAQs →

NEXT STEP

Which Dunn Pairs Will
Your Report Defend?

Which pairs to test and how far to adjust are best fixed before the follow-up runs, and an in-house statistician can set both for your groups within a confirmed scope.

No Commitment Required

Strictly Confidential

Fixed Project Fee

In-House PhD-Level Statisticians

Same-Day Response

Serving Researchers Since 2014