* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Download Notes 15
Survey
Document related concepts
Transcript
MTH4106 Introduction to Statistics Notes 15 Spring 2013 Testing hypotheses about the mean Earlier, we saw how to test hypotheses about a proportion, using properties of the Binomial distribution. It is quite tricky. Testing hypotheses is actually easier when the underlying distribution is continuous, because then we can choose the rejection region to have any specified significance level. First of all we will revisit the “snowy day” example. Example The time required by workers to complete an assembly job usually has a mean of 50 minutes and a standard deviation of 8 minutes. On a snowy day, the supervisor wonders if they are working at the same speed as usual. He intends to record the times that 60 workers take to complete one assembly job apiece. Suppose that the supervisor asks “Has the mean time changed?” The null hypothesis is one of no change, the alternative is there is a change so Null hypothesis: µ = 50 Alternative hypothesis: µ = 6 50 We know that the distribution of X̄ is approximately normal with mean µ and variance 82 2 2 60 , since σ = 8 and n = 60 i.e. 82 ). 60 It follows, taking off the mean and dividing by the standard deviation, that X̄ ∼ N(µ, Z = X̄ − µ √8 60 √ (X̄ − µ) 60 = 8 ∼ N(0, 1) 1 So if the null hypothesis is true the test statistic √ (X̄ − 50) 60 Z= 8 will have a standard normal distribution. Large values of |Z| will give evidence against the null hypothesis H0 . Suppose the supervisor uses a significance level of 5%. Remember this means the probability of a Type I error is 5%, that is the probability of rejecting H0 when it is true is 5%. The rejection region is {z : z < −1.96 or z > 1.96} which we can also write as {z : |z| > 1.96}. ................................... ............ ......... ......... ....... ....... ....... ...... ...... . . . . . .... .... . .... . .. .... . . . .... .. . . . .... ... .... . . .. .... . . . .... .. . . . .... ... . .... . .. . .... . . .. .... . . . .... ... . . .... .. . . .... . ... .... . . .... .. . . . .... ... . .... . .. . .... . . .. ..... . . . . ...... ... . . . ...... . . .... . ...... . . . . ....... ... . . . . . ....... . .... . . ....... . . . . . ........ ..... . . . . . ..... . . ........ . . . . . . . . .............................. . . . ............. ........ . . . . . .... . . . . . . . . . . ..... ........................................................... ............. ...... ........ ....... .. . . . . . . . . . . . . . . . . . . . . . . . . . ....... . . . .................................. ..... ....... ..... ........ ..... ........ .... .... ....... ..... ....... ..... ....... .... .............................. 0.025 0.025 −1.96 0 1.96 If the supervisor observes x̄ = 52.67, the observed value of the test statistic is √ (52.67−50) 60 z= = 2.585. Since 2.585 > 1.96 this value lies in the rejection region 8 and we can reject H0 at the 5% significance level. Note that the probability of a Type II error, i.e. accepting the null hypothesis H0 when it is false, is not usually calculated. Firstly, it needs the supposed true vale of µ. Secondly, it is usually used to compare different tests with equal significance levels to see which is better and here we have only one test. But we can say that the probability of a Type II error will go down the larger n is. Suppose now that the supervisor actually suspects that they have got slower, i.e. they are taking longer to complete the job, and wants to find out if he is right. The null hypothesis is one of no change, the alternative is there is an increase Null hypothesis: µ = 50 Alternative hypothesis: µ > 50 Note we could also write the null hypothesis as µ 6 50 in this one-sided test. 2 As before we know that the distribution of X̄ is approximately N(µ, 82 ). 60 It follows that Z = X̄ − µ √8 60 √ (X̄ − µ) 60 = 8 ∼ N(0, 1) So if the null hypothesis is true the test statistic √ (X̄ − 50) 60 Z= 8 will have a standard normal distribution. Now large values of Z will give evidence against the null hypothesis H0 . Suppose the supervisor uses a significance level of 5%. Remember this means the probability of a Type I error is 5%, that is the probability of rejecting H0 when it is true is 5%. The rejection region is {z > 1.6449}. ........... ................ ........................ ........ ......... ....... ....... ...... ....... ..... ...... . . . .... .. . . .... . ... .... . . .... .. . . . .... .. . . .... . ... .... . . .. .... . . . .... .. . . . .... ... . .... . .. . .... . . .. .... . . . .... ... . . .... ... .... . . .... ... . . .... ... . . .... .. . .... . . .. ...... . . . . . ...... .... . . . . ...... . .... . ....... . . . . . ..... . . . ....................... . . .... . ........ . .. . . . . . ........ ..... ...... . . . . . ......... . . ..... . ........... . . . . . . . . . ....... . . . . ... ......... . . . . . . . . . . ..... ... .................. ........... . . . . . . . . . . . . . . . . . . . ..... .... ..... .... .................................................. . . . . . . . . . ............ ..... ... ..... ... ..... .... 5% 0 1.6449 If the supervisor observes x̄ = 52.67, the observed value of the test statistic is √ (52.67−50) 60 z= = 2.585. Since 2.585 > 1.6449 this value lies in the rejection region 8 and we can reject H0 at the 5% significance level. 3 P values We discussed the use of P values. They can be useful as a hypothesis test with a fixed significance level α does not give any indication of the strength of evidence against the null hypothesis. The P value depends on whether we have a one-sided or two-sided test. Consider a one sided test of H0 : µ = µ0 versus H1 : µ > µ0 . Assuming the population variance is known the P value is P(Z > zobs ) where zobs is the observed value of Z. For H1 : µ < µ0 the P value is P(Z < zobs ). For a two sided test with H1 : µ 6= µ0 it is P(Z > |zobs | ∪ Z < −|zobs |) = 2 P(Z > |zobs |). In each case we can think of the P value as the probability of obtaining a value of the test statistic more extreme than we did observe assuming that H0 is true. What is regarded as more extreme depends on the alternative hypothesis. If the P value is small that is evidence that H0 may not be true. It is useful to have a scale of evidence to help us interpret the size of the P value. There is no agreed scale but the following may be useful as a first indication: P value P > 0.10 0.05 < P < 0.10 0.01 < P < 0.05 0.001 < P < 0.01 P < 0.001 Interpretation No evidence against H0 Weak evidence against H0 Moderate evidence against H0 Strong evidence against H0 Very strong or overwhelming evidence against H0 Note that the P value is the smallest level of significance that would lead to rejection of the null hypothesis. Example Consider the snowy day example again. For the two sided test the P-value is 2 × P(X̄ > 52.67) if µ = 50. This is equal to 52.67 − 50 √ = 2 × P(Z > 2.585) = 0.00974. 2×P Z > 8/ 60 This is very small and there is very strong evidence against H1 . Similarly for the one-sided test the P-value is P(Z > 2.585) = 0.00487 4 Example Drills being manufactured are supposed to have a mean length of 4cm. From past experience we know the standard deviation is equal to 1cm and the lengths are normally distributed. A random sample of 10 drills had a mean of 4.5cm. Test the hypothesis that the mean is 4.0 with significance level α = 0.05 and find the P value. We have H0 : µ = 4.0 versus H1 : µ 6= 4.0 We know that so if H0 is true The observed value of Z is 1 X̄ ∼ N µ, 10 X̄ − 4 ∼ N(0, 1). Z=p 1/10 4.5 − 4 p = 1.58 1/10 For a 2 sided test with α = 0.05 the rejection region is {z : |z| > 1.96}. Since z = 1.58 we do not reject H0 at the 5% level. The P value is 2 × P(Z > 1.58) = 2 × (1 − Φ(1.58)) = 2(1 − 0.9429) = 0.1142 and so there is no evidence against H0 . Example An advertisement for a certain brand of cigarettes claimed that on average there is no more than 18mg of nicotine per cigarette. A test of 12 cigarettes gave a sample mean of x̄ = 19.1. Assuming σ2 = 4 and the distribution of the amount of nicotine is normally distributed test this claim with a significance level of α = 0.05 and find the P value. We have H0 : µ = 18.0 versus H1 : µ > 18.0 We know that so if H0 is true The observed value of Z is 4 X̄ ∼ N µ, 12 X̄ − 18 Z= p ∼ N(0, 1). 1/3 19.1 − 18.0 p = 1.905 1/3 For a 1 sided test with α = 0.05 the rejection region is {z : z > 1.6449}. Since z = 1.9053 we can reject H0 at the 5% level. 5 Note that if we had chosen α = 0.02 then zα = 2.0537 we we would fail to reject H0 at the 2% significance level. The P value is P(Z > 1.905) = (1 − Φ(1.905)) = 1 − 0.9716 = 0.0284. Thus we have moderate evidence against H0 General procedure for hypothesis tests of the mean value Suppose that µ is the unknown mean of some large population with variance σ2 ; that H0 and H1 are phrased in terms of µ; that X̄ is the mean of a random sample of size n; and that we can assume that X̄ is (approximately) normal. Remember that E(X̄) = µ and Var(X̄) = σ2 /n. 1. Population variance σ2 known (a) One-sided tests (also called one-tailed tests) (i) H0 : µ 6 µ0 , where µ0 is known; H1 : µ > µ0 . X̄ − µ0 √ ∼ N(0, 1) under H0 , σ/ n We know that X̄ − µ0 √ as the test statistic. For significance level α, the σ/ n rejection region is {z : z > zα }. so we take .............................................. ........ .......... ....... ........ ...... ....... . . . . . ...... . .... ..... ... .... . . . .... .. . . .... . ... .... . . .. .... . . . .... ... . . .... .. . . .... . .. . .... . . .. .... . . . .... ... . . .... .. . .... . . .... ... . . .... .. . . . .... ... . .... . ... .... . . .... .. . . . ...... .... . . ...... . . ... . ...... . . . . ....... .... . . . . . . .... . ....................... . . . . . ........ .. ..... . . . . . ........ . ..... . ..... . . ......... . . . . . . . .......... ........... .............. ............ . . . . . . . . . . . . . . ..... ... ................... . ......... ..... ... ..... .. ................................................ ................................... ..... .... ..... .... ..... .... α zα 0 Given the sample mean x̄ of the data, reject H0 if x̄ − µ0 √ > zα . σ/ n (ii) H0 : µ > µ0 , where µ0 is known; H1 : µ < µ0 . By a similar argument, reject H0 if 6 x̄ − µ0 √ 6 −zα . σ/ n (b) Two-sided tests (also called two-tailed tests) H0 : µ = µ0 , where µ0 is known; H1 : µ 6= µ0 . X̄ − µ0 √ but with the symmetric rejection region Use the same test statistic σ/ n {z : z < −zα/2 ∪ z > zα/2 }. ...................................... ............ ........ ........ ....... ....... ....... ...... ....... . . . . . .... .... .... . . .... ... . . .... .. . . .... . .. .... . . . .... ... . . .... .. . . .... . .. . .... . . .... ... . . .... .. . . . .... .. . . .... . ... .... . . .... ... . . .... .. . . .... . ... .... . . .... ... . . ..... .. . . . ...... . ... . . ...... . . . ...... .... . . . . . ....... .... . . . ....... . . . .... ....... . . . . . . . ........ ...... . . ..... . . . . . ...... ... . . . . . ... .......................... . . . . . . ........... ........ ........ . .. .. .... . . . . . . . . . . . . ..... .................. ........................................ ............ ....... ...... ........ ...... . . . . . . . . . . . . . . . . .. . . ....... . . . . . . . . . . . . .......................... ..... ...... .... ...... .... ...... ... .... ....... ..... ....... ..... ....... .... .............................. α/2 α/2 −zα/2 Reject H0 if zα/2 0 x̄ − µ0 √ 6 −zα/2 σ/ n or x̄ − µ0 √ > zα/2 . σ/ n 2. σ2 unknown, but n large (n > 30) As Case 1, but replace the known σ by the sample standard deviation s. Thus the test statistic is X̄ − µ0 √ S/ n but the rejection region does not change. These tests are all called “one-sample z-tests”. Relationship between hypothesis tests and confidence intervals √ n If we do a two-sided z-test with H0 : µ = µ0 , test statistic Z = (X̄−µσ0 ) level α, z ∈ Rejection Region ⇐⇒ ⇐⇒ z 6 −zα/2 or z > zα/2 √ (x̄ − µ0 ) n 6 −zα/2 or σ 7 and significance √ (x̄ − µ0 ) n > zα/2 σ ⇐⇒ ⇐⇒ ⇐⇒ ⇐⇒ σ σ x̄ 6 µ0 − zα/2 √ or x̄ > µ0 + zα/2 √ n n σ σ µ0 > x̄ + zα/2 √ or µ0 6 x̄ − zα/2 √ n n σ σ µ0 ∈ / x̄ − zα/2 √ , x̄ + zα/2 √ n n µ0 ∈ / (1 − α)-confidence interval for µ. So a 100(1 − α)% confidence interval is all the values µ0 which would not be rejected using a two-sided z-test with significance level α. Tests of a Poisson mean Suppose X1 , X2 . . . , Xn are independent random variables with the Poisson distribution with mean λ. If nλ > 9 then we can use the normal approximation, which is justified by the Central Limit Theorem. So the sample mean X̄ will be approximately N(λ, λ/n). So we can test a hypothesis about λ , H0 : λ = λ0 by using the test statistics Z= (X̄ − λ0 ) q λ0 n . Example X1 , . . . , Xn is a random sample from a Poisson distribution with mean λ. Suppose n = 10 and x̄ = 1.8 test the null hypothesis H0 : λ = 3 against a two-sided alternative using a significance level of 5%. We use the test statistic (X̄ − 3) Z= q 3 10 and Z ∼ N(0, 1) if H0 is true. For a two-sided test at the 5% significance level the rejection region is {z : |Z| > 1.96}. The observed value of the test statistic is z= (1.8 − 3) q = −2.19 3 10 which is in the rejection region and so we reject H0 at the 5% significance level. For the Poisson distribution, if we know the mean then we know the variance. So there is no longer a simple relationship between two-sided hypothesis test and confidence intervals. 8