Chapter 3: Hypothesis Testing

Chapter 3: Hypothesis Testing M. Angeles Carnero Departamento de Fundamentos del Análisis Económico Curso 2014-15 M. Angeles Carnero (UA) Chapter 3...
41 downloads 1 Views 633KB Size
Chapter 3: Hypothesis Testing M. Angeles Carnero Departamento de Fundamentos del Análisis Económico

Curso 2014-15

M. Angeles Carnero (UA)

Chapter 3: Hypothesis Testing

Curso 2014-15

1 / 71

Basic Concepts on Hypothesis Testing Statistical Hypothesis: statement about a random event Goal of the hypothesis test: given two hypothesis on a random event, we want to select one of them for a given sample. The hypothesis are denoted as null hypothesis (expressed as H0 ) and alternative hypothesis (expressed as H1 ), which must be complementary (only and only one of these two hypothesis is true) These two hypothesis have different names because they do not play a symmetric role: at the end of our study, we will choose the null hypothesis unless the data shows that the statement in this hypothesis is very unlikely (this is similar to the verdict of guilty or not guilty in a trial: the not guilty verdict is the default one unless the opposite can be proved). This is the reason why the result of this type of analysis is expressed as ”there is no evidence to reject the null hypothesis” or ”there is evidence to reject the null hypothesis”. M. Angeles Carnero (UA)

Chapter 3: Hypothesis Testing

Curso 2014-15

2 / 71

Example 1: Let X be a random variable that takes value 1 if the result of tossing a coin is head, or 0 if tail. Let p denote the probability that X takes value 1. If the coin is well made (in the sense that both heads and tails have the same probability), then p = 1/2. We can analyse if the coin is well made with the following hypothesis testing: H0 : p = 1/2 H1 : p 6= 1/2 In order to perform this test, we should obtain a sample of size n of r.v. X (i.e., we toss the coin n times), and we reject the null hypothesis if the results we obtain are not very plausible, assuming that the coin is in fact well made.

M. Angeles Carnero (UA)

Chapter 3: Hypothesis Testing

Curso 2014-15

3 / 71

Example 2: We know that the average duration of a light bulb made by a particular firm is 1400 hours. An expert says that a new process design by him would allow to produce light bulbs with a larger average duration. If X denotes the r.v. indicating the duration of a light bulb with this new process and µ denotes the mean of X, in order to analyse if the statement of the expert is true or not, we can perform the following hypothesis test: H0 : µ = 1400 H1 : µ > 1400 The approach in this test, indicates that we would admit that there is an improvement in the average duration of the light bulb if the data shows that it is not very plausible that the average duration of the bulbs made with the new process is 1400 hours (since the null hypothesis will be only rejected if there is enough evidence against it). M. Angeles Carnero (UA)

Chapter 3: Hypothesis Testing

Curso 2014-15

4 / 71

In order to perform this test, as we will see below, we obtain a sample of size n of X (i.e., we obtain information on the duration of n light bulbs made with the new process), and we compare the mean of this sample with 1400: if this sample mean is significantly larger than 1400, we then reject the null hypothesis. Then, how one could objectively determine that something is “significantly larger” than something else? For example, if the sample mean obtained with the bulbs made with the new process is 1420 hours, should we reject the null hypothesis? The answer mainly depends on 3 factors: the variance of X the sample size the larger probability of error that we are willing to assume (below we will analyse which type of error)

M. Angeles Carnero (UA)

Chapter 3: Hypothesis Testing

Curso 2014-15

5 / 71

General Procedure of a Hypothesis Test: We compute the value that a r.v. T takes in our sample; this random variable will be related with the hypothesis we want to analyse; we will decide to reject the null hypothesis if the value that T takes lies within a subset C of R containing those results of T very implausible to arise if the null hypothesis is true. Therefore, the decision rule of a test is: Reject H0 if T 2 C The random variable T is denoted as a test statistic and subset C is denoted as critical region or rejection region. Now ) general criteria to objectively choose T and C? Later ) choice of T and C for some specific test of interest.

M. Angeles Carnero (UA)

Chapter 3: Hypothesis Testing

Curso 2014-15

6 / 71

Possible situations when taking a decision in a test: : The decision one takes in a hypothesis testing is based in a sample, and therefore, we cannot be completely sure that the taken decision is the correct one. There are 4 possible situations: H0 is true and it is not rejected ! Right decision H0 is true and it is rejected! Error H0 is false and it is not rejected ! Error H0 is false and it is rejected ! Right decision

DECISION

