STAT200C: Hypothesis Testingzhaoxia/teaching/stat200c/200C_HypothesisTesting... · Some De nitions...

52
STAT200C: Hypothesis Testing Zhaoxia Yu Spring 2017

Transcript of STAT200C: Hypothesis Testingzhaoxia/teaching/stat200c/200C_HypothesisTesting... · Some De nitions...

Page 1: STAT200C: Hypothesis Testingzhaoxia/teaching/stat200c/200C_HypothesisTesting... · Some De nitions A hypothesis is a statement about a population parameter. The two complementary

STAT200C: Hypothesis Testing

Zhaoxia Yu

Spring 2017

Page 2: STAT200C: Hypothesis Testingzhaoxia/teaching/stat200c/200C_HypothesisTesting... · Some De nitions A hypothesis is a statement about a population parameter. The two complementary

Some Definitions

• A hypothesis is a statement about a population parameter.

• The two complementary hypotheses in a hypothesis testing

are the null hypothesis (H0 : θ ∈ Ω0) and the alterantive

hypothesis (H1 : θ ∈ Ω1), where Ω0 and Ω1 are two disjoint

subsets of the full parameter space Ω.

• A hypothesis is called a simple hypothesis if the space is a

singleton set; else it is called a composite hypothesis.

1

Page 3: STAT200C: Hypothesis Testingzhaoxia/teaching/stat200c/200C_HypothesisTesting... · Some De nitions A hypothesis is a statement about a population parameter. The two complementary

Some Examples

• simple vs simple: H0; θ = θ0 vs H1 : θ = θ1;

• simple vs composite: H0 : θ = θ0 vs H1 : θ 6= θ0;

• composite vs composite: H0 : θ ≤ θ0 vs H1 : θ > θ0;

• composite vs composite H0 : θ ≥ θ0 vs H1 : θ < θ0.

2

Page 4: STAT200C: Hypothesis Testingzhaoxia/teaching/stat200c/200C_HypothesisTesting... · Some De nitions A hypothesis is a statement about a population parameter. The two complementary

Critical Function

• A test is determined by its critical function: φ(x) = the prob-

ability of rejecting H0 when x is the observed value of X.

• Example: Suppose X ∼ Binomial(5, θ), H0 : θ = 0.5, H1 : θ >

0.5. Consider two critical functions:

φ1(x) =

1 x = 50 x < 5

, φ2(x) =

1 x = 5

0.12 x = 40 x < 4

φ1(x) is a non-randomized test; φ2(x) is randomized test. A

randomized test can ensure a pre-fixed type I error rate; in

practice, it is not used often.

3

Page 5: STAT200C: Hypothesis Testingzhaoxia/teaching/stat200c/200C_HypothesisTesting... · Some De nitions A hypothesis is a statement about a population parameter. The two complementary

Errors in Hypothesis Testing

• Type I error: H0 is rejected when it is true.

• Type I error rate: α = Pr(reject H0|H0 is true)

• Type II error: H0 is failed to reject when it is not true.

• Type II error rate: 1− β = Pr(fail to reject H0|H1 is true)

4

Page 6: STAT200C: Hypothesis Testingzhaoxia/teaching/stat200c/200C_HypothesisTesting... · Some De nitions A hypothesis is a statement about a population parameter. The two complementary

Type I Error

• Type I error: H0 is rejected when it is true.

• Type I error rate: α = Pr(reject H0|H0 is true)

• α is called the significance level of a test.

5

Page 7: STAT200C: Hypothesis Testingzhaoxia/teaching/stat200c/200C_HypothesisTesting... · Some De nitions A hypothesis is a statement about a population parameter. The two complementary

Type I Error: An Example

• Consider the binomial example. Suppose θ = 0.5.

• For φ1(x), α = 1.0 ∗ Pr(X = 5|θ = 0.5) = 0.55 = 0.03125.

• For φ2(x), α = 1.0 ∗ Pr(X = 5|θ = 0.5) + 0.12 ∗ P (X = 4|θ =

0.5) = 0.03125 + 0.12 ∗ 5 ∗ 0.54 ∗ 0.5 = 0.05

6

Page 8: STAT200C: Hypothesis Testingzhaoxia/teaching/stat200c/200C_HypothesisTesting... · Some De nitions A hypothesis is a statement about a population parameter. The two complementary

Type II Error

• Type II error: H0 is failed to reject when it is not true.

• Type II error rate: 1− β = Pr(fail to reject H0|H1 is true)

• The power of a function β = 1−Pr(fail to reject H0|H1 is true)

7

Page 9: STAT200C: Hypothesis Testingzhaoxia/teaching/stat200c/200C_HypothesisTesting... · Some De nitions A hypothesis is a statement about a population parameter. The two complementary

Type II Error: An example

• Example. Consider the binomial example.

• Suppose θ = 0.6. β1 = 1.0 ∗ Pr(X = 5|θ = 0.6) = 0.65 =0.07776, β2 = 1.0 ∗ Pr(X = 5|θ = 0.6) + 0.12 ∗ Pr(X = 4|θ =0.6) = 0.108864

