45
Hypothesis Testing – Two Samples Chapters 12 & 13

Hypothesis Testing – Two Samples Chapters 12 & 13

Embed Size (px)

Citation preview

Page 1: Hypothesis Testing – Two Samples Chapters 12 & 13

Hypothesis Testing – Two Samples

Chapters 12 & 13

Page 2: Hypothesis Testing – Two Samples Chapters 12 & 13

Chapter Topics

Comparing Two Independent Samples Independent samples Z test for the difference in two

means Pooled-variance t test for the difference in two means

F Test for the Difference in Two Variances Comparing Two Related Samples

Paired-sample Z test for the mean difference Paired-sample t test for the mean difference

Two-sample Z test for population proportions Independent and Dependent Samples

Page 3: Hypothesis Testing – Two Samples Chapters 12 & 13

Comparing Two Independent Samples

Different Data SourcesUnrelated Independent

Sample selected from one population has no effect or bearing on the sample selected from the other population

Use the Difference between 2 Sample MeansUse Z Test or t Test for Independent Samples

Page 4: Hypothesis Testing – Two Samples Chapters 12 & 13

Independent Sample Z Test (Variances Known)Assumptions

Samples are randomly and independently drawn from normal distributions

Population variances are known

Test Statistic

1 2 1

2 2

1 2

( ) ( )X XZ

n n

Page 5: Hypothesis Testing – Two Samples Chapters 12 & 13

t Test for Independent Samples (Variances Unknown)Assumptions

Both populations are normally distributed Samples are randomly and independently

drawn Population variances are unknown but assumed

equal If both populations are not normal, need large

sample sizes

Page 6: Hypothesis Testing – Two Samples Chapters 12 & 13

Developing the t Test for Independent Samples

Setting Up the Hypotheses

H0: 1 2

H1: 1 > 2

H0: 1 -2 = 0

H1: 1 - 2

0

H0: 1 = 2

H1: 1 2

H0: 1

2

H0: 1 - 2 0

H1: 1 - 2 > 0

H0: 1 - 2

H1: 1 -

2 < 0

OR

OR

OR Left Tail

Right Tail

Two Tail

H1: 1 < 2

Page 7: Hypothesis Testing – Two Samples Chapters 12 & 13

Developing the t Test for Independent SamplesCalculate the Pooled Sample Variance as

an Estimate of the Common Population Variance

(continued)

2 22 1 1 2 2

1 2

21

21 2

22

( 1) ( 1)

( 1) ( 1)

: Pooled sample variance : Size of sample 1

: Variance of sample 1 : Size of sample 2

: Variance of sample 2

p

p

n S n SS

n n

S n

S n

S

Page 8: Hypothesis Testing – Two Samples Chapters 12 & 13

Developing the t Test for Independent SamplesCompute the Sample Statistic

(continued)

1 2 1 2

2

1 2

2 21 1 2 22

1 2

1 1

1 1

1 1

p

p

X Xt

Sn n

n S n SS

n n

Hypothesized

difference1 2 2df n n

Page 9: Hypothesis Testing – Two Samples Chapters 12 & 13

t Test for Independent Samples: Example

© 1984-1994 T/Maker Co.

You’re a financial analyst for Charles Schwab. Is there a difference in average dividend yield between stocks listed on the NYSE & NASDAQ? You collect the following data:

NYSE NASDAQNumber 21 25Sample Mean 3.27 2.53Sample Std Dev 1.30 1.16

Assuming equal variances, isthere a difference in average yield (= 0.05)?

Page 10: Hypothesis Testing – Two Samples Chapters 12 & 13

Calculating the Test Statistic

1 2 1 2

2

1 2

2 21 1 2 22

1 2

2 2

3.27 2.53 02.03

1 11 1 1.51021 25

1 1

1 1

21 1 1.30 25 1 1.16 1.502

21 1 25 1

p

p

X Xt

Sn n

n S n SS

n n

Page 11: Hypothesis Testing – Two Samples Chapters 12 & 13

Solution

H0: 1 - 2 = 0 i.e. (1 = 2)

H1: 1 - 2 0 i.e. (12)

= 0.05

df = 21 + 25 - 2 = 44

Critical Value(s):

Test Statistic:

Decision:

Conclusion:

Reject at = 0.05.

There is evidence of a difference in means.

t0 2.0154-2.0154

.025

Reject H0 Reject H0

.025

2.03

3.27 2.532.03

1 11.502

21 25

t

