+ - 0:00:00
Notes for current slide
Notes for next slide

Odds Ratios

1 / 27

Odds ratios

  • Go to RStudio Cloud and open Odds ratios
2 / 27

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)
3 / 27

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)
4 / 27

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)
5 / 27

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)
6 / 27

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)
7 / 27

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
8 / 27

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
8 / 27

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?
8 / 27

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
8 / 27

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?
8 / 27

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
8 / 27

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?
8 / 27

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
8 / 27

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
9 / 27

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=39/6122/78=0.6390.282=2.27

9 / 27

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=39/6122/78=0.6390.282=2.27

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

9 / 27

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
10 / 27

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=61/3978/22=1.5643.545=0.441

10 / 27

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=61/3978/22=1.5643.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

10 / 27

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=78/2261/39=3.5451.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

11 / 27

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=78/2261/39=3.5451.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

12 / 27

Odds ratios

  • Go to RStudio Cloud and open Odds ratios
13 / 27

Odds ratios

  • Let's look at some Titanic data. We are interested in whether the sex of the passenger is related to whether they survived.
Female Male Total
Survived 308 142 450
Died 154 709 863
Total 462 851 1313
14 / 27

Odds ratios

What are the odds of surviving for females versus males?

  • Let's look at some Titanic data. We are interested in whether the sex of the passenger is related to whether they survived.
Female Male Total
Survived 308 142 450
Died 154 709 863
Total 462 851 1313
15 / 27

Odds ratios

What are the odds of surviving for females versus males?

  • Let's look at some Titanic data. We are interested in whether the sex of the passenger is related to whether they survived.
Female Male Total
Survived 308 142 450
Died 154 709 863
Total 462 851 1313

OR=308/154142/709=20.2=9.99

15 / 27

Odds ratios

How do you interpret this?

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

OR=308/154142/709=20.2=9.99

16 / 27

Odds ratios

How do you interpret this?

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

OR=308/154142/709=20.2=9.99

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

16 / 27

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
17 / 27

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(odds of survival)β0+β1Sex

17 / 27

Odds ratios

log(odds of survival)β0+β1Sex

glm(Survived ~ Sex, data = Titanic, family = binomial) %>%
tidy()
## # A tibble: 2 x 5
## term estimate std.error statistic p.value
## <chr> <dbl> <dbl> <dbl> <dbl>
## 1 (Intercept) 0.693 0.0987 7.02 2.17e-12
## 2 Sexmale -2.30 0.135 -17.1 2.91e-65
18 / 27

Odds Ratios

What is my referent category?

log(odds of survival)β0+β1Sex

levels(Titanic$Sex)
## [1] "female" "male"
19 / 27

Odds Ratios

How do I change that?

log(odds of survival)β0+β1Sex

Titanic <- Titanic %>%
---(Sex = ---(Sex, c("male", "female")))
20 / 27

Odds Ratios

How do I change that?

log(odds of survival)β0+β1Sex

Titanic <- Titanic %>%
mutate(Sex = fct_relevel(Sex, c("male", "female")))
21 / 27

Odds Ratios

How do you interpret this result?

glm(Survived ~ Sex, data = Titanic, family = binomial) %>%
tidy()
## # A tibble: 2 x 5
## term estimate std.error statistic p.value
## <chr> <dbl> <dbl> <dbl> <dbl>
## 1 (Intercept) -1.61 0.0919 -17.5 1.70e-68
## 2 Sexfemale 2.30 0.135 17.1 2.91e-65
22 / 27

Odds Ratios

How do you interpret this result?

glm(Survived ~ Sex, data = Titanic, family = binomial) %>%
tidy(exponentiate = TRUE)
## # A tibble: 2 x 5
## term estimate std.error statistic p.value
## <chr> <dbl> <dbl> <dbl> <dbl>
## 1 (Intercept) 0.200 0.0919 -17.5 1.70e-68
## 2 Sexfemale 9.99 0.135 17.1 2.91e-65
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

23 / 27

Odds ratios

  • What if the explanatory variable is continuous?
24 / 27

Odds ratios

  • What if the explanatory variable is continuous?
  • We did this already on Tuesday!
24 / 27

Odds ratios

  • What if the explanatory variable is continuous?
  • We did this already on Tuesday!
data("MedGPA")
glm(Acceptance ~ GPA, data = MedGPA, family = binomial) %>%
tidy()
## # A tibble: 2 x 5
## term estimate std.error statistic p.value
## <chr> <dbl> <dbl> <dbl> <dbl>
## 1 (Intercept) -19.2 5.63 -3.41 0.000644
## 2 GPA 5.45 1.58 3.45 0.000553
24 / 27

