Re: [R] pairwise.wilcox.test

From: Dieter Menne <dieter.menne_at_menne-biomed.de>
Date: Wed, 12 Nov 2008 09:20:50 +0000 (UTC)

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")



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Wed 12 Nov 2008 - 09:25:39 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 12 Nov 2008 - 10:30:23 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive