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