• Suppose θ = 0.7. β1 = 0.16807, β2 = 0.211288

• Suppose θ = 0.8. β1 = 0.32768, β2 = 0.376832

• Suppose θ = 0.9. β1 = 0.59049, β2 = 0.629856

8

Page 10: STAT200C: Hypothesis Testingzhaoxia/teaching/stat200c/200C_HypothesisTesting... · Some De nitions A hypothesis is a statement about a population parameter. The two complementary

Power Function

• The power function of test φ: βφ(θ) = Eθ[φ(x)]. Let R be the

rejection region, then we can also define the power function

using: β(θ) = Pr(X ∈ R|θ) It is a measure of

– weakness (type I error) when θ ∈ Ω0

– strength (power) when θ ∈ Ω1

• A test is said to have a size α if supθ∈Θ0β(θ) = α.

• A test is said to have a level α if supθ∈Θ0β(θ) ≤ α.

9

Page 11: STAT200C: Hypothesis Testingzhaoxia/teaching/stat200c/200C_HypothesisTesting... · Some De nitions A hypothesis is a statement about a population parameter. The two complementary

Example Let X = (X1, · · · , Xn) be a random sample fromN(θ, σ2) with σ2 known. H0 : θ = θ0 vs H1 : θ > θ0. Intuitively,we should reject H0 for large values of X − θ0. We can write therejection region as

φ(x) =

1 x−µ0

σ/√n> c

0 x−µ0σ/√n< c

The power function is

β(θ) = Pµ(X − θ0

σ/√n> c) = Pθ(

X − θσ/√n> c+

θ0 − µσ/√n

)

= Pθ(Z > c+θ0 − θσ/√n

)

Here β(θ) is an increasing function of θ. Homework: Write an Rfunction to choose the sample size n such that α = β(θ0) = 0.05and β(θ0 + σ) > 0.8 for θ > θ0 + σ.

10

Page 12: STAT200C: Hypothesis Testingzhaoxia/teaching/stat200c/200C_HypothesisTesting... · Some De nitions A hypothesis is a statement about a population parameter. The two complementary

Power Function: An Example Again, consider the

binomial example.

• β1(0.1) = 1e− 05, β2(0.1) = 6.4e− 05

• β1(0.3) = 0.00243, β2(0.3) = 0.005832

• β1(0.5) = 0.03125, β2(0.5) = 0.05

• β1(0.7) = 0.16807, β2(0.7) = 0.211288

• β1(0.9) = 0.59049, β2(0.9) = 0.629856

11

Page 13: STAT200C: Hypothesis Testingzhaoxia/teaching/stat200c/200C_HypothesisTesting... · Some De nitions A hypothesis is a statement about a population parameter. The two complementary

An Example of Power Calculation

Let’s look at the power function for H0 : µ = µ0 vs H1 : µ > µ0

where µ is the mean of a N(µ, σ2) with known variance. The

likelihood ratio test rejects H0 when x = X−µ0σ/√n> Φ−1(1 − α).

The power function is

β(µ) = P (X − µ+ µ− µ0

σ/√n

> Φ−1(1− α))

= P (Z > Φ−1(1− α)−√nµ− µ0σ)

= 1−Φ(Φ−1(1− α)−√nµ− µ0

σ)

Suppose α, µ, and µ0 are given, for fixed n we can calculate

power and for fixed power we can calculate sample size n.

12

Page 14: STAT200C: Hypothesis Testingzhaoxia/teaching/stat200c/200C_HypothesisTesting... · Some De nitions A hypothesis is a statement about a population parameter. The two complementary

An Example of Power Calculation (contin-ued)

Let β = 0.8, α = 0.05, µ−µ0σ = 0.1, then

Φ(Φ−1(0.95)− 0.1√n) = 0.2

⇒ 0.1√n = Φ−1(0.95)−Φ−1(0.2)

⇒√n = 10 ∗ (1.6449 + 0.84)16

⇒ n ≈ 619

Question. What is the power of the test when n = 400?

β = P (X − µ0

σ/√n> Φ−1(0.95)) = P (

X − µσ/√n> Φ−1(0.95)− n

(µ− µ0)

σ/√n

)

= 1−Φ(1.6449− 2) ≈ 0.64

13

Page 15: STAT200C: Hypothesis Testingzhaoxia/teaching/stat200c/200C_HypothesisTesting... · Some De nitions A hypothesis is a statement about a population parameter. The two complementary

Type I error rate vs Type II error rate / Power

• Consider the two tests for the binomial example

X ∼ Binomial(5,0.5)

φ1(x) =

1 x = 50 x < 5

, φ3(x) =

1 x > 00 x = 0

• Power functions:

β1(θ) = Pr(X = 5) = θ5, β3(θ) = 1−Pr(X = 0) = 1−(1−θ)5

• It can be shown that β1(θ) ≤ β3(θ).

14

