On Aug 16, 2011, at 11:17 AM, m1ch43l at gmx-topmail.de wrote:
> Hi,
>
> When I use the following code I get two different results, even though
> n is length(p) by default.
>
> ---------------------------------------------------------
> pvals <- c(5.722385e-02, NA, 1.018087e-01)
> p.adjust(pvals, method="bonferroni")
> p.adjust(pvals, method="bonferroni", n=length(pvals))
>
>> p.adjust(pvals, method="bonferroni")
> [1] 0.1144477 NA 0.2036174
>
>> p.adjust(pvals, method="bonferroni", n=length(pvals))
> [1] 0.1716716 NA 0.3054261
> ---------------------------------------------------------
>
> Does anybody know what the reason for the different results is and
> which version is correct?
It seems pretty obvious. The first invocation is using only n=2 to
adjust because the NA was dropped, and the second is using n=3 because
you overrode the default. (Look at the code to confirm.)
> c(5.722385e-02, NA, 1.018087e-01)*2
[1] 0.1144477 NA 0.2036174
> c(5.722385e-02, NA, 1.018087e-01)*3
[1] 0.1716716 NA 0.3054261
--
David Winsemius, MD
West Hartford, CT