selthy
2010-Nov-24 01:13 UTC
[R] Wilcoxon Rank Sum in R with a multiple testing correction
Hi there, I'm a total newbie to R. I'd like to use a Wilcoxon Rank Sum test to compare two populations of values. Further, I'd like to do this simultaneously for 114 sets of values. The two populations are C and N. The different sets of values have arbitrary names (I'll call them a, b, c etc). The set-up is as follows: a b c d .... C 2 C 3 C 5 C 9 C 4 C 5 . N 13 N 16 N 18 . Can someone please show me how to read the data in, do the test on each set (a, b, etc) and then do, for example, a Benjamani and Hochberg correction for multiple tests? That would be great! Cheers -- View this message in context: http://r.789695.n4.nabble.com/Wilcoxon-Rank-Sum-in-R-with-a-multiple-testing-correction-tp3056557p3056557.html Sent from the R help mailing list archive at Nabble.com.
Tal Galili
2010-Nov-24 07:54 UTC
[R] Wilcoxon Rank Sum in R with a multiple testing correction
For the BH, you can use the command ?p.adjust(..., "BH") For reading the files in and doing the analysis, here is an example: http://www.r-tutor.com/elementary-statistics/non-parametric-methods/wilcoxon-signed-rank-test You'd then need to extract all the P values like this: x <- wilcox.test(... ) i <- 1 # the place to put the relevant P P.vector[i] <- x$p.value There are many ways to perform this, it depends on how your data is structured (which wasn't fully clear to me from your e-mail)... ----------------Contact Details:------------------------------------------------------- Contact me: Tal.Galili@gmail.com | 972-52-7275845 Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) | www.r-statistics.com (English) ---------------------------------------------------------------------------------------------- On Wed, Nov 24, 2010 at 3:13 AM, selthy <selthy@hotmail.com> wrote:> > Hi there, > I'm a total newbie to R. I'd like to use a Wilcoxon Rank Sum test to > compare > two populations of values. Further, I'd like to do this simultaneously for > 114 sets of values. The two populations are C and N. The different sets of > values have arbitrary names (I'll call them a, b, c etc). The set-up is as > follows: > a b c d .... > C 2 > C 3 > C 5 > C 9 > C 4 > C 5 > . > N 13 > N 16 > N 18 > . > > Can someone please show me how to read the data in, do the test on each set > (a, b, etc) and then do, for example, a Benjamani and Hochberg correction > for multiple tests? > > That would be great! > Cheers > > -- > View this message in context: > http://r.789695.n4.nabble.com/Wilcoxon-Rank-Sum-in-R-with-a-multiple-testing-correction-tp3056557p3056557.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help@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. >[[alternative HTML version deleted]]
Mark Difford
2010-Nov-24 08:27 UTC
[R] Wilcoxon Rank Sum in R with a multiple testing correction
Hi Selthy,>> I'd like to use a Wilcoxon Rank Sum test to compare two populations of >> values. Further, I'd like >> to do this simultaneously for 114 sets of values.Well, you read your data set into R using: ## ?read.table ?read.csv There are other ways to bring in data. Save the import to a workspace object at the same time: myDat <- read.csv (...) Do the Wilcoxon Rank Sum tests using the implementation of your choice (there are several): ## See the examples at foot of help page. Lacking data we will make some. ?wilcox.test pv1 <- wilcox.test(rnorm(10), rnorm(10, 2), conf.int = TRUE)$p.value pv2 <- wilcox.test(rnorm(10), rnorm(10, 2), conf.int = TRUE)$p.value pv3 <- wilcox.test(rnorm(10), rnorm(10, 2), conf.int = TRUE)$p.value Eventually you will discover more elegant ways of assembling a vector (or some other type of storage object). Finally, you feed your p-values to: ## ?p.adjust pAdj <- p.adjust (c(pv1, pv2, pv3), method = c("BH")) ## ?round ?sprintf cbind.data.frame (Uncorrected = c(pv1, pv2, pv3), BH_Corrected = pAdj) Eventually you will discover how to turn all of this into an elegant function. I really do hope that this is not a school assignment. If so.... Well, you still need to do some work to get this going. Regards, Mark. -- View this message in context: http://r.789695.n4.nabble.com/Wilcoxon-Rank-Sum-in-R-with-a-multiple-testing-correction-tp3056557p3056878.html Sent from the R help mailing list archive at Nabble.com.