Page 16: STAT200C: Hypothesis Testingzhaoxia/teaching/stat200c/200C_HypothesisTesting... · Some De nitions A hypothesis is a statement about a population parameter. The two complementary

Type I error rate vs Type II error rate / Power

• Test 3 achieves a smaller Type II error rate, but it has higher

Type I error rate

• How should one choose a test?

• One idea is to find the most powerful test among those with

a Type I error rate no greater than a pre-specified value, say

α.

15

Page 17: STAT200C: Hypothesis Testingzhaoxia/teaching/stat200c/200C_HypothesisTesting... · Some De nitions A hypothesis is a statement about a population parameter. The two complementary

Most Powerful Test: Simple vs Simple

• A test φ is said to be most power (MP) at level α for testingH0 : θ = θ0 vs H1 : θ = θ1 if

E0[φ(X)] ≤ α and E1[φ(X)] ≥ E1[ψ]

for any ψ so that E0[ψ(X)] ≤ α.

• In other words, we say φ is MP if it has the largest poweramong all tests with a level of α.

• How to find a MP test? Neyman-Pearson Lemma can beused to construct a most powerful level α test for simple vssimple hypotheses.

16

Page 18: STAT200C: Hypothesis Testingzhaoxia/teaching/stat200c/200C_HypothesisTesting... · Some De nitions A hypothesis is a statement about a population parameter. The two complementary

Neyman-Pearson Lemma

Neyman-Pearson Lemma (Most powerful level α test for H0 :

θ = θ0 vs H1 : θ = θ1)

• Existence. There exists a test φ and a constant k ≥ 0 such

that

E0[φ(x)] = α

and

φ(x) =

1 if f1(x) > kf0(x)0 if f1(x) < kf0(x)

where fj(x) = f(x|θj). [Note that nothing is being said about

φ on the set x : f1(x) = kf0(x).]

17

Page 19: STAT200C: Hypothesis Testingzhaoxia/teaching/stat200c/200C_HypothesisTesting... · Some De nitions A hypothesis is a statement about a population parameter. The two complementary

• Sufficiency If a test φ satisfies the conditions in Existence

for some k ≥ 0, then it is MP at level α for testing H0 : θ = θ0

vs H1 : θ = θ1.

• Necessity If φ is MP at level α for testing H0 : θ = θ0 vs

H1 : θ = θ1, then with probability 1 under both θ0 and θ1,

φ(x) =

1 if f1(x) > kf0(x)0 if f1(x) < kf0(x)

for some k.

• For α = 0 or 1, the proof is straightforward, provided that

k = 0 and ∞ are allowed. Now let 0 < α < 1.

18

Page 20: STAT200C: Hypothesis Testingzhaoxia/teaching/stat200c/200C_HypothesisTesting... · Some De nitions A hypothesis is a statement about a population parameter. The two complementary

Proof: Existence

Let F (c) = P0[f1(X) ≤ cf0(X)] = P0[f1(X)/f0(X) ≤ c]. Then

F is the cdf of T (X) = f1(X)/f0(X) under θ0. [Note, under θ0,

f0(X) > 0 with probability 1].

Since F is cdf, F ↑, right-continuous: F (c)−F (c−0) = P0(T (X) =

c). Now let

α(c) = 1 − F (c) = P0(T (X) > c).

Then α(−∞) = 1, α(∞) = 0, α ↓, and right continuous: α(c−0)− α(c) = P0[T (X) = c]. Let c0 such that α(c0) ≤ α ≤ α(c0 − 0).

19

Page 21: STAT200C: Hypothesis Testingzhaoxia/teaching/stat200c/200C_HypothesisTesting... · Some De nitions A hypothesis is a statement about a population parameter. The two complementary

Proof: Existence (continued)

Define

φ(x) =

1 if T (x) > k [eqt f1(x) > kf0(x)]

α−α(c0)α(c0−0)−α(c0) if T (x) = k [eqt f1(x) = kf0(x)]

0 if T (x) < k [eqt f1(x) < kf0(x)]

[If F is continuous at c0 , defined 0/0 = 1]

The existence holds with k = c0, because

E0[φ(X)] = P0[T (X) > c0]

+α− α(c0)

α(c0 − 0)− α(c0)P0[T (X) = c0]

= α(c0) + α− α(c0) = α

20

Page 22: STAT200C: Hypothesis Testingzhaoxia/teaching/stat200c/200C_HypothesisTesting... · Some De nitions A hypothesis is a statement about a population parameter. The two complementary

Proof: Sufficiency

Let φ be a test satisfying the conditions in Existence and let φ∗

be an arbitrary level α test i.e., E0[φ∗(X)] ≤ α. We shall show

that

βφ(θ1) = E1[φ(X)] ≥ E1[φ∗(X)] = β∗φ(θ1)

Let S+ = x : φ(x)− φ∗(x) > 0 and S− = x : φ(x)− φ∗(x) < 0.Then for x ∈ S+,

φ(x) > φ∗(x) ≥ 0⇒ f1(x) ≥ kf0(x) [ eqt T (x) ≥ k]

