3

I've had great success using the gtsummary::tbl_regression function to display regression model results. I can't see how to use tbl_regression with pooled regression models from imputed data sets, however, and I'd really like to.

I don't have a reproducible example handy, I just wanted to see if anyone else has found a way to work with, say, mids objects created by the mice package in tbl_regression.

1 Answers1

3

In the current development version of gtsummary, it's possible to summarize models estimated on imputed data from the mice package. Here's an example

# install dev version of gtsummary
remotes::install_github("ddsjoberg/gtsummary")
library(gtsummary)
packageVersion("gtsummary")
#> [1] ‘1.3.5.9012’

# impute the data
df_imputed <- mice::mice(trial, m = 2)

# build the model
imputed_model <- with(df_imputed, lm(age ~ marker + grade))

# present beautiful table with gtsummary
tbl_regression(imputed_model) 
#> pool_and_tidy_mice: Tidying mice model with
#> `mice::pool(x) %>% mice::tidy(exponentiate = FALSE, conf.int = TRUE, conf.level = 0.95)`

enter image description here

Created on 2020-12-16 by the reprex package (v0.3.0)

It's important to note that you pass the mice model object to tbl_regression() BEFORE you pool the results. The tbl_regression() function needs access to the individual models in order to correctly identify the reference row and variable labels (among other things). Internally, the tidying function used on the mice model will first pool the results, then tidy the results. The code used for this process is printed to the console for transparency (as seen in the example above).

Daniel D. Sjoberg
  • 8,820
  • 2
  • 12
  • 28