custom_tidiers: Collection of custom tidiers

Description Usage Arguments Details Example Output Examples

Description

\lifecycle

experimental Collection of tidiers that can be passed to tbl_regression() and tbl_uvregression() to obtain modified results. See examples below.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
tidy_standardize(
  x,
  exponentiate = FALSE,
  conf.level = 0.95,
  conf.int = TRUE,
  ...,
  quiet = FALSE
)

tidy_bootstrap(
  x,
  exponentiate = FALSE,
  conf.level = 0.95,
  conf.int = TRUE,
  ...,
  quiet = FALSE
)

pool_and_tidy_mice(x, pool.args = NULL, ..., quiet = FALSE)

tidy_gam(x, conf.int = FALSE, exponentiate = FALSE, conf.level = 0.95, ...)

Arguments

x

a regression model object

exponentiate

Logical indicating whether or not to exponentiate the the coefficient estimates. This is typical for logistic and multinomial regressions, but a bad idea if there is no log or logit link. Defaults to FALSE.

conf.level

The confidence level to use for the confidence interval if conf.int = TRUE. Must be strictly greater than 0 and less than 1. Defaults to 0.95, which corresponds to a 95 percent confidence interval.

conf.int

Logical indicating whether or not to include a confidence interval in the tidied output. Defaults to FALSE.

...

arguments passed to method;

  • pool_and_tidy_mice(): mice::tidy(x, ...)

  • tidy_standardize(): effectsize::standardize_parameters(x, ...)

  • tidy_bootstrap(): parameters::bootstrap_parameters(x, ...)

quiet

Logical indicating whether to print messages in console. Default is FALSE

pool.args

named list of arguments passed to mice::pool() in pool_and_tidy_mice(). Default is NULL

Details

Ensure your model type is compatible with the methods/functions used to estimate the model parameters before attempting to use the tidier with tbl_regression()

Example Output

Example 1

Example 2

Example 3

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# Example 1 ----------------------------------
mod <- lm(age ~ marker + grade, trial)

tbl_stnd <- tbl_regression(mod, tidy_fun = tidy_standardize)
tbl <- tbl_regression(mod)

if (requireNamespace("effectsize"))
  tidy_standardize_ex1 <-
    tbl_merge(
      list(tbl_stnd, tbl),
      tab_spanner = c("**Standardized Model**", "**Original Model**")
    )

# Example 2 ----------------------------------
# use "posthoc" method for coef calculation
if (requireNamespace("parameters"))
  tidy_standardize_ex2 <-
    tbl_regression(mod, tidy_fun = purrr::partial(tidy_standardize, method = "posthoc"))


# Example 3 ----------------------------------
# Multiple Imputation using the mice package
set.seed(1123)
if (requireNamespace("mice"))
  pool_and_tidy_mice_ex3 <-
    suppressWarnings(mice::mice(trial, m = 2)) %>%
    with(lm(age ~ marker + grade)) %>%
    tbl_regression() # mice method called that uses `pool_and_tidy_mice()` as tidier

ddsjoberg/gtsummary documentation built on April 8, 2021, 5:48 a.m.