Often a model includes interaction (crossed) effects to account for how the effect of a variable changes with the values of
other variables. With an interaction, the terms are first reordered to correspond to the order of the variables in the CLASS
statement. Thus, B
*A
becomes A
*B
if A
precedes B
in the CLASS statement. Then, the GLM parameterization generates columns for all combinations of levels that occur in the
data. The order of the columns is such that the rightmost variables in the interaction change faster than the leftmost variables
(Table 19.5). In the MIXED and GLIMMIX procedures, which support both fixed- and random-effects models, empty columns (that is, columns
that would contain all 0s) are not generated for fixed effects, but they are generated for random effects.
Table 19.5: Example of Interaction Effects
Data |
I |
|
|
|
|||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
|
A1 |
A2 |
B1 |
B2 |
B3 |
A1B1 |
A1B2 |
A1B3 |
A2B1 |
A2B2 |
A2B3 |
||||
1 |
1 |
1 |
1 |
0 |
1 |
0 |
0 |
1 |
0 |
0 |
0 |
0 |
0 |
||||
1 |
2 |
1 |
1 |
0 |
0 |
1 |
0 |
0 |
1 |
0 |
0 |
0 |
0 |
||||
1 |
3 |
1 |
1 |
0 |
0 |
0 |
1 |
0 |
0 |
1 |
0 |
0 |
0 |
||||
2 |
1 |
1 |
0 |
1 |
1 |
0 |
0 |
0 |
0 |
0 |
1 |
0 |
0 |
||||
2 |
2 |
1 |
0 |
1 |
0 |
1 |
0 |
0 |
0 |
0 |
0 |
1 |
0 |
||||
2 |
3 |
1 |
0 |
1 |
0 |
0 |
1 |
0 |
0 |
0 |
0 |
0 |
1 |
In the preceding matrix, main-effects columns are not linearly independent of crossed-effects columns; in fact, the column space for the crossed effects contains the space of the main effect.
When your model contains many interaction effects, you might be able to code them more parsimoniously by using the bar operator
( | ). The bar operator generates all possible interaction effects. For example, A
|B
|C
expands to A
B
A
*B
C
A
*C
B
*C
A
*B
*C
. To eliminate higher-order interaction effects, use the at sign (@) in conjunction with the bar operator. For instance, A
|B
|C
|D
@2 expands to A
B
A
*B
C
A
*C
B
*C
D
A
*D
B
*D
C
*D
.