Skip to content

Instantly share code, notes, and snippets.

@ABohynDOE
Created May 14, 2024 07:26
Show Gist options
  • Select an option

  • Save ABohynDOE/a8dc039bc7dd4a1ecb7f1aecf9d8c1f1 to your computer and use it in GitHub Desktop.

Select an option

Save ABohynDOE/a8dc039bc7dd4a1ecb7f1aecf9d8c1f1 to your computer and use it in GitHub Desktop.
Two different ways of pooling a list of models fitted on imputed data and then generating a summary table of the model using ´tbl_regression´
library(mice)
library(gtsummary)
# impute the data
df_imputed <- mice::mice(trial, m = 2, seed = 123)
# build the model list
imputed_model_list <- purrr::map(
1:df_imputed$m,
~ lm(age ~ marker + grade, complete(df_imputed, .x))
) %>%
as.mira()
# present beautiful table with gtsummary
tbl_regression(imputed_model_list)
# build the model using `with`
imputed_model <- with(df_imputed, lm(age ~ marker + grade))
# present beautiful table with gtsummary
tbl_regression(imputed_model)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment