Finish last time’s slides
Paired Binary Data
Paired Binary Data
Imagine now that our two samples of Bernoulli populations aren’t independent, but paired in some way.
but are paired.
Examples:
- subjects with a disease, and without a disease are sampled then matched (based on demographic factors), response is presence of some risk factor
- Sibling (or twin) studies: pairs of related people where one falls in one group, and the other falls in the other group, observe some binary response on every person.
- Binary before and after measurements on the same person
Paired Binary Data
Gather sample of voters.
Before debate: Will you vote for candidate A?
After debate: Will you vote for candidate A?
subject | before | after |
---|---|---|
1 | 1 | 1 |
2 | 1 | 0 |
3 | 1 | 0 |
4 | 1 | 1 |
5 | 1 | 1 |
6 | 1 | 0 |
Just a table?
0 | 1 | |
---|---|---|
after | 21 | 19 |
before | 23 | 17 |
0 | 1 | |
---|---|---|
0 | 12 | 11 |
1 | 9 | 8 |
How to analyse?
Option 1: Treat like paired two sample data and do a paired t-test
Option 2: McNemar’s test
Paired t-test
Null hypothesis:
Look at (per voter) differences:
subject | before | after | diff |
---|---|---|---|
1 | 1 | 1 | 0 |
2 | 1 | 0 | -1 |
3 | 1 | 0 | -1 |
4 | 1 | 1 | 0 |
5 | 1 | 1 | 0 |
6 | 1 | 0 | -1 |
-1 | 0 | 1 |
---|---|---|
9 | 20 | 11 |
Paired t-test calculations
Paired t-test calculations
##
## One Sample t-test
##
## data: df$diff
## t = 0.4427, df = 39, p-value = 0.6604
## alternative hypothesis: true mean is not equal to 0
## 95 percent confidence interval:
## -0.1784514 0.2784514
## sample estimates:
## mean of x
## 0.05
McNemar’s test
Null hypothesis:
Conditions on the number of discordant pairs, .
0 | 1 | |
---|---|---|
0 | 12 | 11 |
1 | 9 | 8 |
Under Null hypothesis, we expect the number of discordant pairs (e.g. people who change their minds during debate) should be equally split between and .
McNemar’s test
Conditional on ,
Do, one sample Z-test for proportions, leads to (sometimes people square this statistic, and compare to )
Example: McNemar’s
0 | 1 | |
---|---|---|
0 | 12 | 11 |
1 | 9 | 8 |
Compare to N(0,1)
Final points
McNemar’s test is equivalent to the paired t-test, in the sense that the two test statistics are monotone transformations of each other.
For large sample sizes, the two test statistics get closer and closer to the same value: asymptotically equivalent.