and for x ∈ S−,

φ(x) < φ∗(x) ≤ 1⇒ f1(x) ≤ kf0(x) [ eqt T (x) ≤ k]

21

Page 23: STAT200C: Hypothesis Testingzhaoxia/teaching/stat200c/200C_HypothesisTesting... · Some De nitions A hypothesis is a statement about a population parameter. The two complementary

Proof: Sufficiency (continued)

Thus

[φ(x)− φ∗(x)][f1(x)− kf0(x)]

≥ 0 ∨x ∈ S+ ∪ S−= 0 ∨x 6∈ S+ ∪ S−

Hence

E1[φ(X)]− E1[φ∗(X)] =∫

[φ(x)− φ∗(x)]f1(x)dx

=∫

[φ(x)− φ∗(x)][f1(x)− kf0(x)]dx

+ k∫

[φ(x)− φ∗(x)]f0(x)dx

≥ 0 + kE0[φ(x)− E0[φ∗(x)]]≥ 0

22

Page 24: STAT200C: Hypothesis Testingzhaoxia/teaching/stat200c/200C_HypothesisTesting... · Some De nitions A hypothesis is a statement about a population parameter. The two complementary

Proof: Necessity

Suppose that φ∗ is MP at level α. Let φ be a test satisfies theconditions in Existence. Let S+ and S− be as above. The seton which φ∗ violates the conditions is

S = (S+ ∪ S−) ∩ x : f1(x) 6= kf0(x)Clearly S = x : φ(x) 6= φ∗(x), f1(x) 6= kf0(x).

We shall show that

P0(S) = P1(S) = 0

Suppose the distribution is continuous. In this case, it is enoughto show that ∫

Sdx = 0

23

Page 25: STAT200C: Hypothesis Testingzhaoxia/teaching/stat200c/200C_HypothesisTesting... · Some De nitions A hypothesis is a statement about a population parameter. The two complementary

Proof: Necessity (continued)

Note that [φ(x) − φ∗(x)][f1(x) − kf0(x)] > 0 for ∨x ∈ S. Hence∫S dx > 0 implies that∫[φ(x)−φ∗(x)][f1(x)−kf0(x)]dx =

∫S

[φ(x)−φ∗(x)][f1(x)−kf0(x)] > 0,

i.e., ∫[φ(x)− φ∗(x)]f1(x)dx > k

∫[φ(x)− φ∗(x)]f0(x)

> k(α− E0[φ∗(X)]) > 0

The last inequality is true because E0[φ∗(X)] ≤ α. Thus, E1[φ(X)] >

E1[φ∗(X)], contradicting the MP level α property of φ∗.

Note: the proof of discrete distributions is similar - just replace∫with

∑.

24

Page 26: STAT200C: Hypothesis Testingzhaoxia/teaching/stat200c/200C_HypothesisTesting... · Some De nitions A hypothesis is a statement about a population parameter. The two complementary

A Corollary

Corollary. Let β = E1[φ(X)] where φ is a MP test at level α ∈(0,1) for H0 : θ = θ0 vs H1 : θ = θ1. Then β > α.

Proof. For let φ0(x) ≡ α, the test that always reject H0 withprobability α, irregardless the value of x. It is obvious that

E0[φ0(X)] = E1[φ0(X)] = α

i.e., both the Type I error rate and power of φ0(x) is α.

Since φ0(x) is level α test but it does not satisfy the Neyman-Pearson conditions, it is not a MP test (by the necessity), whereasφ(x) is. Therefore,

β = E1[φ(X)] > E1[φ0(X)] = α

25

Page 27: STAT200C: Hypothesis Testingzhaoxia/teaching/stat200c/200C_HypothesisTesting... · Some De nitions A hypothesis is a statement about a population parameter. The two complementary

Remark 1: On x : f1(x) = c0f0(x),

φ(x) =α− α(c0)

α(c0 − 0)− α(c0)=

α− 1 + F (c0)

1− F (c0 − 0)− 1 + F (c0)=

α− 1 + F (c0)

F (c0)− F (c0)− 0

where F is the cdf of T (X) = f1(X)/f0(X). Suppose F underθ0 is discontinuous at c0, then

(1) F (c0−0) < 1−α = F (c0)→ φ(x) = 0 on x : f1(x) = c0f0(x)

(2) F (c0−0) = 1−α < F (c0)→ φ(x) = 1 on x : f1(x) = c0f0(x)

(3) F (c0 − 0) < 1 − α < F (c0) → φ(x) = γ(x) ∈ [0,1] on x :f1(x) = c0f0(x) for any γ(x) satisfying

∫x:f1(x)=c0f0(x) γ(x)f0(x)dx =

α − α(c0) is MP at level α for H0 : θ = θ0 vs H1 : θ = θ1. Thuswe have a unique MP test at level α in case (1) or (2), but notin case (3).

26

Page 28: STAT200C: Hypothesis Testingzhaoxia/teaching/stat200c/200C_HypothesisTesting... · Some De nitions A hypothesis is a statement about a population parameter. The two complementary

