【问题标题】:How to change internal function in MendelianRandomization function in order to change decimal places in output?如何更改 MendelianRandomization 函数中的内部函数以更改输出中的小数位?
【发布时间】:2019-11-05 06:52:05
【问题描述】:

我正在安装此功能的 MAC 计算机上运行此功能:

  library(MendelianRandomization)
  EggerObject <- mr_egger(MRInputObject,robust = FALSE,penalized = FALSE,correl = FALSE,distribution = "normal",alpha = 0.05)

但是 p 值的输出只有 3 个小数位,我想将其扩展到 10 个小数位:

> EggerObject

MR-Egger method

(变量不相关,随机效应模型)

变体数量 = 88

------------------------------------------------------------------
      Method Estimate Std Error  95% CI        p-value
    MR-Egger    0.044     0.009  0.027,  0.061   0.000
 (intercept)   -0.041     0.004 -0.049, -0.033   0.000
------------------------------------------------------------------

我正在查看他们的文档https://www.rdocumentation.org/packages/MendelianRandomization/versions/0.4.1/topics/decimals

但我不确定如何应用它。

我试过了:

> EggerObject <- mr_egger(MRInputObject,robust = FALSE,penalized = FALSE,correl = FALSE,distribution = "normal",alpha = 0.05, decimals(number = p-value, places = 10))
Error in format(round(number, places), nsmall = places) : 
  object 'p' not found

编辑:

> str(EggerObject)
Formal class 'Egger' [package "MendelianRandomization"] with 23 slots
  ..@ Model       : chr "random"
  ..@ Exposure    : chr "exposure"
  ..@ Outcome     : chr "outcome"
  ..@ Robust      : logi FALSE
  ..@ Penalized   : logi FALSE
  ..@ Correlation : logi [1, 1] NA
  ..@ Estimate    : num 0.0441
  ..@ StdError.Est: num 0.00861
  ..@ CILower.Est : num 0.0273
  ..@ CIUpper.Est : num 0.061
  ..@ Pvalue.Est  : num 2.92e-07
  ..@ Intercept   : num -0.041
  ..@ StdError.Int: num 0.00432
  ..@ CILower.Int : num -0.0494
  ..@ CIUpper.Int : num -0.0325
  ..@ Pvalue.Int  : num 0
  ..@ Pleio.pval  : num 0
  ..@ Causal.pval : num 2.92e-07
  ..@ Alpha       : num 0.05
  ..@ SNPs        : int 88
  ..@ RSE         : num 8.79
  ..@ Heter.Stat  : num [1:2] 6649 0
  ..@ I.sq        : num 0.959

【问题讨论】:

  • str(EggerObject) 有什么用?这应该会告诉您在哪里可以找到该值,以便您可以将其格式化为所需的精度。
  • 非常感谢,我将结果添加到我的帖子中。请告诉我从这里做什么?
  • 从该命令的结果中,我可以说 MR-Egger 方法的 p 值为 2.92e-07 吗?

标签: r


【解决方案1】:

EggerObject 是一个“S4”列表,因此您可以使用 S4 访问函数 "@" 访问 Pvalue.Est 项的值。 (就像普通 S3 对象的“$”。)显式的 print 函数允许您控制精度:

 print( EggerObject@Pvalue.Est, digits=10)

类“Egger”的对象可能有一个访问器函数。如果存在这样的功能,那就更好了,因为包作者可能知道使用此类对象的不同组件的潜在缺陷。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-01-14
    • 2016-04-22
    • 2021-04-28
    • 2011-11-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多