Pairwise Mood's median tests with matrix output
pairwiseMedianMatrix.RdConducts pairwise Mood's median tests across groups.
Usage
pairwiseMedianMatrix(
formula = NULL,
data = NULL,
x = NULL,
g = NULL,
digits = 4,
method = "fdr",
...
)Arguments
- formula
A formula indicating the measurement variable and the grouping variable. e.g. y ~ group.
- data
The data frame to use.
- x
The response variable as a vector.
- g
The grouping variable as a vector.
- digits
The number of significant digits to round output.
- method
The p-value adjustment method to use for multiple tests. See
stats::p.adjust.- ...
Additional arguments passed to
coin::median_test.
Value
A list consisting of: a matrix of p-values; the p-value adjustment method; a matrix of adjusted p-values.
Details
The input should include either formula and data;
or x, and g.
Mood's median test compares medians among two or more groups. See https://rcompanion.org/handbook/F_09.html for futher discussion of this test.
The pairwiseMedianMatrix function
can be used as a post-hoc method following an omnibus Mood's
median test. It passes the data for pairwise groups to
coin::median_test.
The matrix output can be converted to a compact letter display, as in the example.
Note
The parsing of the formula is simplistic. The first variable on the left side is used as the measurement variable. The first variable on the right side is used for the grouping variable.
Author
Salvatore Mangiafico, mangiafico@njaes.rutgers.edu
Examples
data(PoohPiglet)
PoohPiglet$Speaker = factor(PoohPiglet$Speaker,
levels = c("Pooh", "Tigger", "Piglet"))
PT = pairwiseMedianMatrix(Likert ~ Speaker,
data = PoohPiglet,
exact = NULL,
method = "fdr")$Adjusted
PT
#> Pooh Tigger Piglet
#> Pooh 1.000000 0.614700 0.001465
#> Tigger 0.614700 1.000000 0.003247
#> Piglet 0.001465 0.003247 1.000000
library(multcompView)
multcompLetters(PT,
compare="<",
threshold=0.05,
Letters=letters)
#> Pooh Tigger Piglet
#> "a" "a" "b"