这是我的森林图代码:
forest(res2, showweights = TRUE,
shade="zebra2",
alim=c(log(0.2), log(5)),
atransf=exp,
at = log(c(0.20, 0.25, 0.50, 1.00, 1.50, 2.00, 2.50, 4.00, 5.00)), digits = 2,# Transform to exp for odds ratios
psize=0.75,
xlim=c(-3,3),
xlab="Odds ratio",
refline=log(1),
cex=0.9, cex.lab = 0.6, cex.axis = 0.7)your text
我想在其上添加有关异质性的信息,但我似乎无法将其放在 x 轴下,这将是这里的最佳选择。有什么建议吗?
我尝试将其添加到图下方:
text(-3, -1.5, paste0("Heterogeneity: I² = ", I2, "%, τ² = ", tau2, ", p-value = ", Q_pval), pos=4, cex=0.7)
但它把它放在 x 轴的正上方,如果我将它移低,它就会被轴覆盖。
您可以在此处使用
mtext
而不是 text
在 margins 中绘制文本。在这里,您可以将文本放置在底部 x 轴 (line=-1
) 上方 (side=1
) 的行上。您可以使用这两个参数和其他参数将文本放置在您喜欢的几乎任何位置。
library(metafor)
dat <- escalc(measure="RR", ai=tpos, bi=tneg, ci=cpos, di=cneg, data=dat.bcg)
res <- rma(yi, vi, data=dat, slab=paste(author, year, sep=", "))
forest(res, showweights = TRUE,
shade="zebra2",
alim=c(log(0.2), log(5)),
atransf=exp,
at = log(c(0.20, 0.25, 0.50, 1.00, 1.50, 2.00, 2.50, 4.00, 5.00)), digits = 2,# Transform to exp for odds ratios
psize=0.75,
xlim=c(-3,3),
xlab="Odds ratio",
refline=log(1),
cex=0.9, cex.lab = 0.6, cex.axis = 0.7)
I2 <- 0.2
tau2 <- 0.9
Q_pval <- 0.02
mtext(paste0("Heterogeneity: I² = ", I2, "%, τ² = ", tau2, ", p-value = ", Q_pval), cex=0.7, side=1, line=-1)