Open mbcann01 opened 6 years ago
Here are some functions I created in the WHI sexual function analysis to help get the results of logistic regression in the format I wanted
tidy_glm <- function(x, ...) { out <- tidy(x) ci <- confint(x) %>% exp() %>% as.data.frame() out <- bind_cols(out, ci) out <- out %>% mutate( estimate = exp(estimate), p_value = round(p.value, 10) %>% format(nsmall = 6L) ) %>% select(-p.value) out } tidy_output_mids <- function(x, ...) { x %>% summary() %>% tidy() %>% mutate( est = exp(est) %>% round(2) %>% format(nsmall = 2L), lo.95 = exp(lo.95) %>% round(2) %>% format(nsmall = 2L), hi.95 = exp(hi.95) %>% round(2) %>% format(nsmall = 2L), p_value = round(`Pr...t..`, 10) %>% format(nsmall = 6L), or_95 = paste0(est, " (", lo.95, " - ", hi.95, ")") ) %>% select(.rownames, est, lo.95, hi.95, or_95, p_value) }
To be honest, I don't love the default output from Broom. I might want to make my own broom-like functions.
Here are some functions I created in the WHI sexual function analysis to help get the results of logistic regression in the format I wanted