The simple models shown so far involve only lists of predictors. Beyond these, analysts often want to define effects that combine two or more predictors. For example, you might posit that the response rate for your marketing campaign relates differently to customer age group depending on whether customers are male or female. This kind of relationship is called an interaction between age group and gender. For these types of effects, a more verbose action specification is called for. An individual crossproduct or interaction is specified by using terms parameters, each of which consists of lists of constituent predictor variables together with a flag subparameter to indicate how they are to be composed. Key tools are the CROSS and BAR flags and the nest list of variables, as shown in Table 3.
Table 3: Models with Interactions and Nesting
| Analysis of covariance, unequal slopes | ||
| SAS code: | ||
class a; model y = a a*x; |
||
| Action specification: | ||
class='a',
model={
depVar='y',
effects={ 'a', {vars={'a','x'}, interaction='CROSS'} }
}
|
||
| Main effects and all two-way crossproducts | ||
| SAS code: | ||
model y = x1 x2 x3 ... x1*x2 x2*x3 ... x8*x9; or equivalently model y = x1|x2|x3|x4|x5|x6|x7|x8|x9@2; |
||
| Action specification: | ||
model={
depVar = 'y',
effects = { {vars='/^x/', interact='BAR', maxinteract=2} }
}
The
model={
depVar = 'y',
effects = { {vars='/^x/', maxinteract=2} }
}
|
||
| Nested model | ||
| SAS code: | ||
class a b c d; model y = a b(a) c(a b) d(a b c); |
||
| Action specification: | ||
class={'a','b','c','d'},
model={
depVar={'y'},
effects={'a',
{vars='b',nest= 'a' },
{vars='c',nest={'a','b'} },
{vars='d',nest={'a','b','c'}} },
|
||
For more information about models that are composed of interactions and nested effects, see the section Specification and Parameterization of Model Effects (SAS Visual Statistics: Procedures).
When your models include composite effects that involve interactions and nesting, the terms have a natural hierarchy, which is defined by effect containment. Consider two terms, T1 and T2. T1 is said to contain T2 when T1 and T2 have the same continuous predictors and all the classification predictors of T2 are also in T1. As far as your model is concerned, T1 is more flexible than T2; conversely, T2 is simpler, so that having T2 in your model instead of T1 makes more stringent assumptions.
For actions that include model effect selection, you can control how term hierarchy affects the selection process by using the hierarchy subparameter in the selection parameter.