Learn R Programming

meta (version 3.0-1)

forest.meta: Forest plot plot function for objects of class meta

Description

Draws a forest plot in the active graphics window (using grid graphics system).

Usage

## S3 method for class 'meta':
forest(x, sortvar, studlab=TRUE,
       comb.fixed=x$comb.fixed, comb.random=x$comb.random,
       overall=TRUE,
       text.fixed=if (x$level!=x$level.comb) paste("Fixed effect model (",
                    round(x$level.comb*100), "%-CI)", sep="") else "Fixed effect model",
       text.random=if (x$level!=x$level.comb) paste("Random effects model (",
                    round(x$level.comb*100), "%-CI)", sep="") else "Random effects model",
       lty.fixed=2, lty.random=3,
       prediction=x$prediction,
       text.predict=if (!(length(x$level.predict)==0) && x$level!=x$level.predict)
                     paste("Prediction interval (", round(x$level.predict*100), "%)",
                     sep="") else "Prediction interval",
       bylab=x$bylab, print.byvar=x$print.byvar,
       text.fixed.w=text.fixed, text.random.w=text.random,
       pooled.totals=comb.fixed|comb.random, pooled.events=FALSE,
       xlab="", xlab.pos=ref,
       smlab=NULL, smlab.pos=ref, xlim="symmetric",
       allstudies=TRUE,
       weight,
       pscale=1,
       ref=ifelse(x$sm %in% c("RR", "OR", "HR"), 1, 0),
       leftcols=NULL, rightcols=NULL,
       leftlabs=NULL, rightlabs=NULL,
       lab.e=x$label.e, lab.c=x$label.c,
       lab.e.attach.to.col=NULL, lab.c.attach.to.col=NULL,
       label.right=x$label.right, label.left=x$label.left,
       lab.NA=".",
       lwd=1,
       at=NULL, label=TRUE,
       col.i="black", col.i.inside.square="white",
       col.square="gray", col.square.lines=col.square,
       col.diamond="gray",
       col.diamond.fixed=col.diamond, col.diamond.random=col.diamond,
       col.diamond.lines="black",
       col.diamond.fixed.lines=col.diamond.lines,
       col.diamond.random.lines=col.diamond.lines,
       col.predict="red", col.predict.lines="black",
       col.by="darkgray",
       print.I2=comb.fixed|comb.random, print.tau2=comb.fixed|comb.random,
       print.Q=FALSE, print.pval.Q=comb.fixed|comb.random,
       hetstat=print.I2|print.tau2|print.Q|print.pval.Q,
       overall.hetstat=overall&hetstat,
       hetlab="Heterogeneity: ",
       fontsize=12,
       fs.heading=fontsize,
       fs.fixed=fontsize, fs.random=fs.fixed, fs.predict=fs.fixed, fs.study=fontsize,
       fs.fixed.labels=fs.fixed, fs.random.labels=fs.random, fs.predict.labels=fs.predict,
       fs.study.labels=fs.study, fs.hetstat=fontsize-2,
       fs.axis=fontsize,
       fs.smlab=fontsize, fs.xlab=fontsize, fs.lr=fontsize,
       ff.heading="bold",
       ff.fixed="bold", ff.random=ff.fixed, ff.predict=ff.fixed, ff.study="plain",
       ff.fixed.labels=ff.fixed, ff.random.labels=ff.random, ff.predict.labels=ff.predict,
       ff.study.labels=ff.study, ff.hetstat="bold.italic",
       ff.axis="plain",
       ff.smlab="bold", ff.xlab="plain", ff.lr="plain",
       ##
       squaresize=0.8,
       boxsize=squaresize,
       ##
       plotwidth=unit(6, "cm"),
       colgap=unit(2, "mm"),
       colgap.left=colgap, colgap.right=colgap,
       colgap.forest=colgap,
       colgap.forest.left=colgap.forest, colgap.forest.right=colgap.forest,
       ##
       just="center",
       just.studlab="left",
       ##
       addspace=TRUE,
       ##
       new=TRUE,
       ##
       digits=2, ...)

Arguments

