Learn R Programming

metafor (version 1.9-2)

addpoly.default: Add Polygons to Forest Plots

Description

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

Usage

## S3 method for class 'default':
addpoly(x, vi, sei, ci.lb, ci.ub, rows=-1, level=95, digits=2,
        annotate=TRUE, mlab, transf=FALSE, atransf=FALSE, targs,
        col="black", efac=1, cex, \dots)

Arguments

x
vector with the values at which the polygons should be drawn.
vi
vector with the corresponding variances.
sei
vector with the corresponding standard errors. (note: only one of the two, vi or sei, needs to be specified)
ci.lb
vector with the corresponding lower confidence intervals bounds. Not needed if vi or sei is specified. See Details.
ci.ub
vector with the corresponding upper confidence intervals bounds. Not needed if vi or sei is specified. See Details.
rows
vector specifying the rows (or more generally, the horizontal positions) for plotting the polygons (defaults is -1). Can also be a single value specifying the row (horizontal position) of the first polygon (the remaining polygons are then plo
level
numerical value between 0 and 100 specifying the confidence interval level (default is 95).
digits
integer specifying the number of decimal places to which the annotations should be rounded (default is 2).
annotate
logical specifying whether annotations should be added to the plot for the polygons that are drawn (default is TRUE).
mlab
optional character vector with the same length as x giving labels for the polygons that are drawn.
transf
optional argument specifying the name of a function that should be used to transform the x values and confidence interval bounds. Defaults to FALSE, which means that no transformation is used.
atransf
optional argument specifying the name of a function that should be used to transform the annotations. Defaults to FALSE, which means that no transformation is used.
targs
optional arguments needed by the function specified via transf or atransf.
col
color of the polygons that are drawn (default is "black").
efac
vertical expansion factor for the polygons. The default value of 1 should usually work okay.
cex
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 example below. 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). The arguments transf, atransf, efac, and cex should always be set equal to the same values used to create the forest plot.

References

Viechtbauer, W. (2010). Conducting meta-analyses in R with the metafor package. Journal of Statistical Software, 36(3), 1--48. http://www.jstatsoft.org/v36/i03/.

See Also

forest.rma, forest.default

Examples

Run this code
### load BCG vaccine data
data(dat.bcg)

### meta-analysis of the log relative risks using a mixed-
### effects model with absolute latitude as a moderator
res <- rma(ai=tpos, bi=tneg, ci=cpos, di=cneg, mods = ~ ablat,
           slab=paste(author, year, sep=", "), data=dat.bcg,
           measure="RR", method="REML")

### forest plot of the observed relative risks
forest(res, addfit=FALSE, atransf=exp, ylim=c(-3.5,16))

### predicted average log relative risk for 10, 30, and 50 degrees absolute latitude
x <- predict(res, newmods=c(10, 30, 50))

### add predicted average relative risks to forest plot
addpoly(x$pred, sei=x$se, atransf=exp,
        mlab=c("10 Degrees", "30 Degrees", "50 Degrees"))
abline(h=0)

Run the code above in your browser using DataLab