Remark 2: A MP level α test for H0 : θ = θ0 vs H1 : θ = θ1

must satisfy E0[φ(x)] = α, unless there exists a test ψ having

size E0[ψ(x)] < α and power E1[ψ(x)] = 1. This exceptional

situation occurs in the following case:

Let X1, · · · , Xn be a random sample from Unif [0, θ] for θ > 0.

We want to test H0 : θ = θ0 vs θ = θ1 < θ0 at level α. Let X(n)be the largest value in the sample and suppose that (θ1/θ0)n < α.

Then the following test is MP

ψ(x) =

1 if 0 ≤ x(n) ≤ θ10 if θ1 < x(n) ≤ θ0

and has size < α and power=1.

27

Page 29: STAT200C: Hypothesis Testingzhaoxia/teaching/stat200c/200C_HypothesisTesting... · Some De nitions A hypothesis is a statement about a population parameter. The two complementary

Remark 3: (omitted)

28

Page 30: STAT200C: Hypothesis Testingzhaoxia/teaching/stat200c/200C_HypothesisTesting... · Some De nitions A hypothesis is a statement about a population parameter. The two complementary

Remark 4:

The Neyman-Pearson lemma expresses the MP level α test φ

for H0 : θ = θ0 vs θ = θ1 in terms of the likelihood ratio, or

equivalently log likelihood ratio (LLR). If X = (X1, · · · , Xn) is a

random sample from fθ(x), then the LLR is

log[f1(x)/f0(x)] =n∑i=1

log[f1(xi)/f0(xi)],

and a MP level α test for H0 vs H1 is

φ(x) =

1 if

∑ni=1 log[f1(xi)/f0(xi)] > k

γ if∑ni=1 log[f1(xi)/f0(xi)] = k

0 if∑ni=1 log[f1(xi)/f0(xi)] < k

where k and γ are determined by the condition E0[φ(x)] = α.

29

Page 31: STAT200C: Hypothesis Testingzhaoxia/teaching/stat200c/200C_HypothesisTesting... · Some De nitions A hypothesis is a statement about a population parameter. The two complementary

Example: A Random Sample from Normal

Let X = (X1, · · · , Xn) be a random sample from N(θ, σ2), where

σ2 is known but θ is unknown.

Consider the following three hypothesis testing problems:

1. H∗0 : θ = θ0 vs H∗1 : θ = θ1

2. H0 : θ ≤ θ0 vs H∗1 : θ = θ1, θ1 > θ0

3. H0 : θ ≤ θ0 vs H1 : θ > θ0

30

Page 32: STAT200C: Hypothesis Testingzhaoxia/teaching/stat200c/200C_HypothesisTesting... · Some De nitions A hypothesis is a statement about a population parameter. The two complementary

A Random Sample from Normal, Problem 1:H∗0 : θ = θ0 vs H∗1 : θ = θ1

Let fj be the joint pdf of X corresponding to θj. The LLR is

log[f1(x)/f0(x)] =1

2σ2[∑

(xi − θ0)2 −∑

(xi − θ1)2]

=n

2σ2(θ2

0 − θ21) +

n

σ2(θ1 − θ0)x

The MP level α test for H∗0 vs H∗1 is:

φ∗1(x) =

1 if x ≥ c10 if x < c1

if θ1 > θ0 , φ∗2(x) =

1 if x ≤ c20 if x < c2

if θ1 < θ0

where c1 = θ0 +σ/√nΦ−1(1−α) and c2 = θ0−σ/

√nΦ−1(1−α).

31

Page 33: STAT200C: Hypothesis Testingzhaoxia/teaching/stat200c/200C_HypothesisTesting... · Some De nitions A hypothesis is a statement about a population parameter. The two complementary

A Random Sample from Normal, Problem 2:H0 : θ ≤ θ0 vs H∗1 : θ = θ1 > θ0

Suppose φ(x) is MP level α for Problem 2. Then it must satisfy

(i) supθ≤θ0Eθ[φ(x)] ≤ α and

(ii) Eθ1[φ(x)] ≥ Eθ1

[ψ(x)] ∨ ψ of level α

The power function of φ∗ obtained in Problem 1 is:

βφ∗1(θ) = Eθ[φ

∗1(x)] = Pθ[x ≥ θ0 + σ/

√nΦ−1(1− α)]

= Φ(Φ−1(α) +

√n(θ − θ0)

σ)

which is ↑ in θ, so that supθ≤θ0Eθ[φ

∗1(x)] = Eθ0

[φ∗1(x)] = α.

32

Page 34: STAT200C: Hypothesis Testingzhaoxia/teaching/stat200c/200C_HypothesisTesting... · Some De nitions A hypothesis is a statement about a population parameter. The two complementary

A Random Sample from Normal, Problem 2:H0 : θ ≤ θ0 vs H∗1 : θ = θ1 > θ0 (continued)

Thus φ∗1 is level α.

Now if ψ satisfies (i) , then

