Learn R Programming

metafor (version 1.4-0)

forest.default: Forest Plots

Description

Function to create forest plots for a given set of data.

Usage

## S3 method for class 'default':
forest(x, vi, sei, annotate=TRUE, showweight=FALSE,
       xlim=NULL, alim=NULL, ylim=NULL, at=NULL, steps=5, 
       level=95, digits=2, refline=0, xlab=NULL, 
       slab=NULL, ilab=NULL, ilab.xpos=NULL, ilab.pos=NULL, 
       subset=NULL, transf=FALSE, atransf=FALSE, targs=NULL, 
       rows=NULL, efac=1, pch=15, psize=NULL, 
       cex=NULL, cex.lab=NULL, cex.axis=NULL, \dots)

Arguments

x
a vector of length $k$ with the observed effect sizes or outcomes.
vi
a vector of length $k$ with the corresponding sampling variances.
sei
a vector of length $k$ with the corresponding standard errors. (note: only one of the two, vi or sei, needs to be specified)
annotate
logical specifying whether annotations should be added to the plot (default is TRUE).
showweight
logical specifying whether the annotations should also include inverse variance weights (default is FALSE).
xlim
horizontal limits of the plot region. Defaults to NULL, which means that the function tries to set the horizontal plot limits to some sensible values.
alim
the actual x axis limits. Defaults to NULL, which means that the function tries to set the x axis limits to some sensible values.
ylim
the y limits of the plot. Defaults to NULL, which means that the function tries to set the y axis limits to some sensible values.
at
position of the x axis tick marks and corresponding labels. Defaults to NULL, which means that the function tries to set the tick mark positions/labels to some sensible values.
steps
the number of tick marks for the x axis (default is 5). Ignored when the user specifies the positions via the at argument.
level
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 tick mark labels of the x axis and the annotations should be rounded (default is 2).
refline
value at which a vertical reference line should be drawn (default is 0). The line can be suppressed by setting this argument to NA.
xlab
title for the x axis. If NULL (default), the function tries to set an appropriate axis title.
slab
an optional vector with unique labels for the $k$ studies. Defaults to NULL, which means that simple labels are created within the function. To suppress labels, set this argument to NA.
ilab
an optional vector or matrix of character strings providing additional information about the studies.
ilab.xpos
numerical value(s) specifying the x axis position(s) of the character vector(s) given via ilab.
ilab.pos
integer(s) (either 1, 2, 3, or 4) specifying the alignment of the character vector(s) given via ilab (2 means right, 4 mean left aligned). The default is to center the labels.
subset
an optional vector indicating the subset of studies that should be used for the plot. This can be a logical vector of length $k$ or a numeric vector indicating the indices of the observations to include. Note that this argument can also be used for reorde
transf
an optional argument specifying the name of a function that should be used to transform the observed effect sizes and corresponding confidence interval bounds (e.g., transf=exp). Defaults to FALSE, which means that no transformat
atransf
an optional argument specifying the name of a function that should be used to transform the x axis labels and annotations (e.g., transf=exp). Defaults to FALSE, which means that no transformation is used.
targs
optional arguments needed by the function specified via transf or atransf.
rows
an optional vector specifying the rows (or more generally, the horizontal positions) for plotting the outcomes. Defaults to NULL, which means that the function sets this value automatically. Can also be a single value specifying the row (hori
efac
vertical expansion factor for arrows, confidence interval limits, and the symbol used to denote summary estimates. The default value of 1 should usually work okay.
pch
plotting symbol to use for the observed effect sizes or outcomes. By default, a filled square is used. See points for other options. Can also be a vector of values.
psize
an optional vector with point sizes for the observed effect sizes or outcomes. Default is NULL, which means that the point sizes are drawn proportional to the precision of the estimates.
cex
an optional character and symbol expansion factor. If NULL (default), the function tries to set this to a sensible value.
cex.lab
an optional expansion factor for the x axis titel. If NULL (default), the function tries to set this to a sensible value.
cex.axis
an optional expansion factor for the x axis labels. If NULL (default), the function tries to set this to a sensible value.
...
other arguments.

Details

The plot shows the individual observed effect sizes or outcomes with corresponding confidence intervals. With the transf argument, the observed effect sizes and corresponding confidence interval bounds can be transformed with an arbitrary function. For example, if log odds ratios are provided to the function, then one could use transf=exp to obtain a forest plot showing the odds ratios. Alternatively, one can use the atransf argument to transform the x axis labels and annotations. The examples below illustrate the use of these arguments. Summary estimates can also be added to the plot with the addpoly function. See the documentation for that function for examples.

References

Lewis, S. & Clarke, M. (2001). Forest plots: Trying to see the wood and the trees. British Medical Journal, 322, 1479--1480. 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, addpoly

Examples

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

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

### forest plot of the observed relative risks
forest(dat$yi, dat$vi, slab=paste(dat$author, dat$year, sep=", "), atransf=exp)

### see also examples for the forest.rma function

Run the code above in your browser using DataLab