Side-by-side forest plots: univariate vs multivariable
Source:R/plot_reg_combine.R
plot_reg_combine.RdCreates two aligned forest plots from compatible gtregression
regression objects such as crude and adjusted outputs from uni_reg(),
multi_reg(), cox_reg(), or surv_reg().
Usage
plot_reg_combine(
tbl_uni,
tbl_multi,
title_uni = NULL,
title_multi = NULL,
caption = NULL,
ref_line = NULL,
order_y = NULL,
log_x = FALSE,
point_color = "#6B7280",
errorbar_color = "#6B7280",
point_size = 2.8,
point_stroke = 0.55,
ci_linewidth = 0.55,
base_size = 12,
show_ref = NULL,
sig_color = "#0072B2",
sig_errorbar_color = "#0072B2",
xlim_uni = NULL,
breaks_uni = NULL,
xlim_multi = NULL,
breaks_multi = NULL,
alpha = 0.05,
show_adjustment_note = TRUE
)Arguments
- tbl_uni
A univariate
gtregressionobject.- tbl_multi
A multivariable
gtregressionobject.- title_uni, title_multi
Optional panel titles.
- caption
Optional combined plot caption. If
NULL, notes are added automatically for adjustedmulti_reg()objects and displayed reference categories.- ref_line
Optional numeric reference line. If
NULL, uses 0 for linear models and 1 otherwise.- order_y
Optional character vector to customize exposure ordering.
- log_x
Logical. If
TRUE, use a log-scaled x-axis for ratio measures. The defaultFALSEuses a linear x-axis.- point_color, errorbar_color
Base colors for non-significant rows.
- point_size
Diameter of estimate points in millimetres.
- point_stroke
Outline width of estimate points.
- ci_linewidth
Line width of confidence intervals.
- base_size
Base font size for the plot theme.
- show_ref
Logical or
NULL. The defaultNULLinherits the setting used to create the supplied tables. IfTRUE, include reference levels as(Ref.). IfFALSE, binary exposures are shown as compact rows for the estimated non-reference category; affirmative levels such asYesor1are displayed using the variable name.- sig_color, sig_errorbar_color
Optional colors for significant rows. If
NULL, base colors are reused.- xlim_uni, breaks_uni
Optional x-axis limits and breaks for the univariate panel.
- xlim_multi, breaks_multi
Optional x-axis limits and breaks for the multivariable panel.
- alpha
Significance level for linear models when
p.valueis available.- show_adjustment_note
Logical; if
TRUE, add a default caption describingadjust_forvariables fromtbl_multiwhen available.