* ch19eg1.sas, Two-way ANOVA, equal sample sizes; * Castle Bakery Company (page 833), 3x2 with n=2; options ls=78 nodate; ; data CBC; input y A B; AB = 10*A + B; lines; 47 1 1 43 1 1 46 1 2 40 1 2 62 2 1 68 2 1 67 2 2 71 2 2 41 3 1 39 3 1 42 3 2 46 3 2 ; **********************************************************************; * One could analyze the date like one would a single-factor experiment; ; * Analysis of variance and multiple comparisons; proc glm data=CBC; class AB; model y = AB; means AB / Tukey; output out=CBC2 r=e p=yhat; title 'Castle Bakery Company (ch19, p833)'; title2 'Analysis of data as if a single-factor experiment'; ; * Residual plots; proc rank normal=Blom; var e; ranks nscore; proc plot; plot e*yhat / vref=0 vpos=18; plot e*nscore / vref=0 href=0 vpos=18; title2 'Residual plots'; ; **********************************************************************; * Better yet, one could take into account both factors in the analysis; ; * Plot the raw data; proc plot; plot y*A=B / vpos=34; title2 'Analysis taking into account the factorial treatment structure'; title3 'Plot of the raw data'; ; * Two-way ANOVA; proc glm data=CBC; class A B; model y = A B A*B; * equivalent model: y = A | B; means A*B; means A / Tukey; output out=CBC3 r=e p=yhat; title3 'Two-way ANOVA'; ; * plot means; proc plot; plot yhat*A=B / vpos=18; plot yhat*B=A / vpos=18; title3 'Means plots'; Castle Bakery Company (ch19, p833) 1 Analysis of data as if a single-factor experiment The GLM Procedure Class Level Information Class Levels Values AB 6 11 12 21 22 31 32 Number of Observations Read 12 Number of Observations Used 12 Castle Bakery Company (ch19, p833) 2 Analysis of data as if a single-factor experiment The GLM Procedure Dependent Variable: y Sum of Source DF Squares Mean Square F Value Pr > F Model 5 1580.000000 316.000000 30.58 0.0003 Error 6 62.000000 10.333333 Corrected Total 11 1642.000000 R-Square Coeff Var Root MSE y Mean 0.962241 6.303040 3.214550 51.00000 Castle Bakery Company (ch19, p833) 3 Analysis of data as if a single-factor experiment The GLM Procedure Tukey's Studentized Range (HSD) Test for y NOTE: This test controls the Type I experimentwise error rate, but it generally has a higher Type II error rate than REGWQ. Alpha 0.05 Error Degrees of Freedom 6 Error Mean Square 10.33333 Critical Value of Studentized Range 5.62835 Minimum Significant Difference 12.793 Means with the same letter are not significantly different. Tukey Grouping Mean N AB A 69.000 2 22 A A 65.000 2 21 B 45.000 2 11 B B 44.000 2 32 B B 43.000 2 12 B B 40.000 2 31 Castle Bakery Company (ch19, p833) 4 Residual plots Plot of e*yhat. Legend: A = 1 obs, B = 2 obs, etc. e | | | | 3 + A A | 2 + A A A | 1 +A | 0 +-------------------------------------------------------------------------- | -1 +A | -2 + A A A | -3 + A A | -+-----------+-----------+-----------+-----------+-----------+-----------+- 40 45 50 55 60 65 70 yhat Castle Bakery Company (ch19, p833) 5 Residual plots Plot of e*nscore. Legend: A = 1 obs, B = 2 obs, etc. e | | | | | | | | 3 + | B | | 2 + | A B | | 1 + | A | | 0 +------------------------------------+------------------------------------- | | -1 + A | | | -2 + A B | | | -3 + B | | | -+-----------+-----------+-----------+-----------+-----------+-----------+- -1.5 -1.0 -0.5 0.0 0.5 1.0 1.5 Rank for Variable e Castle Bakery Company (ch19, p833) 6 Analysis taking into account the factorial treatment structure Plot of the raw data Plot of y*A. Symbol is value of B. y | 71 + 2 70 + 69 + 68 + 1 67 + 2 66 + 65 + 64 + 63 + 62 + 1 61 + 60 + 59 + 58 + 57 + 56 + 55 + 54 + 53 + 52 + 51 + 50 + 49 + 48 + 47 +1 46 +2 2 45 + 44 + 43 +1 42 + 2 41 + 1 40 +2 39 + 1 -+-----------------------------------+-----------------------------------+- 1 2 3 A Castle Bakery Company (ch19, p833) 7 Analysis taking into account the factorial treatment structure Two-way ANOVA The GLM Procedure Class Level Information Class Levels Values A 3 1 2 3 B 2 1 2 Number of Observations Read 12 Number of Observations Used 12 Castle Bakery Company (ch19, p833) 8 Analysis taking into account the factorial treatment structure Two-way ANOVA The GLM Procedure Dependent Variable: y Sum of Source DF Squares Mean Square F Value Pr > F Model 5 1580.000000 316.000000 30.58 0.0003 Error 6 62.000000 10.333333 Corrected Total 11 1642.000000 R-Square Coeff Var Root MSE y Mean 0.962241 6.303040 3.214550 51.00000 Source DF Type I SS Mean Square F Value Pr > F A 2 1544.000000 772.000000 74.71 <.0001 B 1 12.000000 12.000000 1.16 0.3226 A*B 2 24.000000 12.000000 1.16 0.3747 Source DF Type III SS Mean Square F Value Pr > F A 2 1544.000000 772.000000 74.71 <.0001 B 1 12.000000 12.000000 1.16 0.3226 A*B 2 24.000000 12.000000 1.16 0.3747 Castle Bakery Company (ch19, p833) 9 Analysis taking into account the factorial treatment structure Two-way ANOVA The GLM Procedure Level of Level of --------------y-------------- A B N Mean Std Dev 1 1 2 45.0000000 2.82842712 1 2 2 43.0000000 4.24264069 2 1 2 65.0000000 4.24264069 2 2 2 69.0000000 2.82842712 3 1 2 40.0000000 1.41421356 3 2 2 44.0000000 2.82842712 Castle Bakery Company (ch19, p833) 10 Analysis taking into account the factorial treatment structure Two-way ANOVA The GLM Procedure Tukey's Studentized Range (HSD) Test for y NOTE: This test controls the Type I experimentwise error rate, but it generally has a higher Type II error rate than REGWQ. Alpha 0.05 Error Degrees of Freedom 6 Error Mean Square 10.33333 Critical Value of Studentized Range 4.33920 Minimum Significant Difference 6.9743 Means with the same letter are not significantly different. Tukey Grouping Mean N A A 67.000 4 2 B 44.000 4 1 B B 42.000 4 3 Castle Bakery Company (ch19, p833) 11 Analysis taking into account the factorial treatment structure Means plots Plot of yhat*A. Symbol is value of B. yhat | 70 + 2 | | 1 | | 60 + | | | | 50 + | |1 |2 2 | 40 + 1 | -+----------------------------------+----------------------------------+- 1 2 3 A NOTE: 6 obs hidden. Castle Bakery Company (ch19, p833) 12 Analysis taking into account the factorial treatment structure Means plots Plot of yhat*B. Symbol is value of A. yhat | 70 + 2 | | 2 | | 60 + | | | | 50 + | | 1 | 1 | 40 + 3 | ---+-----------------------------------------------+-- 1 2 B NOTE: 7 obs hidden.