Learn R Programming

rcompanion (version 2.4.30)

pairwiseNominalIndependence: Pairwise tests of independence for nominal data

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

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

Value

A data frame of comparisons, p-values, and adjusted p-values.

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 stats::p.adjust.

correct

The correction method to pass to DescTools::GTest.

stats

If "TRUE", includes the Chi-square value and degrees of freedom for Chi-square tests, and the G value.

cramer

If "TRUE", includes an effect size, Cramer's V in the output.

digits

The number of significant digits in the output.

...

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

Acknowledgments

My thanks to Carole Elliott of Kings Park & Botanic Gardens for suggesting the inclusion on the chi-square statistic and degrees of freedom in the output.

Author

Salvatore Mangiafico, mangiafico@njaes.rutgers.edu

References

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

See Also

pairwiseMcnemar, groupwiseCMH, nominalSymmetryTest, pairwiseNominalMatrix

Examples

Run this code
### Independence test for a 4 x 2 matrix
data(Anderson)
fisher.test(Anderson)
Anderson = Anderson[(c("Heimlich", "Bloom", "Dougal", "Cobblestone")),]
PT = pairwiseNominalIndependence(Anderson,
                                 fisher = TRUE,
                                 gtest  = FALSE,
                                 chisq  = FALSE,
                                 cramer = TRUE)
PT                                
cldList(comparison = PT$Comparison,
        p.value    = PT$p.adj.Fisher,
        threshold  = 0.05)                             
                                                              

Run the code above in your browser using DataLab