I am trying to check the assumptions of multiple models following a solution I found here. I want to extend that solution to a list of tidymodels, but I can't figure out how to convert the results into a dataframe/tibble. I tried using dplyr::bind_rows
but I get the error shown in the code example below.
library("tidyverse")
library("tidymodels")
library("olsrr")
# Fit each model separately
lm_spec <- parsnip::linear_reg()
mod1 <- fit(lm_spec, mpg ~ cyl, data = mtcars)
mod2 <- fit(lm_spec, mpg ~ hp, data = mtcars)
# Combine models in list
mod_list <- tibble::lst(mod1 = mod1, mod2 = mod2)
# Function for residual normality tests
get_lm_normality <- function(x) {
x %>%
# get the lm model object
extract_fit_engine() %>%
# transform its format
olsrr::ols_test_normality()
}
mod_normality <-
purrr::map(mod_list, get_lm_normality) %>%
bind_rows(., .id = "name")
# Here I get the error:
# Error: All columns in a tibble must be vectors.
# x Column `mod1` is a `ols_test_normality` object.
# x Column `mod2` is a `ols_test_normality` object.
Any ideas for how to convert the list results to a dataframe?