pairwiseOrdinalIndependence.RdConducts pairwise tests for a 2-dimensional table,
in which one variable is ordered nominal and one variable
is non-ordered nominal.
The function relies on the coin package.
pairwiseOrdinalIndependence(
x,
compare = "row",
scores = NULL,
method = "fdr",
digits = 3,
...
)A two-way contingency table. One dimension is ordered and one is non-ordered nominal.
If "row", treats the rows as the grouping variable.
If "column", treats the columns as the grouping
variable.
Optional vector to specify the spacing of the ordered variable.
The method to adjust multiple p-values.
See stats::p.adjust.
The number of significant digits in the output.
Additional arguments, passed to stats::chisq_test.
A data frame of comparisons, p-values, and adjusted p-values.
### Independence test for table with one ordered variable
data(Breakfast)
require(coin)
chisq_test(Breakfast,
scores = list("Breakfast" = c(-2, -1, 0, 1, 2)))
#>
#> Asymptotic Generalized Pearson Chi-Squared Test
#>
#> data: Breakfast (ordered) by Travel (Walk, Bus, Drive)
#> chi-squared = 8.6739, df = 2, p-value = 0.01308
#>
PT = pairwiseOrdinalIndependence(Breakfast, compare = "row")
PT
#> Comparison p.value p.adjust
#> 1 Walk : Bus 0.12800 0.1570
#> 2 Walk : Drive 0.00462 0.0139
#> 3 Bus : Drive 0.15700 0.1570
cldList(comparison = PT$Comparison,
p.value = PT$p.value,
threshold = 0.05)
#> Group Letter MonoLetter
#> 1 Walk a a
#> 2 Bus ab ab
#> 3 Drive b b
### Similar to Kruskal-Wallis test for Likert data
data(PoohPiglet)
XT = xtabs(~ Speaker + Likert, data = PoohPiglet)
XT
#> Likert
#> Speaker 1 2 3 4 5
#> Piglet 1 6 2 1 0
#> Pooh 0 0 1 6 3
#> Tigger 0 0 2 6 2
require(coin)
chisq_test(XT,
scores = list("Likert" = c(1, 2, 3, 4, 5)))
#>
#> Asymptotic Generalized Pearson Chi-Squared Test
#>
#> data: Likert (ordered) by Speaker (Piglet, Pooh, Tigger)
#> chi-squared = 18.423, df = 2, p-value = 9.991e-05
#>
PT=pairwiseOrdinalIndependence(XT, compare = "row")
PT
#> Comparison p.value p.adjust
#> 1 Piglet : Pooh 0.000310 0.000902
#> 2 Piglet : Tigger 0.000601 0.000902
#> 3 Pooh : Tigger 0.474000 0.474000
cldList(comparison = PT$Comparison,
p.value = PT$p.value,
threshold = 0.05)
#> Group Letter MonoLetter
#> 1 Piglet a a
#> 2 Pooh b b
#> 3 Tigger b b