Odds Ratios

Lucy D’Agostino McGowan

Odds ratios

A study investigated whether a handheld device that sends a magnetic pulse into a person’s head might be an effective treatment for migraine headaches.

  • Researchers recruited 200 subjects who suffered from migraines
  • randomly assigned them to receive either the TMS (transcranial magnetic stimulation) treatment or a placebo treatment
  • Subjects were instructed to apply the device at the onset of migraine symptoms and then assess how they felt two hours later. (either Pain-free or Not pain-free)

Odds ratios

What is the explanatory variable?

A study investigated whether a handheld device that sends a magnetic pulse into a person’s head might be an effective treatment for migraine headaches.

  • Researchers recruited 200 subjects who suffered from migraines
  • randomly assigned them to receive either the TMS (transcranial magnetic stimulation) treatment or a placebo treatment
  • Subjects were instructed to apply the device at the onset of migraine symptoms and then assess how they felt two hours later (either Pain-free or Not pain-free)

Odds ratios

What type of variable is this?

A study investigated whether a handheld device that sends a magnetic pulse into a person’s head might be an effective treatment for migraine headaches.

  • Researchers recruited 200 subjects who suffered from migraines
  • randomly assigned them to receive either the TMS (transcranial magnetic stimulation) treatment or a placebo treatment
  • Subjects were instructed to apply the device at the onset of migraine symptoms and then assess how they felt two hours later (either Pain-free or Not pain-free)

Odds ratios

What is the outcome variable?

A study investigated whether a handheld device that sends a magnetic pulse into a person’s head might be an effective treatment for migraine headaches.

  • Researchers recruited 200 subjects who suffered from migraines
  • randomly assigned them to receive either the TMS (transcranial magnetic stimulation) treatment or a placebo treatment
  • Subjects were instructed to apply the device at the onset of migraine symptoms and then assess how they felt two hours later (either Pain-free or Not pain-free)

Odds ratios

What type of variable is this?

A study investigated whether a handheld device that sends a magnetic pulse into a person’s head might be an effective treatment for migraine headaches.

  • Researchers recruited 200 subjects who suffered from migraines
  • randomly assigned them to receive either the TMS (transcranial magnetic stimulation) treatment or a placebo treatment
  • Subjects were instructed to apply the device at the onset of migraine symptoms and then assess how they felt two hours later (either Pain-free or Not pain-free)

Odds ratios

__ TMS Placebo Total
Pain-free two hours later 39 22 61
Not pain-free two hours later 61 78 139
Total 100 100 200
  • We can compare the results using odds
  • What are the odds of being pain-free for the placebo group?
    • \((22/100)/(78/100) = 22/78 = 0.282\)
  • What are the odds of being pain-free for the treatment group?
    • \(39/61 = 0.639\)
  • Comparing the odds what can we conclude?
    • TMS increases the likelihood of success

Odds ratios

__ TMS Placebo Total
Pain-free two hours later 39 22 61
Not pain-free two hours later 61 78 139
Total 100 100 200
  • We can summarize this relationship with an odds ratio: the ratio of the two odds

\(OR = \frac{39/61}{22/78} = \frac{0.639}{0.282} = 2.27\)

“the odds of being pain free were 2.27 times higher with TMS than with the placebo”

Odds ratios

What if we wanted to calculate this in terms of Not pain-free (with pain-free) as the referent?

__ TMS Placebo Total
Pain-free two hours later 39 22 61
Not pain-free two hours later 61 78 139
Total 100 100 200

\(OR = \frac{61/39}{78/22} = \frac{1.564}{3.545} = 0.441\)

the odds for still being in pain for the TMS group are 0.441 times the odds of being in pain for the placebo group

Odds ratios

What changed here?

__ TMS Placebo Total
Pain-free two hours later 39 22 61
Not pain-free two hours later 61 78 139
Total 100 100 200

\(OR = \frac{78/22}{61/39} = \frac{3.545}{1.564} = 2.27\)

the odds for still being in pain for the placebo group are 2.27 times the odds of being in pain for the TMS group

Odds ratios

  • In general, it’s more natural to interpret odds ratios > 1, you can flip the referent to do so
__ TMS Placebo Total
Pain-free two hours later 39 22 61
Not pain-free two hours later 61 78 139
Total 100 100 200

