Skip to content

Instantly share code, notes, and snippets.

@datalove
Last active August 29, 2015 14:03
Show Gist options
  • Save datalove/c020315d8687ee8480f1 to your computer and use it in GitHub Desktop.
Save datalove/c020315d8687ee8480f1 to your computer and use it in GitHub Desktop.
Calculate P-value for an odds ratio using CIs
# calculation as per:
# http://www.bmj.com/content/343/bmj.d2304
get_odds_p <- function(est, cil, ciu) {
se <- (log(ciu) - log(cil))/(2*1.96)
z <- abs(log(est)/se)
p <- exp(-0.717*z - 0.416*z^2)
p
}
get_odds_p(1.7,0.94,3.08)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment