Learn R Programming

FSA (version 0.8.11)

dunnTest: Dunn's Kruskal-Wallis Multiple Comparisons.

Description

Performs Dunn's (1964) test of multiple comparisons following a significant Kruskal-Wallis test, possibly with a correction to control the experimentwise error rate.

Usage

dunnTest(x, ...)
"dunnTest"(x, g, method = dunn.test::p.adjustment.methods[c(4, 2:3, 5:8, 1)], two.sided = TRUE, ...)
"dunnTest"(x, data = NULL, method = dunn.test::p.adjustment.methods[c(4, 2:3, 5:8, 1)], two.sided = TRUE, ...)
"print"(x, dunn.test.results = FALSE, ...)

Arguments

x
A numeric vector of data values or a formula of the form x~g.
g
A factor vector or a (non-numeric) vector that can be coerced to a factor vector.
method
A single string that identifies the method to use to control the experimentwise error rate. See the list of methods in p.adjustment.methods.
two.sided
A single logical that indicates whether a two-sided p-value should be returned (TRUE; default) or not. See details.
data
A data.frame that minimally contains x and g.
dunn.test.results
A single logical that indicates whether the results that would have been printed by dunn.test function in dunn.test are shown.
...
Not yet used.

Value

A list with three items -- method is the long name of the method used to control the experimentwise error rate, dtres is the strings that would have been printed by dunn.test function in dunn.test, and a data.frame in res with the following variables:
  • Comparison Labels for each pairwise comparison.
  • Z Values for the Z test statistic for each comparison.
  • P.unadj Unadjusted p-values for each comparison.
  • P.adj Adjusted p-values for each comparison.

Details

This function performs “Dunn's” test of multiple comparisons following a Kruskal-Wallis test. Unadjusted two-sided p-values for each pairwise comparison among groups are computed following Dunn's description as implemented in the dunn.test function from dunn.test. These p-values may be adjusted using the methods in the p.adjustment.methods function in dunn.test as implemented in the dunn.test function in dunn.test.

This function is largely a wrapper for the dunn.test function in dunn.test. Changes here are the possible use of formula notation, results that are not printed by the main function (but are printed in a more useful format (in my opinion) by the print function), the p-values are adjusted by default with the “holm” method, and two-sided p-values (two times the p-value produced by the dunn.test function) are returned with two.sided=TRUE. This function returns the same results (in a different format) as the dunn.test function from dunn.test when two.sided=FALSE. See dunn.test function in dunn.test for a more details underlying these computations.

References

Dunn, O.J. 1964. Multiple comparisons using rank sums. Technometrics 6:241-252.

See Also

See kruskal.test, dunn.test in dunn.test, posthoc.kruskal.nemenyi.test in PMCMR, kruskalmc in pgirmess, and kruskal in agricolae.

Examples

Run this code
## pH in four ponds data from Zar (2010)
ponds <- data.frame(pond=as.factor(rep(1:4,each=8)),
                    pH=c(7.68,7.69,7.70,7.70,7.72,7.73,7.73,7.76,
                         7.71,7.73,7.74,7.74,7.78,7.78,7.80,7.81,
                         7.74,7.75,7.77,7.78,7.80,7.81,7.84,NA,
                         7.71,7.71,7.74,7.79,7.81,7.85,7.87,7.91))
ponds <- ponds[complete.cases(ponds),]

# non-formula usage (default "holm" method)
dunnTest(ponds$pH,ponds$pond)

# formula usage (default "holm" method)
dunnTest(pH~pond,data=ponds)

# other methods
dunnTest(pH~pond,data=ponds,method="bonferroni")
dunnTest(pH~pond,data=ponds,method="bh")
dunnTest(pH~pond,data=ponds,method="none")

# print dunn.test results
tmp <- dunnTest(pH~pond,data=ponds)
print(tmp,dunn.test.results=TRUE)

Run the code above in your browser using DataLab