中介 R 包 p 值:获得更多有效数字的解决方法? [英] Mediation R package p-values: workaround to get more significant digits?

查看:32
本文介绍了中介 R 包 p 值:获得更多有效数字的解决方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行多重中介分析,需要纠正多重比较.然而,中介包提供的 p 值似乎已经四舍五入存储,正如@Roland 在这个问题上的非常有用的回答中所观察到的:

I am running multiple mediation analyses and need to correct for multiple comparisons. However, the p-values provided by the mediation package appear to be stored already rounded, as observed in the very helpful answer by @Roland on this question:

R 中介包:逗号后面的数字

有没有人找到一种解决方法来实际为 pvalues 提取更多有效数字?

Has anyone found a workaround to actually pull out more significant digits for the pvalues?

推荐答案

那些是用 2 位数字打印的,因为这就是方法计算的全部内容.这是一个随机分析,因此 p 值只是满足某些条件的模拟的 50(在参考答案中)中的分数.如果您想要更多数字,则需要将 sims 设置为比 50 大得多的值来运行.完成此操作后,您可能可以使用与该帖子中相同的技术更改数字设置,或者更简单的如下:

Those are being printed with 2 digits, because that's all the method computes. It's a randomized analysis, so the p-value is just the fraction out of 50 (in the referenced answer) of the simulations that met some condition. If you want more digits, you'll need to run with sims set to a much larger value than 50. After you do that, you can probably change the digits setting using the same technique as in that post, or more simply as follows:

  1. 执行此操作:

  1. Execute this:

print.summary.mediate <- mediation:::print.summary.mediate

print.summary.mediate <- mediation:::print.summary.mediate

使用 fix(print.summary.mediate) 编辑源代码,并更改行

Use fix(print.summary.mediate) to edit the source, and change the line

printCoefmat(smat,digits = 3)

printCoefmat(smat, digits = 3)

到您想要的任何所需位数.我选择了 6.

to whatever desired number of digits you want. I chose 6.

然后运行代码:

data(jobs)
b <- lm(job_seek ~ treat + econ_hard + sex + age, data=jobs)
c <- lm(depress2 ~ treat + job_seek + econ_hard + sex + age, data=jobs)
 
contcont <- mediate(b, c, sims=1000, treat="treat", mediator="job_seek")
summary(contcont)

我得到了这个输出:

Causal Mediation Analysis 

Quasi-Bayesian Confidence Intervals

                 Estimate 95% CI Lower 95% CI Upper p-value
ACME           -0.0166933   -0.0404983      0.00735   0.168
ADE            -0.0412011   -0.1278011      0.04465   0.348
Total Effect   -0.0578944   -0.1449898      0.02716   0.196
Prop. Mediated  0.2313315   -1.7557486      1.89099   0.288

Sample Size Used: 899 


Simulations: 1000 

您只能在 p 值上看到 3 位数字,因为这是 1000 次模拟的全部结果:n/1000 总是有 3 位数字.如果您选择 sims 不是整数,你会看到更多的数字:但后面的数字将毫无价值,除了像 123/456 这样的分数没有很好的十进制扩展这一事实之外,它们没有真正的意义.

You only see 3 digits on the p-values, because that's all you get with 1000 simulations: n/1000 always has 3 digits. If you choose sims to be something that's not a round number, you'll see more digits: but the later ones will be worthless, they don't really signify anything other than the fact that a fraction like 123/456 doesn't have a nice decimal expansion.

你的会有所不同,因为这是一项随机分析.

Yours will be different, because it's a randomized analysis.

这篇关于中介 R 包 p 值:获得更多有效数字的解决方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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