Performs Conover's test (also known as the Conover-Iman test) for pairwise multiple comparisons of the ranked data, following a significant Kruskal-Wallis test. It is closely related to dunn_test(), but uses the pooled within-group rank variance and refers the test statistic to a t-distribution (with \(N - k\) degrees of freedom) instead of the standard normal distribution. The Conover-Iman test is generally more powerful than Dunn's test, but should only be used as a post-hoc procedure when the Kruskal-Wallis test is itself significant (Conover, 1999).

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

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 x ~ group where x is a numeric variable giving the data values and group is a factor with one or multiple levels giving the corresponding groups. For example, formula = TP53 ~ cancer_group.

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". If you don't want to adjust the p value (not recommended), use p.adjust.method = "none".

ref.group

a character string specifying the reference group. If specified, for a given grouping variable, each of the group levels will be compared to the reference (control) group, and the p-value adjustment is computed over only these comparisons. Note that, like dunn_test(), conover_test() does not support ref.group = "all".

detailed

logical value. Default is FALSE. If TRUE, a detailed result is shown.

Value

return a data frame with some of the following columns:

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

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

  • n1,n2: Sample counts.

  • estimate: mean ranks difference.

  • estimate1, estimate2: show the mean rank values of the two groups, respectively.

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

  • df: degrees of freedom (\(N - k\), the same for every comparison).

  • 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.

Details

The Conover-Iman pairwise statistic for comparing groups \(i\) and \(j\) is $$t_{ij} = \frac{\bar{R}_i - \bar{R}_j}{\sqrt{S^2 \, \frac{N - 1 - H}{N - k} \left(\frac{1}{n_i} + \frac{1}{n_j}\right)}}$$ where \(\bar{R}\) are the mean ranks, \(H\) is the (tie-corrected) Kruskal-Wallis statistic, \(N\) is the total sample size, \(k\) is the number of groups, and \(S^2\) is the variance of the ranks (\(S^2 = N(N+1)/12\) when there are no ties; otherwise \(S^2 = \frac{1}{N - 1}\left(\sum r^2 - \frac{N(N+1)^2}{4}\right)\)). The statistic is referred to a t-distribution with \(N - k\) degrees of freedom.

References

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

Conover, W. J. and Iman, R. L. (1979) On multiple-comparisons procedures. Technical Report LA-7677-MS, Los Alamos Scientific Laboratory.

Examples

# Simple test
ToothGrowth %>% conover_test(len ~ dose)
#> # A tibble: 3 × 10
#>   .y.   group1 group2    n1    n2 statistic    df        p    p.adj p.adj.signif
#> * <chr> <chr>  <chr>  <int> <int>     <dbl> <int>    <dbl>    <dbl> <chr>       
#> 1 len   0.5    1         20    20      6.27    57 5.20e- 8 1.04e- 7 ****        
#> 2 len   0.5    2         20    20     11.2     57 4.68e-16 1.41e-15 ****        
#> 3 len   1      2         20    20      4.95    57 6.92e- 6 6.92e- 6 ****        

# Comparison against a reference (control) group
# each group is compared to the reference; the p-value
# adjustment corrects for only these k - 1 comparisons
ToothGrowth %>% conover_test(len ~ dose, ref.group = "0.5")
#> # A tibble: 2 × 10
#>   .y.   group1 group2    n1    n2 statistic    df        p    p.adj p.adj.signif
#> * <chr> <chr>  <chr>  <int> <int>     <dbl> <int>    <dbl>    <dbl> <chr>       
#> 1 len   0.5    1         20    20      6.27    57 5.20e- 8 5.20e- 8 ****        
#> 2 len   0.5    2         20    20     11.2     57 4.68e-16 9.37e-16 ****        

# Grouped data
ToothGrowth %>%
  group_by(supp) %>%
  conover_test(len ~ dose)
#> # A tibble: 6 × 11
#>   supp  .y.   group1 group2    n1    n2 statistic    df        p    p.adj
#> * <fct> <chr> <chr>  <chr>  <int> <int>     <dbl> <int>    <dbl>    <dbl>
#> 1 OJ    len   0.5    1         10    10      4.55    27 1.03e- 4 2.06e- 4
#> 2 OJ    len   0.5    2         10    10      6.77    27 2.87e- 7 8.62e- 7
#> 3 OJ    len   1      2         10    10      2.22    27 3.48e- 2 3.48e- 2
#> 4 VC    len   0.5    1         10    10      6.86    27 2.26e- 7 4.53e- 7
#> 5 VC    len   0.5    2         10    10     13.1     27 3.12e-13 9.35e-13
#> 6 VC    len   1      2         10    10      6.26    27 1.06e- 6 1.06e- 6
#> # ℹ 1 more variable: p.adj.signif <chr>