You are on page 1of 24

COR-STAT1202

Introductory Statistics
Session 10

Hypothesis Testing
(One Sample)
Objectives
• Formulate Null and Alternative Hypotheses for Single
Population Mean and Proportion
• Decision Rule in Hypothesis Testing
• Use of Critical Value and p-value in Testing Hypothesis
• Type I Type II errors

2
Hypothesis Testing (One Sample) - Dr Gan
Concepts of Hypothesis Testing
A hypothesis is a claim (assumption) about a population
parameter.
Example:
The mean monthly mobile phone bill is:
𝜇 = $52
The proportion of elderly who are aware of the campaign is:
𝑝 = 0.32
Process:
First, there is a claim (e.g. that the mean age of the population is
50, i.e. 𝜇 = 50). Next, we collect a random sample of data and
calculate the sample mean (e.g. sample mean, 𝑥ҧ = 20). We would
like to test if 𝑥ҧ = 20 is likely if 𝜇 = 50. If it is not likely, then the
hypothesis is rejected.

Hypothesis Testing (One Sample) - Dr Gan 3


Formulating the Null and
Alternative Hypothesis
Null Hypothesis:
• Assume it is true unless there is strong evidence against it.
Often refers to as “the status quo”, always contains the
equality sign, e.g. the mean volume of drink in a bottle is
100ml:
𝐻0 : 𝜇 = 100 𝑚𝑙
Alternative Hypothesis:
• Is generally the hypothesis that the researcher is trying to
support
• Challenges the status quo, e.g. the mean volume of drink in
a bottle is not equal to 100ml :
𝐻1 : 𝜇 ≠ 100 𝑚𝑙
Hypothesis Testing (One Sample) - Dr Gan 4
Level of Significance, 𝛼
• The probability of rejecting a null hypothesis that is true
• Selected by the researcher at the beginning
• Provides the critical value(s) of the test
𝛼
𝐻0 : 𝜇 ≥ 3
𝐻1 : 𝜇 < 3 Lower-tail test
−𝑍𝛼 0

𝛼 Also known as
𝐻0 : 𝜇 ≤ 3
critical value, 𝑍𝑐
𝐻1 : 𝜇 > 3 Upper-tail test
0 𝑍𝛼
𝛼 𝛼
𝐻0 : 𝜇 = 3 2 2
𝐻1 : 𝜇 ≠ 3 Two-tail test
−𝑍𝛼 0 𝑍𝛼
2 2
5
Hypothesis Testing (One Sample) - Dr Gan
Decision Rule:
p-Value, Critical Value, Test Statistics
𝑋ത − 𝜇0
• Test statistics, 𝑍 = 𝜎
𝑛
• 𝑝−𝑣𝑎𝑙𝑢𝑒 : Probability of obtaining a test statistic more extreme (≤ or ≥)
than the observed sample value given 𝐻0 is true (e.g. 𝐻0 : 𝜇 = 𝜇0 ).

Example: For an upper-tail test:


𝑋ത − 𝜇0
𝑝−𝑣𝑎𝑙𝑢𝑒 = 𝑃 𝑍 > 𝜎 | 𝜇 = 𝜇0
𝑛
The Decision Rule for upper-tail test:
Critical value, 𝒁𝒄 = 𝒁𝜶 𝒑 − 𝒗𝒂𝒍𝒖𝒆
If test statistic falls into the critical region If 𝑝−𝑣𝑎𝑙𝑢𝑒 < 𝛼 ⇒ reject 𝐻0
(i.e.test statistic > 𝑍𝛼 ) ⇒ reject 𝐻0
If test statistic does not fall into the critical If 𝑝−𝑣𝑎𝑙𝑢𝑒 ≥ 𝛼 ⇒ do not
region ⇒ do not reject 𝐻0 reject 𝐻0
6
Hypothesis Testing (One Sample) - Dr Gan
HYPOTHESIS TEST OF MEANS

Hypothesis Testing (One Sample) - Dr Gan


