Data from Table 11.8, page 221
data table11_8; input a b errors; datalines; 1 1 1 1 1 4 1 1 0 1 1 7 2 1 13 2 1 5 2 1 7 2 1 15 3 1 9 3 1 16 3 1 18 3 1 13 1 2 15 1 2 6 1 2 10 1 2 13 2 2 6 2 2 18 2 2 9 2 2 15 3 2 14 3 2 7 3 2 6 3 2 13 ; run;
Contrast of marginal means in a two-factor design: Numerical Example, top of page 246
proc glm data = table11_8; class a b; model errors = a|b / ss3; contrast 'a1 vs a3' a 1 0 -1; run; quit;
The GLM Procedure
Class Level Information
Class Levels Values
a 3 1 2 3
b 2 1 2
Number of observations 24
Dependent Variable: errors
Sum of
Source DF Squares Mean Square F Value Pr > F
Model 5 280.0000000 56.0000000 3.05 0.0361
Error 18 330.0000000 18.3333333
Corrected Total 23 610.0000000
R-Square Coeff Var Root MSE errors Mean
0.459016 42.81744 4.281744 10.00000
Source DF Type III SS Mean Square F Value Pr > F
a 2 112.0000000 56.0000000 3.05 0.0721
b 1 24.0000000 24.0000000 1.31 0.2675
a*b 2 144.0000000 72.0000000 3.93 0.0384
Contrast DF Contrast SS Mean Square F Value Pr > F
a1 vs a3 1 100.0000000 100.0000000 5.45 0.0313
Table 12.2, page 251. Simple effects of factor A over the levels of B
NOTE: SAS’s lsmeans computes least-squares (marginal) means. The slice option tests for differences between the interaction of the LS-mean effects across the levels of the sliced variable.
proc glm data = table11_8; class a b; model errors = a|b/ss3; lsmeans a*b / slice = b; run; quit;
The GLM Procedure
Dependent Variable: errors
Sum of
Source DF Squares Mean Square F Value Pr > F
Model 5 280.0000000 56.0000000 3.05 0.0361
Error 18 330.0000000 18.3333333
Corrected Total 23 610.0000000
R-Square Coeff Var Root MSE errors Mean
0.459016 42.81744 4.281744 10.00000
Source DF Type III SS Mean Square F Value Pr > F
a 2 112.0000000 56.0000000 3.05 0.0721
b 1 24.0000000 24.0000000 1.31 0.2675
a*b 2 144.0000000 72.0000000 3.93 0.0384
Least Squares Means
errors
a b LSMEAN
1 1 3.0000000
1 2 11.0000000
2 1 10.0000000
2 2 12.0000000
3 1 14.0000000
3 2 10.0000000
Least Squares Means
a*b Effect Sliced by b for errors
Sum of
b DF Squares Mean Square F Value Pr > F
1 2 248.000000 124.000000 6.76 0.0064
2 2 8.000000 4.000000 0.22 0.8061
Table 12.3, page 252. Analyzing the simple effect of the drug condition for the satiated animals (b=1) when there is concern about variance difference
proc glm data = table11_8; where b = 1; class a ; model errors = a / ss3; run; quit;
The GLM Procedure
Class Level Information
Class Levels Values
a 3 1 2 3
Number of observations 12
Dependent Variable: errors
Sum of
Source DF Squares Mean Square F Value Pr > F
Model 2 248.0000000 124.0000000 7.75 0.0110
Error 9 144.0000000 16.0000000
Corrected Total 11 392.0000000
R-Square Coeff Var Root MSE errors Mean
0.632653 44.44444 4.000000 9.000000
Source DF Type III SS Mean Square F Value Pr > F
a 2 248.0000000 124.0000000 7.75 0.0110
Numerical Example, page 257-258. Contrast for control vs. drug X for group 1 (b=1)
NOTE: This contrast statement is set up first by the contrast on A and then a contrast on the A*B interaction designating which level of B A is to be evaluated on.
proc glm data = table11_8;
class a b;
model errors = a|b /ss3;
contrast 'a1 vs a2 at b1' a 1
-1
0
a*b 1 0
-1 0
0 0;
run;
quit;
The GLM Procedure
Class Level Information
Class Levels Values
a 3 1 2 3
b 2 1 2
Number of observations 24
Dependent Variable: errors
Sum of
Source DF Squares Mean Square F Value Pr > F
Model 5 280.0000000 56.0000000 3.05 0.0361
Error 18 330.0000000 18.3333333
Corrected Total 23 610.0000000
R-Square Coeff Var Root MSE errors Mean
0.459016 42.81744 4.281744 10.00000
Source DF Type III SS Mean Square F Value Pr > F
a 2 112.0000000 56.0000000 3.05 0.0721
b 1 24.0000000 24.0000000 1.31 0.2675
a*b 2 144.0000000 72.0000000 3.93 0.0384
Contrast DF Contrast SS Mean Square F Value Pr > F
a1 vs a2 at b1 1 98.00000000 98.00000000 5.35 0.0328
