如何在metafor R-package中将tau ^ 2添加到Forest Plot?

时间:2018-01-11 16:12:17

标签: r forestplot metafor

我正在使用metafor包在R中进行元分析。我按照http://www.metafor-project.org/doku.php/plots:forest_plot_with_subgroups

上的教程进行了操作

如何将tau ^ 2添加到“所有研究的RE模型”?

library(metafor)

### load BCG vaccine dataset
data(dat.bcg)

res <- rma(ai=tpos, bi=tneg, ci=cpos, di=cneg, data=dat.bcg, measure="OR",
       slab=paste(author, year, sep=", "), method="REML")

###Plot Forest Plot
forest(res)

### Add Text
text(-5, -1, pos=4, cex=0.75, bquote(paste("RE Model for All Studies (Q 
= ",.(formatC(res$QE, digits=2, format="f")), ", df = ", .(res$k - 
res$p),", p = ", .(formatC(res$QEp, digits=2, format="f")), "; ", I^2, " = ",.(formatC(res$I2, digits=1, format="f")), "%)")))

提前致谢, C.

1 个答案:

答案 0 :(得分:2)

这将打印一个带有上标-2的希腊语tau,后跟res对象中tau2项的两个小数位:

text(-5, -0.5, pos=4, cex=0.75, bquote(
paste("RE Model for All Studies (Q = ",
.(formatC(res$QE, digits=2, format="f")), 
", df = ", .(res$k - res$p),", p = ", 
.(formatC(res$QEp, digits=2, format="f")),
 "; ", I^2, " = ",
.(formatC(res$I2, digits=1, format="f")), 
 "%)", "; ", tau^2 == 
.(formatC(res$tau2, digits=2, format="f")))))

我将文本向上移动了一半,因此它没有覆盖摘要OR-diamond。您应该了解自己实际上正在使用plotmath粘贴功能,这意味着如果您需要资本 - 希腊语 - Tau,则可以将tau更改为Tau。阅读?plotmath

enter image description here