rcompanion (version 2.2.2)

pairwiseNominalMatrix: Pairwise tests of independence for nominal data with matrix output

Description

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

Usage

pairwiseNominalMatrix(x, compare = "row", fisher = TRUE,
  gtest = FALSE, chisq = FALSE, method = "fdr", correct = "none",
  digits = 3, ...)

Arguments

x

A two-way contingency table. At least one dimension should have more than two levels.

compare

If "row", treats the rows as the grouping variable. If "column", treats the columns as the grouping variable.

fisher

If "TRUE", conducts fisher exact test.

gtest

If "TRUE", conducts G-test.

chisq

If "TRUE", conducts Chi-square test of association.

method

The method to adjust multiple p-values. See p.adjust.

correct

The correction method to pass to DescTools::GTest.

digits

The number of significant digits in the output.

...

Additional arguments, passed to stats::fisher.test, DescTools::GTest, or stats::chisq.test.

Value

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.

@seealso pairwiseMcnemar, groupwiseCMH, nominalSymmetryTest, pairwiseNominalIndependence

References

http://rcompanion.org/handbook/H_04.html

Examples

Run this code
# NOT RUN {
### Independence test for a 4 x 2 matrix
data(Anderson)
fisher.test(Anderson)
Anderson = Anderson[(c("Heimlich", "Bloom", "Dougal", "Cobblestone")),]
PT = pairwiseNominalMatrix(Anderson,
                           fisher = TRUE,
                           gtest  = FALSE,
                           chisq  = FALSE)$Adjusted
PT
library(multcompView)
multcompLetters(PT)
                                                              
# }

Run the code above in your browser using DataLab