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

Two-sample inference

Part 2

Prof. Maria Tackett

1

Is yawning contagious?

Do you think yawning is contagious?

3

Is yawning contagious?

An experiment conducted by the MythBusters tested if a person can be subconsciously influenced into yawning if another person near them yawns.

4

Study description

In this study 50 people were randomly assigned to two groups: 34 to a group where a person near them yawned (treatment) and 16 to a control group where they didn't see someone yawn (control).

5

Study description

In this study 50 people were randomly assigned to two groups: 34 to a group where a person near them yawned (treatment) and 16 to a control group where they didn't see someone yawn (control).

yawn %>% #in the openintro package
count(group, result)
## # A tibble: 4 x 3
## group result n
## <fct> <fct> <int>
## 1 ctrl not yawn 12
## 2 ctrl yawn 4
## 3 trmt not yawn 24
## 4 trmt yawn 10
5

Proportion of yawners

yawn %>%
count(group, result) %>%
group_by(group) %>%
mutate(p_hat = n / sum(n))
## # A tibble: 4 x 4
## # Groups: group [2]
## group result n p_hat
## <fct> <fct> <int> <dbl>
## 1 ctrl not yawn 12 0.75
## 2 ctrl yawn 4 0.25
## 3 trmt not yawn 24 0.706
## 4 trmt yawn 10 0.294
6

Proportion of yawners

yawn %>%
count(group, result) %>%
group_by(group) %>%
mutate(p_hat = n / sum(n))
## # A tibble: 4 x 4
## # Groups: group [2]
## group result n p_hat
## <fct> <fct> <int> <dbl>
## 1 ctrl not yawn 12 0.75
## 2 ctrl yawn 4 0.25
## 3 trmt not yawn 24 0.706
## 4 trmt yawn 10 0.294
  • Proportion of yawners in the treatment group: 1034=0.2941
6

Proportion of yawners

yawn %>%
count(group, result) %>%
group_by(group) %>%
mutate(p_hat = n / sum(n))
## # A tibble: 4 x 4
## # Groups: group [2]
## group result n p_hat
## <fct> <fct> <int> <dbl>
## 1 ctrl not yawn 12 0.75
## 2 ctrl yawn 4 0.25
## 3 trmt not yawn 24 0.706
## 4 trmt yawn 10 0.294
  • Proportion of yawners in the treatment group: 1034=0.2941
  • Proportion of yawners in the control group: 416=0.25
6

Proportion of yawners

yawn %>%
count(group, result) %>%
group_by(group) %>%
mutate(p_hat = n / sum(n))
## # A tibble: 4 x 4
## # Groups: group [2]
## group result n p_hat
## <fct> <fct> <int> <dbl>
## 1 ctrl not yawn 12 0.75
## 2 ctrl yawn 4 0.25
## 3 trmt not yawn 24 0.706
## 4 trmt yawn 10 0.294
  • Proportion of yawners in the treatment group: 1034=0.2941
  • Proportion of yawners in the control group: 416=0.25

  • Difference: 0.29410.25=0.0441

6

Independence?

Based on the proportions we calculated, do you think yawning is really contagious, i.e. are people who see someone yawn more likely to yawn themselves?

## # A tibble: 4 x 4
## # Groups: group [2]
## group result n p_hat
## <fct> <fct> <int> <dbl>
## 1 ctrl not yawn 12 0.75
## 2 ctrl yawn 4 0.25
## 3 trmt not yawn 24 0.706
## 4 trmt yawn 10 0.294
7

Dependence, or another possible explanation?

  • The observed differences might suggest that yawning is contagious, i.e. seeing someone yawn and yawning are dependent.
8

Dependence, or another possible explanation?

  • The observed differences might suggest that yawning is contagious, i.e. seeing someone yawn and yawning are dependent.

  • But the differences are small enough that we might wonder if they might simple be due to chance.

8

Dependence, or another possible explanation?

  • The observed differences might suggest that yawning is contagious, i.e. seeing someone yawn and yawning are dependent.

  • But the differences are small enough that we might wonder if they might simple be due to chance.

  • Perhaps if we were to repeat the experiment, we would see slightly different results.

8

Dependence, or another possible explanation?

  • The observed differences might suggest that yawning is contagious, i.e. seeing someone yawn and yawning are dependent.

  • But the differences are small enough that we might wonder if they might simple be due to chance.

  • Perhaps if we were to repeat the experiment, we would see slightly different results.

  • So we will do just that - well, somewhat - and see what happens.

8

Dependence, or another possible explanation?

  • The observed differences might suggest that yawning is contagious, i.e. seeing someone yawn and yawning are dependent.

  • But the differences are small enough that we might wonder if they might simple be due to chance.

  • Perhaps if we were to repeat the experiment, we would see slightly different results.

  • So we will do just that - well, somewhat - and see what happens.

  • Instead of actually conducting the experiment many times, we will simulate our results.