Hypothesis Test of Mean (𝜎 known)
Sampling 𝐻0 ∶ 𝜇 ≥ 𝜇0 What about
ത with ത 𝑁 𝜇𝑋ത , 𝜎𝑋ത 2 𝐻1 ∶ 𝜇 < 𝜇0 upper-tail test?
Distribution 𝑋, 𝑋~
𝐶 𝐶%
sample size n 𝜇𝑋ത = μ 𝛼 = 1−
100
(Population variance 𝜎2 𝜎
𝜎 2 known) 𝜎𝑋ത 2 = ⇒ 𝜎𝑋ത = 𝛼
Do not
𝑛 𝑛 reject 𝐻0

−𝑍𝛼 𝑍
0
𝑋ത
---------------------------- Test statistics,
𝜇0
𝜎
Assumption: 𝑋ത − 𝜇0 𝜇0 − 𝑍𝛼
𝑛
𝑍= 𝜎
• Population is 𝐻0 ∶ 𝜇 = 𝜇0
𝑛
normally 𝐻1 ∶ 𝜇 ≠ 𝜇0
distributed 𝐶 𝐶%
𝛼 = 1−
100
𝛼 𝛼
2 Do not 2
reject 𝐻0
−𝑍𝛼 𝑍𝛼 𝑍
0
2 2

𝜇0 𝑋ത
𝜎 𝜎
𝜇0 − 𝑍 𝛼 𝜇0 + 𝑍 𝛼
2 𝑛 2 𝑛

8
Hypothesis Testing (One Sample) - Dr Gan
Hypothesis Test of Mean (𝜎 unknown)
Sampling 𝐻0 ∶ 𝜇 ≥ 𝜇0 What about
ത with ത 𝑁 𝜇𝑋ത , 𝜎𝑋ത 2 𝐻1 ∶ 𝜇 < 𝜇0 upper-tail test?
Distribution 𝑋, 𝑋~
𝐶 𝐶%
sample size n 𝜇𝑋ത = μ 𝛼 = 1−
100
(Population variance 𝑠2 𝑠
𝜎 2 unknown) 𝜎𝑋ത 2 = ⇒ 𝜎𝑋ത = 𝛼
Do not
𝑛 𝑛 reject 𝐻0

−𝑡𝜈, 𝛼 0 𝑍
𝑋ത
Test statistics, 𝜇0
𝑠

---------------------------- 𝑡 = 𝑋 − 𝜇0
𝜇0 − 𝑡𝜈, 𝛼
𝑛
𝑠
Assumption: 𝐻0 ∶ 𝜇 = 𝜇0
𝑛
• Population is 𝐻1 ∶ 𝜇 ≠ 𝜇0
normally 𝐶 𝐶%
where 𝜈 = 𝑛 − 1 𝛼 = 1−
distributed 100
𝛼 𝛼
2 Do not 2
reject 𝐻0
− 𝑡𝜈 ,𝛼 𝑡𝜈,𝛼 𝑍
0
2 2
𝜇0 𝑋ത
𝑠 𝑠
𝜇0 − 𝑡𝜈 ,𝛼 𝜇0 + 𝑡𝜈 ,𝛼
2 𝑛 2 𝑛

9
Hypothesis Testing (One Sample) - Dr Gan
Example (known 𝜎)
A manager in the mobile phone industry thinks that customer monthly cell
phone bill has increased, and now average over $52 per month. The
company wishes to test this claim. Suppose a sample is taken with the
following results: n = 64, 𝑋ത = 53.1 (Assume 𝜎 = 10 is known and population
is normally distributed). Test the claim at 𝛼 = 10%.
Step 1: Develop hypotheses
𝐻0 ∶ 𝜇 ≤ 52
Do not
𝐻1 ∶ 𝜇 > 52 reject 𝐻0
0.10

1.2816 Z
0
Step 2: Decision Rule (𝜇0 )

𝛼 = 0.10 ⇒ 𝑍𝛼 = 𝑍0.10 = ±1.2816


𝑋ത −𝜇0 53.1−52
Test statistics, 𝑍 = 𝜎 = 10 = 0.88 < 1.2816 ⇒ 𝑑𝑜 𝑛𝑜𝑡 𝑟𝑒𝑗𝑒𝑐𝑡 𝐻0
𝑛 64

