Re: A very small p-value

Ivan Krylov via R-help <[email protected]>
Newsgroups gmane.comp.lang.r.general
Message-ID <20251025131407.792367ae@Tarkus>
В Sat, 25 Oct 2025 11:45:42 +0200
Christophe Dutang <[email protected]> пишет:

> Indeed, the p-value is lower than the epsilon machine
> 
> > pt(t_score, df = n-2, lower=FALSE) < .Machine$double.eps  
> [1] TRUE

Which means that for lower=TRUE, there will not be enough digits in R's
numeric() type to represent the 5*10^-19 subtracted from 1 and
approximately 16 zeroes.

Instead, you can verify your answer by asking for the logarithm of the
number that is too close to 1, thus retaining more significant digits:

print(
 -expm1(pt(t_score, df = n-2, lower=TRUE, log.p = TRUE)),
 digits=16
)
# [1] 2.539746620181249e-19
print(pt(t_score, df = n-2, lower=FALSE), digits=16)
# [1] 2.539746620181248e-19

expm1(.) computes exp(.)-1 while retaining precision for numbers that
are too close to 0, for which exp() would otherwise return 1.

See the links in
https://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-doesn_0027t-R-think-these-numbers-are-equal_003f
for a more detailed explanation.

-- 
Best regards,
Ivan
(flipping the "days since referring to R FAQ 7.31" sign back to 0)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.