Skip to content

Instantly share code, notes, and snippets.

@malcolmbarrett
Created August 28, 2019 03:54
Show Gist options
  • Select an option

  • Save malcolmbarrett/853c30754f1909e1deee71b4479618c3 to your computer and use it in GitHub Desktop.

Select an option

Save malcolmbarrett/853c30754f1909e1deee71b4479618c3 to your computer and use it in GitHub Desktop.
transform_to_rr <- function(estimate, type) {
if (type == "or") estimate <- sqrt(estimate)
if (type == "hr") {
estimate <- (1 - 0.5^sqrt(estimate)) / (1 - 0.5^sqrt(1 / estimate))
}
if (estimate < 1) estimate <- 1 / estimate
estimate
}
evalue <- function(estimate, type = c("rr", "or", "hr")) {
# validate arguments
if (!is.numeric(estimate)) stop("`estimate` must be numeric")
type <- match.arg(type)
# calculate evalue
estimate <- transform_to_rr(estimate, type)
estimate + sqrt(estimate * (estimate - 1))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment