addpoly.default {metafor} | R Documentation |
Function to add one or more polygons to a forest plot.
## Default S3 method: addpoly(x, vi, sei, row=-1, level=95, digits=2, annotate=TRUE, mlab=NULL, transf=FALSE, atransf=FALSE, targs=NULL, col="black", efac=1, cex=NULL, ...)
x |
a vector with the values at which the polygons should be drawn. |
vi |
a vector with the corresponding variances. |
sei |
a vector with the corresponding standard errors. (note: only one of the two, vi or sei , needs to be specified) |
row |
integer specifying the (starting) row of where the polygon(s) should be placed (default is -1). |
level |
a numerical value between 0 and 100 specifying the confidence interval level (default is 95). |
digits |
integer value 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. Defaults to NULL , which suppresses labels. |
transf |
an 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 |
an 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 |
an optional symbol expansion factor. If NULL (default), the function tries to set this to a sensible value. |
... |
other arguments. |
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 subgrouping of the studies or from models involving moderators can be added to the plot this way. See examples below.
The arguments transf
, atransf
, efac
, and cex
should always be set equal to the same values used to create the forest plot.
Wolfgang Viechtbauer; wvb@www.wvbauer.com; http://www.wvbauer.com/
### load BCG vaccine data data(dat.bcg) ### meta-analysis of the log risk ratios using a mixed- ### effects model with absolute latitude as moderator res <- rma(ai=tpos, bi=tneg, ci=cpos, di=cneg, mods=cbind(ablat), slab=paste(author, year), data=dat.bcg, measure="RR", method="REML") ### forest plot of the observed risk ratios forest(res, addfit=FALSE, atransf=exp, addrows=3, xlab="Relative Risk (log scale)") ### predicted log average risk ratios for 10, 30, and 50 degrees absolute latitude x <- predict(res, newmods=c(10, 30, 50)) ### add predicted average risk ratios to forest plot addpoly(x$pred, sei=x$se, atransf=exp, mlab=c("10 Degrees", "30 Degrees", "50 Degrees"))