[R] pairwise.wilcox.test
Dieter Menne
dieter.menne at menne-biomed.de
Wed Nov 12 10:20:50 CET 2008
LE PAPE Gilles <lepape.gilles <at> neuf.fr> writes:
>
> Could somebody explain me why the pairwise.wilcox.test
> function ever gives the same result with either "paired=FALSE" or
> "paired=TRUE" ?
Because of what I would consider a .. let's call it feature to avoid
flames... in parameter passing in pairwise.wilcox.test.
#----------------------------------------------
x = rnorm(100)
g = as.factor(rep(letters[1:4],25))
pairwise.wilcox.test <-
function (x, g, p.adjust.method = p.adjust.methods, paired = FALSE,...)
{
p.adjust.method <- match.arg(p.adjust.method)
DNAME <- paste(deparse(substitute(x)), "and", deparse(substitute(g)))
g <- factor(g)
METHOD <- if (paired)
"Wilcoxon signed rank test"
else "Wilcoxon rank sum test"
compare.levels <- function(i, j) {
xi <- x[as.integer(g) == i]
xj <- x[as.integer(g) == j]
# was wilcox.test(xi, xj, ...)$p.value
wilcox.test(xi, xj, paired=paired,...)$p.value
}
PVAL <- pairwise.table(compare.levels, levels(g), p.adjust.method)
ans <- list(method = METHOD, data.name = DNAME, p.value = PVAL,
p.adjust.method = p.adjust.method)
class(ans) <- "pairwise.htest"
ans
}
wp = pairwise.wilcox.test(x,g,paired=FALSE,p.adjust.method="none")
wup = pairwise.wilcox.test(x,g,paired=TRUE,p.adjust.method="none")
More information about the R-help
mailing list