SAS example: ANOVA for a two way layout
The data consist of casting hardnesses for 18 samples prepared under 3 levels of sand added and 3 levels of carbon fibre added. See Q 15 in Chapter 11. I use proc anova to test the hypotheses of no effect of either sand content or fibre content after first testing for interactions.
I ran the following SAS code:
options pagesize=60 linesize=80; data plaster; infile 'plaster.dat'; input sand fibre hardness strength; proc anova data=plaster; class sand fibre; model hardness = sand|fibre; means sand fibre / tukey cldiff ; run;
The line labelled model says that I am interested in the effects of sand, fibre and interactions between the two. The line class sand fibre is required so that SAS knows which variables define the levels of the factors.
The output from proc anova is
The SAS System 1 14:05 Tuesday, November 14, 1995 Analysis of Variance Procedure Class Level Information Class Levels Values SAND 3 0 15 30 FIBRE 3 0 25 50 Number of observations in data set = 18 The SAS System 2 14:05 Tuesday, November 14, 1995 Analysis of Variance Procedure Dependent Variable: HARDNESS Sum of Mean Source DF Squares Square F Value Pr > F Model 8 202.77777778 25.34722222 3.10 0.0557 Error 9 73.50000000 8.16666667 Corrected Total 17 276.27777778 R-Square C.V. Root MSE HARDNESS Mean 0.733963 4.105290 2.8577380 69.611111 Source DF Anova SS Mean Square F Value Pr > F SAND 2 106.77777778 53.38888889 6.54 0.0176 FIBRE 2 87.11111111 43.55555556 5.33 0.0297 SAND*FIBRE 4 8.88888889 2.22222222 0.27 0.8887 The SAS System 3 14:05 Tuesday, November 14, 1995 Analysis of Variance Procedure Tukey's Studentized Range (HSD) Test for variable: HARDNESS NOTE: This test controls the type I experimentwise error rate. Alpha= 0.05 Confidence= 0.95 df= 9 MSE= 8.166667 Critical Value of Studentized Range= 3.948 Minimum Significant Difference= 4.6066 Comparisons significant at the 0.05 level are indicated by '***'. Simultaneous Simultaneous Lower Difference Upper SAND Confidence Between Confidence Comparison Limit Means Limit 30 - 15 -2.773 1.833 6.440 30 - 0 1.227 5.833 10.440 *** 15 - 30 -6.440 -1.833 2.773 15 - 0 -0.607 4.000 8.607 0 - 30 -10.440 -5.833 -1.227 *** 0 - 15 -8.607 -4.000 0.607 The SAS System 4 14:05 Tuesday, November 14, 1995 Analysis of Variance Procedure Tukey's Studentized Range (HSD) Test for variable: HARDNESS NOTE: This test controls the type I experimentwise error rate. Alpha= 0.05 Confidence= 0.95 df= 9 MSE= 8.166667 Critical Value of Studentized Range= 3.948 Minimum Significant Difference= 4.6066 Comparisons significant at the 0.05 level are indicated by '***'. Simultaneous Simultaneous Lower Difference Upper FIBRE Confidence Between Confidence Comparison Limit Means Limit 50 - 25 -4.607 0.000 4.607 50 - 0 0.060 4.667 9.273 *** 25 - 50 -4.607 0.000 4.607 25 - 0 0.060 4.667 9.273 *** 0 - 50 -9.273 -4.667 -0.060 *** 0 - 25 -9.273 -4.667 -0.060 ***
The conclusions are that both sand and fibre have an effect on hardness but that there is little evidence of an interaction between the two factors. The Tukey procedures show a clear difference between the 0% fibre and the other two levels but not between the last two levels in terms of effect on hardness. The high level of sand clearly differs from the low level but the intermediate level is not clearly distinguished from the other two.
The model can be run assuming the interactions are all 0 by using
options pagesize=60 linesize=80; data plaster; infile 'plaster.dat'; input sand fibre hardness strength; proc anova data=plaster; class sand fibre; model hardness = sand fibre; means sand / tukey cldiff alpha=0.01; means fibre / tukey cldiff alpha=0.05; run;which produces
The SAS System 1 13:52 Tuesday, November 14, 1995 Analysis of Variance Procedure Class Level Information Class Levels Values SAND 3 0 15 30 FIBRE 3 0 25 50 Number of observations in data set = 18 Analysis of Variance Procedure Dependent Variable: HARDNESS Sum of Mean Source DF Squares Square F Value Pr > F Model 4 193.88888889 48.47222222 7.65 0.0021 Error 13 82.38888889 6.33760684 Corrected Total 17 276.27777778 R-Square C.V. Root MSE HARDNESS Mean 0.701790 3.616463 2.5174604 69.611111 Source DF Anova SS Mean Square F Value Pr > F SAND 2 106.77777778 53.38888889 8.42 0.0045 FIBRE 2 87.11111111 43.55555556 6.87 0.0092 Tukey's Studentized Range (HSD) Test for variable: HARDNESS NOTE: This test controls the type I experimentwise error rate. Alpha= 0.01 Confidence= 0.99 df= 13 MSE= 6.337607 Critical Value of Studentized Range= 4.964 Minimum Significant Difference= 5.1013 Comparisons significant at the 0.01 level are indicated by '***'. Simultaneous Simultaneous Lower Difference Upper SAND Confidence Between Confidence Comparison Limit Means Limit 30 - 15 -3.268 1.833 6.935 30 - 0 0.732 5.833 10.935 *** 15 - 30 -6.935 -1.833 3.268 15 - 0 -1.101 4.000 9.101 0 - 30 -10.935 -5.833 -0.732 *** 0 - 15 -9.101 -4.000 1.101 Analysis of Variance Procedure Tukey's Studentized Range (HSD) Test for variable: HARDNESS NOTE: This test controls the type I experimentwise error rate. Alpha= 0.05 Confidence= 0.95 df= 13 MSE= 6.337607 Critical Value of Studentized Range= 3.734 Minimum Significant Difference= 3.8378 Comparisons significant at the 0.05 level are indicated by '***'. Simultaneous Simultaneous Lower Difference Upper FIBRE Confidence Between Confidence Comparison Limit Means Limit 50 - 25 -3.838 0.000 3.838 50 - 0 0.829 4.667 8.504 *** 25 - 50 -3.838 0.000 3.838 25 - 0 0.829 4.667 8.504 *** 0 - 50 -8.504 -4.667 -0.829 *** 0 - 25 -8.504 -4.667 -0.829 ***
In this case the multiple comparison procedures lead to the same conclusions, even using the harsher 0.01 level. The overall F-tests still conclude that both sand and fibre have an effect. Notice that the tests now have more degrees of freedom for error since no interaction effects are fitted; the corresponding interaction sum of squares has been rolled in with the error sum of squares.