pairwisePermutationTest.RdConducts pairwise two-sample independence tests across groups.
pairwisePermutationTest(
formula = NULL,
data = NULL,
x = NULL,
g = NULL,
method = "fdr",
...
)A formula indicating the measurement variable and the grouping variable. e.g. y ~ group.
The data frame to use.
The response variable as a vector.
The grouping variable as a vector.
The p-value adjustment method to use for multiple tests.
See stats::p.adjust.
Additional arguments passed to
coin::independence_test.
A dataframe of the groups being compared, the p-values, and the adjusted p-values.
The input should include either formula and data;
or x, and g.
This function is a wrapper for coin::independence_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.
For some options for common tests, see Horthorn et al., 2008.
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.
https://rcompanion.org/handbook/K_02.html
Hothorn, T., K. Hornik, M.A. van de Wiel, and A. Zeileis. 2008. Implementing a Class of Permutation Tests: The coin Package. Journal of Statistical Software, 28(8), 1–23.
### Fisher-Pitman test
data(BrendonSmall)
library(coin)
independence_test(Sodium ~ Instructor, data = BrendonSmall,
teststat="quadratic")
#>
#> Asymptotic General Independence Test
#>
#> data: Sodium by
#> Instructor (Brendon Small, Jason Penopolis, Melissa Robins, Paula Small, Coach McGuirk)
#> chi-squared = 30.34, df = 4, p-value = 4.174e-06
#>
PT = pairwisePermutationTest(Sodium ~ Instructor,
data = BrendonSmall,
teststat="quadratic",
method = "fdr")
PT
#> Comparison Stat p.value p.adjust
#> 1 Brendon Small - Jason Penopolis = 0 1.475 0.2245 0.249400
#> 2 Brendon Small - Melissa Robins = 0 9.43 0.002135 0.004270
#> 3 Brendon Small - Paula Small = 0 12.34 0.0004433 0.001208
#> 4 Brendon Small - Coach McGuirk = 0 12.34 0.0004439 0.001208
#> 5 Jason Penopolis - Melissa Robins = 0 7.923 0.004881 0.008135
#> 6 Jason Penopolis - Paula Small = 0 12.18 0.0004822 0.001208
#> 7 Jason Penopolis - Coach McGuirk = 0 12.18 0.000483 0.001208
#> 8 Melissa Robins - Paula Small = 0 3.039 0.08129 0.102600
#> 9 Melissa Robins - Coach McGuirk = 0 3.023 0.08209 0.102600
#> 10 Paula Small - Coach McGuirk = 0 0.0002368 0.9877 0.987700
cldList(comparison = PT$Comparison,
p.value = PT$p.adjust,
threshold = 0.05)
#> Group Letter MonoLetter
#> 1 BrendonSmall a a
#> 2 JasonPenopolis a a
#> 3 MelissaRobins b b
#> 4 PaulaSmall b b
#> 5 CoachMcGuirk b b