Learn R Programming

jarbes (version 2.3.0)

caterplot_compare: Compare Posterior Estimates from Bayesian Models

Description

Generates a caterpillar-style plot (forest plot) for visualizing and comparing posterior parameter estimates from one or two Bayesian models. This function is designed for use within the `jarbes` package and supports models fitted via MCMC. It allows custom labels, credible intervals, and styling for visual model comparison, particularly in meta-analytic and hierarchical modeling contexts.

Usage

caterplot_compare(
  model1,
  model2 = NULL,
  pars,
  plotmath.labels = NULL,
  model1.name = "Model 1",
  model2.name = "Model 2",
  model.legend.title = "Model",
  ref.lines = c(0),
  colors = c("blue", "red"),
  point.size = 3,
  point.shapes = c(16, 17),
  prob = 0.5,
  prob.outer = 0.9,
  point.est = "median",
  x.lab = "Estimate",
  y.lab = NULL,
  inner.line.thickness = 2,
  outer.line.thickness = 0.8,
  ...
)

Arguments

model1

An object containing MCMC draws. Various formats (e.g., arrays, matrices, data frames, `posterior::draws` objects) are accepted.

model2

Optional object containing MCMC draws. Accepted formats are the same as for `model1`.

pars

Character vector of parameter names to include in the plot.

plotmath.labels

Optional character vector for y-axis labels. If provided in R's plotmath syntax (e.g., for Greek letters or mathematical symbols), these labels will be displayed on the plot.

model1.name

Text for the label of the first model.

model2.name

Text for the label of the second model.

model.legend.title

Text for the title of the model legend.

ref.lines

Numeric value indicating vertical reference lines.

colors

Character vector specifying the colors for models.

point.size

Numeric value for the size of points in the plot.

point.shapes

Numeric or character vector specifying the shapes for points, one for each model.

prob

Numeric value for the probability mass to include in the inner interval.

prob.outer

Numeric value for the probability mass to include in the outer interval.

point.est

Text specifying the type of point estimate to show. Either `"median"` (the default), `"mean"`, or `"none"`.

x.lab

Text with the label of the x-axis.

y.lab

Text with the label of the y-axis.

inner.line.thickness

Numeric value for the thickness of the inner interval line.

outer.line.thickness

Numeric value for the thickness of the outer interval line.

...

...