# How do I obtain an odds ratio from logistic regression

LR1<-LRtest1$$LR1 > LR2<-LRtest1$$LR2

> plot(LR2, jitter(LR1, 0.15), pch = 19,
+ xlab = "Count", ylab = "LR1 (0 - Trach, 1 - Ntrach)")
> model <-glm(LR1~LR2, binomial)


Warning message: glm.fit: fitted probabilities numerically 0 or 1 occurred

> summary(model)

Call:
glm(formula = LR1 ~ LR2, family = binomial)

Deviance Residuals:
Min       1Q   Median       3Q      Max
-1.6579  -0.5952  -0.2976   0.2987   1.9068

Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept)  -1.6409     0.4734  -3.466 0.000528 ***
LR2           0.4539     0.1497   3.032 0.002429 **


Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

(Dispersion parameter for binomial family taken to be 1)

Null deviance: 83.178  on 59  degrees of freedom
Residual deviance: 46.705  on 58  degrees of freedom
AIC: 50.705

Number of Fisher Scoring iterations: 9

> xv <- seq(min(LR2), max(LR2),0.01)
> yv <- predict(model, list(LR2= xv), type = "response")
> lines(xv,yv,col= "red")
> summary(LRtest1)
LR1           LR2


Min. :0.0 Min. : 0.00
1st Qu.:0.0 1st Qu.: 0.00
Median :0.5 Median : 2.00
Mean :0.5 Mean : 14.77
3rd Qu.:1.0 3rd Qu.: 9.50
Max. :1.0 Max. :156.00

I am looking for a way to do the odds ratio. I tried EpiR and exec and both do not work. I also tried fisher's test it shows me the p-value only and does not even show the odds ratio.

• Your question is very difficult to read. Plesse format it properly. Also try exp(coef(mymodel)) Jul 27 '20 at 4:38
• It does not work >exp(coef(odds1)) Error in exp(coef(odds1)) : non-numeric argument to mathematical function In addition: Warning message: Unknown or uninitialised column: coefficients. Jul 27 '20 at 4:47
• But you didnt fix the formatting so it is almost impossible to help you. Also try exp(0.4539) Jul 27 '20 at 4:51
• Sorry. a bit new. Hopefully the picture clarifies it. If I do that it gives me one number, is this the odds ratio? It does not have a title so I am not sure: exp(0.4539) [1] 1.574441---- Also you do it this way exp(estimate #) so you will be using the estimate#? Jul 27 '20 at 4:58
• Please don't post a pictiure of your code and output - it is then impossible to copy parts from it !! Just copy the text and put  above and below it. Or if it's just a few lines, put 4 spaces in front of each line. The system will format it properly. The odds ratio for a categorical variable is just the exponentiated coefficient. Jul 27 '20 at 5:14

The odds ratio for LR2 is simply the exponentiated value of the estimate for it:
> exp(0.4539)
`