forestplot.bayesmeta {bayesmeta}R Documentation

Generate a forest plot for a bayesmeta object (based on the forestplot package's plotting functions).


Generates a forest plot, showing individual estimates along with their 95 percent confidence intervals, shrinkage intervals, resulting effect estimate and prediction interval.


  ## S3 method for class 'bayesmeta'
forestplot(x, labeltext, exponentiate=FALSE,
           prediction=TRUE, shrinkage=TRUE, heterogeneity=TRUE, 
           digits=2, plot=TRUE,
           fn.ci_norm, fn.ci_sum, col, legend, boxsize, ...)



a bayesmeta object.


an (alternative) “labeltext” argument which is then handed on to the forestplot() function (see the help there). You can use this to change contents or add columns to the displayed table; see the example below.


a logical flag indicating whether to exponentiate numbers (effect sizes) in table and plot.


a logical flag indicating whether to show the prediction interval below the mean estimate.


a logical flag indicating whether to show shrinkage intervals along with the quoted estimates.


a logical flag indicating whether to quote the heterogeneity estimate and CI (at the bottom left).


The number of significant digits to be shown. This is interpreted relative to the standard errors of all estimates.


a logical flag indicating whether to actually generate a plot.

fn.ci_norm, fn.ci_sum, col, legend, boxsize, ...

other arguments passed on to the forestplot package's forestplot function (see also the help there).


Generates a forest plot illustrating the underlying data and resulting estimates (effect estimate and prediction interval, as well as shrinkage estimates and intervals).


This function is based on the forestplot package's “forestplot()” function.


Christian Roever


C. Roever. Bayesian random-effects meta-analysis using the bayesmeta R package. Journal of Statistical Software, 93(6):1-51, 2020. doi: 10.18637/jss.v093.i06.

C. Lewis and M. Clarke. Forest plots: trying to see the wood and the trees. BMJ, 322:1479, 2001. doi: 10.1136/bmj.322.7300.1479.

C. Guddat, U. Grouven, R. Bender and G. Skipka. A note on the graphical presentation of prediction intervals in random-effects meta-analyses. Systematic Reviews, 1(34), 2012. doi: 10.1186/2046-4053-1-34.

R.D. Riley, J.P. Higgins and J.J. Deeks. Interpretation of random effects meta-analyses. BMJ, 342:d549, 2011. doi: 10.1136/bmj.d549.

See Also

bayesmeta, forestplot, forest.bayesmeta, plot.bayesmeta.


# load data:

## Not run: 
# compute effect sizes (log odds ratios) from count data
# (using "metafor" package's "escalc()" function):
require("metafor") <- escalc(measure="OR",
                   slab=publication, data=CrinsEtAl2014)

# perform meta analysis: <- bayesmeta(, tau.prior=function(t){dhalfcauchy(t,scale=1)})

# generate forest plots

# default options:

# exponentiate values (shown in table and plot), show vertical line at OR=1:
forestplot(, expo=TRUE, zero=1)

# logarithmic x-axis:
forestplot(, expo=TRUE, xlog=TRUE)

# omit prediction interval:
forestplot(, predict=FALSE)

# omit shrinkage intervals:
forestplot(, shrink=FALSE)

# show more decimal places:
forestplot(, digits=3)

# change table values:
# (here: add columns for event counts)
fp <- forestplot(, expo=TRUE, plot=FALSE)
labtext <- fp$labeltext
labtext <- cbind(labtext[,1],
                   paste0(CrinsEtAl2014[,""], "/", CrinsEtAl2014[,""]),
                   paste0(CrinsEtAl2014[,""], "/", CrinsEtAl2014[,""]),
labtext[1,4] <- "OR"
print(fp$labeltext) # before
print(labtext)      # after
forestplot(, labeltext=labtext, expo=TRUE, xlog=TRUE)

# see also the "forestplot" help for more arguments that you may change,
# e.g. the "clip", "xticks", "xlab" and "title" arguments,
# or the "txt_gp" argument for label sizes etc.:
forestplot(, clip=c(-4,1), xticks=(-3):0,
           xlab="log-OR", title="pediatric transplantation example",
           txt_gp = fpTxtGp(ticks = gpar(cex=1), xlab = gpar(cex=1)))

## End(Not run)

[Package bayesmeta version 2.7 Index]