3
$\begingroup$
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

This is my code for logistic regression 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.

$\endgroup$
5
  • $\begingroup$ Your question is very difficult to read. Plesse format it properly. Also try exp(coef(mymodel)) $\endgroup$ Jul 27 '20 at 4:38
  • $\begingroup$ 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. $\endgroup$ Jul 27 '20 at 4:47
  • $\begingroup$ But you didnt fix the formatting so it is almost impossible to help you. Also try exp(0.4539) $\endgroup$ Jul 27 '20 at 4:51
  • $\begingroup$ 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#? $\endgroup$ Jul 27 '20 at 4:58
  • 1
    $\begingroup$ 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. $\endgroup$ Jul 27 '20 at 5:14
5
$\begingroup$

The odds ratio for LR2 is simply the exponentiated value of the estimate for it:

> exp(0.4539)
[1] 1.574441
$\endgroup$
1
  • $\begingroup$ Does this answer your question ? If so please consider marking it as the accepted answer. If not please let us know why so that it can be improved $\endgroup$ Aug 7 '20 at 5:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.