α ≥ supθ≤θ0Eθ[ψ(x)] ≥ Eθ0

[ψ(x)]

i.e., ψ is level α for H∗0 vs H∗1.

Because φ∗1(x) is a MP for H0 : θ = θ0 vs H1 : θ = θ1(> θ0),

Eθ1[φ∗(x)] ≥ Eθ1

[ψ(x)]

Thus, φ∗ is a MP level α for H0 : θ ≤ θ0 vs H∗1 : θ = θ1.

33

Page 35: STAT200C: Hypothesis Testingzhaoxia/teaching/stat200c/200C_HypothesisTesting... · Some De nitions A hypothesis is a statement about a population parameter. The two complementary

A Random Sample from Normal, Problem 3:H0 : θ ≤ θ0 vs H1 : θ > θ0

For this problem, we want (if possible) a uniformly most power

(UMP) level α test for H0 vs H1. In other words, we want a test

φ such that

(i) supθ≤θ0Eθ[φ(x)] ≤ α and

(ii) Eθ[φ(x)] ≥ Eθ[ψ(x)] ∨θ > θ0 whereas ψ satisfies (i).

Since φ∗1 obtained above is the same for ∨θ1 > θ0, it is UMP at

level α for H0 vs H1.

34

Page 36: STAT200C: Hypothesis Testingzhaoxia/teaching/stat200c/200C_HypothesisTesting... · Some De nitions A hypothesis is a statement about a population parameter. The two complementary

Uniformly Most Powerful (UMP)

A test is a uniformly most powerful (UMP) test at level α for

H0 : θ ∈ Ω0 vs H1 : θ ∈ Ω1 if

(i) supθ∈Ω0Eθ[φ(x)] ≤ α and

(ii) Eθ[φ(x)] ≥ Eθ[ψ(x)] ∨θ ∈ Ω1 whereas ψ satisfies (i).

Although requirement (ii) is very stringent, UMP tests do exist

in a certain type of situations. We have seen such situation in

the normal example.

35

Page 37: STAT200C: Hypothesis Testingzhaoxia/teaching/stat200c/200C_HypothesisTesting... · Some De nitions A hypothesis is a statement about a population parameter. The two complementary

Monotone Likelihood Ratio (MLR) Family

• A family of pdfs or pmfs for a univariate random variable X is

said to be a monotone likelihood ratio (MLR) family if there

exists a real-valued T (x) such that for any θ1 < θ2 in Ω,

fθ2(x)/fθ1

(x)

is a nondecreasing function of T (x).

• If fθ1(x) = 0 and fθ2

(x) > 0, define fθ2(x)/fθ1

(x) = +∞

36

Page 38: STAT200C: Hypothesis Testingzhaoxia/teaching/stat200c/200C_HypothesisTesting... · Some De nitions A hypothesis is a statement about a population parameter. The two complementary

Some Examples of MLR

• Suppose X ∼ Binomial(n, θ). Then

f(x|θ2)/f(x|θ1) = (θ2/θ1)x(1− θ2

1− θ1)n−x = (

θ2(1− θ1)

θ1(1− θ2))x(

1− θ2

1− θ1)n

Thus, the family is MLR.

• Any regular exponential family with f(x|θ) = h(x)g(θ)expη(θ)T (x)has an MLR.

– N(θ, σ2) with known σ2.

– N(µ, θ = σ2) with known µ and θ > 0.

– Poisson(θ) for θ > 0

37

Page 39: STAT200C: Hypothesis Testingzhaoxia/teaching/stat200c/200C_HypothesisTesting... · Some De nitions A hypothesis is a statement about a population parameter. The two complementary

Some Examples of MLR

• The hypergeometric distribution H(N,n, θ) with

pθ(x) =

(θx

)(N−θn−x

)(Nn

) ,

where x = max(0, θ+n−N), · · · ,min(n, θ). [θ white and N−θblack balls in a box from which n balls are drawn at random,Pθ(x) is the probability of x white balls in the sample.]

• Unif(0, θ). [We define a/0 =∞ for ∨a > 0.]

• The Cauchy distributions C(θ,1) with Pθ(x) = 1/[π(1 + (x−θ)2)], x ∈ R, θ ∈ R is NOT a MLR family.

38

Page 40: STAT200C: Hypothesis Testingzhaoxia/teaching/stat200c/200C_HypothesisTesting... · Some De nitions A hypothesis is a statement about a population parameter. The two complementary

Theorem of UMP

Suppose that the family of pdfs/pmfs Pθ, θ ∈ R has a MLR inT (X). Then

1. There exists a UMP level α test for H0 : θ ≤ θ0 vs H1 : θ > θ0given by

φ(x) =

1 if T (x) > cγ if T (x) = c0 if T (x) < c

where c and 0 ≤ γ ≤ 1 are determined by Eθ0[φ(x)] = α

2. The power function β(θ) = Eθ[φ(x)] of this φ is strictly in-creasing at all θ for which β(θ) < 1.

39

