Skip to content

Instantly share code, notes, and snippets.

@scoavoux
Created March 6, 2017 09:16
Show Gist options
  • Save scoavoux/ccb2f4333626949838a0ff807da238ff to your computer and use it in GitHub Desktop.
Save scoavoux/ccb2f4333626949838a0ff807da238ff to your computer and use it in GitHub Desktop.
Compute odds.ratio and p.value for logit model report in stargazer
sg_or <- function(mod){
OR <- lapply(mod, function(x) as.data.frame(questionr::odds.ratio(x)))
re <- list(
or = lapply(OR, `[[`, "OR"),
ci = lapply(OR, `[`, 2:3),
p = lapply(OR, `[[`, "p")
)
return(re)
}
# mod <- glm(..., family = "binomial")
# custom_coef <- sg_or(mod)
# stargazer(mod, ci = TRUE,
# coef = custom_coef$or,
#  ci.custom = custom_coef$ci,
#  p = custom_coef$p)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment