0

I am trying to adjust my raw p-values using the Bonferroni method. However, all the adjusted p-values show values of 1. I don't expect this. I have run this function many a times previously. I also tried it with other set of p-values, but only in this set, it shows values of 1. In addition, I checked manually as well as with an excel tool, where it works perfectly fine in this set. But not sure why the p.adjust function does not give the right output.

> bonf_p_value <- p.adjust(results1$p_value, method="bonferroni", n = length(results1$p_value))
> bonf_p_value
[1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
[59] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
[117] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
[175] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
[233] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

I also here paste the output of the first 30 raw p-values:

> results1$p_value [1:30]
 [1] 1.11718083532422e-07 1.51230033705852e-22 0.0306424108597955   0.145414146079963    0.190655506480756   
 [6] 4.1978959530709e-10  2.94936466785171e-22 0.0430124258812526   0.000370518232611833 0.0552390731601288  
[11] 2.00227050966185e-10 1.13669513384145e-07 1.67714177934414e-10 0.00280377485899087  1.34668243167121e-16
[16] 0.129035611905561    0.000174054291588747 3.68035394001236e-10 9.02747138351362e-24 6.24974784951431e-06
[21] 2.88869180470667e-05 5.46785702671633e-11 0.00177979879670995  3.93003744169092e-18 1.17992044937425e-65
[26] 3.89268583374799e-42 0.00113708261328755  0.744722392060977    8.85123774661934e-42 5.27920045337181e-22
560 Levels: 0.000114741095154172 0.000174054291588747 0.000205370871640424 0.000219014679077748 ... 9.84472710150517e-05

and this is the length of "p_value" column:

> length(results1$p_value)
[1] 274

Would anyone know what could be the reason p.adjust is not calculating it right, and what do I need to do, to do it the right way?

Letin
  • 1,255
  • 5
  • 20
  • 36
  • 3
    From the output you paste it seems like the p_values are stored as a factor variable and not as a numerical one. Is 560 the length of your vector? Note that the bonferroni method multiplies the p-values with the number of tests which would be 560 in this case... – kath Jun 20 '19 at 11:31
  • oh yes that's wierd. The length of my p-value column is 274. I have now edited this in my question. Do you know what can I do to convert it from factor to numeric? I just tried using "as.numeric", but it does not give the right values. – Letin Jun 20 '19 at 11:37
  • 1
    try `as.numeric(as.character(your_vector))` – kath Jun 20 '19 at 11:38
  • Should we mark duplicate [to this](https://stackoverflow.com/questions/3418128/how-to-convert-a-factor-to-integer-numeric-without-loss-of-information)? – pogibas Jun 20 '19 at 11:56

0 Answers0