Business Statistics: A First Course (3rd Edition) Chapter 8 Hypothesis Tests for Numerical Data from Two or More Samples © 2003 Prentice-Hall, Inc. Chap 8-1 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 © 2003 Prentice-Hall, Inc. Chap 8-2 Chapter Topics (continued) The Completely Randomized Design: One-Way Analysis of Variance ANOVA Assumptions F Test for Difference in More than Two Means The Tukey-Kramer Procedure © 2003 Prentice-Hall, Inc. Chap 8-3 Comparing Two Independent Samples Different Data Sources Unrelated 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 Means Use Z Test or Pooled-Variance t Test © 2003 Prentice-Hall, Inc. Chap 8-4 Independent Sample Z Test (Variances Known) Assumptions Samples are randomly and independently drawn from normal distributions Population variances are known Test Statistic Z ( X 1 X 2 ) ( 1 ) 2 n1 © 2003 Prentice-Hall, Inc. 2 n2 Chap 8-5 Independent Sample (Two Sample) Z Test in EXCEL Independent Sample Z Test with Variances Known Tools | Data Analysis | z-test: Two Sample for Means © 2003 Prentice-Hall, Inc. Chap 8-6 Pooled-Variance t Test (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 © 2003 Prentice-Hall, Inc. Chap 8-7 Developing the Pooled-Variance t Test Setting Up the Hypotheses H0: 1 = 2 H1: 1 2 OR H0: 1 - 2 = 0 H1: 1 - 2 0 Two Tail H0: 1 2 H1: 1 > 2 OR H0: 1 - 2 0 H1: 1 - 2 > 0 Right Tail H0: 1 2 H1: 1 < 2 OR H0: 1 - 2 H1: 1 - 2 < 0 Left Tail © 2003 Prentice-Hall, Inc. Chap 8-8 Developing the Pooled-Variance t Test (continued) Calculate the Pooled Sample Variance as an Estimate of the Common Population Variance (n1 1) S (n2 1) S S (n1 1) (n2 1) 2 p 2 1 S p2 : Pooled sample variance 2 1 S : Variance of sample 1 2 2 n1 : Size of sample 1 n2 : Size of sample 2 2 2 S : Variance of sample 2 © 2003 Prentice-Hall, Inc. Chap 8-9 Developing the Pooled-Variance t Test (continued) Compute the Sample Statistic X t df n1 n2 2 S © 2003 Prentice-Hall, Inc. 2 p 1 X 2 1 2 1 1 S n1 n2 2 p Hypothesized difference n1 1 S n2 1 S n1 1 n2 1 2 1 2 2 Chap 8-10 Pooled-Variance t Test: Example You’re a financial analyst for Charles Schwab. 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 (a = 0.05)? © 2003 Prentice-Hall, Inc. © 1984-1994 T/Maker Co. Chap 8-11 Calculating the Test Statistic X t 1 X 2 1 2 1 1 S n1 n2 2 p 3.27 2.53 0 1 1 1.510 21 25 2 2 n 1 S n 1 S 1 2 2 S p2 1 n1 1 n2 1 2 2 21 1 1.30 25 1 1.16 21 1 25 1 © 2003 Prentice-Hall, Inc. 2.03 1.502 Chap 8-12 Solution H0: 1 - 2 = 0 i.e. (1 = 2) H1: 1 - 2 0 i.e. (1 2) a = 0.05 df = 21 + 25 - 2 = 44 Critical Value(s): Reject H0 Reject H0 .025 .025 -2.0154 0 2.0154 © 2003 Prentice-Hall, Inc. 2.03 t Test Statistic: t 3.27 2.53 1 1 1.502 21 25 2.03 Decision: Reject at a = 0.05 Conclusion: There is evidence of a difference in means. Chap 8-13 p -Value Solution (p-Value is between .02 and .05) < (a = 0.05). Reject. p-Value is between .01 and .025 2 Reject Reject a -2.0154 0 2.0154 2.03 =.025 Z Test Statistic 2.03 is in the Reject Region © 2003 Prentice-Hall, Inc. Chap 8-14 Pooled-Variance t Test in PHStat and Excel If the Raw Data are Available Tools | Data Analysis | t-Test: Two Sample Assuming Equal Variances If only Summary Statistics are Available PHStat | Two-Sample Tests | t Test for Differences in Two Means... © 2003 Prentice-Hall, Inc. Chap 8-15 Solution in EXCEL Excel Workbook that Performs the PooledVariance t Test © 2003 Prentice-Hall, Inc. Chap 8-16 Confidence Interval Estimate for 1 2 of Two Independent Groups 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 100 1 a % Confidence Interval Estimate: X © 2003 Prentice-Hall, Inc. 1 X 2 ta / 2,n1 n2 2 1 1 S n1 n2 2 p Chap 8-17 Example You’re a financial analyst for Charles Schwab. You collect the following data: NYSE NASDAQ Number 21 25 Sample Mean 3.27 2.53 Sample 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. © 2003 Prentice-Hall, Inc. © 1984-1994 T/Maker Co. Chap 8-18 Example: Solution 2 2 n 1 S n 1 S 1 2 2 S p2 1 n1 1 n2 1 21 11.302 25 11.16 2 1.502 21 1 25 1 X 1 X 2 ta / 2,n1 n2 2 1 1 S n1 n2 2 p 1 1 3.27 2.53 2.0154 1.502 21 25 0.0088 1 2 1.4712 © 2003 Prentice-Hall, Inc. Chap 8-19 Solution in Excel An Excel Spreadsheet with the Solution: © 2003 Prentice-Hall, Inc. Chap 8-20 F Test for Difference in Two Population Variances Test 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 © 2003 Prentice-Hall, Inc. Chap 8-21 The F Test Statistic 2 1 2 2 S F S 2 1 = Variance of Sample 1 S n1 - 1 = degrees of freedom S 2 2= Variance of Sample 2 n2 - 1 = degrees of freedom 0 © 2003 Prentice-Hall, Inc. F Chap 8-22 Developing the F Test Hypotheses H0: 12 = 22 H1: 12 22 Test Statistic F = S12 /S22 Reject H0 Reject H0 a/2 0 Do Not Reject FL a/2 FU F Two Sets of Degrees of Freedom df1 = n1 - 1; df2 = n2 - 1 Critical Values: FL( n1 -1, n2 -1) and FU( n1 -1 , n2 -1) FL = 1/FU* © 2003 Prentice-Hall, Inc. (*degrees of freedom switched) Chap 8-23 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 NASDAQ Number 21 25 Mean 3.27 2.53 Std Dev 1.30 1.16 Is there a difference in the variances between the NYSE & NASDAQ at the a 0.05 level? © 2003 Prentice-Hall, Inc. © 1984-1994 T/Maker Co. Chap 8-24 F Test: Example Solution Finding the Critical Values for a = .05 df1 n1 1 21 1 20 df 2 n2 1 25 1 24 FL 20,24 1/ FU 24,20 1/ 2.41 .415 FU 20,24 2.33 © 2003 Prentice-Hall, Inc. Chap 8-25 F Test: Example Solution H0 : 1 = 2 H1 : 1 2 2 2 a .05 df1 20 df2 24 2 2 Critical Value(s): Reject .025 Reject .025 0 0.415 © 2003 Prentice-Hall, Inc. 2.33 1.25 Test Statistic: 2 1 2 2 2 S 1.30 F 1.25 2 S 1.16 Decision: Do not reject at a = 0.05 Conclusion: There is insufficient F evidence to prove a difference in variances. Chap 8-26 F Test in PHStat PHStat | Two-Sample Tests | F Test for Differences in Two Variances Example in Excel Spreadsheet © 2003 Prentice-Hall, Inc. Chap 8-27 F Test: One-Tail H0: 12 22 H1: 12 < 22 or a = .05 FL n1 1,n2 1 Reject H0: 12 22 H1: 12 > 22 1 FU n2 1,n1 1 Reject a .05 a .05 0 Degrees of freedom switched F FL n1 1,n2 1 © 2003 Prentice-Hall, Inc. 0 FU n1 1,n2 1 F Chap 8-28 Comparing Two Related Samples Test the Means of Two Related Samples Paired or matched Repeated measures (before and after) Use difference between pairs Di X1i X 2i Eliminates Variation between Subjects © 2003 Prentice-Hall, Inc. Chap 8-29 Z Test for Mean Difference (Variance Known) Assumptions Both populations are normally distributed Observations are paired or matched Variance Known Test Statistic Z D D D n © 2003 Prentice-Hall, Inc. n D D i 1 i n Chap 8-30 t Test for Mean Difference (Variance Unknown) Assumptions Both populations are normally distributed Observations are matched or paired Variance unknown If population not normal, need large samples Test Statistic D D t SD n © 2003 Prentice-Hall, Inc. n D Di i 1 n n SD 2 ( D D ) i i 1 n 1 Chap 8-31 Paired-Sample t Test: Example Assume you work in the finance department. Is the new financial package faster (a=0.05 level)? You collect the following processing times: Existing System (1) 9.98 Seconds 9.88 9.84 9.99 9.94 9.84 9.86 10.12 9.90 9.91 © 2003 Prentice-Hall, Inc. New Software (2) Difference Di 9.88 Seconds .10 9.86 .02 9.75 .09 9.80 .19 9.87 .07 9.84 .00 9.87 - .01 9.98 .14 9.83 .07 9.86 .05 D D i n SD .072 D D 2 i n 1 .06215 Chap 8-32 Paired-Sample t Test: Example Solution Is the new financial package faster (0.05 level)? H0: D H1: D > a .5 D = .072 Critical Value=1.8331 df = n - 1 = 9 Test Statistic D D .072 0 t 3.66 SD / n .06215/ 10 © 2003 Prentice-Hall, Inc. Reject a .5 1.8331 t 3.66 Decision: Reject H0 t Stat. in the rejection zone. Conclusion: The new software package is faster. Chap 8-33 Paired-Sample t Test in EXCEL Tools | Data Analysis… | t-test: Paired Two Sample for Means Example in Excel Spreadsheet © 2003 Prentice-Hall, Inc. Chap 8-34 General Experimental Setting Investigator Controls One or More Independent Variables Observe Effects on Dependent Variable Called treatment variables or factors Each treatment factor contains two or more groups (or levels) Response to groups (or levels) of independent variable Experimental Design: The Plan Used to Test Hypothesis © 2003 Prentice-Hall, Inc. Chap 8-35 Completely Randomized Design Experimental Units (Subjects) are Assigned Randomly to Groups Only One Factor or Independent Variable Subjects are assumed homogeneous With 2 or more groups (or levels) Analyzed by One-way Analysis of Variance (ANOVA) © 2003 Prentice-Hall, Inc. Chap 8-36 Randomized Design Example Factor (Training Method) Factor Levels (Groups) Randomly Assigned Units Dependent Variable (Response) © 2003 Prentice-Hall, Inc. 21 hrs 17 hrs 31 hrs 27 hrs 25 hrs 28 hrs 29 hrs 20 hrs 22 hrs Chap 8-37 One-way Analysis of Variance F Test Evaluate the Difference among the Mean Responses of 2 or More (c ) Populations E.g. Several types of tires, oven temperature settings Assumptions Samples are randomly and independently drawn This condition must be met Populations are normally distributed F Test is robust to moderate departure from normality Populations have equal variances © 2003 Prentice-Hall, Inc. Less sensitive to this requirement when samples are of equal size from each population Chap 8-38 Why ANOVA? Could Compare the Means One by One using Z or t Tests for Difference of Means Each Z or t Test Contains Type I Error The Total Type I Error with k Pairs of Means is 1- (1 - a) k E.g. If there are 5 means and use a = .05 © 2003 Prentice-Hall, Inc. Must perform 10 comparisons Type I Error is 1 – (.95) 10 = .40 40% of the time you will reject the null hypothesis of equal means in favor of the alternative when the null is true! Chap 8-39 Hypotheses of One-Way ANOVA H 0 : 1 2 c All population means are equal No treatment effect (no variation in means among groups) H1 : Not all i are the same © 2003 Prentice-Hall, Inc. At least one population mean is different (others may be the same!) There is a treatment effect Does not mean that all population means are different Chap 8-40 One-way ANOVA (No Treatment Effect) H 0 : 1 2 c H1 : Not all i are the same The Null Hypothesis is True 1 2 3 © 2003 Prentice-Hall, Inc. Chap 8-41 One-way ANOVA (Treatment Effect Present) H 0 : 1 2 c H1 : Not all i are the same 1 2 3 © 2003 Prentice-Hall, Inc. The Null Hypothesis is NOT True 1 2 3 Chap 8-42 One-way ANOVA (Partition of Total Variation) Total Variation SST = Variation Due to Treatment SSA Commonly referred to as: Among Group Variation Sum of Squares Among Sum of Squares Between Sum of Squares Model Sum of Squares Explained Sum of Squares Treatment © 2003 Prentice-Hall, Inc. + Variation Due to Random Sampling SSW Commonly referred to as: Within Group Variation Sum of Squares Within Sum of Squares Error Sum of Squares Unexplained Chap 8-43 Total Variation nj c SST ( X ij X ) 2 j 1 i 1 X ij : the i -th observation in group j n j : the number of observations in group j n : the total number of observations in all groups c : the number of groups c X © 2003 Prentice-Hall, Inc. nj X j 1 i 1 n ij the overall or grand mean Chap 8-44 Total Variation SST X 11 X X 2 21 X X (continued) 2 nc c X 2 Response, X X Group 1 © 2003 Prentice-Hall, Inc. Group 2 Group 3 Chap 8-45 Among-Group Variation c SSA n j ( X j X ) j 1 2 SSA MSA c 1 X j : The sample mean of group j X : The overall or grand mean i j © 2003 Prentice-Hall, Inc. Variation Due to Differences Among Groups. Chap 8-46 Among-Group Variation(continued) SSA n1 X 1 X n X 2 2 2 X 2 nc X c X 2 Response, X X3 X1 Group 1 © 2003 Prentice-Hall, Inc. Group 2 X2 X Group 3 Chap 8-47 Within-Group Variation c nj SSW ( X ij X j ) 2 j 1 i 1 SSW MSW nc X j : The sample mean of group j X ij : The i -th observation in group j Summing the variation within each group and then adding over all groups. © 2003 Prentice-Hall, Inc. j Chap 8-48 Within-Group Variation(continued) SSW X 11 X 1 X 21 X 1 2 2 X nc c X c 2 Response, X X3 X1 Group 1 © 2003 Prentice-Hall, Inc. Group 2 X2 X Group 3 Chap 8-49 Within-Group Variation(continued) For c = 2, this is the SSW MSW pooled-variance in the nc t-Test. 2 2 2 (n1 1) S1 (n2 1) S2 (nc 1) Sc (n1 1) (n2 1) (nc 1) •If more than 2 groups, use F Test. •For 2 groups, use t-Test. F Test more limited. © 2003 Prentice-Hall, Inc. j Chap 8-50 One-way ANOVA F Test Statistic Test Statistic MSA F MSW MSA is mean squares among MSW is mean squares within Degrees of Freedom © 2003 Prentice-Hall, Inc. df1 c 1 df 2 n c Chap 8-51 One-way ANOVA Summary Table Degrees Source of of Variation Freedom Among c–1 (Factor) Within (Error) Total © 2003 Prentice-Hall, Inc. Sum of Squares SSA n–c SSW n–1 SST = SSA + SSW Mean Squares (Variance) F Statistic MSA = MSA/MSW SSA/(c – 1 ) MSW = SSW/(n – c ) Chap 8-52 Features of One-way ANOVA F Statistic The F Statistic is the Ratio of the Among Estimate of Variance and the Within Estimate of Variance The ratio must always be positive df1 = c -1 will typically be small df2 = n - c will typically be large The Ratio Should be Close to 1 if the Null is True © 2003 Prentice-Hall, Inc. Chap 8-53 Features of One-way ANOVA F Statistic (continued) If the Null Hypothesis is False The numerator should be greater than the denominator The ratio should be larger than 1 © 2003 Prentice-Hall, Inc. Chap 8-54 One-way ANOVA F Test Example As production manager, you want to see if 3 filling machines have different mean filling times. You assign 15 similarly trained and experienced workers, 5 per machine, to the machines. At the .05 significance level, is there a difference in mean filling times? © 2003 Prentice-Hall, Inc. Machine1 Machine2 Machine3 25.40 26.31 24.10 23.74 25.10 23.40 21.80 23.50 22.75 21.60 20.00 22.20 19.75 20.60 20.40 Chap 8-55 One-way ANOVA Example: Scatter Diagram Machine1 Machine2 Machine3 25.40 26.31 24.10 23.74 25.10 23.40 21.80 23.50 22.75 21.60 27 20.00 22.20 19.75 20.60 20.40 X 1 24.93 X 2 22.61 X 3 20.59 X 22.71 © 2003 Prentice-Hall, Inc. 26 25 24 23 22 21 20 • •• • • X1 •• • •• X2 • •• •• X X3 19 Chap 8-56 One-way ANOVA Example Computations Machine1 Machine2 Machine3 25.40 26.31 24.10 23.74 25.10 23.40 21.80 23.50 22.75 21.60 20.00 22.20 19.75 20.60 20.40 X 1 24.93 nj 5 X 2 22.61 c3 X 3 20.59 n 15 X 22.71 2 2 2 SSA 5 24.93 22.71 22.61 22.71 20.59 22.71 47.164 SSW 4.2592 3.112 3.682 11.0532 MSA SSA /(c -1) 47.16 / 2 23.5820 MSW SSW /( n - c) 11.0532 /12 .9211 © 2003 Prentice-Hall, Inc. Chap 8-57 Summary Table Degrees Source of of Variation Freedom Sum of Squares Mean Squares (Variance) F Statistic MSA/MSW =25.60 Among (Factor) 3-1=2 47.1640 23.5820 Within (Error) 15-3=12 11.0532 .9211 Total 15-1=14 58.2172 © 2003 Prentice-Hall, Inc. Chap 8-58 One-way ANOVA Example Solution Test Statistic: H0: 1 = 2 = 3 H1: Not All Equal a = .05 df1= 2 MSA 23.5820 25.6 F MSW .9211 df2 = 12 Decision: Reject at a = 0.05 Critical Value(s): a = 0.05 0 © 2003 Prentice-Hall, Inc. 3.89 F Conclusion: There is evidence that at least one i differs from the rest. Chap 8-59 Solution In EXCEL Use Tools | Data Analysis | ANOVA: Single Factor EXCEL Worksheet that Performs the One-way ANOVA of the example © 2003 Prentice-Hall, Inc. Chap 8-60 The Tukey-Kramer Procedure Tells which Population Means are Significantly Different 1= 2 Post Hoc (a posteriori) Procedure e.g., 1 = 2 3 2 groups whose means may be significantly different f(X) 3 X Done after rejection of equal means in ANOVA Pairwise Comparisons Compare absolute mean differences with critical range © 2003 Prentice-Hall, Inc. Chap 8-61 The Tukey-Kramer Procedure: Example Machine1 Machine2 Machine3 25.40 23.40 20.00 26.31 21.80 22.20 24.10 23.50 19.75 23.74 22.75 20.60 25.10 21.60 20.40 2. Compute Critical Range: Critical Range QU ( c,nc ) 1. Compute absolute mean differences: X 1 X 2 24.93 22.61 2.32 X 1 X 3 24.93 20.59 4.34 X 2 X 3 22.61 20.59 2.02 MSW 2 1 1 1.618 nj nj' 3. All of the absolute mean differences are greater than the critical range. There is a significance difference between each pair of means at the 5% level of significance. © 2003 Prentice-Hall, Inc. Chap 8-62 Solution in PHStat Use PHStat | c-Sample Tests | Tukey-Kramer Procedure … EXCEL Worksheet that Performs the TukeyKramer Procedure for the Previous example © 2003 Prentice-Hall, Inc. Chap 8-63 Chapter Summary Compared Two Independent Samples Performed Z test for the differences in two means Performed t test for the differences in two means Addressed F Test for Difference in two Variances Compared Two Related Samples Performed paired sample Z tests for the mean difference Performed paired sample t tests for the mean difference © 2003 Prentice-Hall, Inc. Chap 8-64 Chapter Summary (continued) Described The Completely Randomized Design: One-way Analysis of Variance ANOVA Assumptions F Test for Difference in c Means The Tukey-Kramer Procedure © 2003 Prentice-Hall, Inc. Chap 8-65