H0 is true

Reject H0

Do not reject H0

Type I Error

p

p

Type II Error

H1 is true M. Angeles Carnero (UA)

Chapter 3: Hypothesis Testing

Curso 2014-15

7 / 71

We can distinguish between two types of errors: Reject H0 when it is true ! Type I Error Do not reject H0 when it is false ! Type II Error

The level of significance, denoted by α , is the largest probability of type I- error one is willing to assume The power of the test is the probability of rejecting the null hypothesis when it is false, i.e., this is 1 probability of type IIerror. Ideally, the error probabilities should be 0; however, in general, this is not possible. Taking into account that the two hypotheses are asymmetric, we fix a priori the largest probability of type I-error we are willing to assume and then, among the decision rules satisfying this condition, we choose the decision providing the smallest type II-error probability. M. Angeles Carnero (UA)

Chapter 3: Hypothesis Testing

Curso 2014-15

8 / 71

With the notation introduced above, this means that we look for the decision rule satisfying: the significance level must be equal to an apriori fixed value α (usually α = 0,05, although sometimes α = 0,10 or α = 0,01 are also used). the power must be as large as possible

Since the decision rules we take into account are such as “Reject H0 if T 2 C”, these two conditions can be rewritten as P(T 2 C j H0 true) = α; P(T 2 C j H0 false) must be as large as possible

M. Angeles Carnero (UA)

Chapter 3: Hypothesis Testing

Curso 2014-15

9 / 71

Example 1 (continue): In order to analyse whether a coin is well made, we want to perform the following test: H0 : p = 1/2 H1 : p 6= 1/2 where p is the probability of heads. In order to perform this test, we toss the coin 6 times. A reasonable decision rule in this case can be: Reject H0 if b p = 0 or b p=1

where pˆ is the proportion of heads in our sample of 6 tosses. That it is, we reject the null hypothesis if in all the tosses we obtained tails or in all the tosses we obtained heads.

M. Angeles Carnero (UA)

Chapter 3: Hypothesis Testing

Curso 2014-15

10 / 71

Since pˆ = ∑6i=1 Xi /6 (where Xi is the random variable taking value 1 if we obtain heads in the i th toss and 0 otherwise), the probability of type I-error with this decision rule is: P(Type I- Error) = P(Reject H0 j H0 true)

= P(b p = 0 or b p = 1 j H0 true)

= P(b p = 0 j H0 true) + P(b p = 1 j H0 true)

= P(∑6i=1 Xi = 0 j H0 true) + P(∑6i=1 Xi = 6 j H0 true) If the coin is well made, ∑6i=1 Xi has a binomial distribution Bi 6, 21 , so in this case P ∑6i=1 Xi = 0 = (1/2)6 and also P ∑6i=1 Xi = 6 = (1/2)6 . M. Angeles Carnero (UA)

Chapter 3: Hypothesis Testing

Curso 2014-15

11 / 71

Therefore: P(Type I-Error) = (1/2)6 + (1/2)6 = 0,03125 On the other hand, if the coin is not well made, ∑6i=1 Xi has a binomial distribution Bi(6, p), where p 6= 21 . Therefore, the power of the test is: Power = P(Reject H0 j H0 false)

= P(∑6i=1 Xi = 0 j H0 false) + P(∑6i=1 Xi = 6 j H0 false) = (1

p)6 + p6

For example, if p = 0,6 the power is 0,46 + 0,66 = 0,0508, while if p = 0,9 the power is 0,16 + 0,96 = 0,5314. Of course, as the distance of the true value of p to 1/2 increases (i.e. the finish of the coin is worse), the higher the power of the test is (i.e. rejecting H0 is more likely). M. Angeles Carnero (UA)

Chapter 3: Hypothesis Testing

Curso 2014-15

12 / 71

Two requirements that the test statistic T should satisfy (apart from being related with the hypothesis we are testing): it should have a known distribution when H0 holds (so that it is possible to determine C such that condition P(T 2 C j H0 true) = α holds) we should know which areas of the real line R where T is located are more plausible when H0 is false (since we should choose C such that it contains those values that are more plausible when H0 is false).

Most of the hypothesis to be analysed refer to a particular parameter (mean, variance). This type of hypothesis is denoted as parametric hypothesis. The parametric hypothesis can be classified into simple (when only one value is specified) and composite, the latter can be one-sided or two-sided; hence, in example 1, the null hypothesis is simple and the alternative is two-sided composite, while in example 2 the null hypothesis is simple and the alternative is one-sided composite. M. Angeles Carnero (UA)