Odds ratios

  • What if the explanatory variable is continuous?
  • We did this already on Tuesday!
data("MedGPA")
glm(Acceptance ~ GPA, data = MedGPA, family = binomial) %>%
tidy()
## # A tibble: 2 x 5
## term estimate std.error statistic p.value
## <chr> <dbl> <dbl> <dbl> <dbl>
## 1 (Intercept) -19.2 5.63 -3.41 0.000644
## 2 GPA 5.45 1.58 3.45 0.000553

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

24 / 27

Odds ratios

  • What if the explanatory variable is continuous?
  • We did this already on Tuesday!
data("MedGPA")
glm(Acceptance ~ GPA, data = MedGPA, family = binomial) %>%
tidy(exponentiate = TRUE)
## # A tibble: 2 x 5
## term estimate std.error statistic p.value
## <chr> <dbl> <dbl> <dbl> <dbl>
## 1 (Intercept) 4.56e-9 5.63 -3.41 0.000644
## 2 GPA 2.34e+2 1.58 3.45 0.000553
25 / 27

Odds ratios

  • What if the explanatory variable is continuous?
  • We did this already on Tuesday!
data("MedGPA")
glm(Acceptance ~ GPA, data = MedGPA, family = binomial) %>%
tidy(exponentiate = TRUE)
## # A tibble: 2 x 5
## term estimate std.error statistic p.value
## <chr> <dbl> <dbl> <dbl> <dbl>
## 1 (Intercept) 4.56e-9 5.63 -3.41 0.000644
## 2 GPA 2.34e+2 1.58 3.45 0.000553

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

25 / 27

Odds ratios

  • What if the explanatory variable is continuous?
  • We did this already on Tuesday!
data("MedGPA")
glm(Acceptance ~ GPA, data = MedGPA, family = binomial) %>%
tidy(exponentiate = TRUE)
## # A tibble: 2 x 5
## term estimate std.error statistic p.value
## <chr> <dbl> <dbl> <dbl> <dbl>
## 1 (Intercept) 4.56e-9 5.63 -3.41 0.000644
## 2 GPA 2.34e+2 1.58 3.45 0.000553

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).
25 / 27

Odds ratios

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

glm(Acceptance ~ GPA, data = MedGPA, family = binomial) %>%
tidy()
## # A tibble: 2 x 5
## term estimate std.error statistic p.value
## <chr> <dbl> <dbl> <dbl> <dbl>
## 1 (Intercept) -19.2 5.63 -3.41 0.000644
## 2 GPA 5.45 1.58 3.45 0.000553
26 / 27

Odds ratios

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

glm(Acceptance ~ GPA, data = MedGPA, family = binomial) %>%
tidy()
## # A tibble: 2 x 5
## term estimate std.error statistic p.value
## <chr> <dbl> <dbl> <dbl> <dbl>
## 1 (Intercept) -19.2 5.63 -3.41 0.000644
## 2 GPA 5.45 1.58 3.45 0.000553
exp(5.454) ## a one unit increase in GPA
## [1] 234
exp(5.454 * 0.1) ## a 0.1 increase in GPA
## [1] 1.73
26 / 27

Odds ratios

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

glm(Acceptance ~ GPA, data = MedGPA, family = binomial) %>%
tidy()
## # A tibble: 2 x 5
## term estimate std.error statistic p.value
## <chr> <dbl> <dbl> <dbl> <dbl>
## 1 (Intercept) -19.2 5.63 -3.41 0.000644
## 2 GPA 5.45 1.58 3.45 0.000553
exp(5.454) ## a one unit increase in GPA
## [1] 234
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

26 / 27

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) %>%
tidy(exponentiate = TRUE)
## # A tibble: 2 x 5
## term estimate std.error statistic p.value
## <chr> <dbl> <dbl> <dbl> <dbl>
## 1 (Intercept) 0.00000000456 5.63 -3.41 0.000644
## 2 GPA_10 1.73 0.158 3.45 0.000553

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

27 / 27

Odds ratios

  • Go to RStudio Cloud and open Odds ratios
2 / 27
Paused

Help

Keyboard shortcuts

, , Pg Up, k Go to previous slide
, , Pg Dn, Space, j Go to next slide
Home Go to first slide
End Go to last slide
Number + Return Go to specific slide
b / m / f Toggle blackout / mirrored / fullscreen mode
c Clone slideshow
p Toggle presenter mode
t Restart the presentation timer
?, h Toggle this help
Esc Back to slideshow