forest.cdmeta: Forest plot for cdmeta objects

View source: R/forest.R

forest.cdmetaR Documentation

Forest plot for cdmeta objects

Description

Draws a forest plot from an object of class "cdmeta". The plot shows study-specific effect estimates and confidence intervals, the confidence-distribution-based summary estimate for the overall mean effect, and optionally the prediction interval for the effect in a future study.

Usage

## S3 method for class 'cdmeta'
forest(
  x,
  slab = NULL,
  order = c("none", "increasing", "decreasing", "precision", "weight"),
  level = NULL,
  summary_stat = c("mean", "median"),
  refline = 0,
  xlab = "Effect size",
  main = NULL,
  atransf = NULL,
  at = NULL,
  alim = NULL,
  xlim = NULL,
  digits = 2,
  ci_digits = digits,
  weight_digits = 1,
  show_weights = TRUE,
  show_pi = TRUE,
  show_het = TRUE,
  header = TRUE,
  annotate = TRUE,
  cex = 0.85,
  psize = NULL,
  pch = 22,
  box_col = "black",
  box_bg = "white",
  ci_col = "black",
  summary_col = "black",
  summary_bg = "gray20",
  pi_col = "gray40",
  refline_col = "gray70",
  grid = TRUE,
  grid_col = "gray90",
  qtype = 8,
  symmetric_shapes = TRUE,
  mark_summary_estimate = FALSE,
  mark_prediction_estimate = FALSE,
  estimate_mark_col = "black",
  estimate_mark_lwd = 1,
  mar = c(4.5, 1, 3, 1),
  ...
)

forest(x, ...)

Arguments

x

An object of class "cdmeta".

slab

An optional character vector of study labels. If NULL, the names of x$data$y are used when available; otherwise generic study labels are created.

order

A character string specifying the order of studies in the plot. Available options are "none", "increasing", "decreasing", "precision", and "weight".

level

Confidence level used for study-specific and summary intervals. If NULL, 1 - x$alpha is used.

summary_stat

Whether Monte Carlo means ("mean") or medians ("median") are used as point estimates for summary rows.

refline

Numeric location of the reference line.

xlab

Label for the x-axis.

main

Optional main title.

atransf

Optional function used to transform axis labels and printed estimates while plotting coordinates remain on the original analysis scale.

at

Optional numeric vector specifying tick-mark locations on the original analysis scale.

alim

Optional numeric vector of length 2 specifying plotting limits for the effect-size axis on the original analysis scale.

xlim

Optional numeric vector of length 2 specifying full plotting limits including the text columns.

digits

Number of digits used for axis labels.

ci_digits

Number of digits used for effect estimates and intervals.

weight_digits

Number of digits used for study weights.

show_weights

Logical indicating whether study weights are shown.

show_pi

Logical indicating whether the prediction interval is shown.

show_het

Logical indicating whether heterogeneity statistics are shown.

header

Logical indicating whether column headers are shown.

annotate

Logical indicating whether estimates and intervals are printed on the right side of the plot.

cex

Character expansion factor.

psize

Optional point sizes for study-specific estimates. If NULL, point sizes are proportional to random-effects inverse-variance weights.

pch

Plotting symbol for study-specific estimates.

box_col

Border color of study-specific points.

box_bg

Fill color of study-specific points.

ci_col

Color of study-specific confidence intervals.

summary_col

Border color of the summary diamond.

summary_bg

Fill color of the summary diamond.

pi_col

Color of the prediction interval.

refline_col

Color of the reference line.

grid

Logical indicating whether vertical grid lines are drawn.

grid_col

Color of the grid lines.

qtype

Quantile type used in stats::quantile(). Default is 8.

symmetric_shapes

Logical indicating whether the summary diamond and prediction-interval marker are drawn symmetrically around interval midpoints.

mark_summary_estimate

Logical indicating whether the actual summary point estimate is marked inside the summary diamond.

mark_prediction_estimate

Logical indicating whether the actual predictive point estimate is marked on the prediction-interval row.

estimate_mark_col

Color of the actual-estimate marks.

estimate_mark_lwd

Line width of the actual-estimate marks.

mar

Plot margins passed to graphics::par().

...

Additional arguments passed to graphics::plot().

Details

Study-specific confidence intervals are calculated using the normal approximation

y_i \pm z_{1-\alpha/2} se_i,

where \alpha = 1 - level. The summary interval for \mu and the prediction interval are calculated from the Monte Carlo samples in the cdmeta object when available.

If the object was created with transf = exp, forest() uses this transformation automatically when atransf = NULL. Tick marks supplied through at remain on the original analysis scale.

Value

Invisibly returns a data frame containing the plotted study-specific estimates, standard errors, confidence intervals, and weights. Attributes contain the overall, prediction, and heterogeneity summaries on the original analysis scale.

See Also

cdmeta

Examples

data(hf_iron)
fit_hf <- cdmeta(
  y = hf_iron$yi,
  se = hf_iron$sei,
  B = 10000,
  seed = 11111,
  transf = exp,
  transf_name = "exp"
)

forest(
  fit_hf,
  slab = hf_iron$study,
  at = log(c(0.25, 0.5, 1, 2, 4)),
  xlab = "Risk ratio",
  mark_summary_estimate = TRUE,
  mark_prediction_estimate = TRUE
)


cdmeta documentation built on Sept. 15, 2026, 5:09 p.m.