Suppose you use the following statements to fit a full factorial model to a two-way design:
data twoway; input A B Y @@; datalines; 1 1 10.6 1 1 11.0 1 1 10.6 1 1 11.3 1 2 -0.2 1 2 1.3 1 2 -0.2 1 2 0.2 1 3 0.1 1 3 0.4 1 3 -0.4 1 3 1.0 2 1 19.7 2 1 19.3 2 1 18.5 2 1 20.4 2 2 -0.2 2 2 0.5 2 2 0.8 2 2 -0.4 2 3 -0.9 2 3 -0.1 2 3 -0.2 2 3 -1.7 3 1 29.7 3 1 29.6 3 1 29.0 3 1 30.2 3 2 1.5 3 2 0.2 3 2 -1.5 3 2 1.3 3 3 0.2 3 3 0.4 3 3 -0.4 3 3 -2.2 ;
proc glm data=twoway; class A B; model Y = A B A*B; run;
Partial results for the analysis of variance are shown in Figure 41.21. The Type I and Type III results are the same because this is a balanced design.
Source | DF | Type I SS | Mean Square | F Value | Pr > F |
---|---|---|---|---|---|
A | 2 | 219.905000 | 109.952500 | 165.11 | <.0001 |
B | 2 | 3206.101667 | 1603.050833 | 2407.25 | <.0001 |
A*B | 4 | 487.103333 | 121.775833 | 182.87 | <.0001 |
Source | DF | Type III SS | Mean Square | F Value | Pr > F |
---|---|---|---|---|---|
A | 2 | 219.905000 | 109.952500 | 165.11 | <.0001 |
B | 2 | 3206.101667 | 1603.050833 | 2407.25 | <.0001 |
A*B | 4 | 487.103333 | 121.775833 | 182.87 | <.0001 |
The interaction A*B is significant, indicating that the effect of A depends on the level of B. In some cases, you might be interested in looking at the differences between predicted values across A for different levels of B. Winer (1971) calls this the simple effects of A. You can compute simple effects with the LSMEANS statement by specifying the SLICE= option. In this case, since the GLM procedure is interactive, you can compute the simple effects of A by submitting the following statements after the preceding statements.
lsmeans A*B / slice=B; run;
The results are shown Figure 41.22. Note that A has a significant effect for B=1 but not for B=2 and B=3.
A | B | Y LSMEAN |
---|---|---|
1 | 1 | 10.8750000 |
1 | 2 | 0.2750000 |
1 | 3 | 0.2750000 |
2 | 1 | 19.4750000 |
2 | 2 | 0.1750000 |
2 | 3 | -0.7250000 |
3 | 1 | 29.6250000 |
3 | 2 | 0.3750000 |
3 | 3 | -0.5000000 |
A*B Effect Sliced by B for Y | |||||
---|---|---|---|---|---|
B | DF | Sum of Squares | Mean Square | F Value | Pr > F |
1 | 2 | 704.726667 | 352.363333 | 529.13 | <.0001 |
2 | 2 | 0.080000 | 0.040000 | 0.06 | 0.9418 |
3 | 2 | 2.201667 | 1.100833 | 1.65 | 0.2103 |