Mathematical Statistics
Anna Janicka
Lecture XI, 6.05.2019
HYPOTHESIS TESTING III:
LR TEST FOR COMPOSITE HYPOTHESES EXAMPLES OF ONE-SAMPLE TESTS
Plan for today
1. LR test for composite hypotheses 2. Examples of LR tests:
Model I: One- and two-sided tests for the mean in the normal model, σ2 known
Model II: One- and two-sided tests for the mean in the normal model, σ2 unknown
+ One- and two-sided tests for the variance Model III: Tests for the mean, large samples
Model IV: Tests for the fraction, large samples
3. Asymptotic properties of the LR test
4. Test randomization
Testing simple hypotheses – reminder
We observe X. We want to test H 0 : θ = θ 0 against H
1: θ = θ 1 . (two simple hypotheses)
We can write it as:
H 0 : X ~ f 0 against H
1: X ~ f 1 ,
where f 0 and f 1 are densities of distributions
defined by θ and θ (i.e. P and P )
Likelihood ratio test for simple hypotheses.
Neyman-Pearson Lemma – reminder
H 0 : X ~ f 0 against H
1: X ~ f 1 Let
such that
Then, for any K ⊆ X :
if P 0 (K) ≤ α , then P 1 (K) ≤ 1– β .
(i.e.: the test with critical region K* is the most powerful test for testing H
0against H
1)
β
α = −
=
∈ >
=
1
*) (
and
*) (
) (
) : (
*
1 0
0 1
K P
K P
x c f
x x f
K X
Likelihood ratio test for composite hypotheses
X ~ P θ , {P θ : θ ∈ Θ} – family of distributions We are testing H 0 : θ ∈ Θ 0 against H
1: θ ∈ Θ 1
such that Θ 0 ∩ Θ 1 = ∅, Θ 0 ∪ Θ 1 = Θ Let
H 0 : X ~ f 0 ( θ 0 ,⋅) for some θ 0 ∈ Θ 0.
H
1: X ~ f 1 ( θ 1 , ⋅) for some θ 1 ∈ Θ 1 ,
where f 0 and f 1 are densities (for θ ∈ Θ 0 and θ
∈ Θ 1 , respectively)
Just like in the N-P Lemma, but models are statistic –
Neyman-Pearson Lemma – Example 1 – reminder
Normal model: X
1, X
2, ..., X
nare an IID sample from N( µ , σ 2 ), σ 2 is known
The most powerful test for
H 0 : µ = 0 against H
1: µ = 1.
At significance level α :
For obs. 1.37; 0.21; 0.33; -0.45; 1.33; 0.85; 1.78; 1.21; 0.72 from N(µ, 1) we have, for α = 0.05 :
→ we reject H0
µ
0< µ
1
>
=
−n X u
x x
x
K
n 1 ασ
2
1
, ,..., ) : (
*
54 . 9 0
1 645 .
82 1 .
0 > ⋅ ≈
≈ X
Model I
Neyman-Pearson Lemma – Example 1 cont. – reminder
Power of the test
If we change α , µ 1 , n – the power of the test....
− ⋅
Φ
−
=
=
> =
=
µ σ σ µ
n X n
P K
P
1 1
645 .
1 1
....
645 1 .
*) 1 (
≈ 0.91
Neyman-Pearson Lemma:
Generalization of example 1
The same test is UMP for H
1: µ > 0 and for H 0 : µ ≤ 0 against H
1: µ > 0
more generally: under additional assumptions about the family of distributions, the same test is UMP for testing
H
0: µ ≤ µ
0against H
1: µ > µ
0Note the change of direction in the inequality when testing
H
0: µ ≥ µ
0against H
1: µ < µ
0Neyman-Pearson Lemma – Example 2
Exponential model: X
1, X
2, ..., X
nare an IID sample from distr exp( λ ), n = 10.
MP test for
H 0 : λ = ½ against H
1: λ = ¼.
At significance level α = 0.05:
E.g. for a sample: 2; 0.9; 1.7; 3.5; 1.9; 2.1; 3.7; 2.5; 3.4; 2.8:
Σ = 24.5 → no grounds for rejecting H
0.
{ ( , ,..., ) : 31 . 41 }
* = x
1x
2x
10∑ x
i>
K
) ( )
, ( )
, (
) , ( )
, ( )
, 1 ( )
(
exp λ = Γ λ Γ
aλ + Γ
bλ = Γ
a+
bλ Γ
n 1= χ
2 nNeyman-Pearson Lemma – Example 2’
Exponential model: X
1, X
2, ..., X
nare an IID sample from distr exp( λ ), n = 10.
MP test for
H 0 : λ = ½ against H
1: λ = ¾.
At significance level α = 0.05:
E.g. for a sample: 2; 0.9; 1.7; 3.5; 1.9; 2.1; 3.7; 2.5; 3.4; 2.8:
Σ = 24.5 → no grounds for rejecting H
0.
) ( )
, ( )
, (
) , ( )
, ( )
, 1 ( )
(
exp λ = Γ λ Γ
aλ + Γ
bλ = Γ
a+
bλ Γ
n2 12= χ
2 n{ ( , ,..., ) : 10 . 85 }
* = x
1x
2x
10∑ x
i<
K
Example 2 cont.
The test
is UMP for H 0 : λ ≥ ½ against H
1: λ < ½ The test
is UMP for H 0 : λ ≤ ½ against H
1: λ > ½
{ ( , ,..., ) : 31 . 41 }
* = x
1x
2x
10∑ x
i>
K
{ ( , ,..., ) : 10 . 85 }
* = x
1x
2x
10∑ x
i<
K
Likelihood ratio test for composite hypotheses – cont.
Test statistic:
or
where are MLE of the null and alternative hypothesis models
We reject H 0 if λ > c for a constant c
(determined according to significance level)
) ,
( sup
) ,
( sup
0 0
1 1
0 0
1 1
X f
X f
θ λ θ
θ θ
Θ
∈ Θ
=
∈) ˆ ,
(
) ˆ ,
(
0 0
1 1
X f
X f
θ λ = θ
1 0
, ˆ
ˆ θ
θ
Likelihood ratio test for composite hypotheses – justification
Just like in the Neyman-Pearson Lemma, we compare the “highest chance of obtaining
observation X, when the alternative is true” to the “highest chance of obtaining observation X, when the null is true”; we reject the null
hypothesis in favor of the alternative if this
ratio is very unfavorable for the null.
Likelihood ratio test for composite hypotheses – alternative version
Test statistic:
or
where are the ML estimators for the model without restrictions and for the null model.
We reject H 0 if for a constant .
) ,
( sup
) ,
(
~ sup
0
0 0
0
f X
X f
θ λ θ
θ θ
Θ
∈ Θ
=
∈) ˆ ,
(
) ˆ ,
~ (
0
0
X
f
X f
θ λ = θ
ˆ
0ˆ , θ θ
~ > c~
λ c~
more convenient if the null is simple or if models are nested
Likelihood ratio test for composite hypotheses – properties
For some models with composite hypotheses the
UMPT does not exist (so the LR test will not be UMP because there is no such test)
e.g. testing H
0: θ = θ
0against H
1: θ ≠ θ
0if the family of
distributions has a monotonic LR property, i.e. f
1(x)/f
0(x) is an increasing function of a statistic T(x) for any f
0and f
1corresponding to parameters θ
0< θ
1.
In order to have UMPT for H
0: θ = θ
0against H
1: θ < θ
0we would need a critical region of the type T(x)>c, and to have a UMPT for H
0: θ = θ
0against H
1: θ > θ
0we would need a
critical region of the type T(x)<c, so it is impossible to find a
UMPT for H
1: θ ≠ θ
0..
Likelihood ratio test:
special cases
The exact form of the test depends on the distribution.
In many cases, finding the distribution is
hard/complicated (in many such cases, we
use the asymptotic properties of the LR test
instead of precise formulae)
Notation
x
somethingalways means a quantile of rank
something
Model I: comparing the mean
Normal model: X
1, X
2, ..., X
nare an IID sample from N( µ , σ
2), where σ
2is known
H
0: µ = µ
0Test statistic:
H
0: µ = µ
0against H
1: µ > µ
0critical region
H
0: µ = µ
0against H
1: µ < µ
0critical region
H
0: µ = µ
0against H
1: µ ≠ µ
0critical region
Example 1
) 1 , 0 (
0
~
N X n
U σ
µ
= −
} )
( :
{
* = x U x > u
1−αK
} )
( :
{
* = x U x < u
α= − u
1−αK
}
| ) ( :|
{
* = x U x > u
1−α /2K
Model I: example
Let X
1, X
2, ..., X
10be an IID sample from N( µ , 1
2):
-1.21 -1.37 0.51 0.37 -0.75 0.44 1.20 -0.96 -1.14 -1.40
Is µ = 0? (for α = 0.05)
In the sample: mean = -0.43, variance = 0.92 Test statistic:
H
0: µ = 0 against H
1: µ ≠ 0, u
0.975≈1.96 (p-value ≈ 0.172)
H
0: µ = 0 against H
1: µ < 0, u
0.05≈ -1.64 (p-value ≈ 0.086)
H
0: µ = 0 against H
1: µ > 0, u
0.95≈1.64 (p-value ≈ 0.914)
→ in none of these cases are there grounds to reject H
0for α = 0.05
→ but we would reject H : µ = 0 in favor of H : µ < 0 for α = 0.1
36 . 1 1 10
0 43
.
0 − ≈ −
= −
U
Model II: comparing the mean
Normal model: X
1, X
2, ..., X
nare an IID sample from N( µ , σ
2), where σ
2is unknown
H
0: µ = µ
0Test statistic:
H
0: µ = µ
0against H
1: µ > µ
0critical region
H
0: µ = µ
0against H
1: µ < µ
0critical region
H
0: µ = µ
0against H
1: µ ≠ µ
0critical region
) 1 (
0
~ −
= − n t n
S T X µ
)}
1 (
) ( :
{
* = x T x > t
1−n −
K
α)}
1 (
) ( :
{
* = x T x < t n −
K
α)}
1 (
| ) ( :|
{
* = x T x > t
1− / 2n −
K
α) 1 (
) 1
(n − = −t1− n −
tα α
Model II: example (mean)
Let X
1, X
2, ..., X
10be an IID sample from N( µ , σ
2):
-1.21 -1.37 0.51 0.37 -0.75 0.44 1.20 -0.96 -1.14 -1.40
Is µ = 0? (for α = 0.05)
In the sample: mean = -0.43, variance = 0.92 Test statistic:
H
0: µ = 0 vs H
1: µ ≠ 0, t
0.975(9) ≈ 2.26 (p-value ≈ 0.188)
H
0: µ = 0 vs H
1: µ < 0, t
0.05(9) ≈ -1.83 (p-value ≈ 0.094)
H
0: µ = 0 vs H
1: µ > 0, t
0.95(9) ≈1.83 (p-value ≈ 0.906)
→ in none of these cases are there grounds to reject H
0for α = 0.05
→ but we would reject H : µ = 0 in favor of H : µ < 0 for α = 0.1
42 . 1 10
92 . 0
0 43
.
0 − ≈ −
= −
U
Model II: comparing the variance
Normal model: X
1, X
2, ..., X
nare an IID sample from N( µ , σ
2), where σ
2is unknown
H
0: σ = σ
0Test statistic:
H
0: σ = σ
0against H
1: σ > σ
0critical region
H
0: σ = σ
0against H
1: σ < σ
0critical region
H
0: σ = σ
0against H
1: σ ≠ σ
0critical region
) 1 (
) ~ 1
(
22 0
2
2
− −
= n S n
σ χ χ
)}
1 (
) ( :
{
* = x
2x >
12−n −
K χ χ
α)}
1 (
) ( :
{
* = x
2x <
2n −
K χ χ
α)}
1 (
) (
) 1 (
) ( :
{
*
2
2 / 1 2
2 2 / 2
−
>
∨
−
<
=
−
n
x
n x
x K
α α
χ χ
χ
χ
Model II: example (variance)
Let X
1, X
2, ..., X
10be an IID sample from N( µ , σ
2):
-1.21 -1.37 0.51 0.37 -0.75 0.44 1.20 -0.96 -1.14 -1.40
Is σ =1? (for α = 0.05)
In the sample: variance = 0.92 Test statistic:
H
0: σ = 1 against H
1: σ > 1
H
0: σ = 1 against H
1: σ < 1 H
0: σ = 1 against H
1: σ ≠ 1
→ in none of these cases are there grounds to reject H (for α = 0.05)
28 . 1 8
92 . 0
2
9 ⋅ ≈
χ =
92 .
2
16
95 .
0
≈
χ
33 .
2
3
05 .
0
≈
χ
02 . 19
; 70 .
2
02.9752 025 .
0
≈ χ ≈
χ
Model III: comparing the mean
Asymptotic model: X
1, X
2, ..., X
nare an IID sample from a distribution with mean µ and variance
(unknown), n – large.
H
0: µ = µ
0Test statistic:
has, for large n, an approximate distribution N(0,1) H
0: µ = µ
0against H
1: µ > µ
0critical region
H
0: µ = µ
0against H
1: µ < µ
0critical region
H
0: µ = µ
0against H
1: µ ≠ µ
0critical region
S n T X − µ
0=
} )
( :
{
* = x T x > u
1−αK
} )
( :
{
* = x T x < u
α= − u
1−αK
}
| ) ( :|
{
* = x T x > u
1−α /2K
Model IV: comparing the fraction
Asymptotic model: X
1, X
2, ..., X
nare an IID sample from a two-point distribution, n – large.
H
0: p = p
0Test statistic:
has an approximate distribution N(0,1) for large n H
0: p = p
0against H
1: p > p
0critical region
H
0: p = p
0against H
1: p < p
0critical region
H
0: p = p
0against H
1: p ≠ p
0critical region
) 0 (
1 )
1
( X = = p = − P X =
P
p pp n p
p n p
p p
p U X
) 1
( ˆ )
1
* (
0 0
0 0
0
0
−
= −
−
= −
} )
( :
{
* = x U x > u
1−αK
} )
( :
{
* = x U x < u
α= − u
1−αK
}
| ) ( :|
{
* = x U x > u
−αK
Model IV: example
We toss a coin 400 times. We get 180 heads. Is the coin symmetric?
H
0: p = ½
for α = 0.05 and H
1: p ≠ ½ we have u
0.975=1.96 → we reject H
0for α = 0.05 and H
1: p < ½ we have u
0.05= -u
0.95=-1.64
→ we reject H
0for α = 0.01 and H
1: p ≠ ½ we have u
0.995=2.58
→ we do not reject H
0for α = 0.01 and H
1: p < ½ we have u
0.01= -u
0.99=-2.33
→ we do not reject H
0p-value for H
1: p ≠ ½: 0.044 p-value for H
1: p < ½: 0.022
2 ) 400
2 / 1 1
( 2 / 1
) 2 / 1 400
/ 180
* ( = −
−
= −
U
Asymptotic properties of the LR test
We consider two nested models, we test H
0: h( θ ) = 0 against H
1: h( θ ) ≠ 0
Under the assumption that h is a nice function
Θ is a d-dimensional set
Θ
0= { θ : h( θ ) = 0} is a d – p dimensional set
Theorem: If H
0is true, then for n→∞ the distribution of the statistic converges to a chi-squared
distribution with p degrees of freedom
λ ~
ln
2
Asymptotic properties of the LR test – example Exponential model: X
1, X
2, ..., X
nare an IID sample from Exp( θ ).
We test H
0: θ = 1 against H
1: θ ≠ 1
then:
from Theorem:
for a sign. level α =0.05 we have so we reject H
0in favor of H
1if
X MLE ( θ ) = θ ˆ = 1 /
( ( 1 ) )
1 exp )
exp(
) exp(
) (
)
~ (
1 11
ˆ
= −
Σ
−
Σ
= − Π
= Π n X
X x
x x
f
x f
n i
X i X
i
i n
λ
θ) 1 ( )
ln )
1 ((
~ 2 ln
2 λ = n X − − X →
Dχ
2c
c ~ 2 ln ~ ln
~ 2
~ > ⇔ λ >
λ
c~
ln 2 84
. 3 )
1
2
(
95 .
0
≈ ≈
χ
2 / 84 .
~
3> e
λ
Test randomization
Sometimes, a test with a significance level exactly equal to α does not exist (e.g. for discrete random variables).
In such cases, we need randomization.
(The UMPT, if it exists, needs to be randomized).
eg. no of heads in 8 tosses, H
0: p = ½, H
1: p <½, α=0.05:
X≤1 reject, X>2 OK, X=2: p=1/11 reject
xi 0 1 2 3 4 5 6 7 8
pi 0.004 0.03 0.11 0.22 0.27 0.22 0.11 0.03 0.004 cum pi 0.004 0.04 0.15 0.36 0.64 0.86 0.97 0.996 1.000