Page 12: Hypothesis Testing – Two Samples Chapters 12 & 13

p -Value Solution

p-Value 2

(p-Value is between .02 and .05) ( = 0.05) Reject.

02.03

Z

Reject

2.0154

is between .01 and .025

Test Statistic 2.03 is in the Reject Region

Reject

-2.0154

=.025

Page 13: Hypothesis Testing – Two Samples Chapters 12 & 13

Example

© 1984-1994 T/Maker Co.

You’re a financial analyst for Charles Schwab. You collect the following data:

NYSE NASDAQNumber 21 25Sample Mean 3.27 2.53Sample Std Dev 1.30 1.16

You want to construct a 95% confidence interval for the difference in population average yields of the stocks listed on NYSE and NASDAQ.

Page 14: Hypothesis Testing – Two Samples Chapters 12 & 13

Example: Solution

1 2

21 2 / 2, 2

1 2

1 1n n pX X t S

n n

1 13.27 2.53 2.0154 1.502

21 25

1 20.0088 1.4712

2 21 1 2 22

1 2

2 2

1 1

1 1

21 1 1.30 25 1 1.16 1.502

21 1 25 1

p

n S n SS

n n

Page 15: Hypothesis Testing – Two Samples Chapters 12 & 13

Independent Sample (Two Sample) t- Test in JMP

Independent Sample t Test with Variances Known Analyze | Fit Y by X | Measurement in Y box

(Continuous) | Grouping Variable in X box (Nominal) | | Means/Anova/Pooled t

Page 16: Hypothesis Testing – Two Samples Chapters 12 & 13

Comparing Two Related Samples

Test the Means of Two Related Samples Paired or matchedRepeated measures (before and after)Use difference between pairs

Eliminates Variation between Subjects

1 2i i iD X X

Page 17: Hypothesis Testing – Two Samples Chapters 12 & 13

Z Test for Mean Difference (Variance Known)Assumptions

Both populations are normally distributedObservations are paired or matched Variance known

Test Statistic

D

D

DZ

n

1

n

ii

DD

n

Page 18: Hypothesis Testing – Two Samples Chapters 12 & 13

t Test for Mean Difference (Variance Unknown)Assumptions

Both populations are normally distributedObservations are matched or paired Variance unknown If population not normal, need large samples

Test Statistic

D

D

Dt

S

n

2

1

( )

1

n

ii

D

D DS

n

1

n

ii

DD

n

Page 19: Hypothesis Testing – Two Samples Chapters 12 & 13

User Existing System (1) New Software (2) Difference Di

C.B. 9.98 Seconds 9.88 Seconds .10T.F. 9.88 9.86 .02M.H. 9.84 9.75 .09R.K. 9.99 9.80 .19M.O. 9.94 9.87 .07D.S. 9.84 9.84 .00S.S. 9.86 9.87 - .01C.T. 10.12 9.98 .14K.T. 9.90 9.83 .07S.Z. 9.91 9.86 .05

Dependent-Sample t Test: Example

Assume you work in the finance department. Is the new financial package faster (=0.05 level)? You collect the following processing times:

2.072

1 .06215

i

iD

DD

n

D DS

n

Page 20: Hypothesis Testing – Two Samples Chapters 12 & 13

Dependent-Sample t Test: Example Solution

Is the new financial package faster (0.05 level)?

.072D =

.072 03.66

/ .06215/ 10D

D

DtS n

H0: D H1: D

Test Statistic

Critical Value=1.8331 df = n - 1 = 9

Reject

1.8331

Decision: Reject H0

t Stat. in the rejection zone.Conclusion: The new software package is faster.

3.66

t

Page 21: Hypothesis Testing – Two Samples Chapters 12 & 13

Confidence Interval Estimate for of Two Dependent Samples

Assumptions Both populations are normally distributedObservations are matched or paired Variance is unknown

Confidence Interval Estimate:

D

100 1 %

/ 2, 1D

n

SD t

n

Page 22: Hypothesis Testing – Two Samples Chapters 12 & 13

User Existing System (1) New Software (2) Difference Di

C.B. 9.98 Seconds 9.88 Seconds .10T.F. 9.88 9.86 .02M.H. 9.84 9.75 .09R.K. 9.99 9.80 .19M.O. 9.94 9.87 .07D.S. 9.84 9.84 .00S.S. 9.86 9.87 - .01C.T. 10.12 9.98 .14K.T. 9.90 9.83 .07S.Z. 9.91 9.86 .05

