Tutorial 10
The University of Hong Kong
1 Recap
1. Hypothesis Testing
2 This week
1. Hypothesis Testing
2.1 Hypothesis Testing
1. State null hypothesis H0 , alternative hypothesis H1 , and significance level α;
2. Choose test statistic T = T (X1 , . . . , Xn );
3. Calculate realized test statistic t = T (x1 , x2 , . . . , xn );
4. Determine the form of the rejection region C, for example: - {T > k1 } (or {T ≥ k1 } ) - {T < k2 }
(or {T ≤ k2 } ) - {T < k3 or T > k4 } (or {T ≤ k3 or T ≥ k4 } ) without specify those k. (See the
next subsection for more details.)
5. (Adopt these two steps for Critical region method)
(a) Find the upper or/and lower α quantile according to the rejection region, and replace those
k in the fourth step by those quantiles.
(b) Check whether realized test statistic t is in the rejection region or not. If so, reject H0 at α
significance level.
6. (Adopt these two steps for p-value method)
(a) Replace those k in the fourth step by the realized test statistic t and find the probability of
this event to be happened.
(b) Check whether the probability is less than α. If so, reject H0 at α significance level.
1
2.2 Determine the form of the rejection region
2.2.1 Most powerful tests
- A test concerning a simple null hypothesis H0 : θ = θ0 against a simple alternative hypothesis
H1 : θ = θ1 is said to be most powerful if the power of the test at H1 is a maximum.
- (Likelihood ratio test) Let L(θ) be the likelihood function of θ. If the rejection region C of a test
at α significant level is in the form of
L (θ0 )
≤k
L (θ1 )
it is most powerful among all tests having significance level at most α.
2.2.2 Uniformly most powerful tests
- A test concerning a simple null hypothesis H0 : θ = θ0 against a composite alternative hypothesis
H1 : θ ∈ Ω1 , where Ω1 consists of more than one element, is said to be uniformly most powerful if
its power function π(θ) satisfies
π(θ) ≥ π̃(θ), for all θ ∈ Ω1 ,
where π̃(θ) is the power function of any other test with significance level α.
2.2.3 Generalized likelihood ratio tests
- Let θ ∈ Ω, where Ω is the parametric space. A test concerning H0 : θ ∈ Ω0 against H1 : θ ∈ Ω1 ,
where Ω1 is the complement of Ω0 with respect to Ω is said to be generalized likelihood ratio tests
if the form of rejection region is
L (Ω0 )
Λ= ≤ k,
L(Ω)
where 0 ≤ k ≤ 1, L (Ω0 ) = maxθ∈Ω0 L(θ) and L(Ω) = maxθ∈Ω L(θ).
- Recall that MLE θ̂ is the argument which maximizes the L(θ) over the parameter spaces Ω.
Therefore, L(Ω) = L(θ̂).
3 Exercise
1. Let the pdf of X be f (x | θ) = θxθ−1 1{0 < x < 1} for θ = 1, 2. To test the simple hypothesis
H0 : θ = 1 against the alternative simple hypothesis H1 : θ = 2, we use a random sample X1 , X2 of
size 2 and define the critical region C = {(x1 , x2 ) : 0.75 ≤ x1 x2 }.
a. Find the power function of the test.
b. If the realized test statistic x1 and x2 are 0.8 and 0.9 , do we reject the H0 ?
2
Solution:
a. The joint pdf of X1 and X2 is
f (x1 , x2 ) = θ2 (x1 x2 )θ−1 1 {0 < x1 < 1} 1 {0 < x2 < 1} .
When θ = 1, the power function is
Z 1Z 1 Z 1
3
π(1) = Pr {X1 X2 ≥ 3/4 | θ = 1} = dx1 dx2 = 1− dx2
3 3
3/4 4x2
4 4x2
1
3 3 1 3 3
= 1− − ln x2 = + ln .
4 4 3/4 4 4 4
When θ = 2, the power function is
Z 1Z 1 Z 1
9
π(2) = Pr {X1 X2 ≥ 3/4 | θ = 2} = (4x1 x2 ) dx1 dx2 = 2x2 − dx2
3 3
3/4 8x2
4 4x2
1
1 9 7 9 3
= x22 3/4
− ln x2 = + ln .
8 3/4 16 8 4
Therefore, the power function is
(
1 3 3
π(θ) = 4 + 4 ln 4 , θ=1
7 9 3
16 + 8 ln 4 , θ = 2.
b. Since x1 x2 = 0.8 × 0.9 = 0.72 ∈
/ C , the null hypothesis is not rejected.
2. A manufacturer has produced a large batch of fan-belts whose lengths follow a uniform
distribution. From the past experience, he knows that the minimum length is 45 cm. To construct
a test for the mean length µ, 12 items are randomly selected. He would like to know whether the
mean length is 52 cm or 53 cm with type one error probability of the test to at most 0.05 . Note:
Here, we define type one error as rejecting mean = 52 cm given that this is true.
a. State the null and an alternative hypothesis.
b. Find the likelihood ratio Λ between µ0 and µ1 .
c. If the test statistic T is chosen to be the sample maximum maxi Xi , show that the form of test
with the rejection region {max X1 ≥ k} is the most powerful test among all tests having significance
level at most 0.05 . (Remarks: At this stage, no need to determine the k specifically.)
d. Critical region method is applied. Find the critical value k for this test.
e. If he found that the realized sample maximum is 58 cm, what is his conclusion?
f. p-value method is applied. What is the p-value? Does the conclusion coincide with (e)?
3
Solution:
a. H0 : µ = 52 vs H1 : µ = 53.
b. Since the mean of uniform distribution U [45, θ] is µ = 0.5(45 + θ), we may express the pdf of
uniform distribution as
1 1
f (x) = 1{45 ≤ x ≤ θ} = 1{45 ≤ x ≤ 2µ − 45}.
θ − 45 2µ − 90
Therefore, the likelihood function is
12
Y 1
L(µ) = 1 {45 ≤ xi ≤ 2µ − 45}
2µ − 90
i=1
12
1
= 1 min xi ≥ 45 1 max xi ≤ 2µ − 45
2µ − 90 i i
the likelihood ratio between µ1 and µ0 is
12
1
2µ0 −90 1 {mini xi ≥ 45} 1 {maxi xi ≤ 2µ0 − 45}
Λ (µ0 , µ1 ) = 12
1
2µ1 −90 1 {mini xi ≥ 45} 1 {maxi xi ≤ 2µ1 − 45}
12
2µ1 − 90 1 {maxi xi ≤ 2µ0 − 45}
=
2µ0 − 90 1 {maxi xi ≤ 2µ1 − 45}
c. By Neyman-Pearson Lemma, we know that, if exists, the likelihood ratio test is the most
powerful test. Therefore, we consider the likelihood ratio less than a arbitrary positive
constant k,
12
16 1 {maxi xi ≤ 59}
≤k
14 1 {maxi xi ≤ 61}
which is equivalent to
1 {maxi xi ≤ 59}
≤k
1 {maxi xi ≤ 61}
Since (
1 {maxi xi ≤ 59} 0, when 59 < maxi xi ≤ 61
=
1 {maxi xi ≤ 61} 1, when maxi xi ≤ 59
and undefined otherwise, the equation (1) reduced to 1 {maxi xi ≤ 59} ≤ k for maxi xi ≤ 61.
Then, we have to find a set C such that
1 {maxi xi ≤ 59} ≤ k, when (x1 , . . . , xn ) ∈ C
1 {maxi xi ≤ 59} ≥ k, when (x1 , . . . , xn ) ∈
/C
and
P {(X1 , . . . , Xn ) ∈ C} = 0.05 for µ = 52.
Since the value of 1 {maxi xi ≤ 59} only depends on maxi xi , we shall set our test statistic
to be maxi xi . You could see that when maxi xi is large (59 < maxi xi ≤ 61), the likelihood
4
ratio becomes 0 . Hence, we must reject the null hypothesis. Therefore, the rejection region
C should be {(X1 , . . . , Xn ) : maxi xi ≥ k} for some k. (Do not confuse with the k above. This
k is another constant.)
Note: In my hand-written note, I have used ” k ”” and ” k ” to distinguish these two different
constants.
d. To find out the critical value k, we have to first obtain the distribution of the test statistic
T = maxi Xi under H0 : µ = 52, which is
P max Xi ≤ x | µ = 52 = P (X1 ≤ x | µ = 52) × . . . × P (X12 ≤ x | µ = 52)
i
0,
12
for x < 45
x−45
= 14 , for 45 ≤ x ≤ 59
1, Otherwise.
Therefore, the 0.05 upper quantile of T under H0 : µ = 52, i.e. the critical value k, is
0.05 = P max Xi ≥ k | µ = 52
i
12
k − 45
=⇒ 1 − 0.05 =
14
=⇒ k = 58.9403.
e. Since the rejection region C = {maxi Xi ≥ 58.9403} does not include 58 , we do not reject H0
at 0.05 significance level.
f. By considering
12
58 − 45
P (T ≥ 58 | µ = 52) = 1 −
14
= 0.5891 > 0.05
we do not reject H0 at 0.05 significance level, which has the same conclusion as (e).
3. (cont. Q2) Is there a test (uniformly) most powerful if the alternative hypothesis becomes
a. H1 : µ = 54 ?
b. H1 : µ = 50 ?
c. H1 : µ > 52 ?
d. H1 : µ < 52 ?
e. H1 : µ ̸= 52 ?
5
Solution:
a. a. The changes compared to the Q2 is in the cut off line between definiteness and
indefiniteness. Therefore, the most powerful test is still {maxi Xi ≥ 58.9403}.
b. By Neyman-Pearson Lemma again, we know that, if exists, the likelihood ratio test is the
most powerful test. Therefore, we consider the likelihood ratio less than a arbitrary positive
constant k,
12
10 1 {maxi xi ≤ 59}
≤ k,
14 1 {maxi xi ≤ 55}
which is equivalent to
1 {maxi xi ≤ 55}
≥k
1 {maxi xi ≤ 59}
Since (
1 {maxi xi ≤ 55} 0, when 55 < maxi xi ≤ 59,
=
1 {maxi xi ≤ 59} 1, when maxi xi ≤ 55,
and undefined otherwise, the equation (2) reduced to 1 {maxi xi ≤ 55} ≥ k for maxi xi ≤ 59.
Then, we have to find a set C such that
1 {maxi xi ≤ 55} ≥ k, when (x1 , . . . , xn ) ∈ C
1 {maxi xi ≤ 55} ≤ k, when (x1 , . . . , xn ) ∈
/C
and
P {(X1 , . . . , Xn ) ∈ C} = 0.05 for µ = 52.
Since the value of 1 {maxi xi ≤ 55} only depends on maxi xi , we shall set our test statistic to
be maxi xi Hence, we must not reject the null hypothesis. Therefore, the rejection region C
should be {(X1 , . . . , Xn ) : maxi xi ≤ k} for some k. (Do not confuse with the k above again.
This k is another constant.) Then, the 0.05 lower quantile of T under H0 : µ = 52, i.e. the
critical value k, is
0.05 = P max Xi ≤ k | µ = 52
i
12
k − 45
=
14
=⇒ k = 55.9071.
The most powerful test is {maxi Xi ≤ 55.9081}.
c. We know from (a) that for any µ1 > 52, {maxi Xi ≥ 58.9403} is the most powerful test for
alternative H1 : µ > µ1 . Hence, it is the uniformly most powerful test.
d. We know from (b) that for any µ1 < 52, {maxi Xi ≤ 55.9071} is the most powerful test for
alternative H1 : µ < µ1 . Hence, it is the uniformly most powerful test.
6
e. Let πc (µ) and πd (µ) be the power function for the test in part (c) and (d) respectively. We
have, for µ ≥ 52
πc (µ) = P max Xi ≥ 58.9403 | µ
i
= 1 − P max Xi < 58.9403 | µ
i
12
58.9403 − 45
=1−
2µ − 90
and, for µ ≤ 52,
πd (µ) = P (maxi Xi ≤ 55.9071 | µ)
(
1, µ ≤ 50.4536, Note: When µ = 50.4536,
=
55.9071−45
12
2µ−90 , 50.4536 < µ ≤ 51 − 45) ÷ (2µ − 90) = 1
Note: When µ = 50.4536, (55.9071 − 45) ÷ (2µ − 90) = 1
Consider an arbitrary test with power π(µ) for test H0 : µ = 52 vs H1 : µ ̸= 52. Although it
is not the most powerful, we may still use it to test the hypothesis in (c) and (d). Therefore,
π(µ) ≤ πc (µ) for µ ≥ 52
π(µ) ≤ πd (µ) for µ ≤ 52
Consider the generalized likelihood ratio test with Ω0 = {52} and Ω = (45, ∞),
L(52)
Λ (H0 , H1 ) =
maxµ∈(45,∞) L(µ)
14−12 1 {maxi xi ≤ 59}
=
maxµ∈[45,∞] (2µ − 90)−12 1 {maxi xi ≤ 2µ − 90}
14−12 1 {maxi xi ≤ 59}
= .
(maxi xi )−12
For some positive constant k, the generalized likelihood ratio test is
max xi 1 max xi ≤ 59 ≤ k.
i i
Since we are interested at the test with at most 0.05 significant level, it is suffices to consider the
test at 0.05 significance level. Therefore,
P max xi 1 max xi ≤ 59 ≤ k | µ = 52 = 0.05
i i
=⇒ P max xi ≤ k | µ = 52 + P max xi > 59 | µ = 52 = 0.05.
i i
7
As P {maxi xi > 59 | µ = 52} = 0,
P max xi ≤ k | µ = 52 = 0.05
i
12
k − 45
=⇒ = 0.05
14
=⇒ k = 45 + 14 × (0.05)1/12 = 55.9071
Consider the power function of this test πe (θ),
P max Xi 1 max Xi < 59 ≤ 55.9071 | µ
i i
1, for µ ≤ 50.4536,
12
55.9071−45
= 2µ−90 , for 50.4536 < µ ≤ 52,
12 12
55.9071−45
59−45
+ 1 − 2µ−90 , for µ > 52.
2µ−90
Consider the last case, when µ > 52,
12 12 !12 12
14 × (0.05)1/12
55.9071 − 45 59 − 45 14
+1− =1+ −
2µ − 90 2µ − 90 2µ − 90 2µ − 90
12
14
=1− (1 − 0.05)
2µ − 90
!12
14 × 0.951/12
=1−
2µ − 90
58.9403 − 45 12
=1−
2µ − 90
Since this test attained the maximum possible power among all tests, this is the uniformly most
powerful test.
4. Suppose that the random samples X1 , . . . , Xn are i.i.d. and exponentially distributed with mean
1/λ, where λ > 0.
a. Derive a likelihood ratio test of H0 : λ = λ0 against H1 : λ ̸= λ0 , where λ0 > 0 is a fixed
constant.
n o
b. Show that the critical region is of the form X̄e−λ0 X̄ < c .
8
Solution:
a. Test H0 : λ = λ0 vs H1 : λ ̸= λ0 . The likelihood ratio for the hypotheses is
P
L (λ0 ) λn0 e−λ0 xi
= P
L(λ̂) λ̂n e−λ̂ xi
where λ̂ maximizes L(λ). In other words, λ̂ is the MLE. By solving
∂ ∂ X n X
0= ln ℓ(λ) = n ln λ − λ xi = − xi ,
∂λ ∂λ λ
and checking that
∂2 n
2
ln ℓ(λ) = − 2 < 0,
∂λ λ
the MLE λ̂ is Pn = x̄1 . Hence, the likelihood ratio can be expressed as
xi
Λ (H0 , H1 ) = (λ0 x̄)n en−nλ0 x̄ .
b. The critical region is
( )
n n o k 1/n
C = (X1 , . . . , Xn ) : λ0 X̄ en−nλ0 X̄ ≤ k = (X1 , . . . , Xn ) : X̄e−λ0 X̄ < .
λ0 e