Skip to content

extracting p-values in scientific notation

6 messages · Rolf Turner, Kenn Konstabel, (Ted Harding) +2 more

#
Dear all
How does print.htest display the p-value in scientific notation?
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'.
[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
#
Isn't it true that 0 < 2.2e-16?

     cheers,

         Rolf Turner
On 03/10/11 20:53, Liviu Andronic wrote:
#
[1] "htest"
[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:
#
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:
--------------------------------------------------------------------
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 ------------------------------
#
Thanks all for your pointers. The following does trick:
[1] "<2e-16"
On Mon, Oct 3, 2011 at 10:25 AM, Rolf Turner <rolf.turner at xtra.co.nz> wrote:
Yes, but it doesn't mean that the p-value actually hits absolute zero.
And cor.test, as Ted noticed, returns
[1] TRUE

Not that this makes a great practical difference in my case, but I
would still prefer to print "<2e-16" in my Sweave document.

Regards
Liviu
#
format.pval is documented and accessible from outside of base.
So you do not have to qualify it as base::format.pval
On 10/3/2011 11:24 AM, Liviu Andronic wrote: