Вы находитесь на странице: 1из 26

Professor Friedman

Two Sample (Two Group) Hypothesis Tests

Source: Business Week May 29, 2006

The above is a good example of how medical research is conducted. Note


that there are two groups: half received ear tubes and the other half did not.
Subjects are assigned to the two groups randomly. The researcher was
interested in determining whether there was a difference between the two
groups in hearing and language development.

Lecture Notes: Two-Sample Tests

Page 1

Professor Friedman

EXAMPLE:
Compare the following 2 groups
Drug Group
X 1 = 4.4 colds per year
S 1 = 0.7 colds per year
n 1 = 81

Placebo Group
X 2 = 4.8 colds per year
S 2 = 0.8 colds per year
n 2 = 64

Test at = .05 (these tests are usually two-tailed)


How to do this?

Lecture Notes: Two-Sample Tests

Page 2

Professor Friedman

Two-Sample Z-Tests
If the samples are large, random, and independent, then (1 2 ) is a random
variable and has approximately a normal distribution, with

E 1 2 = 1 2

12

and 1 =

n1

22
n2

2 ( 1 2 )

12

So,

n1

22
n2

However, since H 0 is usually 1 = 2 , then 1 2 =0 and:

1 2

n1

for 1 , 2 known

n2

for 1 , 2 unknown

Lecture Notes: Two-Sample Tests

Page 3

Professor Friedman

X1 X 2
Z=

s12 s 22
+
n1 n2

if n 1 + n 2 32

For a 1- % Confidence Interval for the difference between two means:

12
n1

22
n2

When we construct the confidence interval for the mean difference in the
population ( 1 2 ), we check to see whether 0 is in the interval. If 0 is in
the interval, then we are basically saying that there may be no difference
between the two groups and the observed difference between the two sample
means is simply sampling error.
The Null hypothesis that 1 = 2 , is the same as saying that the
hypothesized mean difference is 0, i.e., ( 1 2 ) = 0.

Lecture Notes: Two-Sample Tests

Page 4

Professor Friedman

EXAMPLE:
Compare the following 2 groups
Drug Group
X 1 = 4.4 colds per year
S 1 = 0.7 colds per year
n 1 = 81

Placebo Group
X 2 = 4.8 colds per year
S 2 = 0.8 colds per year
n 2 = 64

(a) Test at = .05 (these tests are usually two-tailed)


0 : 1 = 2
1 : 1 2

.025

.025

-1.96

Z=

4.4 4.8

(.7 )2 + (.8)2
81

.4
.01605

1.96

.4
= 3.15
.127

64

Therefore, REJECT H 0
different.

Lecture Notes: Two-Sample Tests

p < .05. The two groups are indeed statistically

Page 5

Professor Friedman

(b) Construct a 95% Confidence Interval Estimate for the difference between
the two population means

.4 1.96.127 -.15 -.65

.25

The Drug group has fewer colds per year. Since 0 is not in the above
interval, we see that there is a difference between the two groups. If 0 were
in the interval, then we could not reject a 0 mean difference. The drug group
has fewer colds. We are 95% sure that the true population mean difference
between the drug group and the placebo (control) group is between .15
and .65 fewer colds per year.

Lecture Notes: Two-Sample Tests

Page 6

Professor Friedman

EXAMPLE
Scores on a standardized science test. Is there a difference between men and
women? Test at = .05.

s
n

Men

Women

80.0
10
100

76.5
16
64

0 : 1 = 2
1 : 1 2

.025

Z=

-1.96

80.0 76.5
(10)
(16)
+
100
64
2

.025

3.5

1.96

= 1.56

Do not reject H 0 p > .05


There is no statistically difference between men and women on test scores in
science.

(b) 95% CIE

( )

3.5 1.96 5

3.5 4.4

-0.9 +7.9

0 difference is possible. When difference goes from negative to positive or


positive to negative, 0 is contained in the interval. There may indeed be no
difference between men and women on the science test.
Lecture Notes: Two-Sample Tests

Page 7

Professor Friedman

EXAMPLE
Typing Speed using MS Word. Who types faster?

Men
65 wpm
10 wpm
50