8

Two competing claims

9

Two competing claims

  • "There is nothing going on." Yawning and seeing someone yawn are independent, yawning is not contagious, observed difference in proportions is simply due to chance. Null hypothesis
9

Two competing claims

  • "There is nothing going on." Yawning and seeing someone yawn are independent, yawning is not contagious, observed difference in proportions is simply due to chance. Null hypothesis

  • "There is something going on." Yawning and seeing someone yawn are dependent, yawning is contagious (i.e., seeing someone yawn makes you more likely to yawn), and observed difference in proportions is not due to chance. Alternative hypothesis

9

Two competing claims

  • "There is nothing going on." Yawning and seeing someone yawn are independent, yawning is not contagious, observed difference in proportions is simply due to chance. Null hypothesis

  • "There is something going on." Yawning and seeing someone yawn are dependent, yawning is contagious (i.e., seeing someone yawn makes you more likely to yawn), and observed difference in proportions is not due to chance. Alternative hypothesis

H0:pt=pcHa:pt>pc

9

Let's simulate the null distribution...

set.seed(102020)
null_dist <- yawn %>%
specify(result ~ group, success = "yawn") %>%
hypothesize(null = "independence") %>%
generate(reps = 1000, type = "permute") %>%
calculate(stat = "diff in props", order = c("trmt", "ctrl"))
10

Let's simulate the null distribution...

set.seed(102020)
null_dist <- yawn %>%
specify(result ~ group, success = "yawn") %>%
hypothesize(null = "independence") %>%
generate(reps = 1000, type = "permute") %>%
calculate(stat = "diff in props", order = c("trmt", "ctrl"))
11

Let's simulate the null distribution...

set.seed(102020)
null_dist <- yawn %>%
specify(result ~ group, success = "yawn") %>%
hypothesize(null = "independence") %>%
generate(reps = 1000, type = "permute") %>%
calculate(stat = "diff in props", order = c("trmt", "ctrl"))
12

Let's simulate the null distribution...

set.seed(102020)
null_dist <- yawn %>%
specify(result ~ group, success = "yawn") %>%
hypothesize(null = "independence") %>%
generate(reps = 1000, type = "permute") %>%
calculate(stat = "diff in props", order = c("trmt", "ctrl"))
13

Let's simulate the null distribution...

set.seed(102020)
null_dist <- yawn %>%
specify(result ~ group, success = "yawn") %>%
hypothesize(null = "independence") %>%
generate(reps = 1000, type = "permute") %>%
calculate(stat = "diff in props", order = c("trmt", "ctrl"))
14

Let's simulate the null distribution...

set.seed(102020)
null_dist <- yawn %>%
specify(result ~ group, success = "yawn") %>%
hypothesize(null = "independence") %>%
generate(reps = 1000, type = "permute") %>%
calculate(stat = "diff in props", order = c("trmt", "ctrl"))
15

Permuting yawn data

Remember, under H0, there is no association between yawning and seeing someone else yawn (i.e. control vs. treatment group.)

16

Permuting yawn data

Remember, under H0, there is no association between yawning and seeing someone else yawn (i.e. control vs. treatment group.)

If there truly is no association, then shuffling whether someone was in the control or treatment group wouldn't matter -- we would expect similar proportions of people who yawn in each experimental group.

16

Permuting yawn data

Remember, under H0, there is no association between yawning and seeing someone else yawn (i.e. control vs. treatment group.)

If there truly is no association, then shuffling whether someone was in the control or treatment group wouldn't matter -- we would expect similar proportions of people who yawn in each experimental group.

We will do this shuffling again and again, calculate the difference in proportion for each simulation, and use this as an approximation to the null distribution.

16

Permuting yawn data

This distribution approximates all the possible differences in proportion we could have seen if H0 were in fact true.

17

Permuting yawn data

This distribution approximates all the possible differences in proportion we could have seen if H0 were in fact true.

We then use this distribution to obtain the probability that we see our observed data (or more extreme) -- the p-value.

17

Permuting yawn data

This distribution approximates all the possible differences in proportion we could have seen if H0 were in fact true.

We then use this distribution to obtain the probability that we see our observed data (or more extreme) -- the p-value.

Here we sample without replacement; we merely permute the treatment labels of each of our outcomes.

17

Visualizing the null distribution

What would you expect the center of the null distribution to be?

18

Visualizing the null distribution

What would you expect the center of the null distribution to be?

18

Calculating the p-value

null_dist %>%
filter(stat >= 0.0441) %>%
summarise(p_value = n()/nrow(null_dist))
## # A tibble: 1 x 1
## p_value
## <dbl>
## 1 0.505
19

Conclusion

What is the conclusion of the hypothesis test? Do you "buy" this conclusion?


20

Conclusion

What is the conclusion of the hypothesis test? Do you "buy" this conclusion?


We will manually run the permutation simulation in the live lecture session.

20
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