logistic.regression.or.ci <- function(regress.out, level=0.95) { ################################################################ # # # 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 # # # ################################################################ usual.output <- summary(regress.out) z.quantile <- 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) }