Learn R Programming

forestmodel (version 0.3.3)

forest_rma: Generate a forest plot from a meta-analysis

Description

Generate a forest plot from a meta-analysis

Usage

forest_rma(model, panels = NULL, study_labels = NULL,
  additional_data = NULL, point_size = NULL, model_label = NULL,
  show_individual_studies = TRUE, show_stats = list(`I^2` =
  ~sprintf("%0.1f%%", I2), p = ~format.pval(QEp, digits = 4, eps = 1e-04,
  scientific = 1)), trans = I, funcs = NULL, format_options = list(colour
  = "black", shape = 15, text_size = 5, banded = TRUE),
  theme = theme_forest(), limits = NULL, breaks = NULL,
  return_data = FALSE, recalculate_width = TRUE,
  recalculate_height = TRUE)

Arguments

model
a single rma object or a list of them
panels
list with details of the panels that make up the plot (See Details)
study_labels
a character vector of study labels or list of character vectors the same length as model
additional_data
a data.frame of additional data that can be referenced for the data shown in the panels of the forest plot
point_size
a numeric vector with the point sizes for the individual studies, or a single value used for all studies, or a list of numeric vectors if more than one model is to be plotted
model_label
a single model label or character vector of model labels the same length as model
show_individual_studies
whether to show the individual studies (the default) or just the summary diamond
show_stats
a list of stats to show at the bottom of the forest plot for e.g. heterogeneity
trans
an optional transform function used on the numeric data for plotting the axes
funcs
optional list of functions required for formatting panels$display
format_options
formatting options as a list including colour of the point estimate and error bars, shape of the point estimate, banded whether to show light grey bands behind alternate rows, text_size size of text in
theme
theme to apply to the plot
limits
limits of the forest plot on the X-axis (taken as the range of the data by default)
breaks
breaks to appear on the X-axis (note these will be exponentiated if exponentiate == TRUE)
return_data
return the data to produce the plot as well as the plot itself
recalculate_width
TRUE to recalculate panel widths using the current device or the desired plot width in inches
recalculate_height
TRUE to shrink text size using the current device or the desired plot height in inches

Value

  • plot

Details

This produces a forest plot using the rma

Examples

Run this code
if (require("metafor")) {
  data("dat.bcg")
  dat <- escalc(measure="RR", ai=tpos, bi=tneg, ci=cpos, di=cneg, data=dat.bcg)
  model <- rma(yi, vi, data = dat)

  print(forest_rma(model, study_labels = paste(dat.bcg$author, dat.bcg$year),
    trans = exp))

  print(forest_rma(model, panels = forest_panels(Study = ~study,
    N = ~n, ~vline, `Log Relative Risk` = ~forest(line_x = 0),
    ~spacer(space = 0.10),
    ~sprintf("%0.3f (%0.3f, %0.3f)", estimate, conf.low, conf.high)),
    study_labels = paste(dat.bcg$author, dat.bcg$year),
    trans = exp))

}

Run the code above in your browser using DataLab