Chapter 3: Hypothesis Testing

Curso 2014-15

13 / 71

Tests for the mean of a normal population with known variance

Situation:It is assumed that X is normally distributed N (µ, σ2 ), with known σ2 , and we want to test an hypothesis on µ; to do so, we have access to a simple random sample of X. Case 1: We want to test H0 : µ = µ 0 H1 : µ 6= µ0 where µ0 is known. What is a reasonable decision rule to reject H0 in this case?

M. Angeles Carnero (UA)

Chapter 3: Hypothesis Testing

Curso 2014-15

14 / 71

A decision rule with significance level α is “Reject H0 if T 2 C” where X µ T = q 0 and C = ( ∞, σ2 n

or equivalently, ”Reject H0 if

x µ0 q σ2 n

zα/2 ) [ (zα/2 , ∞)

> zα/2 ”.

How has this rule been obtained?

It seems reasonable to think that if we want to say something regarding µ we can use X. In Chapter 1 we obtained: X µ q σ2 n

M. Angeles Carnero (UA)

N (0, 1)

Chapter 3: Hypothesis Testing

Curso 2014-15

15 / 71

Therefore, if H0 is true, we have X µ0 q σ2 n

M. Angeles Carnero (UA)

N (0, 1)

Chapter 3: Hypothesis Testing

Curso 2014-15

16 / 71

If we compute lies between However, if

x µ0 q σ2 n

with our sample and we obtain a value that

zα/2 and zα/2 , there is no evidence to x µ0 x µ q < zα/2 or q 20 > zα/2 then there σ2 σ n

reject H0 . is evidence

n

against the null hypothesis.

Note that it could be the case that H0 is true (and consequently X µ0 q σ2 n

N (0, 1) ) and still the value of T could not lie between

zα/2 and zα/2 . This event has a probability of α, which is precisely the type I-error probability, which can be fixed as small as we want.

M. Angeles Carnero (UA)

Chapter 3: Hypothesis Testing

Curso 2014-15

17 / 71

Example 3: One firm produces shampoo bottles, whose weight is known to follow a normal distribution with population standard deviation of 6 gr. This firm states that the average weight of the bottles, denoted by µ, is 200 gr. We want to test whether the statement of this firm is true. To do so, a sample with 10 bottles has been withdrawn. Test: H0 : µ = 200 H1 : µ 6= 200 Test statistic T=

M. Angeles Carnero (UA)

¯ X

µ0 pσ n

=

¯ X

200 p6 10

Chapter 3: Hypothesis Testing

Curso 2014-15

18 / 71

Since the distribution of T if the null hypothesis is true is N (0, 1) and since the alternative hypothesis is two-sided, the decision rule is: Reject H0 if T 2 ( ∞, zα/2 ) [ (zα/2 , +∞) The sample mean in our sample is 197 gr and the significance level is chosen to be α = 0,05. In this case, the value that the test statistic T takes in the sample is t = 1,581, and z0,025 = 1,96. Therefore: t=

1,581 2 / ( ∞,

1,96) [ (1,96, +∞) ) Do not reject H0

Even if the average weight in the sample is 197 gr, the conclusion is that there is not enough evidence to reject the hypothesis that the population mean weight is 200 gr.

M. Angeles Carnero (UA)

Chapter 3: Hypothesis Testing

Curso 2014-15

19 / 71

Using the option Tools )Test Statistics Calculator in Gretl we can obtain the value of the test statistic t = 1,581 above: 0,5 Dist ribución m uest ral G aussiana E st adí st ico de c ont rast e

0,45 0,4 0,35 0,3 0,25 0,2 0,15 0,1 0,05 0 -3

-2

-1

0

1

2

3

Desviaciones t í picas

M. Angeles Carnero (UA)

Chapter 3: Hypothesis Testing

Curso 2014-15

20 / 71

What would have been our conclusion if a sample of 50 bottles had been withdrawn and if the average weight in this sample had been 198 gr instead? Test statistic with this sample: t=

x

µ0 σ n1/2

=

198

200

6 501/2

=

2,357

Taking α = 0,05 as significance level, the decision rule would still be: Reject H0 if T 2 ( ∞, 1,96) [ (1,96, +∞) Therefore, in this case: t=

2,357 2 ( ∞,

1,96) [ (1,96, +∞) ) Reject H0

In this situation the null hypothesis is rejected. As expected, in this type of analysis, it is not only important to know the sample mean, but also the knowledge of the number of observations we can use. M. Angeles Carnero (UA)

Chapter 3: Hypothesis Testing

Curso 2014-15

21 / 71

The p-value of the test is the lowest significance level such that the null hypothesis would be rejected. The p-value is computed as the probability that our test statistic takes a more extreme value than the value taken in our sample, assuming the null hypothesis is true. That is: If the value that the test statistic T takes in the sample t is positive, t > 0, then if Z is a r.v. with a standard normal distribution we have p-value = P (Z
t) = 2

P (Z > t)

If t < 0, then: p-value = P (Z < t) + P (Z >

t) = 2

P (Z >

t)

Importance of the p-value: if we know the p-value, we can determine for a given significance level α, if the null hypothesis is rejected or not rejected. If p-value > α ) Do not reject H0 . If p-value < α ) Reject H0 . M. Angeles Carnero (UA)