x
An object of class meta.
sortvar
An optional vector used to sort the individual studies (must be of same length as x$TE).
studlab
A logical indicating whether study labels should be printed in the graph. A vector with study labels can also be provided (must be of same length as x$TE then).
level
The level used to calculate confidence intervals for individual studies.
level.comb
The level used to calculate confidence intervals for pooled estimates.
comb.fixed
A logical indicating whether fixed effect estimate should be plotted.
comb.random
A logical indicating whether random effects estimate should be plotted.
overall
A logical indicating whether overall summaries should be plotted. This argument is useful in combination with the argument byvar if summaries should only be plotted on group level.
text.fixed
A character string used in the plot to label the pooled fixed effect estimate.
text.random
A character string used in the plot to label the pooled random effects estimate.
lty.fixed
Line type (pooled fixed effect estimate).
lty.random
Line type (pooled random effects estimate).
prediction
A logical indicating whether a prediction interval should be printed.
level.predict
The level used to calculate prediction interval for a new study.
text.predict
A character string used in the plot to label the prediction interval.
bylab
A character string with a label for the grouping variable.
print.byvar
A logical indicating whether the name of the grouping variable should be printed in front of the group labels.
text.fixed.w
A character string to label the pooled fixed effect estimate within subgroups, or a character vector of same length as number of subgroups with corresponging labels.
text.random.w
A character string to label the pooled random effect estimate within subgroups, or a character vector of same length as number of subgroups with corresponging labels.
pooled.totals
A logical indicating whether total number of observations should be given in the figure.
pooled.events
A logical indicating whether total number of events should be given in the figure.
xlab
A label for the x axis.
xlab.pos
A numeric specifying the center of the label on the x axis.
smlab
A label for the summary measurex (printed at top of figure).
smlab.pos
A numeric specifying the center of the label for the summary measure.
xlim
The x limits (min,max) of the plot, or the character "s" to produce symmetric forest plots.
allstudies
A logical indicating whether studies with inestimable treatment effects should be plotted.
weight
A character string indicating which type of plotting symbols is to be used for individual treatment estimates. One of missing (see Details), "same", "fixed", or "random", can be abbreviated. Plot symbols
pscale
A numeric giving scaling factor for probabilities for objects of class metaprop.
ref
A numerical giving the reference value to be plotted as a line in the forest plot. No reference line is plotted if argument ref is equal to NA.
leftcols
A character vector specifying (additional) columns to be plotted on the left side of the forest plot or a logical value (see Details).
rightcols
A character vector specifying (additional) columns to be plotted on the right side of the forest plot or a logical value (see Details).
leftlabs
A character vector specifying labels for (additional) columns on left side of the forest plot (see Details).
rightlabs
A character vector specifying labels for (additional) columns on right side of the forest plot (see Details).
lab.e
Label to be used for experimental group in table heading.
lab.c
Label to be used for control group in table heading.
lab.e.attach.to.col
A character specifying the column name where label lab.e should be attached to in table heading.
lab.c.attach.to.col
A character specifying the column name where label lab.c should be attached to in table heading.
label.left
Graph label on left side of forest plot.
label.right
Graph label on right side of forest plot.
lab.NA
A character string to label missing values.
lwd
The line width, see par.
at
The points at which tick-marks are to be drawn, see grid.xaxis.
label
A logical value indicating whether to draw the labels on the tick marks, or an expression or character vector which specify the labels to use. See grid.xaxis.
col.i
The colour for individual study results and confidence limits.
col.i.inside.square
The colour for individual study results and confidence limits if confidence limits are completely within squares.
col.square
The colour for squares reflecting study's weight in the meta-analysis.
col.square.lines
The colour for the outer lines of squares reflecting study's weight in the meta-analysis.
col.diamond
The colour of diamonds representing the results for fixed effect and random effects models.
col.diamond.fixed
The colour of diamonds for fixed effect estimates.
col.diamond.random
The colour of diamonds for random effects estimates.
col.diamond.lines
The colour of the outer lines of diamonds representing the results for fixed effect and random effects models.
col.diamond.fixed.lines
The colour of the outer lines of diamond for fixed effect estimate.
col.diamond.random.lines
The colour of the outer lines of diamond for random effects estimate.
col.predict
Background colour of prediction interval.
col.predict.lines
Colour of outer lines of prediction interval.
col.by
The colour to print information on subgroups.
print.I2
A logical value indicating whether to print the value of the I-squared statistic.
print.tau2
A logical value indicating whether to print the value of the between-study variance tau-squared.
print.Q
A logical value indicating whether to print the value of the heterogeneity statistic Q.
print.pval.Q
A logical value indicating whether to print the p-value of the heterogeneity statistic Q.
hetstat
A logical value indicating whether to print results for heterogeneity measures at all.
overall.hetstat
A logical value indicating whether to print results for heterogeneity measures for overall treatment comparisons. This argument is useful in combination with subgroup analyses (list object byvar) if heterogeneity statistics sh
hetlab
Label printed in front of results for heterogeneity measures.
fontsize
The size of text (in points), see gpar.
fs.heading
The size of text for column headings, see gpar.
fs.fixed
The size of text for results of fixed effect model, see gpar.
fs.random
The size of text for results of random effects model, see gpar.
fs.predict
The size of text for results of prediction interval, see gpar.
fs.study
The size of text for results of individual studies, see gpar.
fs.fixed.labels
The size of text for label of fixed effect model, see gpar.
fs.random.labels
The size of text for label of random effects model, see gpar.
fs.predict.labels
The size of text for label of prediction interval, see gpar.
fs.study.labels
The size of text for labels of individual studies, see gpar.
fs.hetstat
The size of text for heterogeneity measures, see gpar.
fs.axis
The size of text on x-axis, see gpar.
fs.smlab
The size of text of label for summary measure, see gpar.
fs.xlab
The size of text of label on x-axis, see gpar.
fs.lr
The size of text of label on left and right side of forest plot, see gpar.
ff.heading
The fontface for column headings, see gpar.
ff.fixed
The fontface of text for results of fixed effect model, see gpar.
ff.random
The fontface of text for results of random effects model, see gpar.
ff.predict
The fontface of text for results of prediction interval, see gpar.
ff.study
The fontface of text for results of individual studies, see gpar.
ff.fixed.labels
The fontface of text for label of fixed effect model, see gpar.
ff.random.labels
The fontface of text for label of random effects model, see gpar.
ff.predict.labels
The fontface of text for label of prediction interval, see gpar.
ff.study.labels
The fontface of text for labels of individual studies, see gpar.
ff.hetstat
The fontface of text for heterogeneity measures, see gpar.
ff.axis
The fontface of text on x-axis, see gpar.
ff.smlab
The fontface of text of label for summary measure, see gpar.
ff.xlab
The fontface of text of label on x-axis, see gpar.
ff.lr
The fontface of text of label on left and right side of forest plot, see gpar.
squaresize
A numeric used to increase or decrease the size of squares in the forest plot.
boxsize
Use of this argument is deprecated.
plotwidth
A unit object specifying width of the forest plot.
colgap
A unit object specifying gap between columns printed on left and right side of forest plot.
colgap.left
A unit object specifying gap between columns printed on left side of forest plot.
colgap.right
A unit object specifying gap between columns printed on right side of forest plot.
colgap.forest
A unit object specifying gap between column adjacent to forest plot and the forest plot.
colgap.forest.left
A unit object specifying gap between column on the left side of forest plot and the forest plot.
colgap.forest.right
A unit object specifying gap between column on the right side of forest plot and the forest plot.
just
Justification of text for additional columns (possible values: "left", "right", "center").
just.studlab
Justification of text for study labels (possible values: "left", "right", "center").
addspace
A logical value indicating whether additional space (i.e. a blank row) is printed above and below study results.
new
A logical value indicating whether a new figure should be printed in an existing graphics window.
digits
Minimal number of significant digits, see print.default.
...
Additional graphical arguments (ignored at the moment).

