[R] p.adjust not working correctly?

Alicia Ellis alicia.m.ellis at gmail.com
Tue Aug 2 21:36:08 CEST 2016


p.adjust for bonferroni p value correction does not appear to be working
correctly:

> p <- runif(50)
>
> p
 [1] 0.08280254 0.08955706 0.19754389 0.52812033 0.68907772 0.21849696
0.02774784 0.23923562 0.03482480 0.76437481 0.87236155 0.76438604
[13] 0.37432032 0.89630318 0.01626565 0.08152060 0.55715478 0.47736921
0.77968275 0.17388127 0.37212900 0.18363170 0.51655538 0.14526733
[25] 0.60870820 0.13752392 0.92412799 0.73045115 0.89887453 0.33744577
0.84966571 0.97797283 0.20571554 0.29115022 0.75928867 0.12929511
[37] 0.64923057 0.68168196 0.19311014 0.83818106 0.85592243 0.56276287
0.80822911 0.53377044 0.44691466 0.59198417 0.36114259 0.35431768
[49] 0.10381694 0.57738429

> p.adjust(p, method = "bonferroni", n=50)
 [1] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
[15] 0.8132824 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
[29] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
[43] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
1.0000000

for the one corrected pvalue that is less than 1, it seems to have been
divided by 0.02 and not 50.

I can do this one manually but would be nice if it worked:)

	[[alternative HTML version deleted]]



More information about the R-help mailing list