Hypothesis Test _Two-sample t-test, Z-test, Proportion Z-test
117 chap8 slides
1. Chapter 8
Hypothesis Testing with Two
Samples
Math 117 --- Eddie Laanaoui 1
2. Chapter Outline
• 8.1 Testing the Difference Between Means (Large
Independent Samples)
• 8.2 Testing the Difference Between Means (Small
Independent Samples)
• 8.3 Testing the Difference Between Means
(Dependent Samples)
• 8.4 Testing the Difference Between Proportions
2
Math 117 --- Eddie Laanaoui
3. Section 8.1
Testing the Difference Between
Means (Large Independent Samples)
(2 sample Z- test)
3
Math 117 --- Eddie Laanaoui
4. Section 8.1 Objectives
• Determine whether two samples are independent or
dependent
• Perform a two-sample z-test for the difference
between two means μ1 and μ2 using large independent
samples
4
Math 117 --- Eddie Laanaoui
5. Two Sample Hypothesis Test
• Compares two parameters from two populations.
• Sampling methods:
Independent Samples
• The sample selected from one population is not
related to the sample selected from the second
population.
Dependent Samples (paired or matched samples)
• Each member of one sample corresponds to a
member of the other sample.
5
Math 117 --- Eddie Laanaoui
6. Independent and Dependent Samples
Independent Samples Dependent Samples
Sample 1 Sample 2 Sample 1 Sample 2
6
Math 117 --- Eddie Laanaoui
7. Example: Independent and Dependent
Samples
Classify the pair of samples as independent or
dependent.
•Sample 1: Resting heart rates of 35 individuals before
drinking coffee.
•Sample 2: Resting heart rates of the same individuals
after drinking two cups of coffee.
Solution:
Dependent Samples (The samples can be paired with
respect to each individual)
7
Math 117 --- Eddie Laanaoui
8. Example: Independent and Dependent
Samples
Classify the pair of samples as independent or
dependent.
•Sample 1: Test scores for 35 statistics students.
•Sample 2: Test scores for 42 biology students who do
not study statistics.
Solution:
Independent Samples (Not possible to form a pairing
between the members of the samples; the sample sizes
are different, and the data represent scores for different
individuals.)
8
Math 117 --- Eddie Laanaoui
9. Two Sample Hypothesis Test with
Independent Samples
1. Null hypothesis H0
A statistical hypothesis that usually states there is
no difference between the parameters of two
populations.
Always contains the symbol ≤, =, or ≥.
1. Alternative hypothesis Ha
A statistical hypothesis that is true when H0 is
false.
Always contains the symbol >, ≠, or <.
9
Math 117 --- Eddie Laanaoui
10. Two Sample Hypothesis Test with
Independent Samples
H0: μ1 = μ2 H0: μ1 ≤ μ2 H0: μ1 ≥ μ2
Ha: μ1 ≠ μ2 Ha: μ1 > μ2 Ha: μ1 < μ2
Regardless of which hypotheses you use, you
always assume there is no difference between the
population means, or μ1 = μ2.
10
Math 117 --- Eddie Laanaoui
11. Two Sample z-Test for the Difference
Between Means
Three conditions are necessary to perform a z-test for
the difference between two population means μ1 and μ2.
1.The samples must be randomly selected.
2.The samples must be independent.
3.Each sample size must be at least 30, or, if not, each
population must have a normal distribution with a
known standard deviation.
11
Math 117 --- Eddie Laanaoui
12. Two Sample z-Test for the Difference
Between Means
If these requirements are met, the sampling distribution
for x1 − x2 (the difference of the sample means) is a
normal distribution with
Mean: µ x − x = µ x − µ x = µ1 − µ 2
1 2 1 2
σ 12 σ 2
2
Standard error: σ x − x 1 2
= σ x +σ x =
2
1
2
+
n1 n2
2
Sampling distribution
for x1 − x2 :
x1 − x2
−σ x − x
1 2
µ − µ2
1 σ x −x
1 2
12
Math 117 --- Eddie Laanaoui
13. Two Sample z-Test for the Difference
Between Means
• Test statistic is x1 − x2
• The standardized test statistic is
z=
( x1 − x2) − ( µ1 − µ2) where σ = σ12 + σ 2
2
σ x −x
1 2
1
x −x
2
n1 n2
• When the samples are large, you can use s1 and s2 in place
of σ1 and σ2. If the samples are not large, you can still use
a two-sample z-test, provided the populations are
normally distributed and the population standard
deviations are known.
13
Math 117 --- Eddie Laanaoui
14. Using a Two-Sample z-Test for the
Difference Between Means (Large
Independent Samples)
In Words In Symbols
1. State the claim mathematically. State H0 and Ha.
Identify the null and alternative
hypotheses.
2. Specify the level of significance. Identify α.
14
Math 117 --- Eddie Laanaoui
15. Using a Two-Sample z-Test for the
Difference Between Means (Large
Independent Samples)
In Words In Symbols
3. Find the standardized test
z=
( x1 − x2) − ( µ1 − µ2)
statistic. σ x −x
1 2
4. Make a decision to reject or If P-value is SMALL,
fail to reject the null reject the NULL.
hypothesis. Otherwise, fail to
5. Interpret the decision in the reject H0.
context of the original claim.
15
Math 117 --- Eddie Laanaoui
16. Example: Two-Sample z-Test for the
Difference Between Means
A consumer education organization claims that there is a
difference in the mean credit card debt of males and
females in the United States. The results of a random
survey of 200 individuals from each group are shown
below. The two samples are independent. Do the results
support the organization’s claim? Use α = 0.05.
Females (1) Males (2)
x1 = $2290 x2 = $2370
s1 = $750 s2 = $800
n1 = 200 n2 = 200
16
Math 117 --- Eddie Laanaoui
17. Solution: Two-Sample z-Test for the
Difference Between Means
• H0: μ1 = μ2 • Test Statistic:
• Ha: μ1 ≠ μ2 (2290 − 2370) − 0
z= = −1.03
• α = 0.05 7502 8002
+
• n1= 200, n2 = 200 200 200
• P-value = 0.302 • Decision: Fail to Reject H0
At the 5% level of significance,
there is not enough evidence to
support the organization’s
claim that there is a difference
in the mean credit card debt of
males and females.
17
Math 117 --- Eddie Laanaoui
18. Example: Using Technology to Perform a
Two-Sample z-Test
The American Automobile Association claims that the
average daily cost for meals and lodging for vacationing in
Texas is less than the same average costs for vacationing in
Virginia. The table shows the results of a random survey of
vacationers in each state. The two samples are independent.
At α = 0.01, is there enough evidence to support the claim?
Texas (1) Virginia (2)
x1 = $248 x2 = $252
s1 = $15 s2 = $22
n1 = 50 n2 = 35
18
Math 117 --- Eddie Laanaoui
19. Solution: Using Technology to Perform a
Two-Sample z-Test
• H0: μ1 ≥ μ2 Calculate:
• Ha: μ1 < μ2
TI-83/84set up:
Draw:
19
Math 117 --- Eddie Laanaoui
20. Section 8.1 Summary
• Determined whether two samples are independent or
dependent
• Performed a two-sample z-test for the difference
between two means μ1 and μ2 using large independent
samples
20
Math 117 --- Eddie Laanaoui
21. Section 8.2
Testing the Difference Between
Means (Small Independent Samples)
(2 sample T- test)
21
Math 117 --- Eddie Laanaoui
22. Section 8.2 Objectives
• Perform a t-test for the difference between two means
μ1 and μ2 using small independent samples
22
Math 117 --- Eddie Laanaoui
23. Two Sample t-Test for the Difference
Between Means
• If samples of size less than 30 are taken from normally-
distributed populations, a t-test may be used to test the
difference between the population means μ1 and μ2.
• Three conditions are necessary to use a t-test for small
independent samples.
1. The samples must be randomly selected.
2. The samples must be independent.
3. Each population must have a normal distribution.
23
Math 117 --- Eddie Laanaoui
24. Two Sample t-Test for the Difference
Between Means
• The standardized test statistic is
t=
( x1 − x2) − ( µ1 − µ2)
σ x −x
1 2
• The standard error and the degrees of freedom of the
sampling distribution depend on whether the
population variances σ 1 and σ 2 are equal.
2 2
24
Math 117 --- Eddie Laanaoui
25. Two Sample t-Test for the Difference
Between Means
• Variances are not equal
(choose Not POOLED in you calculator)
If the population variances are not equal, then the
standard error is
2 2
s1 s2
σ x −x = +
n1 n2
1 2
d.f = smaller of n1 – 1 or n2 – 1
25
Math 117 --- Eddie Laanaoui
26. Two Sample t-Test for the Difference
Between Means
• Variances are equal (choose POOLED in you calculator)
Information from the two samples is combined to
calculate a pooled estimate of the standard deviation
σ.
ˆ
σ=
ˆ
( n1 − 1) s12 + ( n2 − 1) s2
2
n1 + n2 − 2
The standard error for the sampling distribution of
x1 − x2 is
1 1
σ x −x =σ × +
ˆ
1 2
n1 n2
d.f.= n1 + n2 – 2
Math 117 --- Eddie Laanaoui
26
27. Normal or t-Distribution?
Are both sample sizes 2 Sample z-test.
Yes
at least 30?
No
Are both population
Are the 2 Sample t-test
standard deviations No Yes
population “POOLED s.d”
known? d.f = n + n – 2.
variances equal?
No
1 2
Yes
2 Sample t-test
2 Sample z-test. “not POOLED s.d”
d.f = smaller of n1 – 1 or n2 – 1.
Math 117 --- Eddie Laanaoui
27
28. Example: Two-Sample t-Test for the
Difference Between Means
The braking distances of 8 Volkswagen GTIs and 10 Ford
Focuses were tested when traveling at 60 miles per hour on
dry pavement. The results are shown below. Can you
conclude that there is a difference in the mean braking
distances of the two types of cars? Use α = 0.01. Assume the
populations are normally distributed and the population
variances are not equal. (Adapted from Consumer Reports)
GTI (1) Focus (2)
x1 = 134 ft x2 = 143ft
s1 = 6.9 ft s2 = 2.6 ft
n1 = 8 n2 = 10
28
Math 117 --- Eddie Laanaoui
29. Solution: Two-Sample t-Test for the
Difference Between Means
• H0: μ1 = μ2 • Test Statistic:
• Ha: μ1 ≠ μ2 (134 − 143) − 0
t= = −3.496
• α = 0.01 6.92 2.62
+
• d.f. = 8 – 1 = 7 8 10
• P-value = 0.0073 • Decision: Reject H0
At the 1% level of significance,
there is enough evidence to
conclude that the mean braking
distances of the cars are
different.
29
Math 117 --- Eddie Laanaoui
30. Example: Two-Sample t-Test for the
Difference Between Means
A manufacturer claims that the calling range (in feet) of its
2.4-GHz cordless telephone is greater than that of its leading
competitor. You perform a study using 14 randomly selected
phones from the manufacturer and 16 randomly selected
similar phones from its competitor. The results are shown
below. At α = 0.05, can you support the manufacturer’s
claim? Assume the populations are normally distributed and
the population variances are equal.
Manufacturer (1) Competition (2)
x1 = 1275ft x2 = 1250 ft
s1 = 45 ft s2 = 30 ft
n1 = 14 n2 = 16
30
Math 117 --- Eddie Laanaoui
31. Solution: Two-Sample t-Test for the
Difference Between Means
• H0: μ1 ≤ μ2 • Test Statistic:
• Ha: μ1 > μ2 t = 1.811
• α = 0.05
• P-value = 0.0404
• Decision: Reject H0
At the 5% level of significance,
there is enough evidence to
support the manufacturer’s
claim that its phone has a
greater calling range than its
competitors.
31
Math 117 --- Eddie Laanaoui
32. Section 8.2 Summary
• Performed a t-test for the difference between two
means μ1 and μ2 using small independent samples
32
Math 117 --- Eddie Laanaoui
33. Section 8.3
Testing the Difference Between
Means (Dependent Samples)
(t- test “for L3 !!”)
33
Math 117 --- Eddie Laanaoui
34. Section 8.3 Objectives
• Perform a t-test to test the mean of the difference for
a population of paired data
34
Math 117 --- Eddie Laanaoui
35. t-Test for the Difference Between Means
• To perform a two-sample hypothesis test with
dependent samples, the difference between each data
pair is first found:
d = x1 – x2 Difference between entries for a data pair
• The test statistic is the mean d of these differences.
d = ∑ d Mean of the differences between paired
n data entries in the dependent samples
35
Math 117 --- Eddie Laanaoui
36. t-Test for the Difference Between Means
Three conditions are required to conduct the test.
1. The samples must be randomly selected.
2. The samples must be dependent (paired).
3. Both populations must be normally distributed.
If these conditions are met, then the sampling
distribution for d is approximated by a t-distribution
with n – 1 degrees of freedom, where n is the number
of data pairs.
d
-t0 μd t0
36
Math 117 --- Eddie Laanaoui
37. Symbols used for the t-Test for μd
Symbol Description
n The number of pairs of data
d The difference between entries for a data pair,
d = x1 – x2
µd The hypothesized mean of the differences of
paired data in the population
37
Math 117 --- Eddie Laanaoui
38. Symbols used for the t-Test for μd
Symbol Description
d The mean of the differences between the paired
data entries in the dependent samples
∑d
d=
n
sd The standard deviation of the differences
between the paired data entries in the dependent
samples Σ(d − d ) 2
sd =
n −1
38
Math 117 --- Eddie Laanaoui
39. t-Test for the Difference Between Means
• The test statistic is
∑d
d=
n
• The standardized test statistic is
d − µd
t=
sd n
• The degrees of freedom are
d.f. = n – 1
39
Math 117 --- Eddie Laanaoui
40. t-Test for the Difference Between Means
(Dependent Samples)
In Words In Symbols
1. State the claim mathematically. State H0 and Ha.
Identify the null and alternative
hypotheses.
2. Specify the level of significance. Identify α.
3. Use t-Test
(NOT 2 sample t-Test!!)
40
Math 117 --- Eddie Laanaoui
41. t-Test for the Difference Between Means
(Dependent Samples)
In Words In Symbols
4. Calculate d and sd.
d = ∑d
n
(Hint: L3 = L1-L2)
∑(d − d ) 2
sd =
n −1
d − µd
• Find the standardized test t=
sd n
statistic.
41
Math 117 --- Eddie Laanaoui
42. t-Test for the Difference Between Means
(Dependent Samples)
In Words In Symbols
6. Make a decision to reject or If P-value is SMALL,
fail to reject the null reject the NULL.
hypothesis. Otherwise, fail to
reject H0.
7. Interpret the decision in the
context of the original
claim.
42
Math 117 --- Eddie Laanaoui
43. Example: t-Test for the Difference
Between Means
A golf club manufacturer claims that golfers can lower their
scores by using the manufacturer’s newly designed golf
clubs. Eight golfers are randomly selected, and each is asked
to give his or her most recent score. After using the new
clubs for one month, the golfers are again asked to give their
most recent score. The scores for each golfer are shown in
the table. Assuming the golf scores are normally distributed,
is there enough evidence to support the manufacturer’s claim
at α = 0.10?
Golfer 1 2 3 4 5 6 7 8
Score (old) 89 84 96 82 74 92 85 91
Score 83 83 92 84 76 91 80 91
(new)
43
Math 117 --- Eddie Laanaoui
44. Solution: Two-Sample t-Test for the
Difference Between Means
d = (old score) – (new score)
• H0: μd ≤ 0 • Test Statistic:
• Ha: μd > 0
• α = 0.10
• Decision:
44
Math 117 --- Eddie Laanaoui
45. Solution: Two-Sample t-Test for the
Difference Between Means
d = (old score) – (new score)
• H0: μd ≤ 0 • Test Statistic:
• Ha: μd > 0 d − µd
t= = 1.498
• α = 0.10 sd n
• P-value = 0.089 • Decision: Reject H0
At the 10% level of significance,
the results of this test indicate
that after the golfers used the
new clubs, their scores were
significantly lower.
45
Math 117 --- Eddie Laanaoui
46. Section 8.3 Summary
• Performed a t-test to test the mean of the difference
for a population of paired data
46
Math 117 --- Eddie Laanaoui
47. Section 8.4
Testing the Difference Between
Proportions
(2 Prop. Z test)
47
Math 117 --- Eddie Laanaoui
48. Section 8.4 Objectives
• Perform a z-test for the difference between two
population proportions p1 and p2
48
Math 117 --- Eddie Laanaoui
49. Two-Sample z-Test for Proportions
• Used to test the difference between two population
proportions, p1 and p2.
• Three conditions are required to conduct the test.
1. The samples must be randomly selected.
2. The samples must be independent.
3. The samples must be large enough to use a
normal sampling distribution. That is,
n1p1 ≥ 5, n1q1 ≥ 5, n2p2 ≥ 5, and n2q2 ≥ 5.
49
Math 117 --- Eddie Laanaoui
50. Two-Sample z-Test for the Difference
Between Proportions
• If these conditions are met, then the sampling
distribution for p1 − p2 is a normal distribution
ˆ ˆ
• Mean: µ p − p = p1 − p2
ˆ ˆ 1 2
• A weighted estimate of p1 and p2 can be found by
using p = x1 + x2 , where x = n p and x = n p
n1 + n2 1 1 ˆ1 2 2 ˆ2
• Standard error:
σ p − p = pq 1 + 1
ˆ ˆ n n ÷
1 2
1 2
50
Math 117 --- Eddie Laanaoui
51. Two-Sample z-Test for the Difference
Between Proportions
• The test statistic is p1 − p2
ˆ ˆ
• The standardized test statistic is
( p1 − p2) − ( p1 − p2)
ˆ ˆ
z=
pq +
1 1
n n ÷
1 2
where
x1 + x2
p= and q = 1 − p
n1 + n2
51
Math 117 --- Eddie Laanaoui
52. Two-Sample z-Test for the Difference
Between Proportions
In Words In Symbols
1. State the claim. Identify the null State H0 and Ha.
and alternative hypotheses.
2. Specify the level of significance. Identify α.
3. Find the weighted estimate of x1 + x2
p=
p1 and p2. n1 + n2
52
Math 117 --- Eddie Laanaoui
53. Two-Sample z-Test for the Difference
Between Proportions
In Words In Symbols
6. Find the standardized test ( p1 − p2) − ( p1 − p2)
ˆ ˆ
z=
statistic.
pq +
1 1
n n ÷
1 2
7. Make a decision to reject or If P-value is SMALL,
fail to reject the null reject the NULL.
hypothesis. Otherwise, fail to
reject H0.
8. Interpret the decision in the
context of the original claim.
53
Math 117 --- Eddie Laanaoui
54. Example: Two-Sample z-Test for the
Difference Between Proportions
In a study of 200 randomly selected adult female and
250 randomly selected adult male Internet users, 30% of
the females and 38% of the males said that they plan to
shop online at least once during the next month. At
α = 0.10 test the claim that there is a difference between
the proportion of female and the proportion of male
Internet users who plan to shop online.
Solution:
1 = Females 2 = Males
54
Math 117 --- Eddie Laanaoui
55. Solution: Two-Sample z-Test for the
Difference Between Means
• H0: p1 = p2 • Test Statistic:
• Ha: p1 ≠ p2
• α = 0.10
• n1= 200, n2 = 250
• P-value = • Decision:
55
Math 117 --- Eddie Laanaoui
56. Solution: Two-Sample z-Test for the
Difference Between Means
x1 = n1 p1 = 60
ˆ x2 = n2 p2 = 95
ˆ
x1 + x2 60 + 95
p= = ≈ 0.3444
n1 + n2 200 + 250
q = 1 − p = 1 − 0.3444 = 0.6556
Note:
n1 p = 200(0.3444) ≥ 5 n1q = 200(0.6556) ≥ 5
n2 p = 250(0.3444) ≥ 5 n2q = 250(0.6556) ≥ 5
56
Math 117 --- Eddie Laanaoui
58. Solution: Two-Sample z-Test for the
Difference Between Means
• H0: p1 = p2 • Test Statistic:
• Ha: p1 ≠ p2 z = −1.77
• α = 0.10
• Decision: Reject H0
• n1= 200, n2 = 250
At the 10% level of
• P-value = 0.076 significance, there is enough
evidence to conclude that there
is a difference between the
proportion of female and the
proportion of male Internet
users who plan to shop online.
58
Math 117 --- Eddie Laanaoui
59. Example: Two-Sample z-Test for the
Difference Between Proportions
A medical research team conducted a study to test the effect
of a cholesterol reducing medication. At the end of the
study, the researchers found that of the 4700 randomly
selected subjects who took the medication, 301 died of
heart disease. Of the 4300 randomly selected subjects who
took a placebo, 357 died of heart disease. At α = 0.01 can
you conclude that the death rate due to heart disease is
lower for those who took the medication than for those who
took the placebo? (Adapted from New England Journal of
Medicine)
Solution:
1 = Medication 2 = Placebo
59
Math 117 --- Eddie Laanaoui
60. Solution: Two-Sample z-Test for the
Difference Between Means
• H0: p1 ≥ p2 • Test Statistic:
• Ha: p1 < p2
• α = 0.01
• n1= 4700, n2 = 4300
• P-value = • Decision:
60
Math 117 --- Eddie Laanaoui
61. Solution: Two-Sample z-Test for the
Difference Between Means
x1 301 x2 357
p1 =
ˆ = = 0.064 p2 =
ˆ = = 0.083
n1 4700 n2 4300
x1 + x2 301 + 357
p= = ≈ 0.0731
n1 + n2 4700 + 4300
q = 1 − p = 1 − 0.0731 = 0.9269
Note:
n1 p = 4700(0.0731) ≥ 5 n1q = 4700(0.9269) ≥ 5
n2 p = 4300(0.0731) ≥ 5 n2q = 4300(0.9269) ≥ 5
61
Math 117 --- Eddie Laanaoui
63. Solution: Two-Sample z-Test for the
Difference Between Means
• H0: p1 ≥ p2 • Test Statistic:
• Ha: p1 < p2 z = −3.46
• α = 0.01
• Decision: Reject H0
• n1= 4700 , n2 = 4300
At the 1% level of significance,
• P-value = 0.000275 there is enough evidence to
conclude that the death rate due
to heart disease is lower for
those who took the medication
than for those who took the
placebo.
63
Math 117 --- Eddie Laanaoui
64. Section 8.4 Summary
• Performed a z-test for the difference between two
population proportions p1 and p2
64
Math 117 --- Eddie Laanaoui