Chapter 3: Hypothesis Testing

Curso 2014-15

22 / 71

Example 3 (continue): When the sample size is 10 bottles, the value of the test statistic is t = 1,581 and it was concluded that, if the significance level is α = 0,05, we do not reject the null hypothesis. Therefore, we know in this case that the p-value of the test is above 0,05. The p-value is a significance level such that the value the limit of the critical region, that is: p-value = P(Z
1,581) = 0,114

Therefore, with significance level 0,10 we do not reject the null hypothesis neither, although if the significance level is 0,12 the null hypothesis would be rejected (however the significance level usually is not that large). This value is also provided by Gretl in the option Tools ) Test Statistic Calculator M. Angeles Carnero (UA)

Chapter 3: Hypothesis Testing

Curso 2014-15

23 / 71

It is important to mention the existing duality between two-sided hypothesis testing and confidence intervals. In Chapter 2, we concluded that x

σ σ zα/2 p , x + zα/2 p n n

is a confidence interval of level 100(1 mean µ.

α) % for the population

Therefore, in case 1 studied above, the fact of not rejecting H0 with significance level α is equivalent to the fact that µ0 lies within the confidence interval for µ with confidence level 100(1 α) %. Similarly, a confidence interval for µ with confidence level 100(1 α) % is a set of values for which the hypothesis that these values are equal to µ would not be rejected with significance level α. M. Angeles Carnero (UA)

Chapter 3: Hypothesis Testing

Curso 2014-15

24 / 71

Case 2: We want to test H0 : µ = µ 0 H1 : µ > µ 0 where µ0 is known. What is a reasonable decision rule to reject H0 in this case? A decision rule with significance level α is “Reject H0 if T 2 C” where X µ T = q 0 and C = (zα , ∞) σ2 n

or equivalently, ”Reject H0 if

M. Angeles Carnero (UA)

x µ0 q σ2 n

> zα .

Chapter 3: Hypothesis Testing

Curso 2014-15

25 / 71

As seen above, if H0 is true we have X µ T= q 0 σ2 n

M. Angeles Carnero (UA)

N (0, 1)

Chapter 3: Hypothesis Testing

Curso 2014-15

26 / 71

If

x µ0 q σ2 n

is computed with our sample and its value is smaller than

zα , there is no evidence to reject H0 . However, if

x µ0 q σ2 n

> zα then there is evidence against the null

hypothesis and in favour of the alternative. In this case, if statistic T takes value t in the sample, the p-value is computed by: p-value = P (Z > t) where Z follows a standard normal distribution. n case 3 we will analyse that this test is equivalent to test H0 : µ µ 0 H1 : µ > µ 0

M. Angeles Carnero (UA)

Chapter 3: Hypothesis Testing

Curso 2014-15

27 / 71

Example 2 (continue): We want to check whether there is evidence that the average duration µ of the light bulbs produced with the new method is above 1400 hours; thus, we test the following hypothesis: H0 : µ = 1400 H1 : µ > 1400 It is assumed that the duration of a light bulb produced by the new method is a normally distributed random variable with a population standard deviation of 70 hours. If in a sample of 25 light bulbs produced by this new method we obtain a sample mean of 1420 hours, is there enough evidence to reject the null hypothesis?

M. Angeles Carnero (UA)

Chapter 3: Hypothesis Testing

Curso 2014-15

28 / 71

The test statistic is T=

¯ X

µ0 pσ n

=

¯ X

1400 p70 25

Since the sample mean is 1420, the test statistic takes the value t = 1,429. Since this is a one-sided test, and only values above 1400 are in the alternative, the decision rule is: Reject H0 if T 2 (zα , +∞) If we take α = 0,05 as significance level, the critical value is z0,05 = 1,645. Therefore, since T takes a value that does not lie within the region (1,645, +∞), there is no evidence to reject the null hypothesis with this significance level. M. Angeles Carnero (UA)

