I'm doing some statistical analysis with R software (bootstrapped Kolmogorov-Smirnov tests) of very large data sets, meaning that my p values are all incredibly small. I've Bonferroni corrected for the large number of tests that I've performed meaning that my alpha value is also very small in order to reject the null hypothesis.
The problem is, R presents me with p values of 0 in some cases where the p value is presumably so small that it cannot be presented (these are usually for the very large sample sizes). While I can happily reject the null hypothesis for these tests, the data is for publication, so I'll need to write p < ..... but I don't know what the lowest reportable values in R are?
I'm using the ks.boot
function in case that matters.
Any help would be much appreciated!
.Machine$double.xmin
gives you the smallest non-zero normalized floating-point number. On most systems that's 2.225074e-308. However, I don't believe this is a sensible limit.
Instead I suggest that in Matching::ks.boot
you change the line
ks.boot.pval <- bbcount/nboots
to
ks.boot.pval <- log(bbcount)-log(nboots)
and work on the log-scale.
Edit:
You can use trace
to modify the function.
Step 1: Look at the function body, to find out where to add additional code.
as.list(body(ks.boot))
You'll see that element 17 is ks.boot.pval <- bbcount/nboots
, so we need to add the modified code directly after that.
Step 2: trace
the function.
trace (ks.boot, quote(ks.boot.pval <- log(bbcount)-log(nboots)), at=18)
Step 3: Now you can use ks.boot
and it will return the logarithm of the bootstrap p-value as ks.boot.pvalue
. Note that you cannot use summary.ks.boot
since it calls format.pval
, which will not show you negative values.
Step 4: Use untrace(ks.boot)
to remove the modifications.
I don't know whether ks.boot
has methods in the packages Rmpfr
or gmp
but if it does, or you feel like rolling your own code, you can work with arbitrary precision and arbitrary size numbers.