s
n

Women
68 wpm
14 wpm
60

Test at = .01.

0 : 1 = 2
1 : 1 2

.005

.005

2.58

-2.58

Z=

65 68
(10) 2 (14)
+
50
60

3
= 1.30
2.29

Do not reject H o . p > .01.


There is no statistically difference between men and women in typing speed.

Lecture Notes: Two-Sample Tests

Page 8

Professor Friedman

(b) Construct a 92% C.I. for different between the means

4%

4%
-1.75

1.75

3 1.75(2.29 )

3 4
-7 +1

Note that 0 is in the range.

Lecture Notes: Two-Sample Tests

Page 9

Professor Friedman

EXAMPLE
Take-Home Pay. Who earns more: Married or unmarried people?

Married
$639.60
$60
40

S
n

Not Married
$658.20
$90
60

(a) Test at = .04

0 : 1 = 2
1 : 1 2
Z

.02

.02
-2.05

Z=

18.60
(60) 2 (90) 2
+
60
40

2.05

18.60
225

18.60
= 1.24
15

DO NOT REJECT H 0 .
p > .04
There is no statistically difference between married and single individuals
with regard to take-home pay.

Lecture Notes: Two-Sample Tests

Page 10

Professor Friedman

(b) Construct a 95% CIE for the difference between two means
18.60 1.96(15)

))
(
29.40

-$48 +$10.80

Note that 0 is in the interval.

Lecture Notes: Two-Sample Tests

Page 11

Professor Friedman

EXAMPLE
Life Span of Marijuana and non-Marijuana Users
Non users
75.2 years
8.0 years
200

s
n

Marijuana users
73.2 years
7.0 years
100

(a) Test at = .05

0 : 1 = 2
1 : 1 2
Z

.025

.025

-1.96

Z=

75.2 73.2
(8) 2 (7) 2
+
200 100

2
.81

1.96

2
= 2.22
.9

Reject H 0 p < .05. . The two groups are indeed statistically different.
Non-users live longer.

(b) Construct a 95% CIE for the difference between the two means
2 1.96(.9)

2 1.8

+ .2 years
+3.8 years

Lecture Notes: Two-Sample Tests

Page 12

Professor Friedman

EXAMPLE
Are the machine tools manufactured by Company X and Y different with
regard to how long they last?

s
n

Company X
16.2 weeks
.2 weeks
40

Company Y
15.9 weeks
.2 weeks
40

(a) Test at = .04

0 : 1 = 2
1 : 1 2
Z

.02

.02
-2.05

2.05

16.2 15.9
.3
.3
=
=
= 6.67
2
2
(.2)
(.2)
.002 .045
+
40
40

Reject H 0 p<.04. . The two groups are indeed statistically different.


Machine tools manufactured by Company X last longer.

Lecture Notes: Two-Sample Tests

Page 13

Professor Friedman

(b) Construct a 92% Confidence Interval for difference


.31.75(.045) .3.08
+.22 weeks
+.38 weeks

Lecture Notes: Two-Sample Tests

Page 14

Professor Friedman

Two-Sample t-Tests
Use Z if 1 , 2 are known OR samples are large
Use t when 1 , 2 are unknown AND samples are small (n 1 + n 2 < 32)

t n1 +n2 2 =

where

2
pooled

1 2
1 1
2
( + )
S pooled
n1 n2
(n1 1) S12 + (n2 1) S 22
=
n1 + n2 2

2
NOTE: S pooled
is a weighted average of S12 and S 22 , weighted by degrees of
freedom.

----------------------------------------------------------------------------------------Technically, to use this formula one must know (or prove statistically) that
the two variances are equal this property is called homoskedasticity.
(Incidentally, some spell homoskedasticity with a k and others spell it with
a c, homoscedasticity. ) If the variances are not statistically equivalent, one
may not pool the variances. An F-test may be performed to test for whether
2
2
S1 and S1 are statistically equivalent, i.e., homoskedasticity:

Fd . f .L ,d . f .S

2
S LARGER
= 2
S SMALLER

We will learn about this F-test in other courses.


If you do not have homoskedasticity, i.e. the variances are not equal, then
you have to make adjustment to the degrees of freedom.
---------------------------------------------------------------------------------------

Lecture Notes: Two-Sample Tests

Page 15

Professor Friedman

EXAMPLE
Score on a standardized reading examination.
Men

Women

80 = 1
16 = S 1

16 = n1

84 = 2
20 = S 2
15 = n 2

Test at = .05

0 : 1 = 2
1 : 1 2

t 29

.025

.025
2.045

-2.045

2
S pooled
=

15(256) + 14(400) 9440


=
= 325.5
29
29

Note that S 2pooled is between S12 (= 256) and S 22 (= 400).


t 29 =

80 84
325.5(

1 1
+ )
16 15

4
42.04

4
= .62
6.48

Do not reject H 0 . P >.05


There is no statistically difference between men and women on test scores.
Lecture Notes: Two-Sample Tests

Page 16

Professor Friedman

EXAMPLE
Which company, if any, has a better daily wage
Company A
1 = $210
S 1 = $25
n1 = 10

Company B
2 = $175
S 2 = $20
n 2 = 20

Test at = 0.01

0 : 1 = 2
1 : 1 2

t 28

.005

.005

-2.7633

2
S pooled
=

t 28 =

2.7633

9(625) + 19(400)
= 472.3
28

210 175
1
1
472.3( + )
10 20

35
70.845

35
= 4.16
8.42

Reject H 0 at p < .01. The two groups are indeed statistically different.

Lecture Notes: Two-Sample Tests

Page 17

Professor Friedman

EXAMPLE
Two types of precast concrete beams are being considered for sale. The
only difference between the two beams is in the type of material used.
Strength is measured in terms of pounds per square inch (psi) of pressure.
Which beams are stronger, those from Supplier A or those from Supplier B?
Test at = 0.05
Supplier A

Supplier B

1 = 5000 psi

2 = 4975 psi

S1 = 50

psi

S 2 = 60

psi

n1 = 12

batches

n2 = 10

batches

0 : 1 = 2
1 : 1 2

t 20

.025

.025
-2.086

2
S pooled
=

t 20 =

2.086

11(2500) + 7(3600)
= 2995
20

5000 4975
2995(

1 1
+ )
12 10

25
549

25
= 1.07
23.4

Do not reject H 0 . P>.05


There is no statistically difference between the two concrete suppliers.
Lecture Notes: Two-Sample Tests

Page 18

Professor Friedman

EXAMPLE
Two approaches to dealing with liver cancer (additional years of life) Are
they different? Test at a = .05
Approach A

Approach B

1 = 6.2 years

2 = 5.6 years

S1 = .69 years

S 2 = .60 years

n1 = 10

n2 = 17

0 : 1 = 2
1 : 1 2

t 25

.025

.025

2.0595

-2.0595

2
S pooled
=

t 25 =

9(.476) + 16(.36)
= .402
25
6.2 5.6

1 1
.402( + )
10 17

.6
.064

.6
= 2.37
.253

REJECT H 0

Reject H 0 at p < .05. There is a statistically significant difference between


the two treatment approaches.

Lecture Notes: Two-Sample Tests

Page 19

Professor Friedman

EXAMPLE
Who lives longer? Test at =.01

Single Men
1 = 72.5 years

Married Men
2 = 74.5 years

S1 = 7.0 years

S 2 = 8.0 years

n1 = 14

n 2 = 16

0 : 1 = 2
1 : 1 2

t 28

.005

.005

2.7633

2
S pooled

2.7633

13(49) + 15(64)
= 57
28

t 28 =
57(

1
1
+ )
14 16

Do not reject H 0 .

2
7.6

2
= .72
2.76

P >.01. There is no significant difference in lifespan.

Lecture Notes: Two-Sample Tests

Page 20

Professor Friedman

EXAMPLE
Absenteeism of Executives
Test at = .05

Female Executives

Male Executives

1 = 9.2 days
S1 = 1.1 days

2 = 10.4 days
S 2 = .9 days

n1 = 9

n2 = 20

0 : 1 = 2
1 : 1 2

t 27

.025

.025

2.0518

-2.0518

2
S pooled
=

t 27 =

8(1.21) + 19(.81)
= .929
27

9.2 10.4

1 1
.929( + )
9 20

1.2
.14967

1.2
= 3.1
.387

Reject H 0 . at p < .05. There is a statistically significant difference. Male


executives miss work more often than females.

Lecture Notes: Two-Sample Tests

Page 21

Professor Friedman

EXAMPLE USING EXCEL:


A marketer wants to determine whether men and women spend different
amounts on wine. (It is well known that men spend considerably more on
beer.) A researcher decides to test this. She randomly samples 34 people (17
women and 17 men) and finds that the average amount spent on wine (in a
year) by women is $437.47. The average amount spent by men is $552.94.
Given the Excel printout below, is the difference statistically significant?
t-Test:
Two-Sample
Variances

Assuming

Mean
Variance
Observations
Pooled Variance
Hypothesized Mean Difference
df
t Stat
P(T<=t) one-tail
t Critical one-tail
P(T<=t) two-tail
t Critical two-tail

Equal

Variable 1
437.4705882
97784.13971
17
101002.8493
0
32
-1.05928794
0.148699644
1.693888407
0.297399288
2.036931619

Variable 2
552.9412
104221.6
17

Answer: If a two-tail test was done, the probability of getting the sample
evidence (or sample evidence showing an even larger difference) given that
there is no difference in the population means of job satisfaction scores for
men and women is .30 (rounded from .297399288). In another words, if
men and women spend the same on wine, there is a 30% chance of getting
the sample evidence (or sample evidence indicating a larger difference
between men and women) we obtained. Statisticians usually test at an alpha
of .05 so we do not have evidence to reject the null hypothesis. Conclusion:
There is no statistically significant difference between men and women on
how much they spend on wine consumption.

The calculated t-statistic is -1.059287941. Why is it negative?


Answer: The amount spent on wine by women is less than that spent by
men (although the difference is not statistically significant). If you make
men the first variable the t-value will be positive but the results will be

Lecture Notes: Two-Sample Tests

Page 22

Professor Friedman

exactly the same (the t-distribution is symmetric).

What would the calculated t-value have to be for us to reject it?


Answer: If a two-tail test is being done, the critical value of t is
2.036931619. To reject the null hypothesis, we would need a calculated tvalue of more than 2.036931619 or less than -2.036931619.

See more Excel examples in:


TBA

Lecture Notes: Two-Sample Tests

Page 23

Professor Friedman

Matched T-Test (Optional Topic)


(non-independent samples, not two groups)
If you do this in MS Excel, this test is known as the
t-Test: Paired Two Sample for Means
(Example 1)

X 1 (Before) X 2 (After)
150
130
160
145
155
150
170
162
150
140
145
125
170
155
160
140
165
163
160
160

D
=(X 1 -X 2 )
20
15
5
8
10
20
15
20
2
0
115

D2
400
225
25
64
100
400
225
400
4
0
1,843

H 0 : D = 0 (mean difference is 0)
H1 : D 0

Lecture Notes: Two-Sample Tests

Page 24

Professor Friedman

t9

.025

.025

2.2622

-2.2622

t9 =

D
=
SD / n

n D 2 ( D ) 2
n 1

t9 =

115
10(1843) (115) 2
9

115
= 4.78
24.05

Reject H 0 at P<.05. There is a significant difference between the before and


after measures.

Lecture Notes: Two-Sample Tests

Page 25

Professor Friedman

(Example 2)
X 1 (Before) X 2 (After) D=(X 1 -X 2 )
12
15
-3
4
9
-5
17
16
1
3
9
-6
5
5
0
18
14
4
15
7
8
14
8
6
8
1
7
6
17
-11
16
25
-9
15
12
3
-5

D2
9
25
1
36
0
16
64
36
49
121
81
9
447

0 : D = 0
1 : D 0

t 11

.025

.025

2.2010

-2.2010

t11 =

5
5(447) (5) 2
11

5
= .23
22

Do Not Reject H 0 . P >.05. Difference is not significant.

Lecture Notes: Two-Sample Tests

Page 26

Вам также может понравиться