[R] extracting p-values in scientific notation

(Ted Harding) ted.harding at wlandres.net
Mon Oct 3 11:05:54 CEST 2011


One point to note, for information, in this discussion is
that cor.test() has apparently returned the P-value as
an exact zero:

  x$p.value == 0
  # [1] TRUE

  identical(x$p.value, 0)
  # [1] TRUE

(which, by the way, I was led to after trying log10(x$p.value)
and getting -Inf). Perhaps a more interesting question is how
cor.test computes the P-value!

Ted.

On 03-Oct-11 08:48:31, Kenn Konstabel wrote:
>> is(x)
> [1] "htest"
>> # take a look at     stats:::print.htest
>> format.pval(x$p.value)
> [1] "< 2.22e-16"
> 
> Does that answer your question?
> 
> KK
> 
> On Mon, Oct 3, 2011 at 10:53 AM, Liviu Andronic
> <landronimirc at gmail.com> wrote:
>> Dear all
>> How does print.htest display the p-value in scientific notation?
>>> (x <- cor.test(iris[[1]], iris[[3]]))
>>
>> _ _ _ _Pearson's product-moment correlation
>>
>> data: _iris[[1]] and iris[[3]]
>> t = 21.65, df = 148, p-value < 2.2e-16
>> alternative hypothesis: true correlation is not equal to 0
>> 95 percent confidence interval:
>> _0.8270 0.9055
>> sample estimates:
>> _ cor
>> 0.8718
>>
>> Above the p-value comes as '< 2.2e-16', while inspecting the object I
>> get a good old '0'.
>>> x$p.value
>> [1] 0
>>
>> I tried to inspect print.htest but couldn't find it. I also played
>> with format, round and the like to no avail. Any pointers?
>>
>> Regards
>> Liviu
>>
>>
>> --
>> Do you know how to read?
>> http://www.alienetworks.com/srtest.cfm
>> http://goodies.xfce.org/projects/applications/xfce4-dict#speed-reader
>> Do you know how to write?
>> http://garbl.home.comcast.net/~garbl/stylemanual/e.htm#e-mail
>>
>> ______________________________________________
>> R-help at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

--------------------------------------------------------------------
E-Mail: (Ted Harding) <ted.harding at wlandres.net>
Fax-to-email: +44 (0)870 094 0861
Date: 03-Oct-11                                       Time: 10:05:50
------------------------------ XFMail ------------------------------



More information about the R-help mailing list