bcat_plt_coef: Coefficient plot (forest plot)

View source: R/bcat_plt_coef.R

bcat_plt_coefR Documentation

Coefficient plot (forest plot)

Description

Visualize regression coefficients and confidence intervals for one or more models. Uses broom::tidy() to extract estimates.

Usage

bcat_plt_coef(
  models,
  conf_level = 0.95,
  intercept = FALSE,
  coef_rename = NULL,
  highlight = NULL,
  dodge_width = 0.4,
  x_lab = "Estimate",
  y_lab = ggplot2::waiver(),
  title = ggplot2::waiver(),
  subtitle = ggplot2::waiver(),
  caption = ggplot2::waiver(),
  legend_lab = "Model",
  legend_position = "bottom",
  legend_hide = FALSE,
  color_scale = scale_colour_UC()
)

Arguments

models

A model object or a named list of model objects.

conf_level

Numeric. Confidence level. Default is 0.95.

intercept

Logical. Include intercept? Default is FALSE.

coef_rename

Named character vector to rename coefficients. If NULL (default), auto-cleans names to Title Case.

highlight

Character vector of term names to highlight in UC Red.

dodge_width

Numeric. Dodge width for multi-model comparison. Default is 0.4.

x_lab

Label for x-axis (coefficient values).

y_lab

Label for y-axis (term names).

title

Plot title.

subtitle

Plot subtitle.

caption

Plot caption.

legend_lab

Legend title.

legend_position

Legend position.

legend_hide

Logical. Hide legend?

color_scale

scale_color_ function.

Value

A ggplot object.

Author(s)

Saannidhya Rawat

See Also

Other plots: bcat_plt_area(), bcat_plt_bar(), bcat_plt_box(), bcat_plt_diag(), bcat_plt_hist(), bcat_plt_line(), bcat_plt_point(), bcat_plt_ts()

Examples

library(ggplot2)

m <- lm(mpg ~ wt + hp + cyl, data = mtcars)
bcat_plt_coef(m)

m1 <- lm(mpg ~ wt + hp, data = mtcars)
m2 <- lm(mpg ~ wt + hp + cyl + disp, data = mtcars)
bcat_plt_coef(list("Base" = m1, "Full" = m2))

Rbearcat documentation built on March 21, 2026, 5:07 p.m.