\(OR = \frac{78/22}{61/39} = \frac{3.545}{1.564} = 2.27\)

the odds for still being in pain for the placebo group are 2.27 times the odds of being in pain for the TMS group

Odds ratios

  • Let’s look at some Titanic data. We are interested in whether being female is related to whether they survived.
__ Female Male Total
Survived 308 142 450
Died 154 709 863
Total 462 851 1313

Odds ratios

What are the odds of surviving for females versus males?

  • Let’s look at some Titanic data. We are interested in whether being female is related to whether they survived.
____ Female Male Total
Survived 308 142 450
Died 154 709 863
Total 462 851 1313

\[OR = \frac{308/154}{142/709} = \frac{2}{0.2} = 9.99\]

Odds ratios

How do you interpret this?

___ Female Male Total
Survived 308 142 450
Died 154 709 863
Total 462 851 1313

\[OR = \frac{308/154}{142/709} = \frac{2}{0.2} = 9.99\]

the odds of surviving for the female passengers was 9.99 times the odds of surviving for the male passengers

Odds ratios

What if we wanted to fit a model? What would the equation be?

__ Female Male Total
Survived 308 142 450
Died 154 709 863
Total 462 851 1313

\[\log(\textrm{odds of survival}) = \hat\beta_0 + \hat\beta_1 \textrm{Female}\]

Odds ratios

\[\log(\textrm{odds of survival}) = \hat\beta_0 + \hat\beta_1 \textrm{Male}\]

glm(Survived ~ Sex, data = Titanic, family = binomial)

Call:  glm(formula = Survived ~ Sex, family = binomial, data = Titanic)

Coefficients:
(Intercept)      Sexmale  
      0.693       -2.301  

Degrees of Freedom: 1312 Total (i.e. Null);  1311 Residual
Null Deviance:      1690 
Residual Deviance: 1360     AIC: 1360

Odds Ratios

What is my referent category?

\[\log(\textrm{odds of survival}) = \hat\beta_0 + \hat\beta_1 \textrm{Male}\]

levels(Titanic$Sex)
[1] "female" "male"  

Odds Ratios

How do I change that?

\[\log(\textrm{odds of survival}) = \hat\beta_0 + \hat\beta_1 \textrm{Male}\]

Titanic <- Titanic |>
  (Sex = ---(Sex, c("male", "female"))) 

Odds Ratios

How do I change that?

\[\log(\textrm{odds of survival}) = \aht\beta_0 + \hat\beta_1 \textrm{Female}\]

Titanic <- Titanic |>
  mutate(Sex = fct_relevel(Sex, c("male", "female"))) 

Odds Ratios

How do you interpret this result?

model <- glm(Survived ~ Sex, data = Titanic, family = binomial)
summary(model)

Call:
glm(formula = Survived ~ Sex, family = binomial, data = Titanic)

Deviance Residuals: 
   Min      1Q  Median      3Q     Max  
-1.482  -0.604  -0.604   0.900   1.892  

Coefficients:
            Estimate Std. Error z value Pr(>|z|)    
(Intercept)  -1.6080     0.0919   -17.5   <2e-16 ***
Sexfemale     2.3012     0.1349    17.1   <2e-16 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

(Dispersion parameter for binomial family taken to be 1)

    Null deviance: 1688.1  on 1312  degrees of freedom
Residual deviance: 1355.5  on 1311  degrees of freedom
AIC: 1360

Number of Fisher Scoring iterations: 4

Odds Ratios

How do you interpret this result?

Code
glm(Survived ~ Sex, data = Titanic, family = binomial) |>
  summary()

Call:
glm(formula = Survived ~ Sex, family = binomial, data = Titanic)

Deviance Residuals: 
   Min      1Q  Median      3Q     Max  
-1.482  -0.604  -0.604   0.900   1.892  

Coefficients:
            Estimate Std. Error z value Pr(>|z|)    
(Intercept)  -1.6080     0.0919   -17.5   <2e-16 ***
Sexfemale     2.3012     0.1349    17.1   <2e-16 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

(Dispersion parameter for binomial family taken to be 1)

    Null deviance: 1688.1  on 1312  degrees of freedom
Residual deviance: 1355.5  on 1311  degrees of freedom
AIC: 1360

Number of Fisher Scoring iterations: 4
Code
exp(2.301176)
[1] 9.99

