Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

vetted_models

Vetted tidy models


Description

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()

gtsummary

Presentation-Ready Data Summary and Analytic Result Tables

v1.4.0
MIT + file LICENSE
Authors
Daniel D. Sjoberg [aut, cre] (<https://orcid.org/0000-0003-0862-2018>), Michael Curry [aut] (<https://orcid.org/0000-0002-0261-4044>), Margie Hannum [aut] (<https://orcid.org/0000-0002-2953-0449>), Joseph Larmarange [aut] (<https://orcid.org/0000-0001-7097-700X>), Karissa Whiting [aut] (<https://orcid.org/0000-0002-4683-1868>), Emily C. Zabor [aut] (<https://orcid.org/0000-0002-1402-4498>), Esther Drill [ctb] (<https://orcid.org/0000-0002-3315-4538>), Jessica Flynn [ctb] (<https://orcid.org/0000-0001-8310-6684>), Jessica Lavery [ctb] (<https://orcid.org/0000-0002-2746-5647>), Stephanie Lobaugh [ctb], Gustavo Zapata Wainberg [ctb] (<https://orcid.org/0000-0002-2524-3637>)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.