Details

A forest plot, also called confidence interval plot, is drawn in the active graphics window. Subgroup analyses are conducted and displayed in the plot if byvar is not missing. Note, in R package meta, version 3.0-0 the following arguments have been removed from R function forest.meta: byvar, level, level.comb, level.predict. This functionality is now provided by R function update.meta (or directly in R functions metabin, metacont, metagen, metacor, and metaprop). The forest function is based on the grid graphics system. In order to print the forest plot, (i) resize the graphics window, (ii) either use dev.copy2eps or dev.copy2pdf. Information from object x is utilised if argument weight is missing. Weights from the fixed effect model are used (weight="fixed") if argument x$comb.fixed is TRUE; weights from the random effects model are used (weight="random") if argument x$comb.random is TRUE and x$comb.fixed is FALSE.

The arguments leftcols and rightcols can be used to specify columns which are plotted on the left and right side of the forest plot, respectively. If argument rightcols is FALSE, no columns will be plotted on the right side. By default, i.e. if arguments leftcols and rightcols are NULL, the following default columns will be plotted.

Argument rightcols: rightcols=c("effect", "ci"), i.e., estimated treatment effect and its level-confidence interval. In addition, weights of the fixed ("w.fixed") and/or random effects model ("w.random") will be given, if comb.fixed=TRUE and/or comb.random=TRUE. For an object of class metacum or metainf only the estimated treatment effect with level-confidence interval are plotted. Argument leftcols: (i) leftcols=c("studlab", "event.e", "n.e", "event.c", "n.c") for an object of class metabin, (ii) leftcols=c("studlab", "n.e", "mean.e", "sd.e", "n.c", "mean.c", "sd.c") for an object of class metacont, (iii) leftcols=c("studlab", "TE", "seTE") for an object of class metagen, (iv) leftcols=c("studlab", "event", "n") for an object of class metaprop, (v) leftcols=c("studlab", "n") for an object of class metacor, (vi) leftcols=c("studlab") for an object of class metacum or metainf.

