Week13slides

advertisement
STT 200 – LECTURE 5, SECTION 23,24
RECITATION 13
(4/9/2013)
TA: Zhen Zhang
zhangz19@stt.msu.edu
Office hour: (C500 WH) 3-4 PM Tuesday
(office tel.: 432-3342)
Help-room: (A102 WH) 9:00AM-1:00PM, Monday
1
Class meet on Tuesday:
12:40 – 1:30PM A224 WH, Section 23
1:50 – 2:40PM A234 WH, Section 24
Example (sampling distribution and confidence interval)
ο‚—
Recall that the data we have last time contain “yes/no” responses from a
population of 400 persons who were asked if they have wireless internet access
at home. The population proportion of “yes” 𝑝 is 0.5575.
ο‚—
We draw many random samples
with size n, the sampling distribution
of 𝑝 can be approximated by
𝑝 ~ 𝑁 𝑝,
𝑝(1−𝑝)
𝑛
If we really don’t know 𝑝, we draw sample
with size n, obtain 𝑝 and construct
95% confidence interval using 𝑝
± 𝑧∗
𝑝(1−𝑝)
.
𝑛
p = 0.5575
0.3
0.4
0.5
0.6
0.7
0.8
^
p
0.6
0.8
We are 95% confident that 𝑝 is between it.
2
0.4
ο‚—
0.2

 Example
ο‚—
ο‚—
(hypothesis testing)
What if we have certain hypothesis on 𝑝, and want to test it?
For instance, a survey in 2011 suggests that only 40% residents in this
region have wireless internet access at their house. We want to test if
this is true in the data we collected in 2012, or if there is a noticeable
increment. That is: 𝐻0 : 𝑝 = 0.4 versus 𝐻𝐴 : 𝑝 > 0.4.
ο‚—
We decide to draw a sample with size n = 37 to conduct the
proportion test.
ο‚—
… But before that, we need to check several conditions.
3
 Example
(check conditions)
To validate the proportion test, we need to check several conditions
once we determine the sample size n:
οƒ˜
Independence condition: the n = 37 responses in the sample are
chosen independently.
οƒ˜
Randomness condition: the n = 37 responses in the sample are
chosen randomly. We used the table of random digits from 1 to 400.
οƒ˜
10% condition: the sample size n = 37 is less than 10% of the
population size 400.
οƒ˜
Success/failure condition: Both n𝑝 = 37 0.4 =14.8 and nπ‘ž = 37(1
4
 Example
(hypothesis testing, continued)
ο‚—
To test: 𝐻0 : 𝑝 = 0.4 versus 𝐻𝐴 : 𝑝 > 0.4.
ο‚—
We draw a sample with size n = 37, and obtain 𝑝 = 0.5676. If 𝐻0 is
true, that is, 𝑝 = 0.4, then 𝑆𝐷 𝑝 =
=
𝑝−𝑝
0.5676−0.4
=
= 2.08
𝑆𝐷 𝑝
0.081
2.08, 99 , 0, 1 = 0.0187.
and the z-score z =
= normal𝑐𝑑𝑓
𝑝(1−𝑝)
𝑛
0.4(1−0.4)
37
= 0.081,
with P-value P z > 2.08
ο‚—
Which means if really 𝑝 = 0.4, then an observed proportion as large as
0.5676 would occur at random only 19 times in 1000. With a P-value
this small, we reject 𝐻0 and conclude 𝑝 > 0.4.
ο‚—
What if the hypotheses were: 𝐻0 : 𝑝 = 0.4 versus 𝐻𝐴 : 𝑝 ≠ 0.4?
This becomes two-sided, and P-value becomes 2P z > 2.08
= 0.0374. and we will still reject 𝐻0 if our significance level is 𝛼
= 0.05.
ο‚—
5
 Interaction
with confidence interval
We can also construct the confidence interval for 𝑝 given significance level 𝛼 :
οƒ˜
Determine confidence level C. For two-sided test (𝐻𝐴 : 𝑝 ≠ 0.4), C = 1 − 𝛼;
For one-sided test (𝐻𝐴 : 𝑝 > 0.4 or 𝐻𝐴 : 𝑝 < 0.4 ), C = 1 − 2𝛼.
οƒ˜
The critical value 𝑧 ∗ , either using Normal table, or qnorm((C+1)/2) in R, or
invNorm((C+1)/2) in calculator.
𝑝(1−𝑝)
.
𝑛
Note we use 𝑝, not 𝑝, since it is 𝑆𝐸 , not 𝑆𝐷 .
οƒ˜
Find 𝑆𝐸 𝑝 =
οƒ˜
The margin of error is 𝑀𝐸 = 𝑧 ∗ 𝑆𝐸 𝑝 = 𝑧 ∗
οƒ˜
The confidence interval is 𝑝 ± 𝑀𝐸 = (𝑝 − 𝑀𝐸, 𝑝 + 𝑀𝐸), and check that
𝑝(1−𝑝)
𝑛
whether 𝑝 is contained in this interval.
οƒ˜
In our example for 𝐻0 : 𝑝 = 0.4 vs 𝐻𝐴 : 𝑝 > 0.4, and 𝛼 = 0.05, we have C
= 90%, 𝑧 ∗ = 1.645, 𝑆𝐸 𝑝 = 0.0814, hence the 90% confidence interval is6
(0.4336, 0.7015), which is above 𝑝 = 0.4.
 Errors
and power
Some important concepts :
οƒ˜
Type I error: reject 𝐻0 when it is true.
οƒ˜
Type II error: accept 𝐻0 when it is false.
οƒ˜
Power of the test: the probability of rejecting 𝐻0 when it is false (i.e., when
𝐻𝐴 is true).
οƒ˜
In our example for 𝐻0 : 𝑝 = 0.4 vs 𝐻𝐴 : 𝑝 > 0.4, and 𝛼 = 0.05, we will reject
𝐻0 if we observe a z-score z = 1.645, or a proportion 𝑝 = 1.645 × 0.081
+ 0.4 = 0.5332. Under the true proportion 𝐻𝐴 : 𝑝 = 0.5575 > 0.4,
𝑝~ 𝑁 0.5575,
0.5575(1−0.5575)
37
= 0.0817 , so the power of this test is
𝑃 𝑝 > 0.5332 𝑝 = 0.5575 = π‘›π‘œπ‘Ÿπ‘šπ‘Žπ‘™π‘π‘‘π‘“ 0.5332, 99 , 0.5575, 0.0817
= 0.4357.
7

Question #1:
Suppose we want to test whether a coin is fair. We toss it many times,
count the proportion of heads, and find a P-value of 0.32. Which
conclusion is appropriate?
a)
There’s a 32% chance that the coin is fair.
b)
There’s a 32% chance that the coin is not fair.
c)
There’s a 32% chance that natural sampling variation could
produce coin-tossing results like these if the coin is really fair.
d)
There’s a 32% chance that natural sampling variation could
produce coin-tossing results like these if the coin is not fair.
Ans: we discussed in class.
8

