View source: R/tbl_uvregression.R
tbl_uvregression | R Documentation |
This function estimates univariable regression models and returns them in a publication-ready table. It can create regression models holding either a covariate or an outcome constant.
tbl_uvregression(data, ...)
## S3 method for class 'data.frame'
tbl_uvregression(
data,
y = NULL,
x = NULL,
method,
method.args = list(),
exponentiate = FALSE,
label = NULL,
include = everything(),
tidy_fun = broom.helpers::tidy_with_broom_or_parameters,
hide_n = FALSE,
show_single_row = NULL,
conf.level = 0.95,
estimate_fun = ifelse(exponentiate, label_style_ratio(), label_style_sigfig()),
pvalue_fun = label_style_pvalue(digits = 1),
formula = "{y} ~ {x}",
add_estimate_to_reference_rows = FALSE,
conf.int = TRUE,
...
)
## S3 method for class 'survey.design'
tbl_uvregression(
data,
y = NULL,
x = NULL,
method,
method.args = list(),
exponentiate = FALSE,
label = NULL,
include = everything(),
tidy_fun = broom.helpers::tidy_with_broom_or_parameters,
hide_n = FALSE,
show_single_row = NULL,
conf.level = 0.95,
estimate_fun = ifelse(exponentiate, label_style_ratio(), label_style_sigfig()),
pvalue_fun = label_style_pvalue(digits = 1),
formula = "{y} ~ {x}",
add_estimate_to_reference_rows = FALSE,
conf.int = TRUE,
...
)
data |
( |
... |
Additional arguments passed to |
y , x |
( |
method |
( |
method.args |
(named |
exponentiate |
(scalar |
label |
( |
include |
( |
tidy_fun |
( |
hide_n |
(scalar |
show_single_row |
( |
conf.level |
(scalar |
estimate_fun |
( |
pvalue_fun |
( |
formula |
( |
add_estimate_to_reference_rows |
(scalar |
conf.int |
(scalar |
A tbl_uvregression
object
x
and y
argumentsFor models holding outcome constant, the function takes as arguments a data frame,
the type of regression model, and the outcome variable y=
. Each column in the
data frame is regressed on the specified outcome. The tbl_uvregression()
function arguments are similar to the tbl_regression()
arguments. Review the
tbl_uvregression vignette
for detailed examples.
You may alternatively hold a single covariate constant. For this, pass a data
frame, the type of regression model, and a single
covariate in the x=
argument. Each column of the data frame will serve as
the outcome in a univariate regression model. Take care using the x
argument
that each of the columns in the data frame are appropriate for the same type
of model, e.g. they are all continuous variables appropriate for lm, or
dichotomous variables appropriate for logistic regression with glm.
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 original x=
argument
is replaced with the model fit. This will typically go unnoticed; however,if you've
provided a custom tidier in tidy_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 tidier tidy_gam()
to print both parametric and smooth terms.
"lmerMod"
, "glmerMod"
, "glmmTMB"
, "glmmadmb"
, "stanreg"
, "brmsfit"
: These mixed effects
models use broom.mixed::tidy(x, effects = "fixed")
. Specify tidy_fun = broom.mixed::tidy
to print the random components.
Daniel D. Sjoberg
See tbl_regression vignette for detailed examples
# Example 1 ----------------------------------
tbl_uvregression(
trial,
method = glm,
y = response,
method.args = list(family = binomial),
exponentiate = TRUE,
include = c("age", "grade")
)
# Example 2 ----------------------------------
# rounding pvalues to 2 decimal places
library(survival)
tbl_uvregression(
trial,
method = coxph,
y = Surv(ttdeath, death),
exponentiate = TRUE,
include = c("age", "grade", "response"),
pvalue_fun = label_style_pvalue(digits = 2)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.