Step 3: Conclusion
Since the test statistic (0.88) does not fall into the critical region, we do not
reject 𝐻0 at 10% significance level. We therefore conclude that there is not
sufficient evidence that population mean bill is over $52 per month.
10
Hypothesis Testing (One Sample) - Dr Gan
Example (unknown 𝜎)
The average cost of a hotel room in Chicago is said to be $168/night.
From a random sample of 25 hotels, the sample statistics are: 𝑋ത = $172.50
and s = $15.40. Test the claim at 𝛼 = 0.05. Assume the population
distribution is normal.
Step 1: Develop hypotheses
𝐻0 ∶ Do not
𝐻1 ∶ reject 𝐻0

2.0639 𝑡
−2.0639 0
(𝜇0 )
Step 2: Decision Rule
𝛼 = 0.05 ⇒ 𝑡𝜈, 𝛼 = 𝑡(25−1), 0.025 =
2
𝑋ത −𝜇0
Test statistics, 𝑡 = 𝑠 =
𝑛

Step 3: Conclusion
Since the test statistic ( ) _______ fall into the critical region, we____
_________ 𝐻0 at 5% significance level. We therefore conclude that there
__________evidence that population mean cost is ____________$168.
11
Hypothesis Testing (One Sample) - Dr Gan
Example (unknown 𝜎)
The average cost of a hotel room in Chicago is said to be $168/night.
From a random sample of 25 hotels, the sample statistics are: 𝑋ത = $172.50
and s = $15.40. Test the claim at 𝛼 = 0.05. Assume the population
distribution is normal.
Step 1: Develop hypotheses
𝐻0 ∶ 𝜇 = 168 0.025 Do not 0.025
𝐻1 ∶ 𝜇 ≠ 168 reject 𝐻0

2.064 𝑡
−2.064 0
(𝜇0 )
Step 2: Decision Rule
𝛼 = 0.05 ⇒ 𝑡𝜈, 𝛼 = 𝑡(25−1), 0.025 = ±2.064
2
𝑋ത −𝜇0 172.5−168
Test statistics, 𝑡 = 𝑠 = 15.4 = 1.4610 < 2.064
𝑛 25
⇒ 𝑑𝑜 𝑛𝑜𝑡 𝑟𝑒𝑗𝑒𝑐𝑡 𝐻0
Step 3: Conclusion
Since the test statistic (1.4610) does not fall into the critical region, we do
not reject 𝐻0 at 5% significant level. We therefore conclude that there is
not sufficient evidence that population mean cost is different than $168.
12
Hypothesis Testing (One Sample) - Dr Gan
Decision Rule with p-value
Step 2: Decision Rule
𝛼 = 0.05
𝑋ത −𝜇0 172.5−168
Test statistics, 𝑡 = 𝑠 = 15.4 = 1.4610
𝑛 25

𝑃 𝑡 < −1.4610 = 1 − 𝑃 𝑡 < 1.4610 = 1 − 0.9267 = 0.0733

𝑝−𝑣𝑎𝑙𝑢𝑒 = 2𝑃 𝑡 < −1.4610


= 2 0.0733 P(t < -1.461) P(t >1.461)

= 0.1466
> 𝛼 = 0.05
-2.064 0 2.064

t = -1.461 t = 1.461
Since 𝑝−𝑣𝑎𝑙𝑢𝑒 > 𝛼 ⇒ do not eject 𝐻0
13
Hypothesis Testing (One Sample) - Dr Gan
HYPOTHESIS TEST OF
PROPORTION

Hypothesis Testing (One Sample) - Dr Gan


Hypothesis Test of Proportion
Sampling Distribution 𝑝,Ƹ 𝐻0 ∶ 𝑝 ≥ 𝑝0 What about
𝜇𝑝ො = 𝑝 𝐻1 ∶ 𝑝 < 𝑝0 upper-tail test?
with sample size n 2 𝜎2 𝑝(1−𝑝)
𝜎𝑝ො = = 𝐶 𝐶%
𝑛 𝑛 𝛼 = 1−
100
• Involves categorical 𝑝(1−𝑝)
⇒ 𝜎𝑝ො = 𝛼
variables (Two possible 𝑛
outcomes: “Success”
Test statistics, 𝑍
and “Failure”) ො 𝑝0
𝑝−
−𝑍𝛼 0
𝑍= (𝑝0 )
𝑝 (1−𝑝 )
• Assume sample size n is 0
𝑛
0
𝐻0 ∶ 𝑝 = 𝑝0
large if 𝑛𝑝 1 − 𝑝 > 5 ⇒ 𝐻1 ∶ 𝑝 ≠ 𝑝0
the sampling distribution where 𝑝0 is the
is approximately proportion we test 𝛼 = 1−
𝐶 𝐶%
100
normally distributed against with.
𝛼 𝛼
𝑝~Ƹ 𝑁 𝜇𝑝ො , 𝜎𝑝ො 2 2 2

