friedman_conover_test: Conover's All-Pairs Comparisons Test for Friedman Rank Sums

View source: R/friedman_conover_test.R

friedman_conover_testR Documentation

Conover's All-Pairs Comparisons Test for Friedman Rank Sums

Description

Performs Conover's all-pairs comparison test (also known as the Durbin-Conover test) for a two-way balanced complete block design, following a significant Friedman rank sum test. It is the repeated-measures analogue of Conover's test for the Kruskal-Wallis design: the within-block ranks are compared pairwise using the pooled rank variance and the statistic is referred to a t-distribution with (b - 1)(k - 1) degrees of freedom (b blocks, k treatments). It should only be used as a post-hoc procedure when the Friedman test is itself significant (Conover, 1999).

If a reference group is specified (via ref.group), then each of the remaining treatments is compared only to the reference (control) treatment, and the p-value adjustment for multiple comparisons is computed over only these k - 1 comparisons (as for dunn_test()).

See the Datanovia tutorial Friedman Test in R for a worked walkthrough.

Usage

friedman_conover_test(
  data,
  formula,
  p.adjust.method = "holm",
  ref.group = NULL,
  detailed = FALSE
)

Arguments

data

a data.frame containing the variables in the formula.

formula

a formula of the form a ~ b | c, where a (numeric) is the dependent variable name; b is the within-subjects factor variable (the treatment); and c is the column name containing the individuals/subjects (block) identifier. Should be unique per individual.

p.adjust.method

method to adjust p-values for multiple comparisons. Used when pairwise comparisons are performed. Allowed values include "holm", "hochberg", "hommel", "bonferroni", "BH", "BY", "fdr", "none". Default is "holm".

ref.group

a character string specifying the reference treatment. If specified, each of the treatment levels is compared to the reference (control), and the p-value adjustment is computed over only these comparisons.

detailed

logical value. If TRUE, returns the rank-sum estimate and the test method in the output.

Details

For a balanced complete block design with b blocks and k treatments, the observations within each block are ranked. Let R_j be the sum of the within-block ranks for treatment j and let A = \sum r^2 be the sum of the squared within-block ranks. The pairwise statistic for treatments i and j is

t_{ij} = \frac{R_i - R_j}{\sqrt{\dfrac{2\,(b\,A - \sum_j R_j^2)}{(b - 1)(k - 1)}}}

referred to a t-distribution with (b - 1)(k - 1) degrees of freedom. This is the Conover (1999) post-hoc, also known as the Durbin-Conover test. In the returned table each row is oriented with i = group2 and j = group1: estimate is R_{group2} - R_{group1} and statistic carries its sign, the same convention as conover_test() and dunn_test().

The p-values match PMCMRplus::frdAllPairsConoverTest(). That function reports the t statistic for the reversed comparison, so its sign is the opposite of the one returned here; the magnitude is the same.

Value

return a data frame with some of the following columns:

  • .y.: the y (outcome) variable used in the test.

  • group1,group2: the compared treatments in the pairwise tests.

  • n1,n2: the number of blocks (subjects) contributing to each treatment.

  • estimate: the rank-sum difference.

  • estimate1, estimate2: the rank sums of the two treatments, respectively.

  • statistic: Test statistic (t-value) used to compute the p-value.

  • df: degrees of freedom ((b - 1)(k - 1)).

  • p: p-value.

  • p.adj: the adjusted p-value.

  • method: the statistical test used to compare groups.

  • p.adj.signif: the significance level of the adjusted p-values.

The returned object has an attribute called args, which is a list holding the test arguments.

References

Conover, W. J. (1999) Practical Nonparametric Statistics, 3rd edition. Wiley.

See Also

friedman_test, friedman_nemenyi_test, friedman_effsize The Datanovia tutorial: Friedman Test in R.

Examples

# A balanced complete block design: 3 treatments measured on 6 subjects
df <- data.frame(
  id        = factor(rep(1:6, 3)),
  treatment = factor(rep(c("A", "B", "C"), each = 6)),
  score     = c(4, 6, 3, 5, 4, 5,    7, 8, 6, 7, 9, 6,    6, 9, 7, 8, 8, 9)
)

# Omnibus Friedman test
df %>% friedman_test(score ~ treatment | id)

# Conover (Durbin-Conover) all-pairs post-hoc
df %>% friedman_conover_test(score ~ treatment | id)

# Comparison against a reference (control) treatment
df %>% friedman_conover_test(score ~ treatment | id, ref.group = "A")

rstatix documentation built on July 24, 2026, 1:06 a.m.