# The metafor Package

A Meta-Analysis Package for R

### Site Tools

plots:forest_plot

## Forest Plot

### Description

A forest plot is a commonly used visualization technique in meta-analyses, showing the results of the individual studies (i.e., the estimated effects or observed outcomes) together with their (usually 95%) confidence intervals. A four-sided polygon, sometimes called a summary 'diamond', is added to the bottom of the plot, showing the summary estimate based on the model (with the center of the polygon corresponding to the estimate and the left/right edges indicating the confidence interval limits). Below is an example of such a forest plot.

### Plot ### Code

library(metafor)

### copy BCG vaccine meta-analysis data into 'dat'
dat <- dat.bcg

### calculate log risk ratios and corresponding sampling variances (and use
### the 'slab' argument to store study labels as part of the data frame)
dat <- escalc(measure="RR", ai=tpos, bi=tneg, ci=cpos, di=cneg, data=dat,
slab=paste(author, year, sep=", "))

### fit random-effects model
res <- rma(yi, vi, data=dat)

### forest plot with extra annotations
forest(res, atransf=exp, at=log(c(0.05, 0.25, 1, 4)), xlim=c(-16,6),
ilab=cbind(tpos, tneg, cpos, cneg), ilab.xpos=c(-9.5,-8,-6,-4.5),
text(c(-9.5,-8,-6,-4.5), res$k+2, c("TB+", "TB-", "TB+", "TB-")) text(c(-8.75,-5.25), res$k+3, c("Vaccinated", "Control"))
"RE Model (Q = ", .(fmtx(res$QE, digits=2)), ", df = ", .(res$k - res$p), ", ", .(fmtp(res$QEp, digits=3, pname="p", add0=TRUE, sep=TRUE, equal=TRUE)), "; ",
I^2, " = ", .(fmtx(res\$I2, digits=1)), "%)"))) 