Anda di halaman 1dari 25

Comparing Two Groups

Comparing two means



Two-sample z statistic
Two-samples t procedures
Two-sample t significance test
Two-sample t confidence interval
Robustness
Details of the two-sample t procedures (various
cases)
Two-sample z statistic
We have two independent SRSs (simple random samples) possibly
coming from two distinct populations with (
1
,o
1
) and (
2
,o
2
). We use
1
and
2
to estimate the unknown
1
and
2
.

When both populations are normal, the sampling distribution of
(
1

2
) is also normal, with standard deviation :

Then the two-sample z statistic
has the standard normal N(0, 1)
sampling distribution.
2
2
2
1
2
1
n n
o o
+
2
2
2
1
2
1
2 1 2 1
) ( ) (
n n
x x
z
o o

+

=

x

x

x

x
Two independent samples t distribution
We have two independent SRSs (simple random samples) possibly
coming from two distinct populations with (
1
,o
1
) and (
2
,o
2
)
unknown. We use (
1
,s
1
) and (
2
,s
2
) to estimate (
1
,o
1
) and (
2
,o
2
),
respectively.

To compare the means, both populations should be normally
distributed. However, in practice, it is enough that the two distributions
have similar shapes and that the sample data contain no strong
outliers.


x

x

SE =
s
1
2
n
1
+
s
2
2
n
2

s
1
2
n
1
+
s
2
2
n
2
df

1
-
2

x
1
x
2
The two-sample t statistic follows approximately the t distribution with
a standard error SE (spread) reflecting
variation from both samples:
Conservatively, the degrees of
freedom is equal to the smallest
of (n
1
1, n
2
1).

t =
(x
1
x
2
) (
1

2
)
SE
Two-sample t significance test
The null hypothesis is that both population means
1
and
2
are equal,
thus their difference is equal to zero.
H
0
:
1
=
2
<=>
1

2
= 0
with either a one-sided or a two-sided alternative hypothesis.

We find how many standard errors (SE) away
from (
1

2
) is (
1

2
) by standardizing with t:

Because in a two-sample test H
0

poses (
1

2
) = 0, we simply use

With df = smallest(n
1
1, n
2
1)

t =
x
1
x
2
s
1
2
n
1
+
s
2
2
n
2

x

x
Example
A company that makes and sells frozen pizza would like to
know if their product sells at different levels across
geographic locations. To answer this question, we will
compare sales volume data (in pounds) in Dallas and
Denver, to see if sales differ. Weekly sales volume during
the same time period in these two cities over 156 weeks
yields average sales volume of 51,738 lbs in Dallas and
45,743 pounds in Denver.

1 What are the null and alternative hypothesis?
2 How would you test the conditions?
3 Write a conclusion. Use 5% level of significance
Sales s n
Dallas 51738 9842 156
Denver 45743 12271 156
The difference in sample averages follows
approximately the t distribution:


We calculate the t statistic:

t 0,
s
1
2
n
1
+
s
2
2
n
2

|
\


|
.
|
|
, df ~155

t =
x
1
x
2
s
1
2
n
1
+
s
2
2
n
2
=
51738 45743
9842
2
156
+
12271
2
156
t ~ 4.76
In table T, using df=140 (closest to 155) we reject
if |t| > 1.977 . Since 4.76>1.977 we reject H
0
.
Its a very significant difference.
H
0
:
1
=
2
<=> (
1

2
) = 0
H
a
:
1

2
<=> (
1

2
) 0 (two sided)
Hence, there is statistical evidence that their product sells at different level across
geographical locations

x
Two-sample t confidence interval
Because we have two independent samples we use the difference between
both sample averages (
1

2
) to estimate (
1

2
).
C
t* t*
m m

SE =
s
1
2
n
1
+
s
2
2
n
2
Practical use of t: t*
C is the area between t* and t*.
We find t* in the line of Table D for
df = smallest (n
1
1; n
2
1) and the
column for confidence level C.
The margin of error m is:
SE t
n
s
n
s
t m * *
2
2
2
1
2
1
= + =

x

x
Common mistake !!!
A common mistake is to calculate a one-sample
confidence interval for
1
and then check whether

2
falls within that confidence interval, or vice-versa.
This is WRONG because the variability in the
sampling distribution for two independent samples
is more complex and must take into account
variability coming from both samples. Hence the
more complex formula for the standard error.
2
2
2
1
2
1
n
s
n
s
SE + =
Can directed reading activities in the classroom help improve reading ability? A class
of 21 third-graders participates in these activities for 8 weeks while a control
classroom of 23 third-graders follows the same curriculum without the activities.
After 8 weeks, all children take a reading test (scores in table).
95% confidence interval for (
1

2
), with df = 20 conservatively t* = 2.086:


With 95% confidence, (
1

2
), falls within 9.96 8.99 or 1.0 to 18.9.
99 . 8 31 . 4 * 086 . 2 * ; ) ( :
2
2
2
1
2
1
2 1
~ = + =
n
s
n
s
t m m x x CI
Robustness
The two-sample t procedures are more robust than the one-
sample t procedures. They are the most robust when both
sample sizes are equal and both sample distributions are similar.
But even when we deviate from this, two-sample tests tend to
remain quite robust.

When planning a two-sample study, choose equal sample sizes if you
can.
As a guideline, a combined sample size (n
1
+ n
2
) of 40 or more
will allow you to work with even the most skewed distributions.
Details of the two sample t procedures
The true value of the degrees of freedom for a two-sample t-distribution is
quite lengthy to calculate. Thats why we use an approximate value, df =
smallest(n
1
1, n
2
1), which errs on the conservative side (often smaller
than the exact).
Computer software, though, gives the exact degrees of freedomor the
rounded valuefor your sample data.

df =
s
1
2
n
1
+
s
2
2
n
2
|
\

|
.
|
2
1
n
1
1
s
1
2
n
1
|
\

|
.
|
2
+
1
n
2
1
s
2
2
n
2
|
\

|
.
|
2
Pooled two-sample procedures
There are two versions of the two-sample t-test: one
assuming equal variance (pooled 2-sample test) and
one not assuming equal variance (unequal variance,
as we have studied) for the two populations. They have
slightly different formulas and degrees of freedom.
Two normally distributed populations
with unequal variances
The pooled (equal variance) two-
sample t-test was often used before
computers because it has exactly the t
distribution for degrees of freedom n
1

+ n
2
2.
However, the assumption of equal
variance is hard to check, and thus the
unequal variance test is safer.
When both population have the
same standard deviation, the
pooled estimator of
2
is:

The sampling distribution for (x
1
x
2
) has exactly the t
distribution with (n
1
+ n
2
2) degrees of freedom.

A level C confidence interval for
1

2
is
(with area C between t* and t*)

To test the hypothesis H
0
:
1
=
2
against a
one-sided or a two-sided alternative, compute
the pooled two-sample t statistic for the
t(n
1
+ n
2
2) distribution.
Example

1
and
2
unknown, assumed equal
Youre a financial analyst for a brokerage firm. Is there a
difference in dividend yield between stocks listed on the NYSE
& NASDAQ? You collect the following data:
NYSE NASDAQ
Number 21 25
Sample mean 3.27 2.53
Sample std dev 1.30 1.16

Assuming equal variances, is
there a difference in average
yield (o = 0.05)?
Calculating the Test Statistic
( ) ( ) ( ) ( )
1.2256
2 25 21
1.16 1 25 1.30 1 21
2 n n
s 1 n s 1 n
s
2 2
2 1
2
2 2
2
1 1
p
=
+
+
=
+
+
=
( ) ( ) ( )
2.040
25
1
21
1
1.2256
0 2.53 3.27
n
1
n
1
s
x x
t
2 1
p
2 1
2 1
=
+

=
+

=
The test statistic is:
Where:
Solution
H
0
:
1
-
2
= 0 i.e. (
1
=
2
)
H
A
:
1
-
2
0 i.e. (
1

2
)
o = 0.05
df = 21 + 25 - 2 = 44
Critical Values: t = 2.0154 (using software)
Using table T look up the value for df=45
which is 2.014
Test Statistic:
Decision:

Conclusion:

Reject H
0
at o = 0.05
There is evidence that the
means are different.
t
0
2.0154 -2.0154
0.025
Reject H
0
Reject H
0
0.025
2.040
2.040
25
1
21
1
1.2256
2.53 3.27
t =
+

=
Paired Samples
Tests Means of 2 Related Populations
Paired or matched samples
e.g., two different value appraisals on the same home
Repeated measures (before/after)
e.g., weight before and after a diet program
Use difference between paired values:


Eliminates Variation Among Subjects
Assumptions:
Both Populations Are Normally Distributed
Or, the population of the differences is normally
distributed
d = x
1
- x
2
Paired Differences
The i
th
paired difference is d
i
, where
d
i
= x
1i
- x
2i
The point estimate for the
population mean paired
difference is d :
1 n
) d (d
s
n
1 i
2
i
d

=

=
n
d
d
n
1 i
i
=
=
The sample standard deviation
is
n is the number of pairs in the paired sample
Paired Differences
The confidence interval for d is
1 n
) d (d
s
n
1 i
2
i
d

=

=
n
s
t d
d

Where t has n - 1 d.f. and s


d
is:
(continued)
n is the number of pairs in the paired sample
The test statistic for d is
1 n
) d (d
s
n
1 i
2
i
d

=

=
n
s
d
t
d
d

=
Where t has n - 1 d.f.
and s
d
is:
n is the
number
of pairs
in the
paired
sample
Hypothesis Testing for
Paired Samples
Lower tail test:

H
0
:
d
> 0
H
A
:
d
< 0
Upper tail test:

H
0
:
d
0

H
A
:
d
> 0

Two-tailed test:

H
0
:
d
= 0

H
A
:
d
0
Paired Samples
Hypothesis Testing for
Paired Samples
o o/2 o/2 o
-t
o
-t
o/2
t
o
t
o/2
Reject H
0
if t < -t
o
Reject H
0
if t > t
o
Reject H
0
if t < -t
o/2

or t > t
o/2

Where t has n - 1 d.f.
(continued)
Assume you send your salespeople to a customer service
training workshop. Is the training effective? You collect
the following data:

Paired Sample Example
Number of Complaints: (2) - (1)
Salesperson Before (1) After (2) Difference, d
i


C.B. 6 4 - 2
T.F. 20 6 -14
M.H. 3 2 - 1
R.K. 0 0 0
M.O. 4 0 - 4

d =
E
d
i


n
5.67
1 n
) d (d
s
2
i
d
=

=

= -4.2
Has the training made a difference in the number of complaints (at
the 0.05 level)?
- 4.2 d =
1.66
5 5.67/
0 4.2
n / s
d
t
d
d
=

=

=
H
0
:
d
= 0
H
A
:
d
= 0
Test Statistic:
Critical Value = 2.776 d.f. = n - 1 = 4
Reject
o/2
- 2.776 2.776
Decision: Do not reject H
0
(t stat is not in the reject region)
Conclusion: There is not a significant
change in the number of complaints.
Paired Sample: Solution
Reject
o/2
- 1.66
o = 0.05

Anda mungkin juga menyukai