Search code examples
rlogistic-regression

Convert logit coefficient confidence interval to odds ratio in R


I've run a simple logit model in another program, and brought over the resulting coefficient and CI into R to plot.

To convert the logit into an odds ratio, I think I need to use d$oddsratio <- exp(d$logitcoef)/(1+exp(d$logitcoef)). But how would I then go about calculating the confidence interval for the odds ratio as well?


Solution

  • This is pretty common practice in epidemiological circles and accordingly there is a package for that!

    install.packages("epiDisplay")
    library(epiDisplay)
    
    glm_mod <- glm(c1~c2 +c3, family=binomial, data=df) #whatever you are running
    logistic.display(glm_mod) 
    

    The output will be a set of odds ratios and confidence intervals including Wald's Tests and P-Values for each of your included variables and interactions.

    It is pretty straight forward.