Example

Assume you work in the finance department. You want to construct a 95% confidence interval for the mean difference in data entry time. You collect the following processing times:

Page 23: Hypothesis Testing – Two Samples Chapters 12 & 13

Solution:

2

/ 2, 1 0.025,9

/ 2, 1

D

.072 .062151

2.2622

.06215.072 2.2622

10

0.0275 0.1165

iiD

n

Dn

D DDD S

n nt t

SD t

n

Page 24: Hypothesis Testing – Two Samples Chapters 12 & 13

F Test for Difference in Two Population VariancesTest for the Difference in 2 Independent

Populations

Parametric Test Procedure

Assumptions Both populations are normally distributed

Test is not robust to this violation Samples are randomly and independently

drawn

Page 25: Hypothesis Testing – Two Samples Chapters 12 & 13

The F Test Statistic

= Variance of Sample 1

n1 - 1 = degrees of freedom

n2 - 1 = degrees of freedom

F 0

21S

22S = Variance of Sample 2

2122

SF

S

Page 26: Hypothesis Testing – Two Samples Chapters 12 & 13

Hypotheses H0:1

2 = 22

H1: 12 2

2 Test Statistic

F = S12 /S2

2

Two Sets of Degrees of Freedom df1 = n1 - 1; df2 = n2 - 1

Critical Values: FL( ) and FU( )

FL = 1/FU* (*degrees of freedom switched)

Developing the F Test

Reject H0

Reject H0

/2/2Do NotReject

F 0 FL FU

n1 -1, n2 -1 n1 -1 , n2 -1

Page 27: Hypothesis Testing – Two Samples Chapters 12 & 13

Easier Way Put the largest in the num.

Test Statistic F = S1

2 /S22

Developing the F Test

Reject H0

Do NotReject

F 0 F

Page 28: Hypothesis Testing – Two Samples Chapters 12 & 13

F Test: An Example

Assume you are a financial analyst for Charles Schwab. You want to compare dividend yields between stocks listed on the NYSE & NASDAQ. You collect the following data:

NYSE NASDAQNumber 21 25Mean 3.27 2.53Std Dev 1.30 1.16

Is there a difference in the variances between the NYSE & NASDAQ at the 0.05 level?

© 1984-1994 T/Maker Co.

Page 29: Hypothesis Testing – Two Samples Chapters 12 & 13

F Test: Example Solution

Finding the Critical Values for = .05

1 1

2 2

1 21 1 20

1 25 1 24

df n

df n

F. , , .0 5 2 0 2 4 2 0 3

Page 30: Hypothesis Testing – Two Samples Chapters 12 & 13

F Test: Example Solution

H0: 12 = 2

2

H1: 12 2

2

.05

df1 20 df2 24

Critical Value(s):

Test Statistic:

Decision:

Conclusion:

Do not reject at = 0.05.

0 F2.33

.05

Reject

2 212 22

1.301.25

1.16

SF

S

1.25

There is insufficient evidence to prove a difference in variances.

Page 31: Hypothesis Testing – Two Samples Chapters 12 & 13

F Test: One-Tail

H0: 12 2

2

H1: 12 2

2

H0: 12 2

2

H1: 12 > 2

2

Reject

.05

F0 F0

Reject

.05

= .05

or

Degrees of freedom switched

1 2

2 1

1, 11, 1

1L n n

U n n

FF

1 21, 1U n nF 1 21, 1L n nF

Page 32: Hypothesis Testing – Two Samples Chapters 12 & 13

Easier Way Put the largest in the num.

Test Statistic F = S1

2 /S22

F Test: One-Tail

Reject H0

Do NotReject

F 0 F

Page 33: Hypothesis Testing – Two Samples Chapters 12 & 13

Z Test for Differences in Two Proportions (Independent Samples)What is It Used For?

To determine whether there is a difference between 2 population proportions and whether one is larger than the other

Assumptions: Independent samples Population follows binomial distribution Sample size large enough: np 5 and n(1-p)

5 for each population

Page 34: Hypothesis Testing – Two Samples Chapters 12 & 13

Z Test Statistic

Z

p p

p q

n

p q

nPd Pd Pd Pd

1 2

1 2

pn p n p

n n

qn q n q

n n

Pd

Pd

1 1 2 2

1 2

1 1 2 2

1 2

Z

p p p p

p q

n

p q

n

1 2 1 2

1 1

1

2 2

2

