Module 2.4
Module 2.4
1/27
Hypothesis Testing
Introduction
Outline
Introduction
2/27
Hypothesis Testing
Introduction
Hypothesis testing
▶ A hypothesis is a statement about a population parameter:
▶ More precisely, the researcher assumes whether the true (or
population) parameter value belongs to a certain subset of a
parameter space. Mathematically, suppose θ ∈ Θ (Θ is the set
of values θ can take), and the researcher wants to assume that
θ ∈ Θ0 , Θ0 ⊂ Θ;
▶ The goal of an hypothesis test is to use the available sample to
decide between two complimentary complimentary hypotheses:
▶ the null hypothesis, denoted as H0 : θ ∈ Θ0 ⊂ Θ;
▶ the alternative hypothesis, denoted as H1 : θ ∈ Θc0 ;
▶ The test of hypothesis can be used to answer questions of the
type:
▶ Does the treatment X increase the survival odds of patients
with a certain disease?
▶ Does smoking affect people life expectancy?
2/27
Hypothesis Testing
Introduction to Hypothesis Testing
Outline
Introduction
3/27
Hypothesis Testing
Introduction to Hypothesis Testing
Hypothesis Testing Procedure
3/27
Hypothesis Testing
Introduction to Hypothesis Testing
i. Hypotheses and Significance Level
4/27
Hypothesis Testing
Introduction to Hypothesis Testing
i. Hypotheses and Significance Level
5/27
Hypothesis Testing
Introduction to Hypothesis Testing
i. Hypotheses and Significance Level
6/27
Hypothesis Testing
Introduction to Hypothesis Testing
i. Hypotheses and Significance Level
α = Pr[Reject H0 | H0 is true]
= Pr (T ∈ C ∗ | θ ∈ Θ0 )
= / C ∗ | θ ∈ Θc0 )
Pr (T ∈
Example
An insurance company wants to assess whether the mean value of
the claim amount filed by the policyholders is equal to 500$. On a
sample of 10 insurance policies the insurance company finds that
the average claim amount is equal to 525$. Suppose the insurer
carries out a test
at a level of 5% and that claims follow a
2
Normal µ, 50 distribution.
8/27
Hypothesis Testing
Introduction to Hypothesis Testing
i. Hypotheses and Significance Level
Solution
We are testing:
H0 : µ = 500 vs H1 : µ ̸= 500
Hence, under H0 , the we have the test statistic T = X , which under the
null hypothesis µ = 500, follows a Normal distribution with mean 500
and variance 502 /10. The critical region at a level of 5% is therefore the
set of values for the statistics,
√ which exceeds
530.99 = 500 + 1.96 × 50/ 10, where
▶ 1.96 is the one-side quantile of the standard Normal distribution
which leaves 2.5% prob. in the tail (the sample mean follows a
Normal distribution under the CLT);
√
▶ 50 is the known standard deviation (which is then divided by 10;
▶ 500 is the mean of the distribution under the null hypothesis.
9/27
Hypothesis Testing
Introduction to Hypothesis Testing
i. Hypotheses and Significance Level
10/27
Hypothesis Testing
Introduction to Hypothesis Testing
i. Hypotheses and Significance Level
Example
Suppose we have a random sample X1 , X2 , ..., Xn ∼ N(µ, σ 2 ) with
known variance σ 2 , and we would like to test
H0 : µ = µ0 v.s. H1 : µ < µ0 .
X −µ
T = √ ∼ N(0, 1)
σ/ n
11/27
Hypothesis Testing
Introduction to Hypothesis Testing
i. Hypotheses and Significance Level
Example
An extreme value of T is evidence against H0 whilst an extremely
low value of T is evidence in support of H1 . Therefore construct
the critical region such that:
Pr (T ∈ C ⋆ |H0 ) = 5%.
Pr (T < c ⋆ |µ = µ0 ) = 5%.
X − µ0
Pr √ < z5% |µ = µ0 = 5%.
σ/ n
σ
Pr X < µ0 + z5% × √ |µ = µ0 = 5%.
n
Thus reject the null hypothesis if X < µ0 + z5% × √σ
n
12/27
Hypothesis Testing
Introduction to Hypothesis Testing
i. Hypotheses and Significance Level
X − µ0
√ ≥ z1−α/2 ,
σ/ n
X − µ0
√ < z1−α/2 .
σ/ n
13/27
Hypothesis Testing
Introduction to Hypothesis Testing
i. Hypotheses and Significance Level
14/27
Hypothesis Testing
Introduction to Hypothesis Testing
i. Hypotheses and Significance Level
p-value
▶ For T the test statistic, we reject H0 if T ∈ C ∗
▶ An alternative is to use the p-value
▶ The p-value is the smallest value of α for which the null
hypothesis, given the data, will be rejected.
▶ p-value is the probability that a value of the test statistic is as
extreme or more extreme that the actually observed value,
given the null hypothesis is true.
15/27
Hypothesis Testing
Introduction to Hypothesis Testing
i. Hypotheses and Significance Level
Another example
Suppose X1 , X2 , . . . , Xn is a random sample from N (θ, 1) and that
we wish to test H0 : θ = 0 versus Ha : θ ̸= 0 with constant α as a
level of significance.
▶ Suppose the observed sample mean X turned out to be 3, we
can calculate the p-value:
p-value = 2min(Pr X ≥ 3 |θ = 0 , Pr X ≤ 3 |θ = 0 )
∗ X −θ 3−θ
= Pr |Z | = √ ≥ √ |θ=0
σ/ n σ/ n
√ √
= Pr Z ≥ 3 n + Pr Z ≤ −3 n
18/27
Hypothesis Testing
Introduction to Hypothesis Testing
Examples
H0 : θ = 0 versus H1 : θ ̸= 0.
19/27
Hypothesis Testing
Introduction to Hypothesis Testing
Examples
α = Pr (T ∈ C ⋆ |H0 is true )
= Pr X > 2 |θ = 0
= Pr X > 2 |θ = 0 + Pr X < −2 |θ = 0
√ √ √ √
= Pr n · X > 2 n + Pr n · X < −2 n
∗ √ √
= Pr Z > 2 n + Pr Z < −2 n
√
= 2 · Φ −2 n .
Pn
* using X |H0 = i=1 Xi /n ∼ N(0, n1 ).
20/27
Hypothesis Testing
Introduction to Hypothesis Testing
Examples
π (θ) = Pr (T ∈ C |θ ∈ H1 )
= Pr X > 2|θ ∈ H1
= Pr X > 2|θ ∈ H1 + Pr X < −2|θ ∈ H1
∗ √ √
= Pr Z > n (2 − θ) + Pr Z < n (−2 − θ)
√ √
= Φ − n (2 − θ) + Φ n (−2 − θ) .
2
* using X = ni=1 Xi /n ∼ N(θ, σn ) (using m.g.f. technique), and
P
dropping the conditional for brevity.
21/27
Hypothesis Testing
Introduction to Hypothesis Testing
Examples
X − µ0
T = √ ≥ z1−α
σ/ n
23/27
Hypothesis Testing
Introduction to Hypothesis Testing
Examples
Power function
When n increases the power of the test is higher, i.e., more likely to
reject H0 if H1 is correct.
n=20
α n=100
µ0 µ
24/27
Hypothesis Testing
Introduction to Hypothesis Testing
Examples
25/27
Hypothesis Testing
Introduction to Hypothesis Testing
Examples
26/27
Hypothesis Testing
Introduction to Hypothesis Testing
Examples
27/27