11 Hypothesis Testing
11 Hypothesis Testing
1 / 113
Outline
• Principle of hypothesis testing
• Test for population mean
• when the population variance is known
• when the population variance is unknown
• Test for population variance
• Test for comparing two means
2 / 113
Table of contents
1 Statistical Hypotheses: General Concepts
3 Single Sample
4 Two samples
3 / 113
Introduction
4 / 113
Example
• The propellant in the rocket motor of an air crew
escape system should have a mean burning rate of
50 cm/sec.
• If the burning rate is too low, the ejection seat may
not function properly, leading to an unsafe ejection
and possible injury of the pilot. Higher burning
rates may imply instabilty in the propellant or an
ejection seat that is too powerful, again leading to
possible pilot injury. 5 / 113
In this example, we are interested in burning rate of a
solide propellant used to power air crew system
• Burning rate is a random variable that is decribed
by a distribution
• Our interest focus on the mean burning rate
(parameter of distribution)
• Specifically, we are interested in deciding whether
or not the mean burning rate is 50 centimeters
per second.
6 / 113
Table of contents
1 Statistical Hypotheses: General Concepts
3 Single Sample
4 Two samples
7 / 113
Statistical hypothesis
8 / 113
Statistical hypothesis
8 / 113
Remark
Hypothesis is a statement about population, not about
sample statistic
Example
Want to decide whether the average number of TV set in
U.S. Homes is equal to three
9 / 113
Example
We are interested in deciding whether or not the
mean
| burning
{z rate} is 50 centimeters per second.
µ
We may express this formally as
10 / 113
Since the alternative hypothesis H1 : µ ̸= 50 specifies
values of µ that could be either greater or less than 50
centimeters per second, it is called a two-sided
alternative hypothesis. In some situations, we may wish
to formulate a one-sided alternative hypothesis, as in
H0 : µ = 50 vs H1 : µ > 50
or
H0 : µ = 50 vs H1 : µ < 50
11 / 113
One - sided and Two - sided test about parameter θ
• One-sided test
• Upper-tail test
H0 : θ = θ0 H1 : θ > θ0
• Lower-tail test
H0 : θ = θ0 H1 : θ < θ0
• Two-sided test
H0 : θ = θ0 H1 : θ ̸= θ0
12 / 113
Remark
13 / 113
Remark
13 / 113
Example
• Producer advertises that
their cable have an average breaking strength of at least 7,000 psi.
| {z }
statement about qualify of cable which is described by the mean - µ
Express formally as
14 / 113
Example
Need to decide whether the new fuel injection system will
provide a |mean miles-per-gallon
{z rating} exceeding 24
µ
Express formally as
15 / 113
Test of a hypothesis
• A procedure leading to a decision about a particular
hypothesis is called a test of a hypothesis.
• Hypothesis-testing procedures rely on using the
evidence from information in a random sample
from the population of interest.
• reject H0 in favor of H1 if the evidence is
inconsistent with H0
• fail to reject H0 if the evidence is consistent
with H 16 / 113
The truth or falsity of a particular hypothesis can never
be known with certainty, unless we can examine the
entire population.
17 / 113
Hypothesis Testing Process
18 / 113
Rejecting or Accepting H0?
21 / 113
What happens if true population mean age µ = 50 but the
observed sample mean is 58?
We can reject H0 even when H0 is true
Face to a wrong decision making
22 / 113
Error in Decision Making
• Type I error Rejecting the null hypothesis H0 when it is true
• Type II error Failing to reject the null hypothesis when it is
false
23 / 113
Level of significance
24 / 113
Fixed level of significance
• Typical value for level of significance α are 1%, 5%,
10%
• is selected by the researcher at the beginning
• provides critical values for the test
• defines rejection region of the sampling distribution
25 / 113
Critical Region for Fixed level of significance
26 / 113
Disadvantage of fixed significant
level testing
• the null hypothesis was or was not rejected at a
specified level of significance ⇒ no idea about the
statistic is just barely in or far in rejection region
• Level of significance is not usually set up in
advance but rather look at in data to determine a
level
27 / 113
P-value
P - value is the smallest level of
significance that would lead to rejection
of null hypothesis with a given data.
P-value is the observed significance level when we use
value of evidence that we observe from data as critical
value
28 / 113
General Procedure
for Hypothesis Testing (1)
29 / 113
General Procedure for Hypothesis Testing (2)
Critical value approach P- value approach
4 Determine critical value
4 Compute the P - value
and reject region Wα based
based on the value of test
on level of significane α,
statistic vobs
distribution of test statistic
and type of test
5 Draw conclusion
3 Single Sample
4 Two samples
31 / 113
Tests for Single Mean µ
when Population Variance σ2
Known
32 / 113
Problem
Test
H0 : µ = µ0
vs
H1 : µ ̸= µ0 (two-sided test)
or H1 : µ > µ0 (upper tail test)
or H1 : µ < µ0 (lower tail test)
33 / 113
Z-test
Normal population or large sample size n ≥ 30
If H0 : µ = µ0 is true then by central limit theorem or
property of sample mean for normal population, test
statistics
X̄ − µ0
Z= √ ,→ N(0, 1) called Z-test
σ/ n
x̄−µ
√0
The value of Z computed from observed data zobs = σ/ n
34 / 113
Z-test
Normal population or large sample size n ≥ 30
If H0 : µ = µ0 is true then by central limit theorem or
property of sample mean for normal population, test
statistics
X̄ − µ0
Z= √ ,→ N(0, 1) called Z-test
σ/ n
x̄−µ
√0
The value of Z computed from observed data zobs = σ/ n
34 / 113
Conclusion with Critical value(s)
Two-tailed test Upper-tailed test Lower-tailed test
N(0,1) N(0,1) N(0,1)
Critical region Critical region Critical region
36 / 113
Example
A random sample of 100 recorded deaths in the United
States during the past year showed anaverage life span of
71.8 years. Assuming a population standard deviation
of 8.9 years, does this seem to indicate that the mean life
span today is greater than 70 years? Use a 0.05 level of
significance.
37 / 113
Solution
• Parameter of interest: mean life span today µ
• H0 : µ = 70, H1 : µ > 70
• population std σ = 8.9, sample size n = 100,
sample mean x̄ = 71.8
• Z-test
x̄ − µ0 71.8 − 70
zobs = √ = √ = 2.02
σ/ n 8.9/ 100
38 / 113
Solution
• Parameter of interest: mean life span today µ
• H0 : µ = 70, H1 : µ > 70
• population std σ = 8.9, sample size n = 100,
sample mean x̄ = 71.8
• Z-test
x̄ − µ0 71.8 − 70
zobs = √ = √ = 2.02
σ/ n 8.9/ 100
38 / 113
Approach 1 - Draw conclusion with critical value
Upper-tailed test
N(0,1)
Critical region Critical region
Acceptance α
region
40 / 113
Approach 2 - Draw conclusion with P-value
42 / 113
Remark
43 / 113
Example
A manufacturer of sports equipment has developed a new
synthetic fishing line that the company claims has a mean
breaking strength of 8 kilograms with a standard
deviation of .5 kilogram. Test the hypothesis that µ = 8
kilograms against the alternative that µ ̸= 8 kilograms if
a random sample of 50 lines is tested and found to have a
mean breaking strength of 7.8 kilograms. Use a .01 level
of significance
44 / 113
Solution
• H0 : µ = 8, H1 : µ ̸= 8
• σ = .5, n = 50, x̄ = 7.8
• Z-test
x̄ − µ0 7.8 − 8
zobs = √ = √ = 2.83
σ/ n .5/ 50
45 / 113
Critical value approach
Two-tailed test
N(0,1)
Critical region Critical region
α /2 Acceptance α /2
region
–zα /2 0 zα /2 Z0
46 / 113
Find z α2 = z.005 = 2.58
47 / 113
P-value approach
49 / 113
Practice
A researcher wishes to test the claim that the average cost
of tuition and fees at a four year public college is greater
than $5700. She selects a random sample of 36 four-year
public colleges and finds the mean to be $5950. The
population standard deviation is $659. Is there evidence
to support the claim at α = 0.05?
50 / 113
Test for mean µ when population
variance σ 2 is unknown
51 / 113
Problem
Test
H0 : µ = µ0
vs
H1 : µ ̸= µ0 (two-sided test)
or H1 : µ > µ0 (upper tail test)
or H1 : µ < µ0 (lower tail test)
52 / 113
T-test
normal population
If H0 : µ = µ0 is true then test statistics
X̄ − µ0
T= √ ,→ Tn−1
s/ n
called T-test
t - distribution with n − 1 degree of freedom
The value of T computed from data tobs = x̄−µ √0
s/ n
53 / 113
T-test
normal population
If H0 : µ = µ0 is true then test statistics
X̄ − µ0
T= √ ,→ Tn−1
s/ n
called T-test
t - distribution with n − 1 degree of freedom
The value of T computed from data tobs = x̄−µ √0
s/ n
53 / 113
Conclusion with Critical value
tn – 1 tn – 1 tn – 1
α /2 α /2 α α
Conclusion
• Reject H0 if P-value < α
• Fail to reject H0 if P-value > α
55 / 113
Example
If a random sample of 12 homes included in a planned
study indicates that vacuum cleaners use an average of 42
kilowatt hours per year with a standard deviation of 11.9
kilowatt hours. Does this suggest at the .05 level of
significance that vacuum cleaners use, on average, less
than 46 kilowatt hours annually?
Assume the population of kilowatt hours to be normal.
56 / 113
Solution
• Parameter of interest: average kwh that vacuum
cleaners use µ
• H0 : µ = 46, H1 : µ < 46
• Given n = 12, x̄ = 42, s = 11.9
• T-test
x̄ − µ0 42 − 46
tobs = √ = √ = −1.16
s/ n 11.9/ 12
57 / 113
Draw conclusion with Critical value - rejection region
tn – 1
–tα , n – 1 0 T0
59 / 113
Draw conclusion with P- value
61 / 113
Example
A public health official claims that the mean home water
use is 350 gallons a day. 20 randomly selected homes was
investigated with the average daily water uses as follows:
62 / 113
Do the data contradict the claim with level of significant
α = 1%? Assume that the population has normal
distribution.
63 / 113
Solution
• Parameter of interest: mean home water use µ
• Hypothesis H0 : µ = 350, H1 : µ ̸= 350
• x̄ = 353.8, s = 21.8478, n = 20
• T-test
x̄ − µ0 353.8 − 350
tobs = √ = 21.8478
= .7778
s/ n 20
64 / 113
• Critical value for two - sided test tα/2,n−1 =???
(look up table value of t-distribution with 19 degree
of freedom)
• Conclusion??
65 / 113
Practice
A medical investigation claims that the average number
of infections per week at a hospital in southwestern
Pennsylvania is 16.3. A random sample of 10 weeks had
a mean number of 17.7 infections. The sample standard
deviation is 1.8. Is there enough evidence to reject the
investigator’s claim at α = 0.05? Suppose that
population has normal distribution
66 / 113
Test for population mean - z - test or t-test
X̄ − µ0
X̄ − µ0 T= √
Z= √ S/ n
σ/ n
normal population 67 / 113
Test for variance σ2 of normal
population
H0 : σ 2 = σ02
vs
• H1 : σ 2 ̸= σ02 (Two-sided test)
• H1 : σ 2 > σ02 (Upper tail test)
• H1 : σ 2 < σ02 (Lower tail test)
68 / 113
χ2 - test
normal population
2 (n − 1)S2
χ = 2
∼ χ2n−1
σ0
distribution with n − 1 degree of freedom
(n−1)s2
Observed value of χ2 computed from data χ2obs = σ02
69 / 113
Conclusion with critical value(s)
Reject H0 if χ2obs is in the reject region
f (x) f (x) f (x)
2 2 2
n–1 n–1 n–1
α /2 α
α /2 α
0 2 2 x 0 2 x 0 2 x
1 – α /2, n – 1 α /2, n – 1 α, n – 1 1 – α, n – 1
71 / 113
Solution
• Hypothesis H0 : σ 2 = 0.92 = 0.81 vs
H1 : σ 2 > 0.81
• n = 10, s = 1.2 or s2 = 1.22 = 1.44, σ02 = 0.81
• χ2 - test value
(n − 1)s2
χ2obs = = 16.0
σ02
72 / 113
Draw conclusion with Critical value - rejection region
74 / 113
Practice
A machine that automatically controls the amount of
ribbon on a tape has recently been installed. This
machine will be judged to be effective if the standard
deviation σ of the amount of ribbon on a tape is no
greater than .15 cm. If a sample of 20 tapes yields a
sample variance of s2 = .025 cm2, are we justified in
concluding that the machine is ineffective? Use a 0.05
level of significance.
75 / 113
Test for population
proportion
76 / 113
Problem
H 0 : p = p0
vs
H1 : p ̸= p0
H1 : p < p0
H1 : p > p0
For one-sided test, the null hypothesis can be p ≥ p0 or
p ≤ p0
77 / 113
Z-test for large sample size
If p = p0 is true then the number of success in the sample
X ∼ Bin(n, p0) is approximated by N (np0, np0(1 − p0)).
Z-test
X − np0(1 − p0)) P̂ − p0
Z= p =q ∼ N (0, 1)
np0(1 − p0) p0 (1−p0 )
n
80 / 113
Example
A commonly prescribed drug for relieving nervous
tension is believed to be only 60% effective.
Experimental results with a new drug administered to a
random sample of 100 adults who were suffering from
nervous tension show that 70 received relief. Is this
sufficient evidence to conclude that the new drug is
superior to the one commonly prescribed? Use a 0.05
level of significance
81 / 113
Solution
• Problem statement
H0 : p = 0.6 vs H1 : p > 0.6
• Given: n = 100, x = 70, p̂ = 70
100 = 0.7.
• Test statistic
•
0.7 − 0.6
zobs = q = 2.04
(0.6)(1−0.6)
100
82 / 113
• with α = 0.5 and lower tail-test, the critical value
zα = 1.65
• Conclusion: |zobs| > zα implies to reject H0 at 5%,
that is the new drug is superior
83 / 113
Practice
According to the U.S. Bureau of the Census, 25.5 percent
of the population of those age 18 or over smoked in 1990.
A scientist has recently claimed that this percentage has
since increased, and to prove her claim she randomly
sampled 500 individuals from this population. If 138 of
them were smokers, is her claim proved? Use the 5
percent level of significance.
84 / 113
Table of contents
1 Statistical Hypotheses: General Concepts
3 Single Sample
4 Two samples
85 / 113
Comparison means of two populations -
Known variances
87 / 113
Problem statement
H0 : µX − µY = d0
vs
H1 :µX − µY =
̸ d0 two -sided test
H1 :µX − µY > d0 upper - tail test
H1 :µX − µY < d0 lower - tail test
88 / 113
Sampling Distribution
• Sample mean X̄ population 1 is used to estimate µX
• Sample mean X̄ population 2 is used to estimate µY
• X̄ − Ȳ is an estimator for µX − µY
• If both population have normal distributions
N(µX , σX2 ), and N(µY , σY2 ) or large sample sizes
σX2 σY2
then X̄ − Ȳ ∼ N(µX − µY , + ) given H0 is true
nX nY
89 / 113
z- test
two normal populations and variance known
If H0 : µX − µY = d0 is true then
Test statistics is Z-test
X̄ − Ȳ − d0
Z= q ∼ N(0, 1)
σx2 σY2
nX + nY
90 / 113
P-value
• Two-sided test: P-value = 2P(Z > |zobs|)
• One-sided test: P-value = P(Z > |zobs|)
91 / 113
Critical value - Reject region
Two-tailed test Upper-tailed test Lower-tailed test
N(0,1) N(0,1) N(0,1)
Critical region Critical region Critical region
95 / 113
• Critical value?
• Rejection region?
• Conclusion?
96 / 113
Practice
A real estate agent compares the selling prices of homes
in two municipalities in southwestern Pennsylvania to see
if there is a difference. Is there enough evidence to reject
the claim that the average cost of a home in both
locations is the same? Use α = 0.01.
Scott Lionier
x̄1 = $93, 430 x̄2 = $98, 043
σ1 = $5, 602 σ2 = $4732
n1 = 35 n2 = 40
97 / 113
Comparison means of two population -
Unknown variance
98 / 113
Comparison problem
99 / 113
Problem statement
H0 : µX − µY = d0
vs
H1 :µX − µY =
̸ d0 two -sided test
H1 :µX − µY > d0 upper - tail test
H1 :µX − µY < d0 lower - tail test
100 / 113
T- test
two normal populations and unknown variances but equal
If H0 : µX − µY = d0 is true then
Test statistics is T-test
X̄ − Ȳ − d0
T= q ∼ T(nx + ny − 2)
Sx2 Sy2
nX + nY
102 / 113
T-test with pooled estimator
X̄ − Ȳ − d0
T=r ∼ T(nx + ny − 2)
Sp2 n1x + n1y
with
x̄ − ȳ − d0
tobs = r ∼ T(nx + ny − 2)
s2p n1x + n1y
103 / 113
Conclusion with Critical value
tn – 1 tn – 1 tn – 1
α /2 α /2 α α
Conclusion
• Reject H0 if P-value < α
• Fail to reject H0 if P-value > α
105 / 113
Example
Duration for treatment cold
106 / 113
Do the data listed prove that taking 4 grams daily of
vitamin C reduces the mean length of time a cold lasts?
Use α = 5%.
Assume normal populations, equal population variances.
107 / 113
Solution
Test
108 / 113
Given nx = 10, ny = 12, x̄ = 6.450, ȳ = 7.125,
s2x = 0.581, s2y = 0.778. We have
109 / 113
|tobs| = 1.90 > t0.5,20 = 1.725
Conclusion: Reject H0 at 5% level of significance. That
is, at the 5% level of significance the evidence is
significant in establishing that vitamin C reduces the
mean time that a cold persists
110 / 113
Practice
111 / 113
Z- test
two normal populations and unknown and unequal