The sample proportion: −𝑍𝛼 𝑍𝛼 𝑍


0
2 2
(𝑝0 )
𝑛𝑜. 𝑜𝑓 𝑠𝑢𝑐𝑒𝑠𝑠𝑒𝑠 𝑖𝑛 𝑠𝑎𝑚𝑝𝑙𝑒
𝑝Ƹ =
𝑠𝑎𝑚𝑝𝑙𝑒 𝑠𝑖𝑧𝑒

15
Hypothesis Testing (One Sample) - Dr Gan
Example
A marketing company claims that it receives 8% responses from its direct
mail marketing. To test this claim, a random sample of 500 were surveyed
with 25 responses. Test the claim at the 𝛼 = 0.05.
Check if sample size is large enough (for approximate normal distribution):
25
Approximation for population proportion: 𝑝Ƹ = = 0.05
500
n𝑝 1 − 𝑝 = 500 0.05 0.95 = 23.75 > 5 → normally distributed
Step 1: Develop hypotheses
𝐻0 ∶ 𝑝 = 0.08
𝐻1 ∶ 𝑝 ≠ 0.08
0.025 0.025
Step 2: Decision Rule 𝑍
−1.96 0 1.96
𝛼 = 0.05 ⇒ 𝑍𝛼 = 1.96 (0.08)
2
ො 𝑝0
𝑝− 0.05−0.08
Test statistics, 𝑍 = = = −2.4727 < −1.96 ⇒ reject 𝐻0
𝑝0 (1−𝑝0 ) 0.08(1−0.08)
𝑛 500

16
Hypothesis Testing (One Sample) - Dr Gan
Example
Step 3: Conclusion
Since the test statistic (_______) falls into the critical region,
we_______ 𝐻0 at 5% significance level. We therefore
conclude that _____________evidence to reject the
company’s claim of 8% response rate.

17
Hypothesis Testing (One Sample) - Dr Gan
Example
Step 3: Conclusion
Since the test statistic (-2.4727) falls into the critical region,
we reject 𝐻0 at 5% significance level. We therefore conclude
that there is sufficient evidence to reject the company’s claim
of 8% response rate.

18
Hypothesis Testing (One Sample) - Dr Gan
Decision Rule with p-value
Step 2: Decision Rule
𝛼 = 0.05
ො 𝑝0
𝑝− 0.05−0.08
Test statistics, 𝑍 = = = −2.4727
𝑝0 (1−𝑝0 ) 0.08(1−0.08)
𝑛 500

𝑃 𝑍 < −2.4727 = 0.0067

𝑝−𝑣𝑎𝑙𝑢𝑒 = 2𝑃 𝑍 < −2.4727


.0067 .0067
= 2(1 − 𝑃 𝑍 < 2.4727)
= 2 0.00676
-1.96 0 1.96
= 0.0135
Z = -2.47 Z = 2.47

Since 𝑝−𝑣𝑎𝑙𝑢𝑒 < 𝛼 = 0.05 ⇒ Reject 𝐻0


19
Hypothesis Testing (One Sample) - Dr Gan
Type I and Type II Error
Reality
H0 is True H0 is Not True
Do Not Correct Decision Type II Error: 𝛽
Reject H0
(1 − 𝛼): confidence level (𝛽: the probability of not
rejecting a false H0)
Decision
Reject H0 Type I Error: 𝛼 Correct Decision
from test
(significance level)
(1 − 𝛽): power of test
(𝛼: the probability of
rejecting a true H0)

The power of a statistical test is the probability that it will correctly


