Consider data frame that comprises a binary outcome column (y), and multiple independent predictor columns (x1, x2, x3...)
I want to run many single-variable logistic regression models (e.g. y ~ x1, y ~ x2, y ~ x3), and extract the exponentiated coefficients (odds ratios), 95% confidence intervals and p-values for each model into rows of a data frame/tibble.
I am trying to find a solution by using a combination of purrr and broom.
Working from the example in the referenced question:
library(tidyverse)
library(broom)
df <- mtcars
df %>%
names() %>%
paste('am~',.) %>%
map(~glm(as.formula(.x), data= df, family = "binomial"))