Page 41: STAT200C: Hypothesis Testingzhaoxia/teaching/stat200c/200C_HypothesisTesting... · Some De nitions A hypothesis is a statement about a population parameter. The two complementary

Proof

First consider H∗0 : θ = θ0 vs H∗1 : θ = θ1 where θ1 > θ0 isfixed. Then a MP level α test for H∗0 vs H∗1 rejects H∗0 forlarge values of fθ1

(x)/fθ0(x), i.e., for large values of T (x) (by

the MLR property). Moreover, by the existence part of the N-Plemma, there exist c and 0 ≤ γ ≤ 1 such that the test φ(x) =I(c,∞)(T (x)) + γIc(T (x)) satisfies Eθ0

[φ(x)] = α.

Since the forms:

φ(x) =

1 T (x) > c0 T (x) < c

and φ(x) =

1 f

θ′′(x) > kf

θ′(x)

0 fθ′′(x) < kf

θ′(x)

are equivalent for any θ′< θ

′′, this test is MP at level α

′= β(θ

′)

for testing H∗∗0 : θ = θ′

vs H∗∗1 : θ = θ′′

whenever θ′< θ

′′(by the

sufficiency part of the N-P lemma).

40

Page 42: STAT200C: Hypothesis Testingzhaoxia/teaching/stat200c/200C_HypothesisTesting... · Some De nitions A hypothesis is a statement about a population parameter. The two complementary

Proof (continued)

Next note that by the Corollary to the N-P lemma, β(θ′′) > α

′=