Page 35: Hypothesis Testing – Two Samples Chapters 12 & 13

The Hypotheses for the Z Test

Research Questions

Hypothesis No DifferenceAny Difference

Prop 1 Prop 2Prop 1 < Prop 2

Prop 1 Prop 2Prop 1 > Prop 2

H0 p1 - p2 p1 - p2 0 p1 - p2 0

H1 p1 - p2 0 p1 - p2 < 0 p1 - p2 > 0

Page 36: Hypothesis Testing – Two Samples Chapters 12 & 13

Z Test for Differences in Two Proportions: Example

As personnel director, you want to test the perception of fairness of two methods of performance evaluation. 63 of 78 employees rated Method 1 as fair. 49 of 82 rated Method 2 as fair. At the 0.01 significance level, is there a difference in perceptions?

.p 1

6 3

7 80 8 0 7 7

.p 2

4 9

8 20 5 9 8

n 1 7 8

n 2 8 2

np 5 n p1 5

Page 37: Hypothesis Testing – Two Samples Chapters 12 & 13

Calculating the Test Statistic

Z

p p p p

p q

n

p q

nPd Pd Pd Pd

.

1 2 1 2

1 2

2 8 9 8

pn p n p

n n

qn q n q

n n

Pd

Pd

1 1 2 2

1 2

1 1 2 2

1 2

Page 38: Hypothesis Testing – Two Samples Chapters 12 & 13

Z Test for Differences in Two Proportions: Solution

H0: p1 - p2 = 0

H1: p1 - p2 0

= 0.01

n1 = 78 n2 = 82

Critical Value(s):

Test Statistic:

Decision:

Conclusion:

Reject at = 0.01.

There is evidence of a difference in proportions.

Z 290.

Z0 2.58-2.58

.005

Reject H0 Reject H0

.005

Page 39: Hypothesis Testing – Two Samples Chapters 12 & 13

Confidence Interval for Differences in Two ProportionsThe Confidence Interval for

Differences in Two Proportions 100 1 %

p p z

p p

n

p p

n1 21

2

1 1

1

2 2

2

1 1

Page 40: Hypothesis Testing – Two Samples Chapters 12 & 13

Confidence Interval for Differences in Two Proportions: Example

As personnel director, you want to find out the perception of fairness of two methods of performance evaluation. 63 of 78 employees rated Method 1 as fair. 49 of 82 rated Method 2 as fair. Construct a 99% confidence interval for the difference in two proportions.

.p 1

6 3

7 80 8 0 7 7

.p 2

4 9

8 20 5 9 8

n 1 7 8

n 2 8 2

np 5 n p1 5

Page 41: Hypothesis Testing – Two Samples Chapters 12 & 13

Confidence Interval for Differences in Two Proportions: Solution

We are 99% confident that the difference between two proportions is somewhere between 0.0294 and 0.3909.

. . .. . . .

. .

p p zp p

n

p p

n

p p

1 21

2

1 1

1

2 2

2

1 2

1 1

0 8 0 7 7 0 5 9 7 6 2 5 7 5 80 8 0 7 7 1 0 8 0 7 7

7 8

0 5 9 7 6 1 0 5 9 7 6

8 20 0 2 9 4 0 3 9 0 9

Page 42: Hypothesis Testing – Two Samples Chapters 12 & 13

Z Test for Differences in Two Proportions (Dependent Samples)What is It Used For?

To determine whether there is a difference between 2 population proportions and whether one is larger than the other

Assumptions: Dependent samples Population follows binomial distribution Sample size large enough: np 5 and n(1-p)

5 for each population

Page 43: Hypothesis Testing – Two Samples Chapters 12 & 13

Z Test Statistic for Dependent Samples

Za d

a d

Sample Two

Category 1 Category 2

Sample One Category 1 a b a+b

Category 2 c d c+d

a+c b+d N

This Z can be used when a+d>10 If 10<a+d<20, use the correction in the text

Page 44: Hypothesis Testing – Two Samples Chapters 12 & 13

Unit Summary

Compared Two Independent Samples Performed Z test for the differences in two

means Performed t test for the differences in two

means Performed Z test for differences in two

proportions Addressed F Test for Difference in Two Variances

Page 45: Hypothesis Testing – Two Samples Chapters 12 & 13

Unit Summary

Compared Two Related Samples Performed dependent sample Z tests for the

mean difference Performed dependent sample t tests for the

mean difference Performed Z tests for proportions using

dependent samples