Chapter 3: Hypothesis Testing

Curso 2014-15

29 / 71

The p-value of this test is logically larger than 0,05. Taking into account that the test statistic follows a standard normal distribution under the null hypothesis, that this is a one-sided test and that the value taken by this test statistic in the sample is 1,429, the p-value is: p-value = P(Z > 1,429) = 0,0765

Therefore, with a significance level α = 0,10, the null hypothesis would be rejected.

M. Angeles Carnero (UA)

Chapter 3: Hypothesis Testing

Curso 2014-15

30 / 71

Case 3: We want to test H0 : µ µ 0 H1 : µ > µ 0 where µ0 is known. The decision rule is the same as in case 2 since: if µ = µ0 the type I-error probability is α for values µ < µ0 the type I-error probability with this procedure is even lower therefore the significance level (the largest probability of type I-error) is still equal to α.

The p-value of the test in this case is also the same as the p-value in case 2.

M. Angeles Carnero (UA)

Chapter 3: Hypothesis Testing

Curso 2014-15

31 / 71

Case 4: We want to test H0 : µ = µ 0 H1 : µ < µ 0 where µ0 is known. The decision rule and the p-value are symmetrically obtained as in case 2. A decision rule with significance level α is “Reject H0 if T 2 C” where X µ T = q 0 and C = ( ∞, zα ) σ2 n

or equivalently, ”Reject H0 if

M. Angeles Carnero (UA)

x µ0 q σ2 n


1400

M. Angeles Carnero (UA)

Chapter 3: Hypothesis Testing

Curso 2014-15

43 / 71

If the population standard deviation is unknown, the test statistic that should be used is: T=

¯ X

µ0 pS n

=

¯ X

1400 pS 25

Since n = 25, the distribution of T under the null hypothesis is t24 . Since this is a one-sided test and the alternative hypothesis contains only values above 1400, the decision rule is: Reject H0 if T 2 (t24;α , +∞) If the sample size is 1420 gr and the sample standard deviation is 63 gr., the value of T in the sample is: t=

M. Angeles Carnero (UA)

1420

1400

p63 25

= 1,587

Chapter 3: Hypothesis Testing

Curso 2014-15

44 / 71

If the significance level is α = 0,05, then the critical value is t24;0,05 = 1,711. Therefore: t = 1,587 2 / (1,711, +∞) ) Do not reject H0 The p-value of this test is: p-value = P(t24 > 1,587) = 0,063 Then, with a significance level of 0,10 the null hypothesis would be rejected.

M. Angeles Carnero (UA)

Chapter 3: Hypothesis Testing

Curso 2014-15

45 / 71

Tests for the mean or a proportion with large samples Situation: It is assumed that X has mean µ and variance σ2 , both unknown, and we want to test a hypothesis on µ (without assuming that the distribution of F is normal); to do so, we assume we have access to a simple random sample of X. Case 1: We want to test H0 : µ = µ 0 H1 : µ 6= µ0 where µ0 is known. A decision rule with significance level α is “Reject H0 if T 2 C” where X µ T = q 0 and C = ( ∞, S2 n

M. Angeles Carnero (UA)

Chapter 3: Hypothesis Testing

zα/2 ) [ (zα/2 , ∞)

Curso 2014-15

46 / 71

Note that this statistic is the same we used in the tests for the mean of a normal population with unknown variance, but the critical values must be obtained from the distribution used in the tests for the mean of a normal population with known variance. The reason is the Central Limit Theorem. When the sample size is large, the distribution of the sample mean is approximately normal. In this case, the p-value would be obtained as in previous sections: If the value that T takes in the sample t is positive, t > 0, then if Z denotes a random variable with standard normal distribution, we have that p-value ' P (Z
t) = 2

P (Z > t)

If t < 0, then: p-value ' P (Z < t) + P (Z >

M. Angeles Carnero (UA)

Chapter 3: Hypothesis Testing

t) = 2

P (Z >

t)

Curso 2014-15

47 / 71

Additionally, note that the test can be also performed from the confidence interval as in the previous sections. Cases 2, 3, 4 and 5: The test statistic is the same as in case 1: X µ T= q 0 S2 n

The critical region and the p-value must be modified with respect to case 1 and analogously as in previous sections.

M. Angeles Carnero (UA)

Chapter 3: Hypothesis Testing

