Mediation R package p-values: workaround to get more significant digits?

跟風遠走 提交于 2021-01-27 11:47:55

问题


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 mediation package : digit behind comma

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


回答1:


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. Execute this:

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

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

    printCoefmat(smat, digits = 3)

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

Then run the code:

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)

I got this output:

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 

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.



来源:https://stackoverflow.com/questions/64829727/mediation-r-package-p-values-workaround-to-get-more-significant-digits

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