[Rd] p.adjust; n > length(p) (PR#13519)
Steven McKinney
smckinney at bccrc.ca
Wed Feb 11 21:13:17 CET 2009
Hi Ludo,
Issues such as this are best posed as
questions to the list before filing a bug
report. (False bug reports create extra
work for volunteer R-core members.)
What is your use case for setting
n larger than length(p) (the default)?
The documentation does say
"n number of comparisons, must be at least length(p); only set this
(to non-default) when you know what you are doing!"
Because the default
n = length(p)
is not evaluated until n is first needed in
the function body ('lazy evaluation') n is
by default set to length(p) after NAs
are removed in about line 8 of the function
line "stopifnot(n >= length(p))" )
and I'm not finding any problems with the
function, even when supplying p-values with NAs.
The documentation also states
"Note that you can set n larger than length(p) which means the
unobserved p-values are assumed to be greater than all the observed p
for "bonferroni" and "holm" methods and equal to 1 for the other
methods."
so it is up to the user to properly interpret the function
output when using a non-default setting for n. The ensuing warning
is just a warning, not an error, requiring proper interpretation
and understanding by the user that chooses to set n to a non-default
setting.
> -----Original Message-----
> From: r-devel-bounces at r-project.org
[mailto:r-devel-bounces at r-project.org]
> On Behalf Of lpagie at xs4all.nl
> Sent: Wednesday, February 11, 2009 7:10 AM
> To: r-devel at stat.math.ethz.ch
> Cc: R-bugs at r-project.org
> Subject: [Rd] p.adjust; n > length(p) (PR#13519)
>
> Full_Name: Ludo Pagie
> Version: 2.8.1
> OS: linux
> Submission from: (NULL) (194.171.7.39)
>
>
> p.adjust in stats seems to have a bug in handling n>length(p) for (at
> least) the
> methods 'holm' and 'hochberg'.
>
> For method 'holm' the relevant code:
> i <- 1:n
> o <- order(p)
> ro <- order(o)
> pmin(1, cummax((n - i + 1) * p[o]))[ro]
>
> where p is the supplied vector of pvalues and n is the supplied number
of
> comparisons. If n>length(p) p.adjust() gives a warning:
> Warning message:
> In (n - i + 1) * p[o] :
> longer object length is not a multiple of shorter object length
>
> to me it seems that instead of 'i <- 1:n', 'i <- 1:length(p)' is
required.
This is the case if you do not specify n. Lazy evaluation yields
n = length(p)
> Similar cases seem to be true for 'hochberg' and possibly other
methods.
>
> (I tried checking whether this bug has been reported but the website
broke
> on
> me. appologies if the bug is known already)
>
> Best, Ludo
>
> Netherlands Cancer Institute
> Gene Regulation (B4)
> van Steensel Group
> Plesmanlaan 121
> 1066 CX Amsterdam
> The Netherlands
>
> Tel.: ++ 20 512 7986
> Fax: ++ 20 669 1383
> email: lpagie at xs4all.nl
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
Best
Steven McKinney, Ph.D.
Statistician
Molecular Oncology and Breast Cancer Program
British Columbia Cancer Research Centre
email: smckinney at bccrc.ca
tel: 604-675-8000 x7561
BCCRC
Molecular Oncology
675 West 10th Ave, Floor 4
Vancouver B.C.
V5Z 1L3
Canada
More information about the R-devel
mailing list