What's the lowest number R will present before rounding to 0?

浪尽此生 提交于 2019-12-02 16:01:06

问题


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!


回答1:


.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.




回答2:


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.



来源:https://stackoverflow.com/questions/18123559/whats-the-lowest-number-r-will-present-before-rounding-to-0

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!