What was the most important thing you learned during this class?
What important question remains unanswered for you?
The mid-term exam has been posted to Blackboard.
Missing Data.
mice
(my preferred package) and Amelia
.The infer
package.
infer
package.Two scientists want to know if a certain drug is effective against high blood pressure. The first scientist wants to give the drug to 1,000 people with high blood pressure and see how many of them experience lower blood pressure levels. The second scientist wants to give the drug to 500 people with high blood pressure, and not give the drug to another 500 people with high blood pressure, and see how many in both groups experience lower blood pressure levels. Which is the better way to test this drug?
- 500 get the drug, 500 don't
The GSS asks the same question, below is the distribution of responses from the 2010 survey:
Response | n |
---|---|
All 1000 get the drug | 99 |
500 get the drug 500 don't | 571 |
Total | 670 |
Parameter of interest: Proportion of all Americans who have good intuition about experimental design.
p(populationproportion)
Point estimate: Proportion of sampled Americans who have good
intuition about experimental design.
ˆp(sampleproportion)
What percent of all Americans have good intuition about experimental design (i.e. would answer "500 get the drug 500 don't?"
Using a confidence interval pointestimate±ME
We know that ME = critical value x standard error of the point estimate. SEˆp=√p(1−p)n
Sample proportions will be nearly normally distributed with mean equal to the population mean, p, and standard error equal to √p(1−p)n.
ˆp∼N(mean=p,SE=√p(1−p)n)
This is true given the following conditions:
Given: n=670, ˆp=0.85.
Conditions:
Independence: The sample is random, and 670 < 10% of all Americans, therefore we can assume that one respondent's response is independent of another.
Success-failure: 571 people answered correctly (successes) and 99 answered incorrectly (failures), both are greater than 10.
Given: n=670, ˆp=0.85.
0.85±1.96√0.85×0.15670=(0.82,0.88)
We are 95% confidence the true proportion of Americans that have a good intuition about experimental designs is betwee 82% and 88%.
Suppose you want a 3% margin of error, how many people would you have to survey?
Use ˆp=0.5
0.03=1.96×√0.5×0.5n 0.032=1.962×0.5×0.5n n≈1,068
Scientists predict that global warming may have big effects on the polar regions within the next 100 years. One of the possible effects is that the northern ice cap may completely melt. Would this bother you a great deal, some, a little, or not at all if it actually happened?
Response | GSS | Duke |
---|---|---|
A great deal | 454 | 69 |
Some | 124 | 40 |
A little | 52 | 4 |
Not at all | 50 | 2 |
Total | 680 | 105 |
Parameter of interest: Difference between the proportions of all Duke students and all Americans who would be bothered a great deal by the northern ice cap completely melting.
pDuke−pUS
Point estimate: Difference between the proportions of sampled Duke students and sampled Americans who would be bothered a great deal by the northern ice cap completely melting.
ˆpDuke−ˆpUS
Standard error of the difference between two sample proportions
SEˆp1−ˆp2=√p1(1−p1)n1+p2(1−p2)n2
Conditions:
Construct a 95% confidence interval for the difference between the proportions of Duke students and Americans who would be bothered a great deal by the melting of the northern ice cap ( pDuke−pUS ).
Data | Duke | US |
---|---|---|
A great deal | 69 | 454 |
Not a great deal | 36 | 226 |
Total | 105 | 680 |
ˆp | 0.657 | 0.668 |
(ˆpDuke−ˆpUS)±z∗×√pDuke(1−pDuke)nDuke+pUS(1−pUS)nUS
(0.657−0.668)±1.96×√0.657×0.343105+0.668×0.332680=(−0.108,0.086)
Walter Frank Raphael Weldon (1860 - 1906), was an English evolutionary biologist and a founder of biometry. He was the joint founding editor of Biometrika, with Francis Galton and Karl Pearson.
In 1894, he rolled 12 dice 26,306 times, and recorded the number of 5s or 6s (which he considered to be a success).
In 2009, Zacariah Labby (U of Chicago), repeated Weldon’s experiment using a homemade dice-throwing, pip counting machine. http://www.youtube.com/watch?v=95EErdouO2w
The table below shows the observed and expected counts from Labby's experiment.
Outcome | Observed | Expected |
---|---|---|
1 | 53,222 | 52,612 |
2 | 52,118 | 52,612 |
3 | 52,465 | 52,612 |
4 | 52,338 | 52,612 |
5 | 52,244 | 52,612 |
6 | 53,285 | 52,612 |
Total | 315,672 | 315,672 |
Do these data provide convincing evidence of an inconsistency between the observed and expected counts?
H0: There is no inconsistency between the observed and the expected counts. The observed counts follow the same distribution as the expected counts.
HA: There is an inconsistency between the observed and the expected counts. The observed counts do not follow the same distribution as the expected counts. There is a bias in which side comes up on the roll of a die.
To evaluate these hypotheses, we quantify how different the observed counts are from the expected counts.
Large deviations from what would be expected based on sampling variation (chance) alone provide strong evidence for the alternative hypothesis.
This is called a goodness of fit test since we're evaluating how well the observed data fit the expected distribution.
point estimate−null valueSE of point estimate
This construction is based on
These two ideas will help in the construction of an appropriate test statistic for count data.
When dealing with counts and investigating how far the observed counts are from the expected counts, we use a new test statistic called the chi-square ( χ2 ) statistic.
χ2=k∑i=1(O−E)2E where k = total number of cells
Outcome | Observed | Expected | (O−E)2E |
---|---|---|---|
1 | 53,222 | 52,612 | (53,222−52,612)252,612=7.07 |
2 | 52,118 | 52,612 | (52,118−52,612)252,612=4.64 |
3 | 52,465 | 52,612 | (52,465−52,612)252,612=0.41 |
4 | 52,338 | 52,612 | (52,338−52,612)252,612=1.43 |
5 | 52,244 | 52,612 | (52,244−52,612)252,612=2.57 |
6 | 53,285 | 52,612 | (53,285−52,612)252,612=8.61 |
Total | 315,672 | 315,672 | 24.73 |
Squaring the difference between the observed and the expected outcome does two things:
In order to determine if the χ2 statistic we calculated is considered unusually high or not we need to first describe its distribution.
When conducting a goodness of fit test to evaluate how well the observed data follow an expected distribution, the degrees of freedom are calculated as the number of cells (k) minus 1.
df=k−1
For dice outcomes, k=6, therefore df=6−1=5
p-value = P(χ2df=5>24.67) is less than 0.001
The 1-6 axis is consistently shorter than the other two (2-5 and 3-4), thereby supporting the hypothesis that the faces with one and six pips are larger than the other faces.
Pearson's claim that 5s and 6s appear more often due to the carved-out pips is not supported by these data.
Dice used in casinos have flush faces, where the pips are filled in with a plastic of the same density as the surrounding material and are precisely balanced.
The p-value for a chi-square test is defined as the tail area above the calculated test statistic.
This is because the test statistic is always positive, and a higher test statistic means a stronger deviation from the null hypothesis.
Assume we have a population of 100,000 where groups A and B are independent with pA=.55 and pB=.6 and nA=99,000 (99% of the population) and nB=1,000 (1% of the population). We can sample from the population (that includes groups A and B) and from group B of sample sizes of 1,000 and 100, respectively. We can also calculate ˆp for group A independent of B.
propA <- .55 # Proportion for group ApropB <- .6 # Proportion for group Bpop.n <- 100000 # Population sizesampleA.n <- 1000sampleB.n <- 100
pop <- data.frame( group = c(rep('A', pop.n * 0.99), rep('B', pop.n * 0.01) ), response = c( sample(c(1,0), size = pop.n * 0.99, prob = c(propA, 1 - propA), replace = TRUE), sample(c(1,0), size = pop.n * 0.01, prob = c(propB, 1 - propB), replace = TRUE) ))sampA <- pop[sample(nrow(pop), size = sampleA.n),]sampB <- pop[sample(which(pop$group == 'B'), size = sampleB.n),]
ˆp for the population sample
mean(sampA$response)
## [1] 0.536
ˆp for the population sample, excluding group B
mean(sampA[sampA$group == 'A',]$response)
## [1] 0.5372984
ˆp for group B sample
mean(sampB$response)
## [1] 0.58
Complete the one minute paper: https://forms.gle/p9xcKcTbGiyYSz368
What was the most important thing you learned during this class?
What important question remains unanswered for you?
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 |