Created
May 27, 2021 09:08
-
-
Save chrissyhroberts/b0ba4902fb5a4fd83ab0d5273a07c505 to your computer and use it in GitHub Desktop.
Make a univariate regression table for many variables from raw data frame
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library (gtsummary) | |
Univariate Regression | |
The tbl_uvregression() function produces a table of univariate regression models. The function is a wrapper for tbl_regression(), and as a result, accepts nearly identical function arguments. The function’s results can be modified in similar ways to tbl_regression(). | |
trial %>% | |
select(response, age, grade) %>% | |
tbl_uvregression( | |
method = glm, | |
y = response, | |
method.args = list(family = binomial), | |
exponentiate = TRUE, | |
pvalue_fun = ~style_pvalue(.x, digits = 2) | |
) %>% | |
add_global_p() %>% # add global p-value | |
add_nevent() %>% # add number of events of the outcome | |
add_q() %>% # adjusts global p-values for multiple testing | |
bold_p() %>% # bold p-values under a given threshold (default 0.05) | |
bold_p(t = 0.10, q = TRUE) %>% # now bold q-values under the threshold of 0.10 | |
bold_labels() | |
#> add_global_p: Global p-values for variable(s) `add_global_p(include = c("age", | |
#> "grade"))` were calculated with | |
#> `car::Anova(mod = x$model_obj, type = "III")` | |
#> add_q: Adjusting p-values with | |
#> `stats::p.adjust(x$table_body$p.value, method = "fdr")` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment