forest_rma: Generate a forest plot from a meta-analysis

Description Usage Arguments Details Value Examples

View source: R/forest_rma.R

Description

Generate a forest plot from a meta-analysis

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
forest_rma(
  model,
  panels = NULL,
  study_labels = NULL,
  additional_data = NULL,
  point_size = NULL,
  model_label = NULL,
  show_individual_studies = TRUE,
  show_model = TRUE,
  show_stats = list(`I^2` = rlang::quo(sprintf("%0.1f%%", I2)), p =
    rlang::quo(format.pval(QEp, digits = 4, eps = 1e-04, scientific = 1))),
  trans = I,
  funcs = NULL,
  format_options = forest_model_format_options(),
  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_model

a logical value, if 'TRUE', show model result, otherwise only show forest plots for studies

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 as generated by forest_model_format_options

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

Details

This produces a forest plot using the rma

Value

plot

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
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
  ))
}

Example output

Loading required package: ggplot2
Loading required package: metafor
Loading required package: Matrix
Loading 'metafor' package (version 2.0-0). For an overview 
and introduction to the package please type: help(metafor).
Warning: Ignoring unknown aesthetics: x
Warning: Ignoring unknown aesthetics: x
Warning messages:
1: In recalculate_width_panels(panel_positions, mapped_text = mapped_text,  :
  Unable to resize forest panel to be smaller than its heading; consider a smaller text size
2: In recalculate_width_panels(panel_positions, mapped_text = mapped_text,  :
  Unable to resize forest panel to be smaller than its heading; consider a smaller text size

forestmodel documentation built on July 19, 2020, 5:06 p.m.