This function takes a regression model object and returns a formatted table
that is publication-ready. The function is customizable
allowing the user to create bespoke regression model summary tables.
Review the
tbl_regression() vignette
for detailed examples.
Usage
tbl_regression(x, ...)
# Default S3 method
tbl_regression(
x,
label = NULL,
exponentiate = FALSE,
include = everything(),
show_single_row = NULL,
conf.level = 0.95,
intercept = FALSE,
estimate_fun = ifelse(exponentiate, label_style_ratio(), label_style_sigfig()),
pvalue_fun = label_style_pvalue(digits = 1),
tidy_fun = broom.helpers::tidy_with_broom_or_parameters,
add_estimate_to_reference_rows = FALSE,
conf.int = TRUE,
...
)Arguments
- x
(regression model)
Regression model object- ...
Additional arguments passed to
broom.helpers::tidy_plus_plus().- label
(
formula-list-selector)
Used to change variables labels, e.g.list(age = "Age", stage = "Path T Stage")- exponentiate
(scalar
logical)
Logical indicating whether to exponentiate the coefficient estimates. Default isFALSE.- include
(
tidy-select)
Variables to include in output. Default iseverything().- show_single_row
(
tidy-select)
By default categorical variables are printed on multiple rows. If a variable is dichotomous (e.g. Yes/No) and you wish to print the regression coefficient on a single row, include the variable name(s) here.- conf.level
(scalar
real)
Confidence level for confidence interval/credible interval. Defaults to0.95.- intercept
(scalar
logical)
Indicates whether to include the intercept in the output. Default isFALSE- estimate_fun
(
function)
Function to round and format coefficient estimates. Default islabel_style_sigfig()when the coefficients are not transformed, andlabel_style_ratio()when the coefficients have been exponentiated.- pvalue_fun
(
function)
Function to round and format p-values. Default islabel_style_pvalue().- tidy_fun
(
function)
Tidier function for the model. Default is to usebroom::tidy(). If an error occurs, the tidying of the model is attempted withparameters::model_parameters(), if installed.- add_estimate_to_reference_rows
(scalar
logical)
Add a reference value. Default isFALSE.- conf.int
(scalar
logical)
Logical indicating whether or not to include a confidence interval in the output. Default isTRUE.
Methods
The default method for tbl_regression() model summary uses broom::tidy(x)
to perform the initial tidying of the model object. There are, however,
a few models that use modifications.
"parsnip/workflows": If the model was prepared using parsnip/workflows, the original model fit is extracted and the originalx=argument is replaced with the model fit. This will typically go unnoticed; however,if you've provided a custom tidier intidy_fun=the tidier will be applied to the model fit object and not the parsnip/workflows object."survreg": The scale parameter is removed,broom::tidy(x) %>% dplyr::filter(term != "Log(scale)")"multinom": This multinomial outcome is complex, with one line per covariate per outcome (less the reference group)"gam": Uses the internal tidiertidy_gam()to print both parametric and smooth terms."lmerMod","glmerMod","glmmTMB","glmmadmb","stanreg","brmsfit": These mixed effects models usebroom.mixed::tidy(x, effects = "fixed"). Specifytidy_fun = broom.mixed::tidyto print the random components.