lead to the rejection of a false null hypothesis.
Hence, Power = P(Reject H0 | H1 is true)
Remember: R(A)
We either 'reject H0 ‘
in favour of H1 or 'do not reject H0‘ Reject Null Do not
→ we never conclude 'reject H1’, (Type I) reject Null
20
Hypothesis Testing (One Sample) - Dr Gan (Type II)
or 'accept H1'.
Type II Error Calculation
𝐻0 ∶ 𝜇 ≥ 𝜇0 Reject 𝑯𝟎
𝐻1 ∶ 𝜇 < 𝜇0 𝛽

𝛼 Do Not Reject 𝑯𝟎
𝑋ത
𝜇∗ 𝑋ത𝑐 𝜇0

𝑍
𝑍𝛼 = 𝑍𝑐
𝑍∗
𝑍𝛽 = 𝑍𝑐 ∗
From hypothesized mean graph: From actual mean graph:
1. Find 𝑍𝛼 using: 𝑃 𝑍 < 𝑍𝛼 = 𝛼 3. Find 𝛽 = 𝑃 𝑋ത > 𝑋ത𝑐 |𝜇 = 𝜇 ∗ where 𝑋~𝑁(𝜇
ത ∗
, 𝜎 2)
𝜎
2. Find 𝑋ത𝑐 using: 𝑋ത𝑐 = 𝜇0 + 𝑍𝛼 𝑛 Alternatively:
𝑋ത𝑐 −𝜇 ∗
3. Find 𝑍𝛽 using:𝑍𝛽 = 𝜎
𝑛
4. Find 𝛽 = 𝑃(𝑍 > 𝑍𝛽 ) where Z~𝑁(0 , 1)

21
Hypothesis Testing (One Sample) - Dr Gan
Type II Error Calculation
A hypothesis test is conducted to test the following
hypotheses at 5% significance level, given that 𝑛 = 64 and
𝜎 = 6. Suppose that the conclusion is “we do not reject the
null hypothesis”. If the true mean is in fact 50, determine the
probability of Type II error.

𝐻0 ∶ 𝜇 ≥ 52
𝐻1 ∶ 𝜇 < 52

22
Hypothesis Testing (One Sample) - Dr Gan
Example
Reject 𝑯𝟎 𝛽

𝑛 = 64 and 𝜎 = 6
𝛼 = 0.05
Do Not Reject 𝑯𝟎
𝑋ത
𝜇∗ = 50 𝑋ത𝑐 𝜇0 =52

𝑍
𝑍𝛼 = 𝑍𝑐
𝑍∗
From hypothesized mean graph: 𝑍𝛽 = 𝑍𝑐 ∗ From actual mean graph:
1. Find 𝑍𝛼 using: 𝑃 𝑍 < 𝑍𝛼 = 𝛼 3. Find 𝛽 = 𝑃 𝑋ത > 𝑋ത𝑐 |𝜇 = 𝜇 ∗ where (𝑋~𝑁(𝜇
ത ∗
, 𝜎2)
𝜎
2. Find 𝑋ത𝑐 using: 𝑋ത𝑐 = 𝜇0 + 𝑍𝛼 𝑛 = 𝑃 𝑍 > 𝑍𝛽
𝑋ത𝑐 −𝜇∗
𝛼 = 0.05 ⇒ 𝑍𝛼 = 1.6449 =𝑃 𝑍> 𝜎 where (Z~𝑁(0 , 1)
𝑛

𝜎
𝑋ത𝑐 = 𝜇0 + 𝑍𝛼
𝑛 𝛽 = 𝑃 𝑋ത ≥ 𝑋ത𝑐 |𝜇 ∗ = 50
6 𝑋ത𝑐 −𝜇 ∗ 50.7663−50
= 52 + −1.6449 = 50.7663 𝛽=𝑃 𝑍> 𝜎 =𝑃 𝑍> 6 = 𝑃 𝑍 > 1.0217 =
64 𝑛 64
1 − 𝑃 𝑍 < 1.0217 = 1 − 0.8461 = 0.1539

What is the Power of the Test? 1 − 𝛽 = 0.8465


23
Hypothesis Testing (One Sample) - Dr Gan
- The End -

24
Hypothesis Testing (One Sample) - Dr Gan

You might also like