[R] R: forest plot metafor

Viechtbauer Wolfgang (STAT) wolfgang.viechtbauer at maastrichtuniversity.nl
Sat Dec 12 17:22:20 CET 2015

No, this is not possible. But you can just add the weights yourself. One difficulty here is that you want the weights to the right of the estimates and corresponding CIs and those are always placed at the right of the figure. One possibility would be to make the right margin large and then use mtext() to place the weights in that margin. An example:

dat <- escalc(measure="RR", ai=tpos, bi=tneg, ci=cpos, di=cneg, data=dat.bcg)
res <- rma(yi, vi, data=dat, method="FE")
wi <- formatC(weights(res), format="f", digits=1, width=4)
forest(res, xlim=c(-7,8), digits=c(2,0))
mtext(wi, side=4, at=13:1, line=4, las=2, adj=1)

Adjust as needed for your data.

From: R-help [r-help-bounces at r-project.org] On Behalf Of Mario Petretta [petretta at unina.it]
Sent: Saturday, December 12, 2015 3:57 PM
To: r-help at r-project.org
Subject: [R] R:  forest plot metafor

Many thanks to Professor Michael Dewey for his time.

I apologize for the error about the claim to obtain weights from escalc and I realise that the weights are a function of the fit, not the data.

weights(res) is OK to extract the weights from the fitted object and to put them in the data  frame.

However, I again ask:


 forest(res, showweights=TRUE)

it is possible to directly order the columns, simply placing the weights after effect size and CI?


Mario Petretta

More information about the R-help mailing list