Nemenyi Post-Hoc Test for Friedman

Statistics
Introduced by
Peter Nemenyi
Year
1963
Type
Nonparametric post-hoc multiple comparison

What does it do?

The Nemenyi test is a nonparametric post-hoc multiple comparison procedure introduced by Peter Nemenyi in his 1963 Princeton doctoral thesis.

It is applied after a significant Friedman test to identify which specific pairs of conditions differ in a repeated-measures or blocked design.

The intuition behind the method

Once the Friedman test indicates that at least one condition in a repeated-measures study differs from the others, the Nemenyi test is the follow-up that identifies which pairs are responsible. It works on rank sums rather than raw values, so beyond the block structure and the independence of blocks it makes no distributional assumptions. It can be thought of as a rank-based analogue of Tukey's HSD, adapted for within-subject or matched-group data.

History

Peter Nemenyi introduced the procedure in his 1963 Princeton doctoral thesis, Distribution-Free Multiple Comparisons. It is commonly used as the post-hoc follow-up to the Friedman test.

When to use it

Use the Nemenyi test after a significant Friedman test in a repeated-measures or randomised complete block design with three or more conditions, when you need to know which specific pairs differ. The data should be continuous or ordinal, the blocks (subjects or matched units) should be independent of one another, and every block should contain all conditions. Do not use it for independent groups; for those, a Kruskal-Wallis test followed by a Dunn or Conover–Iman comparison is the appropriate route. A minimum sample size of 10 applies to this test, but a rank-based test does not by itself guarantee adequate power or valid results at small n, so the sample size should be judged for the specific study.

Limitations and considerations

  • It can be conservative relative to the Conover–Iman test, so it may miss real pairwise differences.
  • The Friedman test is conventionally used as a gate before pairwise comparisons. Running Nemenyi comparisons without a significant omnibus result is not recommended, because the pairwise results are then interpreted without the evidence that conventionally justifies them.
  • The test does not produce an effect size. The difference in mean ranks is what it directly tests, and any standardised effect size for blocked pairs has to be chosen and justified separately.

Source conditions do not replace independent scientific review or validation by an analysis engine.

Strengths

  • Makes no normality assumption, so it can be applied to ordinal data.
  • Because the comparisons are built on a common critical value, it is designed to control the family-wise error rate across all pairwise comparisons simultaneously.
  • The logic is easy to follow: raw values are replaced by ranks, and the decision rule is structured in the same way as Tukey's HSD.

Applications

  • Comparing the effectiveness of several treatments applied to the same subjects in medical or psychological repeated-measures studies.
  • Comparing several algorithms or methods evaluated on the same set of benchmark datasets.
  • Comparing panelists' ratings of several products in sensory evaluation or consumer research, where each panelist rates all products.
  • Identifying which time points or conditions differ in longitudinal ordinal-scale data in which the same units are observed repeatedly.

How it works

How it works

1

For every pair of conditions i and j (i ≠ j), θ_i denotes the rank-based location of condition i. The null hypothesis states that the two conditions have equal location, which the test assesses through their mean ranks. The two-sided alternative states that the two conditions differ in location. With k conditions there are k(k−1)/2 distinct pairs, and all of them are tested simultaneously. The procedure is designed to control the family-wise error rate across these pairs. The test does not establish that the full rank distributions of the conditions are identical.

Formula
H_0:\ \theta_i = \theta_j \quad H_1:\ \theta_i \neq \theta_j \quad (i \neq j)
2

Within each block, the k conditions are ranked from 1 to k, and tied observations receive the average of the ranks they span. R̄_i is the mean of condition i's within-block ranks across the n blocks. The test statistic for each pair is the absolute difference between the two conditions' mean ranks, divided by a standard error term that depends on the number of conditions k and the number of blocks (subjects) n, as given in the formula above. Each pair therefore receives a single standardised value that can be compared with a critical value. The same within-block ranking underlies the Friedman test, so the two procedures should be read on the same ranks.

Formula
q_{ij} = \dfrac{|\bar{R}_i - \bar{R}_j|}{\sqrt{\dfrac{k(k+1)}{6n}}}
3

The computed q value for each pair is compared with the critical value from the Studentised range distribution at the chosen significance level and with k groups. If q exceeds that critical value, the null hypothesis for that pair is rejected, indicating that the two conditions differ. The critical value must be on the same scale as this statistic, so the scaling convention of the table or software used should be checked against its documentation before decisions are reported. Results are commonly displayed as a pairwise p-value matrix.

Formula
\text{reject } H_0 \text{ if } q_{ij} > q_{\alpha,k} \;\text{(Studentised range critical value)}

Common pitfalls

  • Running Nemenyi comparisons without first confirming a significant Friedman result, which skips the conventional omnibus gate and risks false positives.
  • Applying the test to independent groups rather than related or blocked designs. For independent groups, use a Dunn or Conover–Iman test after Kruskal-Wallis.
  • Reporting only which pairs are significant without the mean rank of each condition, which is needed to interpret the direction of each difference.

Frequently asked questions

When should I choose the Nemenyi test over the Conover–Iman test?

The Nemenyi test is generally the more conservative of the two, which means it may detect fewer real differences. The Conover–Iman test is usually more powerful but involves a more complex calculation, so when power is a priority it is often considered first.

Can I run the Nemenyi test if my Friedman test was not significant?

No. The Friedman test is the conventional gate before pairwise comparisons. Running post-hoc comparisons after a non-significant omnibus result is not recommended, because it bypasses the evidence that normally justifies the pairwise tests. The Friedman test should reach significance before any pairwise Nemenyi comparisons are conducted.

Does the Nemenyi test work for independent groups?

No. It is designed for repeated-measures or randomised complete block designs in which the same subjects (or matched units) appear under every condition. For independent groups, run a Kruskal-Wallis test first and use a Dunn or Conover–Iman test as the post-hoc procedure.

How do I report the results?

Report the Friedman chi-square statistic and its p-value first, then present the Nemenyi pairwise p-value matrix. State the mean rank for each condition and identify which pairs differ significantly, so that the direction of each difference is clear. If an effect size is reported, choose a measure suited to blocked pairwise comparisons and state why it was chosen.

Related methods

Sources

  1. Nemenyi, P. (1963). Distribution-Free Multiple Comparisons. PhD thesis, Princeton University.

    Open publication reference