Professional Documents
Culture Documents
7 M235
Chapter 7
Hypothesis Testing
Introduction
Researchers from all areas, such as engineering,
agriculture and medicine, formulate hypotheses
about a population being studied.
1
Examples:
Hypothesis concerning one mean
µ = 50, µ ≠ 50, µ > 50, µ < 50
Hypothesis concerning two means
µ1 = µ2, µ1 ≠ µ2, µ1 > µ2, µ1 < µ2
The best way to determine whether a
statistical hypothesis is true would be to
examine the entire population. Since that
is often impractical, researchers examine
a random sample to test the statistical
hypothesis.
Hypothesis testing refers to the formal
procedures to accept or reject statistical
hypotheses.
Example: A medical researcher would like
to determine whether a new drug is
effective or not. A random sample of
patients is taken. Half the sample is given
the new drug and the other half is given a
2
placebo (no medication is given).
Hypothesis testing can be used to conclude
whether the new drug is effective.
There are two types of statistical hypotheses.
Null hypothesis: denoted by H0, is usually the
hypothesis that differences result purely from
chance. (Sampling error)
Alternative hypothesis: The alternative
hypothesis, denoted by H1 or Ha, is the
hypothesis that differences are influenced by
treatment effect in addition to chance variation).
Example: Compare two population means
µ1 and µ2
H0 : µ1 = µ 2
H1 : µ1 ≠ µ 2
Take a sample from the first population,
the sample mean X̄
3
Take a sample from the first population,
the sample mean Ȳ
4
the mean survival period is known to be 4.2
years. The new treatments are administered to
100 patients and their duration of survival
recorded, the sample mean is 4.5 years and the
standard deviation is 1.1 years. Is the claim
supported by these results? Test at α=0.05.
µ: mean survival period of cancer patients using
the new drug.
Research hypothesis: The new drug is more
effective than the standard drug.
µ: mean survival period of patients using the
new drug.
4.2: mean survival period of patients using the
standard drug.
New drug more effective than the standard drug
Equivalent to mean survival period using new
drug is higher than mean survival period using
standard drug (i.e. µ > 4.2). As a general
5
guideline, a research hypothesis such as this
should be formulated as the alternative
hypothesis. Thus,
H0: µ ≤ 4.2
H1: µ > 4.2
2 -Testing the Validity of a Claim
The validity of claims that companies made
about their products, the null hypothesis is
generally based on the assumption that the
claim is true.
Example: A manufacturer of soft drinks
who states that 2-liter containers of its
products have an average of at least 67.6
fluid ounces. A sample of 2-liter containers
will be selected, and the contents will be
measured to test the manufacture’s claim. In
this type of hypothesis testing situation, we
generally follow the rationale suggested by
6
the criminal trial analogy. That is, the
manufacture’s claim should be assumed true
(innocent) unless the sample evidence
proves otherwise (guilty). Using this
approach:
H0: µ ≥ 67.6
H1: µ < 67.6
3- Testing in Decision-Making Situations
Example: On the basis of a sample of parts
from a shipment that has been just received,
a quality-control inspector must decide
whether to accept or return the shipment to
the supplier because it does not meet
specifications. Assume that specifications
for a particular part indicate a mean
length of 2 inches per part required.
7
If the average length of the parts is greater
or less than 2-inch standard, the parts will
cause quality problems in the assembly
operation, so
H0 : µ = 2
H1 : µ ≠ 2
How to express null hypothesis and
alternative hypothesis in symbolic form?
Identify H1 first.
If the original claim of the question uses
words such as
“greater, larger, increased, improved
and so on”,
use “>” for H1.
If it uses words such as
“less, decreased, smaller and so on”,
apply “<” for H1.
8
If words such as “the same, change,
different/difference and so on”
appear in the claim, use “≠” for H1.
The opposite symbol = will be used
for H0)
Types of Errors in Hypothesis Testing
Truth
(for population studied)
H0 True H0 False
Decision Reject Type I Correct
H0 Error Decision
(based Fail to
on Correct Type II
reject
sample) H0 Decision Error
9
Type I error. A Type I error occurs
when the researcher rejects a null
hypothesis when it is true.
The probability of committing a Type I
error is called the significance level.
and is often denoted by α.
10
Power=1−β=P(Reject H 0| H 0 is false)
Power=P (Reject H 0| H 1 is true)
Relation between Type I Error (α)
and Type II Error (β)
Example: Let X1,X2,…,Xn denote a random
sample of size n = 25 from a normal population
with variance σ2 = 4, whose mean is known to
be either 0 or 1.
Test
H0: µ = 0
H1: µ = 1
Reject H0 if
13
As α↓, β↑
As β ↓, α↑
We cannot minimize both types
of error simultaneously.
Type I error can be controlled.
The value of alpha, which is
related to the level of
significance.
α is the maximum probability that
we have a type I error.
Usually α = 0.01, 0.05, 0.1
14
Hypothesis Testing
of a Population Mean (µ)
Let X1, X2,…, Xn be random sample
from normal population with mean μ
2
and variance σ , 2 N( μ,σ )
15
Z-Test for the Mean (µ)
(σ2 is known)
Sampling from normal.
Step 1. Decide on the significance level, α .
Step 2. Compute the value of the test statistic
with the one sample Z-test:
X̄−μ0
Z=
σ /√n
Step 3. Find the critical values using the Z-
table. Write down clearly the rejection region.
Check to see if the value of the test statistic falls
in the rejection region. If it does, then reject Ho .
If it does not fall in the rejection region, do not
reject Ho.
Two-tailed
H0: µ = µ0
H1: µ ≠ µ0
16
- Zα/2 Zα/2
Reject H0 if
z > zα/2 or z < - zα/2
or
Reject H0 if |Z| > Zα/2
Right-tailed
H0: µ = µ0
H1: µ > µ0
17
Zα
Reject H0 if Z > Zα
Left-tailed
H0: µ = µ0
H1: µ < µ0
-Z α
Reject H0 if Z < - Zα
18
Example: A company claims to fill its bags
with 50 kg of cement (σ = 0.25 kg). A sample of
10 bags is taken, and found that on an average a
bag weighs 49.75 kg. Use a 1% significance
level to test if the data are consistent with this
claim.
Solution:
Given data:
Standard deviation of the population data σ =
0.25 kg
Sample size n = 10 bags
Sample mean = 49.75 kg
Significance level = 1%
Hypotheses formulation:
H0: μ = 50 kg or μ ≥ 50 kg
H1: μ< 50 kg
20
Step 1. Set up the hypotheses as one of:
Two-tailed
H0: µ = µ0
H1: µ ≠ µ0
Right-tailed
H0: µ = µ0
H1: µ > µ0
Left-tailed
H0: µ = µ0
H1: µ < µ0
Step 2. Decide on the significance level, α .
Step 3. Compute the value of the test statistic
with the one sample t-test:
X̄−μ0
t=
s/√n
21
Step 4. Find the critical values using the t-table.
Write down clearly the rejection region. Check
to see if the value of the test statistic falls in the
rejection region. If it does, then reject Ho . If it
does not fall in the rejection region, do not reject
Ho.
Two-tailed
H0: µ = µ0
H1: µ ≠ µ0
-tα/2,n-1 tα/2,n-1
Reject H0 if t > tα/2,n-1 or t < - tα/2,n-1
22
or
Right-tailed
H0: µ = µ0
H1: µ > µ0
tα,n-1
Reject H0 if t > tα,n-1
Left-tailed
H0: µ = µ0
H1: µ < µ0
23
-tα,n-1
Reject H0 if t <- tα,n-1
Step 5. State the conclusion in words.
Example: The foundation for a building is
designed to rest on 100 piles and the capacity of
the pile is 80 tons. Nine test piles were driven at
random and the failure loads were recorded. The
results of the 9 tests are given below;
24
Based on these results, at 5% significance level,
find out whether the foundation based on the
piles should be accepted?
Answer
Given data:
Sample size = 9
Sample mean = 85 tons
Sample standard deviation = 6.76 tons
Significance level = 5%
25
Hypotheses formulation:
H0: μ ≤ 80 ton or μ = 80 ton
H1: μ > 80 ton
X̄−μ0 85−80
t= = =2. 22
s/ √ n 6 .76 / √9
t – Value corresponding to 5 % significance
level (for one tailed testing) is t0.05,9 =1.86.
Since t=2.2 > 1.86, the conclusion is “reject the
null hypothesis”.
Testing Hypothesis
Traditional Method
(The Rejection Region Method)
Example: A random sample of size n =
100 yields, assume σ=0.5
x̄=1.1
Need to test
26
H0: = 1
H1: ≠ 1
The test statistic
X̄−μ0
1.1−1
Z= = =2
σ/ √ n 0.5/ √ 100
Testing at α = 0.05. The critical values are
27
- Zα/2 Zα/2
-Z0.005=-2.578 Z0.005=2.578
Z = 2 < Zα = 2.578, we do not reject H0.
At α = 0.05, we reject H0
At α = 0.01, we do not reject H0
28
we make a yes or no decision without
discussing borderline cases.
Using the p-value approach, we reject
H0 if
p-value < α
and do not reject H0 if
p-value ≥ α
Using P-values for a z-test for a Mean µ
Calculate the test statistic
X̄ −μ 0
Z 0=
σ /√n
Right-tailed
H0: µ = µ0
H1: µ > µ0
29
Z0
Z0
30
P-Value = Area in in tail of test statistic
P-Value = 2[1-P(Z < |Z0|)]
Example: A random sample of size n =
100 yields, σ=0.5
x̄=1.1
Need to test
H0: = 1
H1: ≠ 1
The test statistic
X̄−μ0 1 .1−1
Z= = =2
σ / √ n 0 . 5/ √ 100
P-Value = 2 [ P(Z > 2) ] =2[1-P(Z<2)]
31
=2(1-0.9772) = 0.0456
Example: Suppose that we want to test the
hypothesis with a significance level of .05 that
the climate has changed since industrialization.
Suppose that the mean temperature throughout
history is 50 degrees. During the last 40 years,
the mean temperature has been 51 degrees and
suppose the population standard deviation is
σ=2 degrees. Compute the p-value, what can we
conclude?
H0: = 50
H1: ≠ 50
We compute the z:
33
Reject H0 if
34
2
2 (100−1 )(0 .0063 )
χ 0= =0 . 39
0 .01
2 2
χ α = χ 0 . 025, 99=129 .56
, n−1
2
2 2
χ α = χ 0 .975,99=74.22
1− ,n−1
2
Critical region: Reject H0 if
2
χ 0 <74 .22
or
2
χ 0 >129. 56
The test statistic value of 0.3903 is much
smaller than the lower critical value, so we
35
reject the null hypothesis and conclude that the
variance is not equal to 0.01.
Comparison of Two Groups or Means
Two independent samples t-test
A common form of scientific
experimentation is the comparison of two
groups (two different treatments, or a
treatment to a control).
36
Testing Hypothesis
Population-1
X 1 , X 2 ,..., X n
Let 1 be random sample
∑ Xi ∑Yi
i =1 i =1
X̄ = Ȳ =
n1 , n2
38
The estimate of the common variance can be
obtained by
Where
n1
∑ ( x i− x̄ )2
i=1
s 21 =
n1−1
n2
∑ ( y i− ȳ )2
i=1
s 22 =
n2 −1
39
X̄ −Ȳ
t=
1 1
sp
√ +
n1 n2
which has t distribution with n1+n2-2 d.f
Two-tailed
H0 : µ1 = µ 2
H1 : µ1 ≠ µ 2
tα, n1+n2-2
Reject H0 if t > tα, n1+n2-2
Left-tailed
H0 : µ1 = µ 2
41
H 1 : µ 1 < µ2
-tα, n1+n2-2
Reject H0 if t <- tα, n1+n2-2
Example – Consider the following two
independent samples
sample 1 sample 2
51.0 54.0
53.3 56.1
55.6 52.1
51.0 56.4
55.5 54.0
53.0 52.9
52.1
42
Test the equality of the two population
means
H0 : µ1 = µ 2
H1 : µ1 ≠ µ 2
x̄=53 .07 , ȳ =54 .25 , s 1=1 . 91 , s 2=1 . 71
2 2
(7−1 )(1. 91) +(6−1)(1 .71 )
s p=
√
The test statistic
7+6−2
= 1. 82
43
-tα/2,n1+n2-2 tα/2, n1+n2-2
-t.025,11=-2.201 t0.025, 11=2.201
t = |-1.16| = 1.16 not greater than 2.201, we do not
reject H0. We conclude that no significant
difference between the two means
44
Test
H0: μ1 = μ2
H1: μ1 ≠ μ2
For the above hypotheses, the test statistic
46
47
Test
H0: σ12 = σ22
H1: σ12 ≠ σ22
The test statistic,
48
Reject H0
if F > Fα/2,n1-1,n2-1
or F < F 1-α/2,n1-1,n2-1
Remark:
1
F α =
1− ,n 1−1,n 2−1 F α
2 , n −1, n −1
2 2 1
mean ni si
Sample 1 3.6 4.5 3.9 4.3 4.075 4 0.403
Sample 2 4.6 5.2 4.9 4.900 3 0.300
Test at α=0.05
49
H0: σ12 = σ22
H1: σ12 ≠ σ22
Calculation of the test statistic
2
s1 ( 0. 403 )2
F0 = 2 = 2
=1 . 805
s2 (0. 3 )
Fα/2,n1-1,n2-1=F0.025,4-1,3-1=F0.025,3,2=39.2
1 1 1
F α = = = =0. 0625
1− , n 1−1, n 2−1 F α F0 . 025, 2,3 16
2 , n −1, n −1
2 2 1
Reject H0
if F0 =1.805 is not less than 0.0625
or greater than 39.2, then we do not reject H0,
we will accept the assumption that the two
variances (standard deviations) are equal.
50
Paired Samples t-test
Compare the two treatments under the same,
similar or identical conditions
Instead of two independent groups of
patients, each patient is administered both
drugs at different times, with an intervening
washout period to minimize carry-over
effects, we randomly choose which
treatment is administered first for each
patient, this is called paired design. The
idea the drugs are compared under similar
conditions
51
Data Diagram for a Paired Design
Patient Drug 1 Drug 2
1 X1 Y1
2 X2 Y2
. . .
. . .
. . .
n Xn Yn
52
Paired data (dependent samples)
Paired Samples or dependent samples (Paired
Design)
The usual analysis is based on the
differences between X and Y values
The structure of paired data is:
Subject No. Treatment 1 Treatment 2 Difference
1 X1 Y1 d1 = x1 –y1
2 X1 Y1 d2 = x2 –y2
. . . .
. . . .
. . . .
n X1 Yn dn = xn –yn
53
The differences d1,d2,…,dn represent a random
sample with mean d̄ and standard deviation
sd , where
n
∑ di
i =1
d̄=
n
and
n
sd=
√ ∑ i
(
i=1
n
d − d̄ )2
n−1
sd=
√ d
∑ i
i=1
2
−n( d̄ )2
n−1
54
By taking the differences d1,d2,…, dn we
minimize the variations between the subjects
and focus on the effects of treatments.
Let d1,d2,…,dn be a random sample from
2 2
N ( μd , σ d ) with unknown σd . Then
the sampling distribution of d̄ is
approximately normal with mean and
standard deviation:
σd
μd̄ =μ d and σ d̄ =
√n
Where
µd = mean of the paired differences for the
population (µd =µ1-µ2)
σd = standard deviation of the paired
differences for the population
55
Result
d̄−μ d
t= ≈t-dist . with d . f .=n-1
sd / √ n
Two-tailed
H0: µd = 0 (corresponds to µ1= µ2)
H1: µd ≠ 0 (corresponds to µ1≠ µ2)
-tα/2,n-1 tα/2,n-1
Reject H0 if t > tα/2,n-1 or t < - tα/2,n-1
or
Reject H0 if |t| > tα/2,n-1
56
Right-tailed
H0: µd = 0 (corresponds to µ1= µ2)
H1: µd > 0 (corresponds to µ1> µ2)
tα,n-1
Reject H0 if t > tα,n-1
Left-tailed
H0: µd = 0 (corresponds to µ1= µ2)
H1: µd < 0 (corresponds to µ1< µ2)
57
-tα,n-1
Reject H0 if t <- tα,n-1
Example 1: The sleep hours of 5 patients before
and after taking a medication are given by the
following table
2 5 4
3 7 9
4 4 7
5 5 6
58
Can you conclude that the medication is
effective in increasing the sleep hours? Use
alpha = 0.01.
Solution: Need to test
H0 : µd = 0
H1: µd < 0 (µ1<µ2, increase)
d̄ sd
First, we compute mean and
2 5 4 1 1
3 7 9 -2 4
4 4 7 -3 9
5 5 6 -1 1
59
n
∑ di
−8
i =1
d̄= = =−1. 6
n 5
n
sd=
√ d
∑ i
i=1
2
−n(
n−1
d̄ )2
=
√24−5(−1. 6 )2
-1. 6-0
t= =-2.14
1 . 67/ √ 5
The cut-of-value = -tα,n-1 = -t0.01,4 = -3.747
60
Example 2: Drinking Water
61
Locatio Zinc concentration Zinc
n concentration
In bottom water d d2
In surface water
1 0.430 0.415 0.015 0.000225
2 0.266 0.238 0.028 0.000784
3 0.567 0.390 0.177 0.031329
4 0.531 0.410 0.121 0.014641
5 0.707 0.605 0.102 0.010404
6 0.716 0.609 0.107 0.011449
7 0.651 0.632 0.019 0.000361
8 0.589 0.523 0.066 0.004356
9 0.469 0.411 0.058 0.003364
10 0.723 0.612 0.111 0.012321
Total 0.804 0.08923
0
0 . 8040
d̄= =0 . 0804
10
62
n
sd=
√ ∑ d2i −n ( d̄ )2
i =1
n−1
0 .08923−10(0 . 0804 )2
sd=
√
10−1
= 0 .052
63