Curso 2014-15

48 / 71

Example 4: It is known that the mean wage income (in thousands of euros) of those households living in a large population was 22,5 thousands of euros last year. We want to analyse if the mean wage income of these households this year, denoted by µ, is equal to that of the mean income last year or not. This is why we decide to test: H0 : µ = 22,5 H1 : µ 6= 22,5 The population variance is unknown, and it is known that the income distribution is not normal. We have access to a sample of 500 households of this population and the sample mean of the wage income this year is 21.9 thousand of euros, with a sample standard deviation (S) of 6 thousand of euros.

M. Angeles Carnero (UA)

Chapter 3: Hypothesis Testing

Curso 2014-15

49 / 71

The test statistic takes the value: t=

21,9

22,5

p6 500

=

2,237

Since the test is two-sided, the decision rule is: Reject H0 if T 2 ( ∞,

zα/2 ) [ (zα/2 , +∞)

If the significance value is α = 0,01, the critical value is z0,005 = 2,576. Therefore: t=

2,237 2 / ( ∞,

2,576) [ (2,576, +∞) ) Do not reject H0

The approximate p-value is: p-value = P(Z
2,237) = 0,025

Therefore, with a significance level of 0,05,the null hypothesis would be rejected. M. Angeles Carnero (UA)

Chapter 3: Hypothesis Testing

Curso 2014-15

50 / 71

Situation: It is assumed that p is an unknown proportion and we want to test a hypothesis on p; to do so, we compute the sample proportion b p with a simple random sample. Solution: As we studied above, this situation is a particular case of tests for the mean without assuming normality. Therefore, all the results seen for the general case in this section can be applied with the following changes: µ should be replaced by p µ0 should be replaced by p0 X should be replaced by b p S2 should be replaced by p0 (1

M. Angeles Carnero (UA)

p0 ) .

Chapter 3: Hypothesis Testing

Curso 2014-15

51 / 71

If we want to test H0 : p = p0 H1 : p < p0 where µ0 is known. The critical region is

M. Angeles Carnero (UA)

Chapter 3: Hypothesis Testing

Curso 2014-15

52 / 71

Example 5: The government wants to establish a new measure, but before, it is going to survey the degree of acceptance of its measure; the measure will not be established if there is evidence against the hypothesis ”at least half of the population supports this measure”. If p denotes the proportion of people in this population supporting the measure, we want to perform the following test: H0 : p 0,5 H1 : p < 0,5 Suppose that 1000 people belonging to this population have been interviewed, and only 475 of them are in favour of this measure. In this case the test statistic takes the value: b p T= q

p0

p0 (1 p0 ) n

M. Angeles Carnero (UA)

0,475 )t= q

0,5

0,5(1 0,0,5) 1000

Chapter 3: Hypothesis Testing

=

1. 118

Curso 2014-15

53 / 71

Since this is a one-sided test and the alternative hypothesis only contains values below 0.5, the decision rule of this test is: Reject H0 if T 2 ( ∞,

zα )

Taking α = 0,05 as significance level, the critical value is z0,05 = 1,645. Therefore: t=

1. 118 2 / ( ∞,

1,645) ) Do not reject H0

