Skip to contents

Conducts pairwise two-sample symmetry tests across groups.

Usage

pairwisePermutationSymmetry(
  formula = NULL,
  data = NULL,
  x = NULL,
  g = NULL,
  b = NULL,
  method = "fdr",
  ...
)

Arguments

formula

A formula indicating the measurement variable and the grouping variable. e.g. y ~ group | block.

data

The data frame to use.

x

The response variable as a vector.

g

The grouping variable as a vector.

b

The blocking variable as a vector.

method

The p-value adjustment method to use for multiple tests. See stats::p.adjust.

...

Additional arguments passed to coin::symmetry_test.

Value

A dataframe of the groups being compared, the p-values, and the adjusted p-values.

Details

The input should include either formula and data; or x, g, and b.

This function is a wrapper for coin::symmetry_test, passing pairwise groups to the function. It's critical to read and understand the documentation for this function to understand its use and options.

Note

The parsing of the formula is simplistic. The first variable on the left side is used as the measurement variable. The first variable on the right side is used for the grouping variable. The second variable on the right side is used for the blocking variable.

Author

Salvatore Mangiafico, mangiafico@njaes.rutgers.edu

Examples

data(BobBelcher)

BobBelcher$Instructor = factor( BobBelcher$Instructor, 
                                levels = c("Linda Belcher", "Louise Belcher",
                                           "Tina Belcher", "Bob Belcher",
                                           "Gene Belcher"))
                                           
library(coin)

symmetry_test(Likert ~ Instructor | Rater, data= BobBelcher,
              ytrafo   = rank_trafo,
              teststat = "quadratic")
#> 
#> 	Asymptotic General Symmetry Test
#> 
#> data:  Likert by
#> 	 Instructor (Linda Belcher, Louise Belcher, Tina Belcher, Bob Belcher, Gene Belcher) 
#> 	 stratified by Rater
#> chi-squared = 22.283, df = 4, p-value = 0.0001761
#> 

PT = pairwisePermutationSymmetry(Likert ~ Instructor | Rater,
                                 data     = BobBelcher,
                                 ytrafo   = rank_trafo,
                                 teststat = "quadratic",
                                 method   = "fdr")
PT
#>                            Comparison     Stat  p.value p.adjust
#> 1  Linda Belcher - Louise Belcher = 0   0.6761   0.4109  0.51360
#> 2    Linda Belcher - Tina Belcher = 0 0.008163    0.928  0.92800
#> 3     Linda Belcher - Bob Belcher = 0    5.912  0.01503  0.03210
#> 4    Linda Belcher - Gene Belcher = 0    6.778  0.00923  0.03210
#> 5   Louise Belcher - Tina Belcher = 0   0.8491   0.3568  0.50970
#> 6    Louise Belcher - Bob Belcher = 0    5.163  0.02307  0.03845
#> 7   Louise Belcher - Gene Belcher = 0    7.516 0.006117  0.03210
#> 8      Tina Belcher - Bob Belcher = 0    5.797  0.01605  0.03210
#> 9     Tina Belcher - Gene Belcher = 0    6.531   0.0106  0.03210
#> 10     Bob Belcher - Gene Belcher = 0   0.4737   0.4913  0.54590

cldList(comparison = PT$Comparison,
        p.value    = PT$p.adjust,
       threshold  = 0.05)
#>           Group Letter MonoLetter
#> 1  LindaBelcher      a         a 
#> 2 LouiseBelcher      a         a 
#> 3   TinaBelcher      a         a 
#> 4    BobBelcher      b          b
#> 5   GeneBelcher      b          b