Skip to content
Prev 327195 / 398502 Next

BH correction with p.adjust

My understanding was that the vector was ranked, the adjusted p vector was calculated and then the vector is returned to the original order - I came across a stack overflow answer saying this:

http://stackoverflow.com/questions/10323817/r-unexpected-results-from-p-adjust-fdr

Although the code there does not appear to be the same as when I type "p.adjust" into the command line. The order shouldn't matter anyway since my data was ordered by p.

Yesterday I tried a short example of 5 numbers and it seemed to work out though today I tried to do another short example to demonstrate that the order in the p vector you input doesn't matter but didn't quite get a working example this time. Maybe due to a rounding to first significant figure or something?
first second   last 
 2e-02  5e-01  3e-04
[1] 0.015
[1] 0.5
[1] 3e-04

In any case I reconstructed a large example which can be run without real data where the figure is way off and definitely not the result of a rounding error:
[1] 9999991
[1] 1e-07
[1] 0.1
[1] 0.9999991

Any help with this would be very much appreciated. It seems like it ought to be such a simple and commonly used method and yet I am struggling and not sure what to do about it.

Thanks,

Scott