Group comparison
Kruskal-Wallis H Test
Compares three or more independent groups using rank positions rather than raw values, and tests whether the groups occupy different positions in the pooled distribution.
Method summary
The Kruskal-Wallis H test compares three or more independent groups after the whole sample has been placed in a single ordering. Every observation receives a rank, each group gets a mean rank, and the H statistic summarises how far those mean ranks sit from the common value expected when no group differs from another. Because it is the rank-based counterpart of one-way analysis of variance, it asks nothing about normality and reacts less to extreme values; in exchange the question changes, since what is tested is the equality of distribution positions rather than of means. YouReply Analyze reports H, the degrees of freedom given by the number of groups minus one, and the asymptotic p value, provides epsilon squared as the effect size, and appends pairwise comparisons with a Bonferroni correction whenever the omnibus result reaches significance.
Which research questions does it answer?
- Do three income brackets rank public services differently in terms of satisfaction?
- Does trust in an institution differ across participants living in four regions?
- Does the ranking of attitudes towards online shopping shift as education level rises?
- Do five occupational groups separate on a single-item rating of their working conditions?
When should you use it?
- When at least three independent groups are compared and every participant belongs to one group only.
- When the dependent variable is measured at ordinal level, such as a single Likert item, a preference rating or a set of graded categories.
- When a continuous variable is clearly skewed, or a handful of extreme values is dragging the mean around.
- When the groups are small and normality is not a defensible assumption, since moving to ranks removes that requirement.
- When variances are plainly unequal and a mean-based comparison would feel forced.
Required variable types
- Dependent variable: a numerically coded column measured at least at ordinal level. You may mark it as 'ordinal' or 'scale' on the Variable tab; either way the test converts the values to ranks.
- Independent variable: the categorical column holding the groups. Two categories are accepted, but that design is answered more directly by the Mann-Whitney U test.
- Each group needs at least three valid observations; if one group falls short the run stops with an error.
- One row should correspond to one participant, which puts designs with repeated measurements on the same person outside the scope of this test.
Key assumptions
- Independence of groups
- The groups consist of different people and no participant's answer is tied to another's. Repeated measurements, matched pairs, or one respondent counted in several categories all break this condition.
- An orderable dependent variable
- The values have to line up meaningfully from low to high. The distances between categories need not be equal; a consistent ordering is enough.
- At least three observations per group
- Each group needs three valid values before its rank distribution can support a comparison. Missing values are dropped row by row before the test, so the effective group size can be smaller than the raw row count suggests.
- Comparable distribution shapes
- Reading the result directly as a difference in position requires the group distributions to have broadly similar shapes. Where the shapes differ markedly, a significant H only states that the distributions are not identical, and whether the difference comes from shifted medians or from unequal spread is a separate question.
- No normality or equal-variance requirement
- Since the test works on ranks rather than raw values, neither a normal population distribution nor equal variances are required. The two checks that matter for the parametric counterpart are simply beside the point here.
How YouReply checks these assumptions
- Independence of groups: The panel does not check this assumption automatically; the researcher evaluates it.
- An orderable dependent variable: The method picker looks for an orderable numeric column in this slot and dims the method with a stated reason where a column does not qualify. The data requirements box lists which of your columns satisfy the condition.
- At least three observations per group: This condition is enforced during the run: if any group holds fewer than three observations the analysis stops and names that group instead of quietly continuing.
- Comparable distribution shapes: The panel runs no check that compares distribution shapes. Reading the medians alongside the mean ranks in the result lets you form that judgement yourself.
- No normality or equal-variance requirement: No normality or homogeneity-of-variance test is run for this method, and none is missing, because the test does not rest on either.
How the analysis is run
- 1Drag your file onto the upload area. The panel reads CSV and XLSX and shows the rows in an editable grid.
- 2On the Data tab, look over the categories of the grouping column; twin categories created by typing differences, such as a leading space, make the group count look larger than it is.
- 3On the Variable tab set the measurement level to ordinal, declare your missing-value codes, and add category labels if you have them, since those labels become the group names in the result tables.
- 4On the Analysis tab type the method name into the search box. The 'Only ones that fit my data' switch narrows the list; methods that do not fit are never hidden, only dimmed with a reason.
- 5In the parameter form pick the grouping column and the value column to be compared, then start the analysis.
- 6Work through the rank table, the test statistics and the effect size in the collapsible sections. If the omnibus p value falls below 0.05, a block of pairwise comparisons joins them.
- 7Export the tables to Excel. The computation credits card names the library call and its version, and the history tab takes you back to earlier runs.
Statistics and tables produced
- Rank table
- Sample size, mean rank and median for every group. Mean ranks come from ranks assigned across the entire sample, so they describe a group's position in the shared ordering rather than any within-group reordering.
- H statistic and degrees of freedom
- The H value together with degrees of freedom equal to the number of groups minus one. As the number of groups grows, H has to be larger to reach the same p value.
- Asymptotic significance value
- The p value comes from the chi-square approximation. No exact, permutation-based p value is produced, which is worth keeping in mind when the groups are very small.
- Epsilon squared with a verbal label
- The effect size is derived from H and the total number of observations, accompanied by a label reading negligible, small, medium or large.
- Pairwise comparison block
- Added only when the omnibus p value is below 0.05. For each pair of groups it lists the Mann-Whitney U value, the raw p value, the Bonferroni-adjusted p value and whether the pair clears the adjusted alpha; pairs in which one side holds fewer than three observations are left out.
Effect size and confidence intervals
- Epsilon squared
- Expresses the share of rank variability accounted for by group membership and runs from 0 to 1. The labels in the panel use 0.01 as the boundary for negligible, 0.06 for small and 0.14 for medium, with anything above counted as large. These are reading aids rather than firm cut-offs: the same value can be notable in a population survey and modest in an experimental comparison.
No confidence interval is produced for this method. H, the p value, epsilon squared and the mean ranks all arrive as point estimates, and no Hodges-Lehmann style interval for median differences is returned either. If a publication requires an interval, you will need to obtain it outside the panel, preferably with a resampling approach.
Example research question and example result
The numbers below are a representative example, not data from a real study or a real user.
- Research question
- In an illustrative corporate reputation study, does trust in the institution, rated on a single 1-7 item, rank differently across three education categories?
- Variables
- Dependent variable: trust in the institution, single item scored 1-7 (ordinal) · Independent variable: education level (secondary, bachelor's, postgraduate)
- Example result
- 214 valid responses in total. Secondary (n = 78): mean rank 92.4, median 4. Bachelor's (n = 86): mean rank 108.6, median 5. Postgraduate (n = 50): mean rank 129.2, median 5. The omnibus result was H(2) = 11.42, p = 0.003, with epsilon squared of 0.054 (small). Significance triggered three pairwise comparisons at an adjusted alpha of 0.0167. Secondary versus postgraduate was significant with a raw p of 0.001 and an adjusted p of 0.003, whereas secondary versus bachelor's (adjusted p = 0.213) and bachelor's versus postgraduate (adjusted p = 0.126) were not.
- Interpretation
- Mean ranks climb with education level, so the trust ordering trends upward. A significant omnibus test says only that the three groups do not share one distribution; which groups separate is read from the pairwise block, and here only the two extreme categories part company. Because neither adjacent comparison reached the adjusted threshold, the data do not by themselves support a claim of a steady increase across all three levels, and with medians spanning a single scale point a small epsilon squared is exactly what one would expect. The figures are illustrative and come from no real study.
Real output on a sample dataset
The results below were produced by the analysis engine from this data file. Changing the variable changes the research question as well; every run was computed in advance, so the page sends no request to the engine.
General customer survey (synthetic)
A wide survey of three hundred respondents: two and three category grouping variables, continuous measures, a five point ordinal scale, a binary purchase outcome, a four category brand choice, three repeated measurements, paired binary questions, three raters, four price questions and deliberately empty cells.
- Rows
- 300
- Columns
- respondent_id, gender, education, region, age, income, satisfaction, service_score, price_score, quality_score, loyalty, nps_score, purchased, brand_choice, satisfaction_level, pre_score, post_score, measure_1, measure_2, measure_3, use_before, use_after, use_followup, rater_1, rater_2, rater_3, price_too_cheap, price_cheap, price_expensive, price_too_expensive, feedback_score, followup_rating
The data is synthetic: it comes from a fixed random seed, not from a real study. The values below were produced by the analysis engine from this file, so uploading the same file to the panel gives the same results.
Research question: Does the income distribution differ across the three education levels?
- Grouping variable
- education
- Measured variable
- income
- Grouping variable
- education
- Analyzed variable
- income
Ranks
| Row | Bachelor | High school | Postgraduate |
|---|---|---|---|
| Sample Size | 100 | 104 | 96 |
| Mean Rank | 174.80 | 69.40 | 213.05 |
| Median | 47.10 | 31.25 | 58.25 |
Test statistics
- Kruskal-Wallis H
- 148.67
- Degrees of freedom
- 2
- Asymptotic significance (p)
- < 0.001
Effect size
- Epsilon squared
- 0.497
Pairwise comparisons (post hoc)
| Row | Mann-Whitney U (pairwise) | p value (uncorrected) | p value (adjusted) | Significant |
|---|---|---|---|---|
| Bachelor - High school | 9,397 | < 0.001 | < 0.001 | Yes |
| Bachelor - Postgraduate | 3,032.50 | < 0.001 | < 0.001 | Yes |
| High school - Postgraduate | 754.50 | < 0.001 | < 0.001 | Yes |
Computation credits: scipy 1.18.0 · statsmodels 0.14.6 · scikit-learn 1.9.0 · numpy 2.5.1 · pandas 3.0.5 · semopy 2.3.11 · 89fc29a · Data seed: 20260914
How to report the result
Trust rankings differed by education level, H(2) = 11.42, p = .003, epsilon squared = .054; in Bonferroni-corrected pairwise comparisons only the secondary and postgraduate groups separated (adjusted p = .003).
An example sentence close to APA style; the numbers are representative.
When you should not use it
- The omnibus result does not identify which groups differ; that detail arrives only in the pairwise block added when p falls below 0.05, and running pair-by-pair tests after a non-significant omnibus test is not appropriate.
- The Bonferroni correction applied to those pairs is conservative, so genuine differences become easier to miss as the number of comparisons grows.
- It cannot be used for repeated measurements taken from the same participants; dependent observations call for the Friedman test.
- When distribution shapes differ markedly, a significant result cannot be read as a shift in position, only as evidence that the distributions are not identical.
- Mean ranks carry no meaning in the units of your scale, so reporting medians and category distributions alongside them is what makes a finding interpretable in practice.
- In very small groups the asymptotic p value is only an approximation to the true probability, and below three observations per group the analysis does not run at all.
What to use when the assumptions are not met
- One-Way ANOVAWhy: When the dependent variable is continuous and the distributions are close to normal; it reports mean differences in the original units.
- Mann-Whitney U TestWhy: When there are two groups to compare; it applies the same rank logic in a single comparison.
- Dunn's TestWhy: When you want the standard follow-up test that keeps one set of ranks computed across the whole sample; it is selected as a method of its own.
- Friedman TestWhy: When the measurements come from the same people under several conditions, where independence fails and Kruskal-Wallis does not apply.
Frequently asked questions
- The test is significant. How do I see which groups differ?
- When the omnibus p value falls below 0.05 the panel adds the pairwise block by itself, listing the Mann-Whitney U value and both the raw and Bonferroni-adjusted p values for every pair. Base your decision on the adjusted p value, or on the adjusted alpha obtained by dividing 0.05 by the number of comparisons. If the omnibus result is not significant, the block is never built.
- Are the panel's pairwise comparisons the same as Dunn's test?
- No. The follow-up analysis added automatically here runs a separate Mann-Whitney U test for each pair of groups, with ranks reassigned inside those two groups only. Dunn's test instead uses a single set of ranks computed across the whole sample and sits in the catalog as its own method; it does not run as part of a Kruskal-Wallis analysis, so you have to choose it separately.
- Should I run a normality test first?
- There is no need. A rank-based test does not expect a normal population distribution, and the panel performs no normality or equal-variance check for this method. The only numeric requirement is three valid observations per group. If you still want to see the shape of the distributions, run the descriptive statistics method on its own.
- One of my groups has only two valid answers. What happens?
- The analysis does not start and the error message names the group. Because missing values are dropped row by row, this can happen in groups that look more populated in the raw file. The way out is to merge categories where that is defensible, or to leave a very small category out of the analysis. Pairs with one side below three observations are also skipped silently in the pairwise block, so you may not find every pair you expected there.
References
- Field, A. (2018). Discovering Statistics Using IBM SPSS Statistics
- Siegel, S., & Castellan, N. J. (1988). Nonparametric Statistics for the Behavioral Sciences
- Kruskal, W. H., & Wallis, W. A. (1952). Use of Ranks in One-Criterion Variance Analysis
- scipy.stats.kruskal documentation
Try it with your own data
The free plan includes 50 analysis runs a month and needs no card.