-1

I got a list of p-values, obtained from two large datasets, by using the wilcox.test() function.

Since there's a multiple comparisons, I have to do adjustment of the p-values.

Problem is I just don't get how the p.adjust() function works.
Could someone please tell me step by step what to do, so I get adjusted p-values for all my known p-values?

Sandipan Dey
  • 21,482
  • 2
  • 51
  • 63
metazoa
  • 55
  • 1
  • 1
  • 9
  • I know, but I don't get the information there. I'm no brainiac when it comes to statistics or programming, that's why I ask. – metazoa Feb 09 '17 at 11:34
  • try a package "exactRankTest" https://cran.r-project.org/web/packages/exactRankTests/exactRankTests.pdf there is a function wilcox.exact. I have never used it but from description seems to be a right tool – Mateusz1981 Feb 09 '17 at 11:40
  • The package is not available for my version of R (3.2.4). Thanks for your replies, anyways. – metazoa Feb 09 '17 at 11:46
  • What do you mean by model? I don't think I have a model... I obtained all the p-values by manually plotting them with wilcox.test(), one by one. E.g. wilcox.test(d1$x1,d2$x1,paried=T), wilcox.test(d1$x2,d2$x2,paried=T), and so on... – metazoa Feb 09 '17 at 11:54
  • wilcox test is a kind of model that you can save to the object `p` and use somwhere else when coding. Maybe it is worth to update your R – Mateusz1981 Feb 09 '17 at 12:24
  • @metazoa you better gives a reproducible example on your question. seems it is straightforward to get solution easily. – Jerry07 Feb 09 '17 at 12:33

1 Answers1

1

I simply reproduce your data and bring this simple function:

dat <- data.frame(
    value=c(4409, 55.5, 3951.5),
    p.value=c(2.766e-15, 0.04606, 1.545e-15)
)

This is the simple function to get adjusted p-value:

getAdjustPval <- function(df, pAdjustMethod="BH", ...) {
    if(is.null(df$p.value)) {
        stop("p-value is required")
    } else {
        p <- df$p.value
        df$adjust.pvalue <- p.adjust(p, method = pAdjustMethod)
        df
    }
}

you'll get this:

   value   p.value adjust.pvalue
1 4409.0 2.766e-15     4.149e-15
2   55.5 4.606e-02     4.606e-02
3 3951.5 1.545e-15     4.149e-15
Jerry07
  • 929
  • 1
  • 10
  • 28
  • This is amazing. Thank you so much! – metazoa Feb 09 '17 at 16:14
  • @metazoa don't forget to accept the answer and upvote it if you benefit from the solution. Please check out the `SO` community rules. – Jerry07 Feb 09 '17 at 16:38
  • I gave it an upvote but it won't be registered... it's because I don't have enough reputations or something.. thank you again for your help! – metazoa Feb 09 '17 at 17:12