the odds of surviving for the female passengers was 9.99 times the odds of surviving for the male passengers

Odds ratios

  • What if the explanatory variable is continuous?
  • We did this already!
Code
data("MedGPA")
glm(Acceptance ~ GPA, data = MedGPA, family = binomial) |>
  summary()

Call:
glm(formula = Acceptance ~ GPA, family = binomial, data = MedGPA)

Deviance Residuals: 
   Min      1Q  Median      3Q     Max  
-1.780  -0.852   0.441   0.782   2.097  

Coefficients:
            Estimate Std. Error z value Pr(>|z|)    
(Intercept)   -19.21       5.63   -3.41  0.00064 ***
GPA             5.45       1.58    3.45  0.00055 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

(Dispersion parameter for binomial family taken to be 1)

    Null deviance: 75.791  on 54  degrees of freedom
Residual deviance: 56.839  on 53  degrees of freedom
AIC: 60.84

Number of Fisher Scoring iterations: 4

A one unit increase in GPA yields a 5.45 increase in the log odds of acceptance

Odds ratios

  • What if the explanatory variable is continuous?
  • We did this already!
Code
data("MedGPA")
glm(Acceptance ~ GPA, data = MedGPA, family = binomial) |>
  summary()

Call:
glm(formula = Acceptance ~ GPA, family = binomial, data = MedGPA)

Deviance Residuals: 
   Min      1Q  Median      3Q     Max  
-1.780  -0.852   0.441   0.782   2.097  

Coefficients:
            Estimate Std. Error z value Pr(>|z|)    
(Intercept)   -19.21       5.63   -3.41  0.00064 ***
GPA             5.45       1.58    3.45  0.00055 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

(Dispersion parameter for binomial family taken to be 1)

    Null deviance: 75.791  on 54  degrees of freedom
Residual deviance: 56.839  on 53  degrees of freedom
AIC: 60.84

Number of Fisher Scoring iterations: 4
  • A one unit increase in GPA yields a 234-fold increase in the odds of acceptance
  • 😱 that seems huge! Remember: the interpretation of these coefficients depends on your units (the same as in ordinary linear regression).

Odds ratios

How could we get the odds associated with increasing GPA by 0.1?

Code
glm(Acceptance ~ GPA, data = MedGPA, family = binomial) |>
  summary()

Call:
glm(formula = Acceptance ~ GPA, family = binomial, data = MedGPA)

Deviance Residuals: 
   Min      1Q  Median      3Q     Max  
-1.780  -0.852   0.441   0.782   2.097  

Coefficients:
            Estimate Std. Error z value Pr(>|z|)    
(Intercept)   -19.21       5.63   -3.41  0.00064 ***
GPA             5.45       1.58    3.45  0.00055 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

(Dispersion parameter for binomial family taken to be 1)

    Null deviance: 75.791  on 54  degrees of freedom
Residual deviance: 56.839  on 53  degrees of freedom
AIC: 60.84

Number of Fisher Scoring iterations: 4
Code
exp(5.454) ## a one unit increase in GPA
[1] 234
Code
exp(5.454 * 0.1) ## a 0.1 increase in GPA
[1] 1.73

A one-tenth unit increase in GPA yields a 1.73-fold increase in the odds of acceptance

Odds ratios

How could we get the odds associated with increasing GPA by 0.1?

MedGPA <- MedGPA |>
  mutate(GPA_10 = GPA * 10)

glm(Acceptance ~ GPA_10, data = MedGPA, family = binomial) |>
  summary()

Call:
glm(formula = Acceptance ~ GPA_10, family = binomial, data = MedGPA)

Deviance Residuals: 
   Min      1Q  Median      3Q     Max  
-1.780  -0.852   0.441   0.782   2.097  

Coefficients:
            Estimate Std. Error z value Pr(>|z|)    
(Intercept)  -19.207      5.629   -3.41  0.00064 ***
GPA_10         0.545      0.158    3.45  0.00055 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

(Dispersion parameter for binomial family taken to be 1)

    Null deviance: 75.791  on 54  degrees of freedom
Residual deviance: 56.839  on 53  degrees of freedom
AIC: 60.84

Number of Fisher Scoring iterations: 4

A one-tenth unit increase in GPA yields a 1.73-fold increase in the odds of acceptance