The approximate p-value of the test can be computed using a random variable Z with standard normal distribution: P(Z
χ2n

∞, χ2n

and C =

(n 1)S2 σ20

1;1 α/2

< χ2n

1;1 α/2

[ χ2n

1;α/2 , ∞

or if

1;α/2 ”.

How has this rule been obtained? It seems reasonable to think that if we want to say something about σ2 we can use S2 . In Chapter 1 we saw that

(n

1)S2 σ2

M. Angeles Carnero (UA)

χ2n

Chapter 3: Hypothesis Testing

1

Curso 2014-15

56 / 71

Therefore, if H0 is true we have that

(n

1 ) S2 σ20

M. Angeles Carnero (UA)

χ2n

1

Chapter 3: Hypothesis Testing

Curso 2014-15

57 / 71

If

(n 1)S2 σ20

is computed with our sample and we obtain a value that

lies within χ2n

1;1 α/2

and χ2n

1;α/2

there is evidence to reject H0 . 2

1)S2

< χ2n 1;1 α/2 or (n σ12)S > χ2n 1;α/2 then we find 0 evidence against the null hypothesis. Note that it could be the case that H0 is true and therefore ( n 1 ) S2 χ2n 1 and we could still find a value of T that does not lie σ2 However, if

(n

σ20

0

within χ2n 1;1 α/2 and χ2n 1;α/2 . This happens with probability α, which is precisely the type I-error probability that we can fix as small as possible.

M. Angeles Carnero (UA)

Chapter 3: Hypothesis Testing

Curso 2014-15

58 / 71

The p-value is computed as the probability that our test statistic takes a more extreme value than the value taken in our sample. In this case it would be: n o p-value = m«ın 2 P χ2n 1 < t ; 2 P χ2n 1 > t

where t is the value in our sample of statistic T.

This test can also be performed from the confidence interval as in the case of the mean. The test statistic for cases 2, 3, 4 and 5 is the same as in case 1, but the critical region and how the p-value is computed differ depending on the alternative hypothesis. The computations are done exactly as in the previous sections.

M. Angeles Carnero (UA)

Chapter 3: Hypothesis Testing

Curso 2014-15

59 / 71

Example 3 (continue): Let’s assume that the weight of the shampoo bottles is normally distributed. Without making any additional assumption on the average weight, we want to test whether the population variance of the weight, denoted by σ2 is 36 gr2 versus a two-sided alternative hypothesis, that is: H0 : σ2 = 36 H1 : σ2 6= 36

In order to perform this test we have a sample with 10 bottles.The test statistic is S2 S2 T = (n 1) 2 = 9 36 σ0 Since the distribution of T if the null hypothesis is true is χ29 and the alternative hypothesis is two-sided, the decision rule is: Reject H0 if T 2 (0, χ29;1 M. Angeles Carnero (UA)

α 2

) [ (χ29; α , + ∞)

Chapter 3: Hypothesis Testing

2

Curso 2014-15

60 / 71

If the variance in the sample is 25 gr2 ; in this case, the test statistic takes the following value t = 9 (25/36) = 6,25. If the significance level is α = 0,05, then the values defining the critical region are χ29;0,975 = 2,70, and also χ29;0,025 = 19,02. Therefore: t = 6,25 2 / (0, 2,70) [ (19,02, + ∞) ) Do not reject H0 Therefore, there is not enough evidence to reject the hypothesis that the population variance is 36 gr2 .

M. Angeles Carnero (UA)

Chapter 3: Hypothesis Testing

Curso 2014-15

61 / 71

Computing the p-value of the test: Since the null hypothesis has not been rejected with significance level α = 0,05, we know that the p-value is above 0,05. In this case the p-values must be computed using a random variable with chi-square distribution with 9 degrees of freedom. In particular, since the test statistic takes value 6,25 and the alternative hypothesis is two-sided, the p-value is : p-value = 2

P(χ29 < 6,25)

= 2

0,285 = 0,57

The p-value obtained is high; the null hypothesis had not been rejected with any of the usual significance levels.

M. Angeles Carnero (UA)

Chapter 3: Hypothesis Testing

Curso 2014-15

62 / 71

With the decision rule used, we know that the probability of rejecting H0 if σ2 is 36 is 0,05. What is the probability of rejecting H0 if σ2 had been 25 , for instance? P(Reject H0 j σ2 = 25) = P 9

+P 9

S2 > 19,02 j σ2 = 25 36

+P 9

36 S2 > 25 25

S2 < 2,70 j σ2 = 25 + 36

=P 9

19,02 j σ2 = 25

36 S2 < 25 25

2,70 j σ2 = 25

= P(χ29 < 3,89) + P(χ29 > 27,39

= 0,081 + 0,001 = 0,082 This test is not very powerful to detect that σ2 = 25; this is natural since the sample size n = 10 is very small. M. Angeles Carnero (UA)

Chapter 3: Hypothesis Testing

Curso 2014-15

63 / 71

DECISION RULES (TWO-SIDED TESTS)

REJECT H0 IF

TEST

H0 : µ = µ0 vs H1 : µ 6= µ0 (normal pop.; σ2 known) H0 : µ = µ0 vs H1 : µ 6= µ0 (normal pop.; σ2 unknown) H0 : µ = µ0 vs H1 : µ 6= µ0 (non normal pop.; σ2 unknown; n large) H0 : p = p0 vs H1 : p 6= p0 (n large) H0 : σ2 = σ20 vs H1 : σ2 6= σ20 (normal population)

M. Angeles Carnero (UA)

¯ µ X 0

2 ( ∞, z α2 ) [ (z α2 , +∞)

¯ µ X 0

2 ( ∞, tn

¯ µ X 0

2 ( ∞, z α2 ) [ (z α2 , +∞)

pσ n

pS n

pS n

q

b p p0

p0 (1 p0 ) n

(n

1)

Chapter 3: Hypothesis Testing

1; α2 ) [ (tn 1; α2 , + ∞

2 ( ∞, z α2 ) [ (z α2 , +∞)

S2 2 (0, χ2n σ20

1;1

α 2

) [ (χ2n

Curso 2014-15

1; α2 ,

64 / 71

DECISION RULES (ONE-SIDED TESTS)

REJECT H0 IF

TEST

H0 : µ = µ0 vs H1 : µ > µ0 (normal pop.; σ2 known) H0 : µ = µ0 vs H1 : µ > µ0 (normal pop.; σ2 unknown.) H0 : µ = µ0 vs H1 : µ > µ0 (non normal population; σ2 unknown; n large) H0 : p = p0 vs H1 : p > p0 (n large) H0 : σ2 = σ20 vs H1 : σ2 > σ20 (normal population)

M. Angeles Carnero (UA)

¯ µ X 0 pσ n

¯ µ X 0 pS n

¯ µ X 0 pS n

q

(zα , + ∞ ) 2 ( tn

2 (zα , + ∞ )

b p p0

p0 (1 p0 ) n

(n

Chapter 3: Hypothesis Testing

1;α , + ∞ )

1)

2 (zα , + ∞ )

S2 2 (χ2n σ20

1;α , + ∞ )

Curso 2014-15

65 / 71

DECISION RULES (ONE-SIDED TESTS)

REJECT H0 IF

TESTS

H0 : µ = µ0 vs H1 : µ < µ0 (normal pop.; σ2 known) H0 : µ = µ0 vs H1 : µ < µ0 (normal pop.; σ2 unknown.) H0 : µ = µ0 vs H1 : µ < µ0 (non normal population; σ2 unknown; n large) H0 : p = p0 vs H1 : p < p0 (n large) H0 : σ2 = σ20 vs H1 : σ2 < σ20 (normal population)

M. Angeles Carnero (UA)

¯ µ X 0

2 ( ∞, zα )

¯ µ X 0

2 ( ∞, tn

¯ µ X 0

2 ( ∞, zα )

pσ n pS n

pS n

q

b p p0

p0 (1 p0 ) n

(n

Chapter 3: Hypothesis Testing

1)

1;α )

2 ( ∞, zα )

S2 2 (0, χ2n σ20

1;1 α )

Curso 2014-15

66 / 71

P-VALUE COMPUTATION (TWO-SIDED TESTS) TESTS

P-VALUE

H0 : µ = µ0 vs H1 : µ 6= µ0 (normal pop.; σ2 known)

2

P Z>

H0 : µ = µ0 vs H1 : µ 6= µ0 (normal pop.; σ2 unknown)

2

P tn

H0 : µ = µ0 vs H1 : µ 6= µ0 (non normal population; σ2 unknown; n large)

2

P Z>

H0 : p = p0 vs H1 : p 6= p0 (n large) H0 : σ2 = σ20 vs H1 : σ2 6= σ20 (normal population) M. Angeles Carnero (UA)

2

m«ın

> > : 2

Chapter 3: Hypothesis Testing

pσ n

x µ0

>

1

P Z> 8 > > < 2

x µ0

ps n

x µ0 ps n

q

b p p0

p0 (1 p0 ) n

!

P χ2n

1




1)s2

(n (n

σ20

;

1 ) s2

σ20

Curso 2014-15

67 / 71

P-VALUE COMPUTATION (ONE-SIDED TESTS)

TEST

P-VALUE

H0 : µ = µ0 vs H1 : µ > µ0 (normal pop.; σ2 known)

P Z>

x µ0

H0 : µ = µ0 vs H1 : µ > µ0 (normal pop.; σ2 unknown)

P tn

>

H0 : µ = µ0 vs H1 : µ > µ0 (non normal population; σ2 unknown; n large)

P Z>

1

H0 : p = p0 vs H1 : p > p0 (n large)

P Z>

H0 : σ2 = σ20 vs H1 : σ2 > σ20 (normal population)

P χ2n

M. Angeles Carnero (UA)

Chapter 3: Hypothesis Testing

1

pσ n

x µ0 ps n

x µ0 ps n

q

b p p0

p0 (1 p0 ) n

>

(n

! 1 ) s2

σ20 Curso 2014-15

68 / 71

P-VALUE COMPUTATION (ONE-SIDED TESTS)

TESTS

P-VALUE

H0 : µ = µ0 vs H1 : µ < µ0 (normal pop.; σ2 known)

P Z