pairwiseNominalIndependence.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.
pairwiseNominalIndependence(
x,
compare = "row",
fisher = TRUE,
gtest = TRUE,
chisq = TRUE,
method = "fdr",
correct = "none",
yates = FALSE,
stats = FALSE,
cramer = FALSE,
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 stats::p.adjust.
The correction method to pass to DescTools::GTest.
Passed to correct in stats::chisq.test.
If "TRUE", includes the Chi-square value and degrees of
freedom for Chi-square tests, and the G value.
If "TRUE", includes an effect size, Cramer's V in the
output.
The number of significant digits in the output.
Additional arguments, passed to stats::fisher.test,
DescTools::GTest, or stats::chisq.test.
A data frame of comparisons, p-values, and adjusted p-values.
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.
### 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 = pairwiseNominalIndependence(Anderson,
fisher = TRUE,
gtest = FALSE,
chisq = FALSE,
cramer = TRUE)
PT
#> Comparison p.Fisher p.adj.Fisher Cramer.V
#> 1 Heimlich : Bloom 0.740000 0.74000 0.0475
#> 2 Heimlich : Dougal 0.013100 0.02620 0.3930
#> 3 Heimlich : Cobblestone 0.000994 0.00596 0.4980
#> 4 Bloom : Dougal 0.037600 0.05640 0.3530
#> 5 Bloom : Cobblestone 0.003960 0.01190 0.4600
#> 6 Dougal : Cobblestone 0.720000 0.74000 0.1160
cldList(comparison = PT$Comparison,
p.value = PT$p.adj.Fisher,
threshold = 0.05)
#> Group Letter MonoLetter
#> 1 Heimlich a a
#> 2 Bloom ab ab
#> 3 Dougal bc bc
#> 4 Cobblestone c c