* ch1617eg.sas; * This SAS program fits a cell means (1-way ANOVA) model to * the data of Table 16.1, and also illustrated analysis of * factor effects, the topic of chapter 17; options ls=78 nodate; ; data KFC; input y A j; * A=i; drop j; lines; 11 1 1 17 1 2 16 1 3 14 1 4 15 1 5 12 2 1 10 2 2 15 2 3 19 2 4 11 2 5 23 3 1 20 3 2 18 3 3 17 3 4 27 4 1 33 4 2 22 4 3 26 4 4 28 4 5 ; * Do ANOVA using proc glm, modeling the factor as a * class(ification) variable; proc glm; title 'Kenton Food Company, Table 16.1 data.'; title2 'ANOVA and analysis of factor effects'; class A; model y = A / solution; * (for a solution to normal equations); means A; * factor level means and standard deviations; output out=B p=yhat r=e; * option for multiple comparison procedures, alpha=0.05 is the default; * the option "bon" would request Bonferonni's method; means A / alpha=0.05 tukey; * testing one linear combination, in this case a pairwise comparison; contrast 'A3-A2' A 0 -1 1 0; * testing 3 contrasts simultaneously; contrast 'A' A -1 1 0 0, A -1 0 1 0, A -1 0 0 1; * information for constructing a CI for a pairwise comparison; estimate 'A3-A2' A 0 -1 1 0; * information for constructing a CI for a treatment mean; estimate 'A1' intercept 1 A 1 0 0 0; ; * plot the raw data and fitted model; proc plot; plot yhat*A='*' y*A / overlay; title2 'Plot of raw data and fitted model'; ; * Generate residual plots; proc rank normal=Blom; var e; ranks nscore; proc plot; plot e*A e*yhat / vpos=13 vref=0; plot e*nscore / vpos=13 vref=0 href=0; title2 'Residual plots'; Kenton Food Company, Table 16.1 data. 1 ANOVA and analysis of factor effects The GLM Procedure Class Level Information Class Levels Values A 4 1 2 3 4 Number of observations 19 Kenton Food Company, Table 16.1 data. 2 ANOVA and analysis of factor effects The GLM Procedure Dependent Variable: y Sum of Source DF Squares Mean Square F Value Pr > F Model 3 588.2210526 196.0736842 18.59 <.0001 Error 15 158.2000000 10.5466667 Corrected Total 18 746.4210526 R-Square Coeff Var Root MSE y Mean 0.788055 17.43042 3.247563 18.63158 Source DF Type I SS Mean Square F Value Pr > F A 3 588.2210526 196.0736842 18.59 <.0001 Source DF Type III SS Mean Square F Value Pr > F A 3 588.2210526 196.0736842 18.59 <.0001 Standard Parameter Estimate Error t Value Pr > |t| Intercept 27.20000000 B 1.45235441 18.73 <.0001 A 1 -12.60000000 B 2.05393930 -6.13 <.0001 A 2 -13.80000000 B 2.05393930 -6.72 <.0001 A 3 -7.70000000 B 2.17853162 -3.53 0.0030 A 4 0.00000000 B . . . NOTE: The X'X matrix has been found to be singular, and a generalized inverse was used to solve the normal equations. Terms whose estimates are followed by the letter 'B' are not uniquely estimable. Kenton Food Company, Table 16.1 data. 3 ANOVA and analysis of factor effects The GLM Procedure Level of --------------y-------------- A N Mean Std Dev 1 5 14.6000000 2.30217289 2 5 13.4000000 3.64691651 3 4 19.5000000 2.64575131 4 5 27.2000000 3.96232255 Kenton Food Company, Table 16.1 data. 4 ANOVA and analysis of factor effects The GLM Procedure Tukey's Studentized Range (HSD) Test for y NOTE: This test controls the Type I experimentwise error rate. Alpha 0.05 Error Degrees of Freedom 15 Error Mean Square 10.54667 Critical Value of Studentized Range 4.07597 Comparisons significant at the 0.05 level are indicated by ***. Difference A Between Simultaneous 95% Comparison Means Confidence Limits 4 - 3 7.700 1.421 13.979 *** 4 - 1 12.600 6.680 18.520 *** 4 - 2 13.800 7.880 19.720 *** 3 - 4 -7.700 -13.979 -1.421 *** 3 - 1 4.900 -1.379 11.179 3 - 2 6.100 -0.179 12.379 1 - 4 -12.600 -18.520 -6.680 *** 1 - 3 -4.900 -11.179 1.379 1 - 2 1.200 -4.720 7.120 2 - 4 -13.800 -19.720 -7.880 *** 2 - 3 -6.100 -12.379 0.179 2 - 1 -1.200 -7.120 4.720 Kenton Food Company, Table 16.1 data. 5 ANOVA and analysis of factor effects The GLM Procedure Dependent Variable: y Contrast DF Contrast SS Mean Square F Value Pr > F A3-A2 1 82.6888889 82.6888889 7.84 0.0135 A 3 588.2210526 196.0736842 18.59 <.0001 Standard Parameter Estimate Error t Value Pr > |t| A3-A2 6.1000000 2.17853162 2.80 0.0135 A1 14.6000000 1.45235441 10.05 <.0001 Kenton Food Company, Table 16.1 data. 6 Plot of raw data and fitted model Plot of yhat*A. Symbol used is '*'. Plot of y*A. Legend: A = 1 obs, B = 2 obs, etc. yhat | | 35.0 + | | | A 32.5 + | | | 30.0 + | | | A 27.5 + * | A | A | 25.0 + | | | A 22.5 + | A | | 20.0 + A | * | A | A 17.5 + | A A | A | 15.0 + A A | * | A | * 12.5 + | A | A A | 10.0 + A | ---+-----------------+-----------------+-----------------+-- 1 2 3 4 A NOTE: 15 obs hidden. Kenton Food Company, Table 16.1 data. 7 Residual plots Plot of e*A. Legend: A = 1 obs, B = 2 obs, etc. 10 + | | | A 5 + A | A e | A | A A A 0 +--B-------------------------------------A------------------A-- | A A A | A A | A A -5 + A ---+------------------+------------------+------------------+-- 1 2 3 4 A Kenton Food Company, Table 16.1 data. 8 Residual plots Plot of e*yhat. Legend: A = 1 obs, B = 2 obs, etc. 10 + | | | A 5 + A | A e | A | A A A 0 +------------B---------------------A---------------------------------A----- | A A A | A A | A A -5 + A -+--------+--------+--------+--------+--------+--------+--------+--------+- 12 14 16 18 20 22 24 26 28 yhat Kenton Food Company, Table 16.1 data. 9 Residual plots Plot of e*nscore. Legend: A = 1 obs, B = 2 obs, etc. 10 + | | | | | | | A 5 + | A | | A e | | A | | A A A 0 +------------------------------A-A-A-A---------------------------- | A A A | | A A | | A A | -5 + A | ---+--------------+--------------+--------------+--------------+-- -2 -1 0 1 2 Rank for Variable e