Function to add one or more polygons to a forest plot.

# S3 method for default
addpoly(x, vi, sei, ci.lb, ci.ub, pi.lb, pi.ub,
rows=-1, level=95, annotate=TRUE, digits=2, width, mlab,
transf, atransf, targs, efac=1, col, border, lty, fonts, cex, ...)

## Arguments

x vector with the values at which the polygons should be drawn. vector with the corresponding variances. vector with the corresponding standard errors (note: only one of the two, vi or sei, needs to be specified). vector with the corresponding lower confidence interval bounds. Not needed if vi or sei is specified. See ‘Details’. vector with the corresponding upper confidence interval bounds. Not needed if vi or sei is specified. See ‘Details’. optional vector with the corresponding lower prediction interval bounds. optional vector with the corresponding upper prediction interval bounds. vector to specify the rows (or more generally, the horizontal positions) for plotting the polygons (defaults is -1). Can also be a single value to specify the row (horizontal position) of the first polygon (the remaining polygons are then plotted below this starting row). numeric value between 0 and 100 to specify the confidence interval level (the default is 95). logical to specify whether annotations should be added to the plot for the polygons that are drawn (the default is TRUE). integer to specify the number of decimal places to which the annotations should be rounded (the default is 2). optional integer to manually adjust the width of the columns for the annotations. optional character vector with the same length as x giving labels for the polygons that are drawn. optional argument to specify a function that should be used to transform the x values and confidence interval bounds (e.g., transf=exp; see also transf). If unspecified, no transformation is used. optional argument to specify a function that should be used to transform the annotations (e.g., atransf=exp; see also transf). If unspecified, no transformation is used. optional arguments needed by the function specified via transf or atransf. vertical expansion factor for the polygons. The default value of 1 should usually work okay. optional character string to specify the name of a color to use for the polygons. If unspecified, the function sets a default color. optional character string to specify the name of a color to use for the border of the polygons. If unspecified, the function sets a default color. optional character string to specify the line type for the prediction interval. If unspecified, the function sets this to "dotted" by default. optional character string to specify the font to use for the labels and annotations. If unspecified, the default font is used. optional symbol expansion factor. If unspecified, the function tries to set this to a sensible value. other arguments.

## Details

The function can be used to add one or more polygons to an existing forest plot created with the forest function. For example, summary estimates based on a model involving moderators can be added to the plot this way (see ‘Examples’).

To use the function, one should specify the values at which the polygons should be drawn (via the x argument) together with the corresponding variances (via the vi argument) or with the corresponding standard errors (via the sei argument). Alternatively, one can specify the values at which the polygons should be drawn together with the corresponding confidence interval bounds (via the ci.lb and ci.ub arguments). Optionally, one can also specify the bounds of the corresponding prediction interval bounds via the pi.lb and pi.ub arguments.

The arguments transf, atransf, efac, and cex should always be set equal to the same values used to create the forest plot.

## Author

Wolfgang Viechtbauer wvb@metafor-project.org https://www.metafor-project.org

## References

Viechtbauer, W. (2010). Conducting meta-analyses in R with the metafor package. Journal of Statistical Software, 36(3), 1--48. https://doi.org/10.18637/jss.v036.i03

forest.rma, forest.default

## Examples

### calculate log risk ratios and corresponding sampling variances
dat <- escalc(measure="RR", ai=tpos, bi=tneg, ci=cpos, di=cneg, data=dat.bcg)

### fit mixed-effects model with absolute latitude as a moderator
res <- rma(yi, vi, mods = ~ ablat, slab=paste(author, year, sep=", "), data=dat)

### forest plot of the observed risk ratios
forest(res, addfit=FALSE, atransf=exp, xlim=c(-8,5), ylim=c(-4.5,16), cex=.8,
order=dat$ablat, ilab=dat$ablat, ilab.xpos=-4,
addpoly(x$pred, sei=x$se, atransf=exp, rows=-2,