[R] -log10 of 0

David Winsemius dwinsemius at comcast.net
Sun Aug 28 18:09:06 CEST 2011


On Aug 28, 2011, at 11:37 AM, Ram H. Sharma wrote:

> Dear R users:
>
> Sorry for this simple question:
>
> I am writing a function where I would need to pickup p values and make
> -log10 of it.
>
> The p values are from an anova output and sometime it can yield me 0.
>
> -log10 (0)
>
> [1] Inf
>
> I can not replace Inf with 0, which not case here.

Well you could, but if you did, you would be shooting yourself in the  
foot.

>
>
> This is restricting me to go further in the function and out me the  
> error.
> You help is highly appreciated.

I would think that one would be better served , not by trying to  
redefine the log of small numbers, but rather by first putting a  
lowering bound on the p-values.

pvec.trimmed <- pmax(pvec, 0.0000001)

min(log10(pvec.trimmed))   # now would be -7

The alternative that you suggest would be putting all of the p-values  
of 0 in the same locations as the p-values of 1 after log  
transformation. That cannot be a wise idea. Rather like redefining pi  
to be 3.14.

-- 
David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list