Skip to contents

Conducts pairwise two-sample symmetry tests across groups.

Usage

pairwisePermutationSymmetryMatrix(
  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.

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 list consisting of: A matrix of p-values; the p-value adjustment method; a matrix of 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 = pairwisePermutationSymmetryMatrix(Likert ~ Instructor | Rater,
                                 data     = BobBelcher,
                                 ytrafo   = rank_trafo,
                                 teststat = "quadratic",
                                 method   = "fdr")
PT
#> $Unadjusted
#>                Linda Belcher Louise Belcher Tina Belcher Bob Belcher
#> Linda Belcher             NA         0.4109       0.9280     0.01503
#> Louise Belcher            NA             NA       0.3568     0.02307
#> Tina Belcher              NA             NA           NA     0.01605
#> Bob Belcher               NA             NA           NA          NA
#> Gene Belcher              NA             NA           NA          NA
#>                Gene Belcher
#> Linda Belcher      0.009230
#> Louise Belcher     0.006117
#> Tina Belcher       0.010600
#> Bob Belcher        0.491300
#> Gene Belcher             NA
#> 
#> $Method
#> [1] "fdr"
#> 
#> $Adjusted
#>                Linda Belcher Louise Belcher Tina Belcher Bob Belcher
#> Linda Belcher         1.0000        0.51360       0.9280     0.03210
#> Louise Belcher        0.5136        1.00000       0.5097     0.03845
#> Tina Belcher          0.9280        0.50970       1.0000     0.03210
#> Bob Belcher           0.0321        0.03845       0.0321     1.00000
#> Gene Belcher          0.0321        0.03210       0.0321     0.54590
#>                Gene Belcher
#> Linda Belcher        0.0321
#> Louise Belcher       0.0321
#> Tina Belcher         0.0321
#> Bob Belcher          0.5459
#> Gene Belcher         1.0000
#> 

PA = PT$Adjusted
library(multcompView)
multcompLetters(PA,
                compare="<",
                threshold=0.05,
                Letters=letters)     
#>  Linda Belcher Louise Belcher   Tina Belcher    Bob Belcher   Gene Belcher 
#>            "a"            "a"            "a"            "b"            "b"