Question #2:
Many people have trouble setting up all the features of their cell phones,
so a company has developed what it hopes will be easier instructions. The
goal is to have at least 96% of customers succeed. The company test it on
200 people, and 188 were successful. Is this a strong evidence that their
system fails to meet the goal? A student’s test of this hypothesis is shown.
How many mistakes can you find?
ο‚—
To test: 𝐻0 : 𝑝 = 0.96 versus 𝐻𝐴 : 𝑝 ≠ 0.96.
The sample is SRS, with 0.96(200)>10.
ο‚—
𝑝=
ο‚—
188
=
200
0.96−0.94
0.017
0.94. 𝑆𝐷 𝑝 =
0.94(0.06)
200
= 0.017, and the z-score z
=
= 1.18 with P-value P z > 1.18
= normal𝑐𝑑𝑓 1.18, 99 , 0, 1 = 0.12.
ο‚— There is strong evidence that the new instructions do not work.
9
Ans: we discussed in class.

Question #3:
Many people have trouble setting up all the features of their cell phones,
so a company has developed what it hopes will be easier instructions. The
goal is to have at least 86% of customers succeed. The company test it on
100 people, and 93 were successful. Is this a strong evidence that their
system fails to meet the goal? Our second student’s test of this hypothesis
is shown. How many mistakes can you find?
ο‚—
To test: 𝐻0 : 𝑝 = 0.86 versus 𝐻𝐴 : 𝑝 < 0.86.
The sample is SRS, with 0.86(100)>10 and 0.14(100)>10 .
ο‚—
𝑝=
ο‚—
93
=
100
0.93−0.86
0.0347
0.93. 𝑆𝐷 𝑝 =
0.86(0.14)
100
= 0.0347, and the z-score z
=
= 2.02 with P-value P z > 2.02
= normal𝑐𝑑𝑓 2.02, 99 , 0, 1 = 0.0217.
ο‚— Since this is significant under 𝛼=0.05, we reject 𝐻0 and conclude
there is strong evidence that the new instructions do not work.
Ans: The only error is the P-value should be 𝑃 𝑧 < 2.02 = 0.9783!
10

Question #4:
A basketball player with a poor foul-shot record practices intensively
during the off-season. He tells the coach that he has raised his proficiency
from 60% to 80%. Dubious, the coach asks him to take 10 shots, and
surprised when the player hits 9 out 10 shots. Did the player prove that he
has improved?
a)
b)
c)
d)
Suppose the player really is no better than before, still 60%
shooter. What’s the probability he can hit at least 9 of 10 shots
anyway?
If that is what happened, now the coach thinks the player has
improved when he has not. Which type of error is that?
If the player really can hit 80% now, and it takes at least 9 out of
10 successful shots to convince the coach, what’s the power of the
test?
List two ways the coach and player could increase the power to
detect any improvement.
11

Question #4 - solution:
a) Suppose the player really is no better than before, still 60%
shooter. What’s the probability he can hit at least 9 of 10 shots
anyway?
Let X be the number of shots he hits, which follows Binomial model with n=10
and p=0.6 under the null hypothesis. We have 𝑃 𝑋 = 9 = 10
0.69 0.41
9
10 0.40 = 0.610 = 0.0061, so 𝑃 𝑋 ≥ 9
= 0.0403, and 𝑃 𝑋 = 10 = 10
0.6
10
= 𝑃 𝑋 = 9 + 𝑃 𝑋 = 10 = 0.0464.
b)
If that is what happened, now the coach thinks the player has
improved when he has not. Which type of error is that?
The null hypothesis is that the player really is no better than before. So if the
coach thinks the player has improved (reject the null hypothesis) when he
actually has not (when the null hypothesis is true), this is Type I error.
12

Question #4 – solution (continued):
c) If the player really can hit 80% now, and it takes at least 9 out of
10 successful shots to convince the coach, what’s the power of the
test?
The power is the probability that we reject the null hypothesis when it is false,
i.e., the alternative is true. Since X the number of shots he hits follows Binomial
model with n=10 and p=0.8 under the alternative hypothesis, we have 𝑃(𝑋
13
Thank you.
14
Download