#' @title logistic.regression.or.ci
#' @description
#' This function takes the output from a glm
#' (logistic model) command in R and provides not
#' only the usual output from the summary command, but
#' adds confidence intervals for all coefficients and OR's.
#' This version accommodates multiple regression parameters
#'
#' @param regress.out logistic regression output
#' @param level level to test at, default is 0.95
#'
#' @export
logistic.regression.or.ci <- function(regress.out, level = 0.95) {
usual.output <- summary(regress.out)
z.quantile <- stats::qnorm(1 - (1 - level) / 2)
number.vars <- length(regress.out$coefficients)
OR <- exp(regress.out$coefficients[-1])
temp.store.result <- matrix(rep(NA, number.vars * 2), nrow = number.vars)
for (i in 1:number.vars) {
temp.store.result[i, ] <- summary(regress.out)$coefficients[i] +
c(-1, 1) * z.quantile * summary(regress.out)$coefficients[i + number.vars]
}
intercept.ci <- temp.store.result[1, ]
slopes.ci <- temp.store.result[-1, ]
OR.ci <- exp(slopes.ci)
output <- list(
regression.table = usual.output, intercept.ci = intercept.ci,
slopes.ci = slopes.ci, OR = OR, OR.ci = OR.ci
)
return(output)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.