The arguments leftlabs and rightlabs can be used to specify column headings which are plotted on left and right side of the forest plot, respectively. For certain columns predefined labels exist. If the arguments leftlabs and rightlabs are NULL, the following default labels will be used: for columns c("studlab", "TE", "seTE", "n.e", "n.c", "event.e", "event.c", "mean.e", "mean.c", "sd.e", "sd.c", "effect", "ci", "w.fixed", "w.random") the labels c("Study", "TE", "seTE", "Total", "Total", "Events", "Events", "Mean", "Mean", "SD", "SD", summary measure, level for confidence interval, "W(fixed)", "W(random)"). For additional columns the column name will be used as label. It is possible to only provide labels for new columns (see Examples). Otherwise the length of leftlabs and rightlabs must be the same as the number of printed columns. The value NA can be used to specify columns using the default labels (see Example).

If arguments lab.e and lab.c are NULL, "Experimental" and "Control" are used as labels for experimental and control group, respectively. The arguments pscale can be used to rescale proportions for objects of class metaprop, e.g. pscale=100 means that proportions are expressed per 100 observations. This is useful in situations with (very) low proportions. For pscale=100, column heading and x-axis label are changed to "Prop (in %)" and "Proportion (in %)", respectively.

A prediction interval for treatment effect of a new study (Higgins et al., 2009) is given in the forest plot if arguments prediction and comb.random are TRUE. For graphical presentation of prediction intervals the approach by Guddat et al. (2012) is used.

References

Guddat C, Grouven U, Bender R, Skipka G 2012), A note on the graphical presentation of prediction intervals in random-effects meta-analyses. Systematic Reviews, 1, 34.

Higgins JPT, Thompson SG, Spiegelhalter DJ (2009), A re-evaluation of random-effects meta-analysis. Journal of the Royal Statistical Society: Series A, 172, 137-159.

See Also

metabin, metacont, metagen

Examples

Run this code
data(Olkin95)
meta1 <- metabin(event.e, n.e, event.c, n.c,
                 data=Olkin95, subset=c(41,47,51,59),
                 sm="RR", method="I",
                 studlab=paste(author, year))


##
## Do (symmetric) forest plot
##
forest(meta1)


##
## Forest plot specifying argument xlim
##
forest(meta1, xlim=c(0.01, 10))


##
## Add prediction interval to forest plot
##
forest(meta1, prediction=TRUE)


##
## Forest plot with 'classic' layout used in
## R package meta, version < 1.6-0
##
forest(meta1, col.square="black", hetstat=FALSE)


##
## Change set of columns printed on left side
## of forest plot
##
forest(meta1, comb.random=FALSE,
       leftcols="studlab")


##
## Do not print columns on right side of forest plot
##
forest(meta1, rightcols=FALSE)


##
## Change study label to "Author"
##
forest(meta1, comb.random=FALSE,
       leftlabs=c("Author", NA, NA, NA, NA))


##
## Just give effect estimate and 95% confidence interval
## on right side of forest plot
##
forest(meta1, rightcols=c("effect", "ci"))


##
## 1. Change order of columns on left side
## 2. Attach labels to columns 'event.e' and 'event.c'
##    instead of columns 'n.e' and 'n.c'
##
forest(meta1,
       leftcols=c("studlab", "n.e", "event.e", "n.c", "event.c"),
       lab.e.attach.to.col="event.e",
       lab.c.attach.to.col="event.c")


Olkin95$studlab <- paste(Olkin95$author, Olkin95$year)
##
## Add variables 'year' and 'author' to meta-analysis object
##
meta1$year <- addvar(meta1, Olkin95, "year")
meta1$author <- addvar(meta1, Olkin95, "author")

##
## Specify column labels only for newly created variables
## 'year' and 'author'
##
forest(meta1,
       leftcols=c("studlab", "event.e", "n.e", "event.c", "n.c",
                  "author", "year"),
       leftlabs=c("Author", "Year of Publ"))


##
## Change some fontsizes and fontfaces
##
forest(meta1,
       fs.study=10, ff.study="italic",
       fs.study.label=11, ff.study.label="bold",
       fs.axis=5, ff.axis="italic",
       ff.smlab="bold.italic",
       ff.fixed="plain", ff.hetstat="plain")


##
## Change some colours
##
forest(meta1,
       col.diamond="green", col.diamond.lines="red",
       col.i=c("green", "blue", "red", "orange"),
       col.square="pink", col.square.lines="black")

Run the code above in your browser using DataLab