pairwiseNominalMatrix.RdConducts pairwise tests for a 2-dimensional matrix, in which at at least one dimension has more than two levels, as a post-hoc test. Conducts Fisher exact, Chi-square, or G-test.
pairwiseNominalMatrix(
x,
compare = "row",
fisher = TRUE,
gtest = FALSE,
chisq = FALSE,
method = "fdr",
correct = "none",
digits = 3,
...
)A two-way contingency table. At least one dimension should have more than two levels.
If "row", treats the rows as the grouping variable.
If "column", treats the columns as the grouping variable.
If "TRUE", conducts fisher exact test.
If "TRUE", conducts G-test.
If "TRUE", conducts Chi-square test of association.
The method to adjust multiple p-values.
See p.adjust.
The correction method to pass to DescTools::GTest.
The number of significant digits in the output.
Additional arguments, passed to stats::fisher.test,
DescTools::GTest, or stats::chisq.test.
A list consisting of: the test used, a matrix of unadjusted p-values, the p-value adjustment method used, and a matrix of adjusted p-values.
### Independence test for a 4 x 2 matrix
data(Anderson)
fisher.test(Anderson)
#>
#> Fisher's Exact Test for Count Data
#>
#> data: Anderson
#> p-value = 0.000668
#> alternative hypothesis: two.sided
#>
Anderson = Anderson[(c("Heimlich", "Bloom", "Dougal", "Cobblestone")),]
PT = pairwiseNominalMatrix(Anderson,
fisher = TRUE,
gtest = FALSE,
chisq = FALSE)$Adjusted
PT
#> Heimlich Bloom Dougal Cobblestone
#> Heimlich 1.00000 0.7400 0.0262 0.00596
#> Bloom 0.74000 1.0000 0.0564 0.01190
#> Dougal 0.02620 0.0564 1.0000 0.74000
#> Cobblestone 0.00596 0.0119 0.7400 1.00000
library(multcompView)
multcompLetters(PT)
#> Heimlich Bloom Dougal Cobblestone
#> "a" "ab" "bc" "c"