在四舍五入为 0 之前,R 出现的最小数字是多少? [英] What's the lowest number R will present before rounding to 0?

查看:26
本文介绍了在四舍五入为 0 之前,R 出现的最小数字是多少?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 R 软件(引导 Kolmogorov-Smirnov 测试)对非常大的数据集进行一些统计分析,这意味着我的 p 值都非常小.我已经对我执行的大量测试进行了 Bonferroni 校正,这意味着我的 alpha 值也非常小,以拒绝零假设.

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.

问题是,在某些情况下,R 显示的 p 值为 0,其中 p 值可能太小以至于无法显示(这些通常用于非常大的样本量).虽然我可以很高兴地拒绝这些测试的零假设,但数据是用于发布的,所以我需要写 p <..... 但我不知道 R 中的最低可报告值是多少?

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?

我正在使用 ks.boot 函数以防万一.

I'm using the ks.boot function in case that matters.

任何帮助将不胜感激!

推荐答案

.Machine$double.xmin 为您提供最小的非零标准化浮点数.在大多数系统上是 2.225074e-308.但是,我不认为这是一个合理的限制.

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

相反,我建议在 Matching::ks.boot 中更改行

Instead I suggest that in Matching::ks.boot you change the line

ks.boot.pval <- bbcount/nboots

ks.boot.pval <- log(bbcount)-log(nboots) 并在对数尺度上工作.

ks.boot.pval <- log(bbcount)-log(nboots) and work on the log-scale.

您可以使用trace来修改函数.

You can use trace to modify the function.

第 1 步:查看函数体,找出添加额外代码的位置.

Step 1: Look at the function body, to find out where to add additional code.

as.list(body(ks.boot))

你会看到第17个元素是ks.boot.pval <- bbcount/nboots,所以我们需要在这之后直接添加修改后的代码.

You'll see that element 17 is ks.boot.pval <- bbcount/nboots, so we need to add the modified code directly after that.

第 2 步:trace 函数.

trace (ks.boot, quote(ks.boot.pval <- log(bbcount)-log(nboots)), at=18)

第 3 步:现在您可以使用 ks.boot,它将以 ks.boot.pvalue 形式返回 bootstrap p 值的对数.请注意,您不能使用 summary.ks.boot,因为它调用了 format.pval,它不会显示负值.

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.

第 4 步:使用 untrace(ks.boot) 删除修改.

Step 4: Use untrace(ks.boot) to remove the modifications.

这篇关于在四舍五入为 0 之前,R 出现的最小数字是多少?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