Understand the idea
Imagine testing the same group of people under three or more different conditions (three drug doses, say, or scores measured at three time points). The Friedman test asks whether these related conditions tend to differ, without assuming the underlying measurements follow a bell curve. Its key trick: instead of ranking every single measurement against the whole dataset, it ranks the conditions SEPARATELY WITHIN EACH SUBJECT, so each person contributes the ranks 1 through k across their own k conditions.
This within-subject ranking is exactly what makes it a genuine REPEATED-MEASURES test: any difference in overall level between subjects (one person's scores just tend to run higher than another's, regardless of condition) gets automatically canceled out, because you're only ever comparing a person's OWN ranks against their OWN other ranks, never against a different person's raw numbers.
Kendall's W turns the test statistic into a 0-to-1 measure of how much the subjects AGREE on the ordering of the conditions: W near 0 means subjects ranked the conditions in essentially random, disagreeing orders; W near 1 means every subject ranked the conditions in exactly the same order. A significant Friedman test tells you SOME conditions differ, but not which ones; a follow-up post-hoc comparison (pairwise Wilcoxon signed-rank tests, with a correction for running several comparisons) is needed to pin down exactly which specific conditions differ from each other.
The Friedman test, sometimes called Friedman ANOVA, is the standard nonparametric repeated measures test: it ranks each subject's values across the conditions.
Practitioner explanation
KernelStats requires WIDE-format data (one column per condition, one row per subject) and computes chi2_F = (12/(n*k*(k+1))) * sum(R_j^2) - 3*n*(k+1), df = k-1, with Kendall's W = chi2_F / (n*(k-1)) as the effect size (bands: <0.1 negligible, 0.1-0.3 small, 0.3-0.5 moderate, >0.5 large). A subject missing ANY condition is dropped as an incomplete block, with the exact count reported: complete blocks only are used, never a partial row.
A specific degenerate case is handled honestly rather than silently: if EVERY subject gives the exact same value under every condition, all within-subject ranks tie completely and the statistic becomes mathematically 0/0: UNDEFINED, not zero. The card reports NO chi2_F, NO p-value, NO Kendall's W, and NO decision in that case (matching R's friedman.test, which returns NaN on the same data), rather than fabricating a spurious 'no difference' result. A FEW fully-tied subjects among many are fine and simply drop out of the calculation as if unmeasured; only complete, universal tying across every subject breaks the test.
Post-hoc pairwise comparisons use Wilcoxon signed-rank tests with Bonferroni correction (adjusted p = min(1, m*p) for m = k(k-1)/2 pairs), and CRITICALLY, each pairwise p-value's computation ROUTE is named explicitly on the card, because signed-rank p-values can be computed three different ways that do not always agree: the exact signed-rank distribution (no ties, no zero differences, n<=50), exact sign-flip permutation (ties or zeros present, n<=13), or a tie-corrected normal approximation with NO continuity correction (larger tied samples, n>50). The product states directly that R's pairwise.wilcox.test(paired=TRUE) uses a DIFFERENT default (normal approximation WITH continuity correction on tied data), so a discrepancy against R on small tied samples reflects a genuine methodological difference, not an error in either program, and the R code export uses THIS card's exact route specifically so it reproduces the card's own numbers rather than R's default behavior.
When to use it
Consider it when
The same subjects or matched blocks were measured under three or more related conditions (wide format, one column per condition), and normality of the differences is doubtful, the response is ordinal, or the sample is small.
Use caution when
Exactly two related conditions are being compared (use the Wilcoxon signed-rank test instead), the groups are independent rather than related (use Kruskal-Wallis), the data are roughly normal and sphericity is plausible (repeated-measures ANOVA is more powerful in that case), or every subject shows an identical value across every condition (the statistic is mathematically undefined, not zero, and the card reports this honestly).
Formulas and symbols
Friedman test statistic
n subjects/blocks, k conditions, R_j the sum of within-subject ranks for condition j. This is the no-ties form; with tied ranks within a subject, scipy's friedmanchisquare (which the card uses) divides it by a tie-correction factor, as R's friedman.test does. Under H0, chi2_F is approximately chi-square(k-1).
Kendall's coefficient of concordance
Rescales the statistic to [0,1]: the degree to which subjects agree on the ordering of conditions. 0 = no agreement, 1 = identical rankings by every subject.
Bonferroni-adjusted post-hoc p-value
m pairwise comparisons across k conditions; each pairwise p-value comes from a Wilcoxon signed-rank test, with its exact computation route stated on the card.
Assumptions and checks
- Independence of observations. Friedman's test assumes the SAME subjects/blocks appear in every condition (a within-subject design); comparing unrelated groups instead would need Kruskal-Wallis, not Friedman.
In KernelStats: Not checked by KernelStats as a statistical test: assumed from the design; the card states this directly, and separately drops any row missing a condition so every remaining block is complete, as the ranking procedure requires.
- With fewer than about 6 blocks (subjects), the chi-square approximation to the Friedman statistic can be inaccurate, so the reported p-value should be treated as approximate.
In KernelStats: Checked directly: the card flags fewer than 6 blocks as a warning, or reports the check as not assessed when the statistic itself is undefined (e.g. every block fully tied).
- If every subject gave the identical value under every condition (all blocks fully tied), there is no within-subject variation for the test to rank, and the Friedman statistic is undefined; reporting a p-value anyway would be fabricating a result from a chi-square statistic with no genuine number to approximate.
In KernelStats: Checked directly: the card detects the all-tied-blocks case and reports the statistic as undefined (a named failure) rather than printing a fabricated p-value or NaN.
Alternatives
- Wilcoxon Signed-Rank Test. There are exactly two related conditions rather than three or more.
- Kruskal-Wallis Test. The groups being compared are independent rather than related/repeated-measures.
- Repeated-Measures ANOVA. The data are roughly normal and sphericity is plausible, where the parametric repeated-measures ANOVA is more powerful.
Worked example
Scenario
Reaction times measured on the same 20 participants under three drug conditions (placebo, low dose, high dose).
Result
chi2_F(2) = 14.3, p < .001, Kendall's W = 0.36 (moderate agreement); post-hoc Bonferroni-corrected Wilcoxon shows placebo vs. high dose significant (p = .003), placebo vs. low dose not significant (p = .21).
Interpretation
Reaction times differ meaningfully across at least some of the three conditions, with moderate agreement among participants about the ordering; the post-hoc comparisons pin down that the high dose specifically differs from placebo, while the low dose does not yet show a reliable difference from placebo at this sample size.
Common misconceptions
Misconception
If the Friedman test statistic can't be computed because every subject gave identical values across conditions, that must mean the test result is 'no significant difference' (p=1).
Correction
This case is mathematically UNDEFINED (a 0/0 calculation), not a p-value of 1 or a confirmed null result. While the data plainly show no variation to test, there is genuinely no statistic or p-value the test can report; the card (matching R's friedman.test, which returns NaN) shows no chi-square, no p-value, and no decision, rather than fabricating a spurious result.
Misconception
A significant Friedman test tells you exactly which pair of conditions differs.
Correction
A significant Friedman test only establishes that SOME conditions differ somewhere among the k conditions: it does not identify WHICH pair. Pairwise post-hoc comparisons (Wilcoxon signed-rank tests with a multiple-comparison correction) are required to pin down which specific conditions actually differ from each other.
References
- The use of ranks to avoid the assumption of normality implicit in the analysis of variance, Friedman, M. (1937), Journal of the American Statistical Association, 32(200), 675-701.
- The problem of m rankings, Kendall, M. G. and Babington Smith, B. (1939), Annals of Mathematical Statistics, 10(3), 275-287.
