Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
“Teach A Level Maths” Statistics 1 Hypothesis Testing © Christine Crisp Hypothesis Testing Statistics 1 MEI/OCR "Certain images and/or photos on this presentation are the copyrighted property of JupiterImages and are being used with permission under license. These images and/or photos may not be copied or downloaded without permission from JupiterImages" Hypothesis Testing Suppose there is a new drug treatment which we hope will be better than the existing one. To test whether it is better, we could set up a trial involving a certain number of people. We could then see how long it takes people to get well with the new drug and compare it with results for the old one. However, sampling involves random effects and we need to know whether the apparently good results are really due to improvements in treatment. Statistics has a big part to play in making decisions of this type and this presentation introduces an important theory that is widely used. Hypothesis Testing e.g. 1. In a trial of 20 patients with a new drug, the condition of 15 was greatly improved. On the older drug, 60% reported the same improvement. Is there evidence that the new drug is more effective than the old one? We can’t just say that the drug is clearly better because 75% of patients improved compared with 60% before. We need to find out what the probability is that 15 patients improve even if the new drug is no more effective than the old one. The situation can be modelled with the Binomial distribution. We let p, the probability of success, be the probability that a patient improved with the new drug. Hypothesis Testing We set up a hypothesis ( a theory ) that the new drug is not more effective and only reject this if we have significant evidence against it. We write H0 : p 06 H0 is called the null hypothesis. ( I think of it as “no change”. ) The null hypothesis is using the value of p from data for the old drug. We want to test if the new drug is better than the old one so we also have H1 : p 06 H1 is the alternative hypothesis. Hypothesis Testing We now want to test the hypothesis. Let X be the random variable ”the number of patients that improve” There were 20 patients in the trial so n = 20. So, Also, H0 : H1 : X ~ B( 20, p) p 06 p 06 We want to find out how likely, or unlikely it is that, with the old drug, 15 or more patients will improve. We will only reject H0 if this probability is less than 0·05. We say that we reject the null hypothesis at the 5% level of significance. Hypothesis Testing X ~ B( 20, p) H0 : p 0 6 H1 : p 0 6 Test at 5% level of significance. Assuming the null hypothesis we have n = 20 and p = 0·6: P ( X 15) 1 P ( X 14) 1 0 8744 0 1256 There is a probability of 0·1256 ( more than 12% ) that 15 or more patients will improve even with the old drug. We do not reject the null hypothesis. If you have Autograph you can illustrate this and see the probabilities for other values of x. I’ve copied an example on the next slide. Hypothesis Testing P( X 15) 0 1256 12 56% We have to consider P ( X 15) because we are comparing with the end 5% of the distribution. Let’s see how many patients would need to improve on the new drug before we could reject H0 and accept that the new drug is better than the old. Hypothesis Testing P ( X 16) 0 0510 5 10% ( Near, but still greater than 5% ) P ( X 17) 0 0160 1 60% So, if 17 patients improved we would have our evidence. H0 would be rejected. Hypothesis Testing Critical Region The critical region for the test consists of the values of the random variable, X, that would cause us to reject the null hypothesis. In this example, the critical region is 17, 18, 19 and 20. 5% I’ll write out the example again with the complete solution so you see how we set it out. Hypothesis Testing e.g. 1. In a trial of 20 patients with a new drug, the condition of 15 was greatly improved. On the older drug, 60% reported the same improvement. Is there evidence that the new drug is more effective than the old one? Solution: Let X be the random variable ”the number of patients that improve” X ~ B( 20, p) Test at 5% level H0 : p 0 6 of significance. H1 : p 0 6 P ( X 15) 1 P ( X 14) 1 0 8744 0 1256 0 05 There is a probability of 0·1256 ( more than 12% ) that 15 or more patients will improve even with the old drug. We do not reject the null hypothesis. There is insufficient evidence to suggest the new drug is better. Hypothesis Testing 1-tailed and 2-tailed tests In our example the alternative hypothesis, H1, was given by H1 : p 06 This is called a 1-tailed test because we are only considering values of p greater than 0·6. We would also have a 1-tailed test if we had H 1 : p 0 6. If our alternative hypothesis were H1 : p 06 we would have a 2-tailed test. For a 2-tailed test, the percentage for the significance is split into 2, one half at each end of the distribution. Hypothesis Testing e.g. 2. In a trial, 16 seeds are sown and only 11 germinate. Use a 10% significance level to test the supplier’s claim that 85% germinate. Find the critical region for the test. Solution: Let X be the random variable ”the number of seeds that germinate” X ~ B(16, p) Test at 10% level H 0 : p 0 85 of significance. H : p 0 85 To1 test the supplier’s claim, the alternative hypothesis is that fewerathan 85% test This is again 1-tailed but this P( X 11 ) germinate. 0 0791 0 1time we need to test the bottom end of the distribution. There is a probability of 0·0791 ( less than 10% ) that 11 or fewer seeds will germinate. We reject the null hypothesis at the 10% level of significance and conclude that the germination rate is below 85% . Hypothesis Testing The Autograph illustration is as follows: X ~ B(16, 0 85) P ( X 11) 0 0791 7 91% The probability of 12 or fewer germinating is 0·2101 ( 21·01% ), so the critical region for the test is 0, 1, 2, . . . 10, 11. Hypothesis Testing e.g. 3. A team captain thinks the coin tossed at the start of a match is biased. Find the critical region for the number of heads in 30 tosses using a 5% significance level. Solution: Let X be the random variable “ number of heads ”. So, X ~ B( 30, p) The null hypothesis is that the coin is fair, so H0 : p 05 H1 : p 05 We don’t know whether there might be more or fewer heads than on a fair coin so the alternative hypothesis is We have a 2-tailed test, so the 5% must be split into 2·5% at each end of the distribution. Hypothesis Testing We want to find out how many heads would convince us that the coin is biased. We refer to tables to get an idea of the number we want and then check by doing the calculation. 1 P ( X 19) P ( X 20) 1 0 9506 0 0494 We would not reject H0 with 20 heads because, although we are using a 5% significance level, we are looking for values in the top or bottom 2·5% of the distribution. 2 5% 2 5% Hypothesis Testing P ( X 20) 0 0494 We now try 21: P ( X 21) 1 P ( X 20) 1 0 9786 0 0214 This gives 2·14% which is less than 2·5% so with 21 or more heads we reject H0 in favour of H1. However, we are doing a 2-tailed test so we must also consider the bottom end of the distribution. With a value of p other than 0·5, the Binomial distribution is not symmetric so we would need to do the calculation. However, with p = 0·5, the Binomial is symmetric, so without further calculations, we know that X 9 would also cause us to reject H0. Hypothesis Testing 2 5% 2 5% The critical region has 2 parts: 0, 1, 2, . . . 9, and 21, 22, . . . 30. The values of X where we would accept H0 form the acceptance region, so in this example they are 10, 11, . . . 20. Hypothesis Testing SUMMARY To carry out a hypothesis test on a Binomial model we • define a random variable • • write down the distribution with n equal to the number of trials and using p for the probability of success state the null (H0) and alternative (H1) hypotheses using < or > for a 1-tailed test and for a 2-tailed test write down the significance level of the test • calculate the cumulative probability • reject H0 if the probability is less than the significance level ( or, for a 2-tailed test, less than half the total significance level ). continued • Hypothesis Testing SUMMARY The critical region consists of the values of the random variable that cause H0 to be rejected. A 1-tailed test is used if we are testing a claim that the probability is higher or lower than defined in H0. If there is no indication, we use a 2-tailed test. For a 2-tailed test, the significance level is split into 2 halves so, for example, 5% becomes 2·5% at each end. Hypothesis Testing Exercise 1. In a survey it was found that 35% of members of a political party supported candidate D to be leader. A month later, D claimed his support had increased. A 2nd survey of 20 members showed that 11 supported him. Would you accept D’s claim at the 5% significance level? 2. Hyacinth bulbs are sold to a retailer in packs of 100 which claim to have equal numbers of bulbs producing blue and pink flowers. A random sample of 25 produces 17 blue flowers. Test at the 10% level of significance whether the retailer has a right to complain that there are not equal numbers of each colour. Find the critical region for the test. Hypothesis Testing Solution: 1. Let X be the r.v.” number supporting D” X ~ B( 20, p) H0 : H1 : p 0 35 Test at 5% significance level. p 0 35 P ( X 11) 1 P ( X 10) 1 0 9468 0 0532 0 05 We do not reject H0 and so the candidate cannot claim greater support. At a 10% level of significance we would reject H0 and conclude that D’s support had increased. The Autograph diagram on the next slide illustrates the solution. Hypothesis Testing 10% 5% P ( X 11) 0 0532 11 is outside the critical region at 5% significance but inside it at 10%. Hypothesis Testing 2. Let X be the r.v. “ number of blue flowers” X ~ B( 25, p) H0 : H1 : p 05 p 05 Test at 10% significance level. ( This is a 2-tailed test so we check against 5% each end of the distribution. ) P ( X 17) 1 P ( X 16) 1 0 9461 0 0539 0 05 We do not reject H0. There is insufficient evidence at the 10% level of significance to claim that there are more of one colour than the other. Hypothesis Testing The value 0·0539 is so close to 0·05 that we are sure the critical region starts at 18. However, we should check. P ( X 18) 1 P ( X 17) 1 0 9784 0 0216 0 05 18 blue flowers would fall within the critical region. Since this is a 2-tailed test the critical region is in 2 parts. With p = 0·5, the Binomial distribution is symmetrical, so the critical region is 0, 1, . . . 7 and 18, 19, . . . 25 The following slides contain repeats of information on earlier slides, shown without colour, so that they can be printed and photocopied. Hypothesis Testing SUMMARY To carry out a hypothesis test on a Binomial model we • define a random variable • • write down the distribution with n equal to the number of trials and using p for the probability of success state the null (H0) and alternative (H1) hypotheses using < or > for a 1-tailed test and for a 2-tailed test write down the significance level of the test • calculate the cumulative probability • reject H0 if the probability is less than the significance level ( or, for a 2-tailed test, less than half the total significance level ). continued • Hypothesis Testing The critical region consists of the values of the random variable that cause H0 to be rejected. A 1-tailed test is used if we are testing a claim that the probability is higher or lower than defined in H0. If there is no indication, we use a 2-tailed test. For a 2-tailed test, the significance level is split into 2 halves so, for example, 5% becomes 2·5% at each end. Hypothesis Testing e.g. 1. In a trial of 20 patients with a new drug, the condition of 15 was greatly improved. On the older drug, 60% reported the same improvement. Is there evidence that the new drug is more effective than the old one? Solution: Let X be the random variable ”the number of patients that improve” X ~ B( 20, p) Test at 5% level H0 : p 0 6 of significance. H1 : p 0 6 P ( X 15) 1 P ( X 14) 1 0 8744 0 1256 0 05 There is a probability of 0·1256 ( more than 12% ) that 15 or more patients will improve even with the old drug. We do not reject the null hypothesis. Hypothesis Testing e.g. 2. In a trial, 16 seeds are sown and only 11 germinate. Use a 10% significance level to test the supplier’s claim that 85% germinate. Find the critical region for the test. Solution: Let X be the random variable ”the number of seeds that germinate” H0 : H1 : p 0 85 p 0 85 X ~ B(16, p) Test at 10% level of significance. To test the supplier’s claim, the alternative hypothesis is that fewer than 85% germinate. This is again a 1-tailed test but this time we need to test the bottom end of the distribution. P ( X 11) 0 0791 0 1 There is a probability of 0·0791 ( less than 10% ) that 11 or fewer seeds will germinate. Hypothesis Testing We reject the null hypothesis at the 10% level of significance and conclude that the germination rate is below 85% . The Autograph illustration is as follows: P ( X 11) 0 0791 7 91% The probability of 12 or fewer germinating is 0·2101 ( 21·01% ), so the critical region for the test is 0, 1, 2, . . . 10, 11. Hypothesis Testing e.g. 3. A team captain thinks the coin tossed at the start of a match is biased. Find the critical region for the number of heads in 30 tosses using a 5% significance level. Solution: Let X be the random variable “ number of heads ”. So, X ~ B( 30, p) The null hypothesis is that the coin is fair, so H0 : p 05 H1 : p 05 We don’t know whether there might be more or fewer heads than on a fair coin so the alternative hypothesis is We have a 2-tail test, so the 5% must be split into 2·5% at each end of the distribution. Hypothesis Testing We want to find out how many heads would convince us that the coin is biased. A reasonable guess would be 20 out of 30. P ( X 20) 1 P ( X 19) 1 0 9506 0 0494 0 025 2 5% 2 5% We would not reject H0 with 20 heads because we are looking for values in the top or bottom 2·5% of the distribution. Hypothesis Testing P ( X 20) 0 0494 We now try 21: P ( X 21) 1 P ( X 20) 1 0 9786 0 0214 This gives 2·14% which is less than 2·5% so with 21 or more heads we reject H0 in favour of H1. However, we are doing a 2-tailed test so we must also consider the bottom end of the distribution. With a value of p other than 0·5, the Binomial distribution is not symmetric so we would need to do the calculation. However, with p = 0·5, the Binomial is symmetric, so without further calculations, we know that X 9 would also cause us to reject H0. Hypothesis Testing 2 5% 2 5% The critical region has 2 parts: 0, 1, 2, . . . 9, and 21, 22, . . . 30. The values of X where we would accept H0 form the acceptance region, so in this example they are 10, 11, . . . 20.