β(θ′

if α′< 1, which proves that β(θ) is strictly increasing, so

long as it is < 1.

Now note that for this test, β(θ) = Eθ[φ(x)] ≤ α ∨θ ≤ θ0, whichmakes φ a level α test for H0 : θ ≤ θ0. Let

Ψα = all tests ψ such that supθ≤θ0Eθ[ψ(x)] ≤ α

and

Ψ∗α = all tests ψ such that Eθ0[ψ(x)] ≤ α

Then Ψα ⊂ Ψ∗α. We have shown that Eθ1[φ(x)] ≥ Eθ1

[ψ(x)]∨ψ ∈ Ψ∗α. Hence Eθ1

[φ(x)] ≥ Eθ1[ψ(x)] ∨ψ ∈ Ψα (by the N-P

Lemma). This makes φ a MP test at level α for H0 : θ ≤ θ0 vsH∗1 : θ = θ1 > θ0.

41

Page 43: STAT200C: Hypothesis Testingzhaoxia/teaching/stat200c/200C_HypothesisTesting... · Some De nitions A hypothesis is a statement about a population parameter. The two complementary

Proof (continued)

Finally, since φ is independent of θ1 > θ0, it is a UMP test at

level α for H0 : θ ≤ θ0 vs H1 : θ > θ0.

Note, the theory for H0 : θ ≥ θ0 vs H1 : θ < θ can be stated and

proved analogously.

42

Page 44: STAT200C: Hypothesis Testingzhaoxia/teaching/stat200c/200C_HypothesisTesting... · Some De nitions A hypothesis is a statement about a population parameter. The two complementary

Example: Uniform Distribution

Let X = (X1, · · · , Xn) be a random sample from Unif(0, θ).

(i) Find a MP test for H0 : θ = θ0 vs H1 : θ = θ1, θ1 > θ0.

(ii) Show that any level α test with the rejection region X(n) >

θ0 is a UMP level α test for H0 : θ ≤ θ0 vs H1 : θ > θ0.

Solution :(i) The likelihood ratio is

λ(x) =fθ1

(x)

fθ0(x)

=

(θ0

θ1

)n I(x(n) ≤ θ1)

I(x(n) ≤ θ0)=

∞ x(n) > θ0

(θ0/θ1)n 0 < x(n) ≤ θ0

43

Page 45: STAT200C: Hypothesis Testingzhaoxia/teaching/stat200c/200C_HypothesisTesting... · Some De nitions A hypothesis is a statement about a population parameter. The two complementary

Solution (continued)

By the Neyman-Pearson Lemma, a UMP level α satisfies

φ(x) =

1 λ(x) > (θ0/θ1)n

γ λ(x) = (θ0/θ1)n

0 λ(x) < (θ0/θ1)n this cannot happen

which is equivalent to

φ(x) =

1 x(n) > θ0γ 0 < x(n) ≤ θ0

Because it is a level α test, γ satisfies α = Eθ0[φ(x)] = Pθ0

[X(n) >

θ0] = γ.

Note, because the ratio λ(x) is nondecreasing in X(n), the test

is also a UMP for H0 : θ ≤ θ0 vs H1 : θ > θ0.

44

Page 46: STAT200C: Hypothesis Testingzhaoxia/teaching/stat200c/200C_HypothesisTesting... · Some De nitions A hypothesis is a statement about a population parameter. The two complementary

Solution (continued) Now, let’s determine the rejectionregion using the theorem to construct UMP for MLR family. Thefact that the family is a MLR family in X(n) implies that a UMPlevel α test for H0 : θ < θ0 vs H1 : θ > θ0 is:

φ2(x) =

1 x(n) > k

0 0 < x(n) < k

where k satisfies α = Pθ0(X(n) > k) = (1− k/θ0)n = 1− (k/θ0)n,

which gives k = θ0(1− α)1/n.

Since both φ and φ2 are UMP level α test, UMP is not uniquein this situation. This happens because the likelihood ratio λ(x)is constant on [0, θ0]. In fact we can show that they have thesame power function, i.e., for any θ > θ0,

β(θ) = β1(θ) = 1− (1− α)(θ0

θ

)n45

Page 47: STAT200C: Hypothesis Testingzhaoxia/teaching/stat200c/200C_HypothesisTesting... · Some De nitions A hypothesis is a statement about a population parameter. The two complementary

UMP Does Not Always Exist

• In many situations, because the class of level α tests is so

large, no one dominates all the others in power.

• Example. Let (X1, · · · , Xn) be a random sample from ∼N(θ, σ2) with σ2 known, H0 : θ = θ0 and H1 : θ 6= θ0. Here

the tests

φ1(x) =

1 x > θ0 + σ√

nΦ−1(1− α)

0 otherwiseand φ1(x) =

1 x < θ0 − σ√

nΦ−1(1− α)

0 otherwise

are the UMP level α tests for H0 : θ = θ0 vs K1 : θ > θ0 and

K2 : θ < θ0 respectively.

46

Page 48: STAT200C: Hypothesis Testingzhaoxia/teaching/stat200c/200C_HypothesisTesting... · Some De nitions A hypothesis is a statement about a population parameter. The two complementary

• Consider an alternative parameter θ1. Eθ1[φ1(x)] < α ∨θ1 <

θ0 and Eθ1[φ2(x)] < α ∨θ1 > θ0.

• φ1 is UMP level α when θ1 > θ0; φ2 is UMP level α whenθ1 < θ0.

• φ1 is more powerful than φ2 when θ1 > θ0, but φ2 is morepowerful when θ1 < θ0.

• As a result, a UMP test at level α for H:θ = θ0 vs H1 : θ 6= θ0does not exist.

Draw the power functions here (p394 of Casella andBerger)

47

Page 49: STAT200C: Hypothesis Testingzhaoxia/teaching/stat200c/200C_HypothesisTesting... · Some De nitions A hypothesis is a statement about a population parameter. The two complementary

Unbiased Test

• In the above example, UMP does not exist. To find/definea “goog” test in the situation, we then narrow the class oflevel α test to the class of “unbiased” level α tests.

• Definition. A test φ is said to be an unbiased test at levelα for H0 : θ ∈ Ω0 vs H1 : θ ∈ Ω1 if

(i) Eθ[φ(x)] ≤ α ∨θ ∈ Ω0

(ii) Eθ[φ(x)] ≥ α ∨θ ∈ Ω1

• An unbiased test rejects the null hypothesis H0 with at leastas much probability when it is false as when it is true.

48

Page 50: STAT200C: Hypothesis Testingzhaoxia/teaching/stat200c/200C_HypothesisTesting... · Some De nitions A hypothesis is a statement about a population parameter. The two complementary

Uniformly Most Powerful Unbiased (UMPU)Test

• A test φ is said to be a uniformly most powerful unbiased

(UMPU) test at level α for H0 : θ ∈ Ω0 vs H1 : θ ∈ Ω1 , if

(i) φ is an unbiased test at level α for H0 vs H1

(ii) if Eθ[φ(x)] ≥ Eθ[ψ(x)] ∨θ ∈ Ω1, where ψ is also an unbi-

ased level α test for H0 vs H1.

• UMPU tests usually exist for several types of hypothesis tests

for a natural exponential family.

49

Page 51: STAT200C: Hypothesis Testingzhaoxia/teaching/stat200c/200C_HypothesisTesting... · Some De nitions A hypothesis is a statement about a population parameter. The two complementary

UMPU (continued)

• For testing H:θ = θ0 vs H1 : θ 6= θ0 at level α, an unbiasedtest must satisfy Eθ0

[φ(x)] ≤ α and Eθ[φ(x)] ≥ α ∨θ 6= θ0.

• Neither φ1 nor φ2 in the above example is an unbiased test.

• If we restrict to the class of unbiased level α tests, then testssuch as φ1 and φ2 would not quality, and in the restrictedclass, a UMP test does exist.

• The following test is an UMPU:

φ3(x) =

1 |x− θ0| > σ√

nΦ−1(1− α/2)

0 otherwise50

Page 52: STAT200C: Hypothesis Testingzhaoxia/teaching/stat200c/200C_HypothesisTesting... · Some De nitions A hypothesis is a statement about a population parameter. The two complementary

• Note. φ3(x) = I[0,∞)(|x− θ0| > σ√n

Φ−1(1− α/2))

• In practice, MP, UMP, or UMPU test often does not exist.

• We often seek for intuitively reasonable solutions. These

solutions frequently coincide with optimal tests.

51