Testing of Hypothesis - Final
Testing of Hypothesis - Final
𝐻0 is true 𝐻0 is false
Statistical test
A statistical test of a hypothesis is a rule, stated in terms of a sample, that prescribes
whether a hypothesis is to be accepted or rejected, based on the value of the sample point
obtained
Critical region
The critical region of a test is the region of the sample space such that if the sample point
lies in it, the null hypothesis 𝐻0 is rejected
Power function (𝑲)
The power function 𝐾 of a test is the probability that the sample point falls in the critical
region of the test
𝐾 = 𝑃(Rejecting 𝐻0 )
The value of the function 𝐾 at a particular point is called as the power of the test at that
point
Level of significance (𝜶)
The level of significance of a test is the size of the critical region of the test
Level of significance = 𝑃(Type I error) = 𝛼
Exercise
1. 𝑋 has a pdf of the form 𝑓(𝑥, 𝜃) = 𝜃𝑥 𝜃−1 , 0 < 𝑥 < 1, 𝜃 > 0. To test 𝐻0 : 𝜃 = 1 against
𝐻1 : 𝜃 = 2, it is decided to use a random sample (𝑋1 , 𝑋2 ) of size 2 with the critical
3
region as 𝐶 = {(𝑥1 , 𝑥2 )|𝑥1 𝑥2 ≥ }. Compute the power function 𝐾(𝜃) and the
4
significance level 𝛼 of the test.
Solution:
3
𝐾(𝜃) = 𝑃(critical region 𝐶) = 𝑃 (𝑋1 𝑋2 ≥ )
4
1 1
=∫ ∫ 𝜃 2 (𝑥1 𝑥2 )𝜃−1 𝑑𝑥2 𝑑𝑥1
3 3
𝑥1 = 𝑥2 =
4 4𝑥1
1
1 3 𝜃
= 𝜃∫ (𝑥1𝜃−1 − ( ) ) 𝑑𝑥1
𝑥1 =
3 𝑥1 4
4
3 𝜃 3
= 1 − ( ) [1 − 𝜃 log ( )]
4 4
Level of significance, 𝛼 = 𝐾(1) (since 𝐻0 : 𝜃 = 1)
= 0.0342
2. Let (𝑋1 , 𝑋2 ) be a random sample of size 2 from the distribution having pdf 𝑓(𝑥, 𝜃) =
𝑥
1
𝑒 −𝜃 , 𝑥 > 0, 𝜃 > 0. We reject 𝐻0 : 𝜃 = 2 and accept 𝐻1 : 𝜃 = 1 if the observed value
𝜃
(𝑥1 , 𝑥2 ) of the sample is such that
𝑓(𝑥1 , 2) 𝑓(𝑥2 , 2) 1
≤
𝑓(𝑥1 , 1)𝑓(𝑥2 , 1) 2
Find the significance level of the test and the power of the test when 𝐻1 is true.
Solution:
The critical region is given by
𝑓(𝑥1 , 2) 𝑓(𝑥2 , 2) 1
≤
𝑓(𝑥1 , 1)𝑓(𝑥2 , 1) 2
1 −𝑥21 1 −𝑥22
𝑒 × 𝑒 1
2 2 ≤
1 −𝑥11 1 −𝑥12 2
𝑒 × 𝑒
1 1
𝑥1 +𝑥2
𝑒 2 ≤2
𝑥1 + 𝑥2
≤ log 2
2
𝑥1 + 𝑥2 ≤ log 4
1 log 4 −log 4 𝑥
− 1
=− ∫ (𝑒 𝜃 − 𝑒 𝜃 ) 𝑑𝑥1
𝜃 𝑥1=0
log 4 −log 4 log 4
=− 𝑒 𝜃 − 𝑒− 𝜃 + 1
𝜃
Significance level = 𝛼 = 𝐾(2) (since 𝐻0 : 𝜃 = 2)
= 0.1534
Power of the test when 𝐻1 is true (i.e., 𝜃 = 1) is 𝐾(1) = 0.4034
3. The life length of a tyre in miles, 𝑋 is normally distributed with mean 𝜃 and standard
deviation 5000. The past experience indicates that 𝜃 = 30,000. The manufacturer
claims that the tyres made by a new procedure have 𝜃 > 30,000 and it is very likely
that 𝜃 = 35,000. Check the claim by testing 𝐻0 : 𝜃 ≤ 30,000 against 𝐻1 : 𝜃 > 30,000.
Observe 𝑛 independent values of 𝑋, say 𝑥1 , 𝑥2 , … , 𝑥𝑛 and reject 𝐻0 if and only if 𝑋̅ >
𝑐. Determine 𝑛 and 𝑐 so that the power function 𝐾(𝜃) has values 𝐾(30,000) = 0.01
and 𝐾(35,000) = 0.98.
Solution:
𝑲(𝟑𝟎, 𝟎𝟎𝟎) = 𝟎. 𝟎𝟏 𝑲(𝟑𝟓, 𝟎𝟎𝟎) = 𝟎. 𝟗𝟖
𝑃(𝑋̅ > 𝑐|𝜃 = 30000) 𝑃(𝑋̅ > 𝑐|𝜃 = 35000)
= 0.01 = 0.98
𝑐 − 30000 𝑐 − 35000
𝑃 [𝑍 > ] = 0.01 𝑃 [𝑍 > ] = 0.98
5000/√𝑛 5000/√𝑛
𝑐 − 35000 𝑐 − 35000
𝑃 [𝑍 ≤ ] = 0.99 𝑃 [𝑍 ≤ ] = 0.02
5000 5000
√𝑛 √𝑛
𝑐 − 30000 𝑐 − 35000
= 2.33 = −2.06
5000 5000
√𝑛 √𝑛
0 𝑒𝑙𝑠𝑒𝑤ℎ𝑒𝑟𝑒
Let 𝐻0 : 𝜃 = 2, 𝐻1 : 𝜃 = 4. Use random samples (𝑋1 , 𝑋2 ) of size 2 and define critical
region to be 𝐶 = {(𝑥1 , 𝑥2 )|9.5 ≤ 𝑋1 + 𝑋2 ≤ ∞}. Find the significance level of the test.
Solution:
𝐾(𝜃) = 𝑃 ((𝑥1 , 𝑥2 ) ∈ 𝐶)= 𝑃 (9.5 ≤ 𝑋1 + 𝑋2 ≤ ∞) = (1 − 𝑃(0 ≤ 𝑋1 + 𝑋2 ≤ 9.5)
1 9.5 9.5−𝑥2 − 𝑥1 +𝑥2 9.5+𝜃 9.5
−
𝐾(𝜃) = 1 − ∫ ∫0 𝑒 𝜃 𝑑𝑥1 𝑑𝑥2 = 𝑒 𝜃
𝜃2 0 𝜃
𝐾(2) = 𝛼 = 0.05
1 1
5. Let 𝑋 have binomial distribution with parameter 𝑛 = 10 and 𝑝 ∈ {𝑝 ∶ 𝑝 = , }.
4 2
1 1
𝐻0 : 𝑝 = , is rejected and 𝐻1 : 𝑝 = is accepted. If the observed values of 𝑋1 is a
2 4
random sample of size 1 is less than or equal to 3, find the power function of the test.
Solution:
𝐶 = {𝑥1 | 𝑥1 ≤ 3 }
𝑃(𝑋1 = 0) = 10𝐶0 𝑝0 (1 − 𝑝)10−0
𝑃(𝑋1 = 1) = 10𝐶1 𝑝1 (1 − 𝑝)10−1 and so on
𝐾(𝜃) = 𝑃(𝐶) = 𝑃{𝑥1 | 𝑥1 ≤ 3 }
= 𝑃(𝑋1 = 0) + 𝑃(𝑋1 = 1) + 𝑃(𝑋1 = 2) + 𝑃(𝑋1 = 3)
= 10𝐶0 𝑝0 (1 − 𝑝)10−0 + 10𝐶1 𝑝1 (1 − 𝑝)10−1 + 10𝐶2 𝑝2 (1 − 𝑝)10−2
+10𝐶3 𝑝3 (1 − 𝑝)10−3
1 11
𝐾( ) = 𝛼 =
2 64
6. Let 𝑋 have a poisson distribution with mean 𝜃. Test the simple hypothesis 𝐻0 : 𝜃 = 0.5
against the composite hypothesis 𝜃 < 0.5 by using a sample (𝑋1 , 𝑋2 , … , 𝑋12 ) of size
12. Reject 𝐻0 if and only if the observed value 𝑌 = 𝑋1 + 𝑋2 + ⋯ + 𝑋12 ≤ 2. Find the
1 1 1 1 1
powers 𝐾 ( ) . 𝐾 ( ) , 𝐾 ( ) , 𝐾 ( ) and 𝐾 ( ). What is the significance level of the
2 3 4 6 12
test?
Solution:
Since 𝑋~𝑃(𝜃), 𝑌 = 𝑋1 + 𝑋2 + ⋯ + 𝑋12 ~𝑃(12𝜃)
𝑒 −12𝜃 (12𝜃)𝑦
i.e. 𝑃(𝑌 = 𝑦) = , 𝑦 = 0,1,2, …
𝑦!
2
𝑒 −12𝜃 (12𝜃)𝑦
𝐾(𝜃) = 𝑃(𝑌 ≥ 2) = ∑ = 𝑒 −12𝜃 (1 + 12𝜃 + 72𝜃 2 )
𝑦!
𝑦=0
𝜃 1 1 1 1 1
2 3 4 6 12
𝐾(𝜃) 0.0619 0.2382 0.4232 0.6765 0.9198
Significance level is
𝛼 = 𝐾(0.5)(∵ 𝐻0 : 𝜃 = 0.5) = 0.0619
1
7. Let 𝑌 have a binomial distribution with parameters 𝑛 and 𝑝. We reject 𝐻0 : 𝑝 = and
2
1
accept 𝐻1 = 𝑝 > if 𝑦 ≥ 𝑐. Find 𝑛 and 𝑐 to give a power function 𝑘(𝑝) which is such
2
1 2
that 𝑘 ( ) = 0.1 and 𝑘 ( ) = 0.95 approx.
2 3
Solution:
𝑌 ~ 𝐵(𝑛, 𝑝) ⇒ 𝜇 = 𝑛𝑝, 𝜎 2 = 𝑛𝑝𝑞
𝐾(𝑝) = 𝑃(𝑌 ≥ 𝑐)
𝑌−𝑛𝑝 𝑐−𝑛𝑝 𝑐−𝑛𝑝
= 𝑃( ≥ ) = 𝑃 (𝑧 ≥ )
√𝑛𝑝𝑞 √ 𝑛𝑝𝑞 √𝑛𝑝𝑞
1 2𝑐 − 𝑛
𝐾 ( ) = 0.1 ⟹ 𝑃(𝑧 ≥ ) = 0.1
2 √𝑛
2𝑐−𝑛
i.e., 1 − 𝑃 (𝑧 < ) = 0.1
√𝑛
2𝑐 − 𝑛
𝜙( ) = 0.9
√𝑛
2𝑐 − 𝑛
= 𝜙 −1 (0.9) = 1.28
√𝑛
2𝑐 − 𝑛 = 1.28√𝑛 − (𝑖)
2 3𝑐 − 2𝑛
𝐾 ( ) = 0.95 ⟹ 𝑃(𝑧 ≥ ) = 0.95
3 √2𝑛
3𝑐−2𝑛
i.e., 1 − 𝑃 (𝑧 < ) = 0.95
√2𝑛
3𝑐 − 2𝑛
𝜙( ) = 0.05
√2𝑛
3𝑐 − 2𝑛
= 𝜙 −1 (0.05) = −𝜙 −1 (0.95) = −1.64
√2𝑛
3𝑐 − 2𝑛 = 1.64√2𝑛 = −2.3193√𝑛 − (𝑖𝑖)
= 0.7188
Chi-Square Test
Now imagine that the same question is asked about a given six-sided die. Again, we can
test the hypothesis that the die is fair, by throwing it 𝑛 times and observing the
distribution of the resulting outcomes. Now, however, we have not two but six different
classes into which the outcomes are divided – namely the number of appearances of 1,
the number of appearances of 2,⋯, the number of appearances of 6. Let these numbers
be denoted by 𝑥1 , 𝑥2 , ⋯ , 𝑥6 . We also have the probabilities 𝑝1 , 𝑝2 , ⋯ , 𝑝6 for the
occurrence of the respective faces 1,2, ⋯ ,6 of the die in each throw. In the case of a fair
1
die, each of these would be 𝑝𝑖 = . Since 𝑛 is the total number of throws, we expect that
6
each observed number 𝑥𝑖 should be more or less equal to 𝑛𝑝𝑖 .
(For instance, if we throw the die 60 times, then if the die is fair, each face should
appear roughly 10 times.)
Therefore, the difference 𝑥𝑖 − 𝑛𝑝𝑖 between the observed and expected number of
appearances is a measure of how false our hypothesis is likely to be.
Therefore, we need to design a test that uses these deviations to estimate the
probability of the truth or falsehood of the hypothesis.
Firstly, observe that 𝑥6 = 𝑛 − (𝑥1 + ⋯ + 𝑥5 ), so that we only need to consider
𝑥1 , 𝑥2 , ⋯ , 𝑥5 . The sample (𝑋1 , ⋯ , 𝑋5 ) has what is known as the multinomial distribution
with parameters 𝑛, 𝑝1 , ⋯ , 𝑝5 . Then if we define
(𝑋1 −𝑛𝑝1 )2 (𝑋2 −𝑛𝑝2 )2 (𝑋3 −𝑛𝑝3 )2 (𝑋4 −𝑛𝑝4 )2 (𝑋5 −𝑛𝑝5 )2 (𝑋6 −𝑛𝑝6 )2
𝒬5 = + + + + + ,
𝑛𝑝1 𝑛𝑝2 𝑛𝑝3 𝑛𝑝4 𝑛𝑝5 𝑛𝑝6
𝒬5 ~𝜒52 approximately for large 𝑛 (i.e., in the limiting case where 𝑛 → ∞).
Now the test is as follows. Select a value 𝑐, and reject the hypothesis that the die is fair if
𝒬5 ≥ 𝑐. What should be the ideal value of 𝑐? That depends on the significance level of
the test. What we can do therefore, is to set a desired significance level 𝛼 and select 𝑐
such that 𝑃(𝒬5 ≥ 𝑐) = 𝛼. This value of 𝑐 can be obtained from the chi-square.
The chi-square test in general can therefore be described as follows. Given 𝑘 classes
𝐶1 , 𝐶2 , ⋯ 𝐶𝑘 , to test the hypothesis 𝐻0 that the probability distribution of these classes is
𝑝1 , 𝑝2 , ⋯ , 𝑝𝑘 respectively (where 𝑝1 + 𝑝2 + ⋯ + 𝑝𝑘 ), we conduct 𝑛 trials and observe
the frequencies 𝑋1 , 𝑋2 , ⋯ , 𝑋𝑛 , of the respective classes (so that 𝑋1 + 𝑋2 + ⋯ + 𝑋𝑛 =
1).
(𝑋𝑖 −𝑛𝑝𝑖 )2
Now define 𝒬𝑘−1 = ∑𝑘𝑖=1 .
𝑛𝑝𝑖
Then the chi-square test with significance level 𝛼 is to reject 𝐻0 if 𝒬𝑘−1 ≥ 𝑐, where 𝑐 is
the value such that 𝑃[𝒬𝑘−1 ≥ 𝑐] = 𝛼. Common values of 𝛼 are 0.05 and 0.01, written as
5% and 1% respectively.
Exercise
1. A six-sided die is thrown 60 times and observed frequencies of the faces 1,2, ⋯ ,6 are
13,19,11,8,5,4 respectively. Test whether the die is fair at 5% level of significance?
Solution:
Here we have number of classes 𝑘 = 6, and theoretical probabilities 𝑝1 = 𝑝2 = ⋯ =
1
𝑝6 = (since a fair die must have equally likely outcomes), so that 𝑛𝑝𝑖 = 10, 𝑖 =
6
1,2, ⋯ ,10. Then
6
(𝑥𝑖 − 𝑛𝑝𝑖 )2
𝒬5 = ∑
𝑛𝑝𝑖
𝑖=1
(13 − 10)2 (19 − 10)2 (11 − 10)2 (8 − 10)2 (5 − 10)2 (4 − 10)2
= + + + + +
10 10 10 10 10 10
= 15.6
But 𝜒52 = 11.1 at 5% level of significance. Thus, 𝒬5 > 𝜒52 , which means that we reject
the hypothesis that the die is fair.
2. The Mendelian theory of genetics of crossing two types of peas states that the
9 13 13 1
probabilities of classification of the four resulting types are , , and
16 16 16 16
respectively. If from 160 independent observations, the observed frequencies of these
classifications are 86,35,26,13 respectively, test whether the data is consistent with
the theory with 𝛼 = 0.01.
Solution:
Here 𝑘 = 4, 𝑛 = 160 and 𝑛𝑝1 = 90, 𝑛𝑝2 = 30, 𝑛𝑝3 = 30, 𝑛𝑝4 = 10.
Therefore,
3
(𝑥𝑖 − 𝑛𝑝𝑖 )2
𝒬3 = ∑
𝑛𝑝𝑖
𝑖=1
(86−90)2 (35−30)2 (26−30)2 (13−10)2
= + + +
90 30 30 10
= 2.44 < 11.345 = χ23
at 1% level of significance (since 𝛼 = 0.01).
Thus, we accept the hypothesis that the data is consistent with the theory.
3. The table below lists the observed results of 𝑛 = 120 independent throws of a die.
Face 1 2 3 4 5 6
Frequency 𝑎 20 20 20 20 40 − 𝑎
For what values of 𝑎 would the hypothesis that the die is unbiased be rejected at 0.025
level of significance in a chi-square test?
Solution:
(𝑏−20)2
Since our test (at 0.025 level of significance) is to reject this if > 12.833 (this
10
number is obtained by comparing to a 𝜒 2 (5) distribution), we solve
(𝑏 − 20)2
> 12.833
10
If (𝑏 − 20) > √128.33 + 20
Or 𝑏 < 20 − √128.33
There are two sides coming from the positive and negative square root of (𝑏 − 20)2 ;
both need to be accounted for.
4. A manufacturer of lightbulbs claims that the lightbulbs produced fall into five
categories A, B, C, D, and E by quality, from highest to lowest, and that the percentages
of lightbulbs in these five categories are 15, 25, 35, 20, and 5 respectively. A contractor
who purchases a large number of the lightbulbs tests the claim by taking a random
sample of 30 lightbulbs and observes that the numbers of lightbulbs that fall in the
categories A, B, C, D, and E are 3, 6, 9, 7, and 5 respectively. Test whether the
manufacturer is speaking the truth, using a chi-square test at
(i) 5% significance level.
(ii) 1% significance level.
Solution:
Category A B C D E
15 25 35 20 5
Expected 30 ∗ = 4.5 30 ∗ = 7.5 30 ∗ = 10.5 30 ∗ =6 30 ∗ = 1.5
100 100 100 100 100
Observed 3 6 9 7 5
5. A survey of 320 families with 5 children each revels the following distribution
Number of boys 5 4 3 2 1 0
Number of families 14 55 110 88 40 12
As the result consistent with the hypothesis that the male and female birth are equally
probable at 0.05 significance level.
Solution:
Let 𝐻0 : Male and female birth is equal probable
1 1
If 𝐻0 is true, then 𝑝 = 𝑎𝑛𝑑 1 − 𝑝 =
2 2