Below is a list of models vetted for use in tbl_regression and tbl_uvregression. If a model is passed to these functions and the model is not listed below and a tidy() function is not specified in the tidy_fun= argument, the model object will be passed to broom::tidy or broom.mixed::tidy.

model support

If broom::tidy or broom.mixed::tidy supports a class of model not listed above, please submit a GitHub Issue. The model can be added to the list of vetted models. Unit tests will be put in place to ensure continued support for the model.

custom tidiers

In some cases you may need to use a custom function to tidy regression model results. A user may pass a custom tidier function to tbl_regression and tbl_uvregression in the tidy_fun= argument. The function passed, however, must be a proper tidier. For example, it must return a tibble that is one line per variable in the regression model; it must accept arguments exponentiate=, conf.level=, and conf.int= since these arguments will be passed to the function internally (we recommend including ... to capture any arguments you may not need). See below for an example where the confidence limits for a linear regression model are calculated using Wald's method.

Examples

my_tidy <- function(x, exponentiate = FALSE, conf.level = 0.95, ...) { tidy <- dplyr::bind_cols( broom::tidy(x, conf.int = FALSE), # calculate the confidence intervals, and save them in a tibble stats::confint.default(x) %>% tibble::as_tibble() %>% rlang::set_names(c("conf.low", "conf.high")) ) # exponentiating, if requested if (exponentiate == TRUE) tidy <- dplyr::mutate_at(vars(estimate, conf.low, conf.high), exp) tidy } lm(age ~ grade + response, trial) %>% my_tidy()
#> # A tibble: 4 x 7 #> term estimate std.error statistic p.value conf.low conf.high #> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> #> 1 (Intercept) 45.0 1.93 23.3 5.67e-56 41.2 48.8 #> 2 gradeII 1.11 2.60 0.425 6.71e- 1 -4.00 6.21 #> 3 gradeIII 1.86 2.58 0.722 4.71e- 1 -3.19 6.92 #> 4 response 3.83 2.29 1.67 9.61e- 2 -0.657 8.32