简体   繁体   English

在森林图中绘制不同的置信区间

[英]Draw different confidence intervals in forest plot

I try to create different confidence intervals with boxes in forest plot. 我尝试用森林图中的框创建不同的置信区间。 I want to plot c(fpDrawNormalCI, fpDrawCircleCI) depending on line p-value. 我想根据线p值绘制c(fpDrawNormalCI, fpDrawCircleCI) My DF 我的DF

l  hr u p-value names
1  2  3  0.01    A
2  3  4  0.0001  B
3  4  5  0.01    C

If the p-value is less than 0.001 the box should be fpDrawNormalCI , otherwise fpDrawCircleCI 如果p值小于0.001,则该框应为fpDrawNormalCI ,否则为fpDrawCircleCI

I create forestplot by using the following code 我通过使用以下代码创建forestplot

library(forestplot)
forestplot(DF$names,DF$hr, DF$l, DF$u, fn.ci_norm=c(fpDrawNormalCI))

I have tried to use if () else () ifelse () but it didnt work. 我试过使用if () else () ifelse ()但是没有用。 Could you please help me. 请你帮助我好吗。 Thank you beforehand. 预先谢谢你。

What you need to do is either use the size argument or the confidence interval width and then pass onto subfunctions. 您需要使用size参数或置信区间宽度,然后传递给子函数。 If you have a that a confidence interval width of 20 == p-value 0.001 then you could do: 如果您的置信区间宽度为20 == p值0.001,则可以执行以下操作:

custom_ci_norm = function(lower_limit,
                           estimate,
                           upper_limit,
                           ...) {
  if((upper_limit - lower_limit) > 20){
     return fpDrawCircleCI(lower_limit,
                           estimate,
                           upper_limit,
                           ...)
  }else{
     return fpDrawNormalCI(lower_limit,
                           estimate,
                           upper_limit,
                           ...)
  }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM