Shared Concepts

GLM Parameterization of Classification Variables and Effects

Table 14 shows the types of effects that are available in actions in this book; they are discussed in more detail in the following subsections. Let A, B, and C represent classification variables, and let X and Z represent continuous variables.

Table 14: Available Types of Effects

Effect SAS Syntax Description
Intercept Default Intercept (unless the noint parameter is specified)
Regression X Z effects={{vars={’X’,’Z’}}} Continuous variables
Polynomial X*Z effects={{vars={’X’,’Z’},
interaction=’cross’}}
Interaction of continuous variables
Main A B effects={{vars={’A’,’B’} CLASS variables
Interaction A*B effects={{vars={’A’,’B’},
interaction=’cross’}
Crossing of CLASS variables
Nested A(B) effects={{vars=’A’,nest=’B’}} Main effect A nested within CLASS effect B
Continuous-by-class X*B effects={{vars={’X’,’B’},
interaction=’cross’}}
Crossing of continuous and CLASS variables
Continuous-nesting-class X(A) effects={{vars={’X’},nest=’A’}} Continuous variable X nested within CLASS variable A
General X*Z*B(A) effects={{vars={’X’,’Z’,’B’},
interaction=’cross’,nest=’A’}}
Combinations of different types of effects


Table 15 shows some examples of effects parameters that use various types of effects.

Table 15: effects Parameter Examples

SAS Specification Type of Model
X effects={{vars=’X’}} Simple regression
X Z effects={{vars={’X’,’Z’}}} Multiple regression
X X*X effects={{vars={’X’,’X’},interaction=’bar’}} Polynomial regression
A effects={{vars=’A’}} One-way analysis of variance (ANOVA)
A B C effects={{vars={’A’,’B’,’C’}}} Main-effects ANOVA
A|B effects={{vars={’A’,’B’},interaction=’bar’}} Factorial ANOVA with interaction
A B(A) C(A B) effects={{vars=’A’},{vars=’B’,nest=’A’},
{vars=’C’,nest={’A’,’B’},interaction=’bar’}}
Nested ANOVA
A X effects={{vars={’A’,’X’}}} Analysis of covariance (ANCOVA)
A X(A) effects={{vars=’A’},{vars=’X’,nest=’A’}} Separate-slopes regression
A|X effects={{vars={’A’,’X’},interaction=’bar’}} Homogeneity-of-slopes regression


Intercept

By default, linear models that are created by actions in this book automatically include a column of 1s in bold upper X. This column corresponds to an intercept parameter. In many actions, you can use the noint parameter to suppress this intercept. For example, the noint parameter is useful when the model contains a classification effect and you want the parameter estimates to be in terms of the mean response for each level of that effect.

Regression Effects

Numeric variables or polynomial terms that involve them can be included in the model as regression effects (covariates). The actual values of such terms are included as columns of the relevant model matrices. You can use the bar operator along with a regression effect to generate polynomial effects. For example, vars={’X’,’X’,’X’},interaction=’bar’ creates columns for X, X*X, and X*X*X, which is a cubic model.

Main Effects

If a classification variable has m levels, the GLM parameterization generates m columns for its main effect in the model matrix. Each column is an indicator variable for a particular level. The order of the columns is the sort order of the values of their levels and can be controlled by the order subparameter in the class parameter.

Table 16 is an example where beta 0 denotes the intercept and A and B are classification variables that have two and three levels, respectively.

Table 16: Example of Main Effects

Data I A B
A B beta 0 A1 A2 B1 B2 B3
1 1 1 1 0 1 0 0
1 2 1 1 0 0 1 0
1 3 1 1 0 0 0 1
2 1 1 0 1 1 0 0
2 2 1 0 1 0 1 0
2 3 1 0 1 0 0 1


There are usually more columns for these effects than there are degrees of freedom to estimate them. In other words, the GLM parameterization of main effects is singular.

Interaction Effects

Often a model includes interaction (crossed) effects to account for how the effect of a variable changes along with the values of other variables. With an interaction, 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 17).

Table 17: Example of Interaction Effects

Data I A B A*B
A B beta 0 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 maxinteract subparameter in conjunction with the bar operator.

Nested Effects

Nested effects are generated in the same manner as crossed effects. Hence, the design columns that are generated by the following two statements are the same (but the ordering of the columns is different):

\Code{effects={{vars='A'},{vars='B',nest='A'}}}

\Code{effects={{vars='A'},{vars={'A','B'},interaction='cross'}}}

The nesting operator in actions in this book is more of a notational convenience than an operation that is distinct from crossing. Nested effects are typically characterized by the property that the nested variables do not appear as main effects. The order of the columns is such that containing variables index faster than the nested variables, and the rightmost nested variables index faster than the leftmost variables (Table 18).

Table 18: Example of Nested Effects

Data I A B(A)
A B beta 0 A1 A2 B1A1 B2A1 B3A1 B1A2 B2A2 B3A2
1 1 1 1 0 1 0 0 0 0 0
1 2 1 1 0 0 1 0 0 0 0
1 3 1 1 0 0 0 1 0 0 0
2 1 1 0 1 0 0 0 1 0 0
2 2 1 0 1 0 0 0 0 1 0
2 3 1 0 1 0 0 0 0 0 1


Continuous-Nesting-Class Effects

When a continuous variable nests or crosses with a classification variable, the design columns are constructed by multiplying the continuous values into the design columns for the classification effect (Table 19).

Table 19: Example of Continuous-Nesting-Class Effects

Data I A X(A)
X A beta 0 A1 A2 X(A1) X(A2)
21 1 1 1 0 21 0
24 1 1 1 0 24 0
22 1 1 1 0 22 0
28 2 1 0 1 0 28
19 2 1 0 1 0 19
23 2 1 0 1 0 23


This model estimates a separate intercept and a separate slope for X within each level of A.

Continuous-by-Class Effects

Continuous-by-class effects generate the same design columns as continuous-nesting-class effects. Table 20 shows the construction of the X*A interaction. The two columns for this effect are the same as the columns for the X(A) effect in Table 19.

Table 20: Example of Continuous-by-Class Effects

Data I X A X*A
X A beta 0 X A1 A2 X*A1 X*A2
21 1 1 21 1 0 21 0
24 1 1 24 1 0 24 0
22 1 1 22 1 0 22 0
28 2 1 28 0 1 0 28
19 2 1 19 0 1 0 19
23 2 1 23 0 1 0 23


You can use continuous-by-class effects together with pure continuous effects to test for homogeneity of slopes.

General Effects

An example that combines all the effects is X*Z*A*B(C D):

effects={{vars={'X','Z','A','B'},interaction='bar',nest={'C','D'}}}

The continuous list comes first, followed by the crossed list, followed by the nested list in parentheses.

The sequencing of the parameters that are generated by an effect is determined by the variables whose levels are indexed faster:

  • Variables in the crossed list index faster than variables in the nested list.

  • Within a crossed or nested list, variables to the right index faster than variables to the left.

For example, suppose that a model includes four classification effects—A, B, C, and D—each having two levels, 1 and 2. The effect B*A(C D) is specified as follows:

effects={{vars={'B','A'},interaction='cross',nest={'C','D'}}}

and order of the parameters is as follows:

StartLayout 1st Row 1st Column upper B 1 upper A 1 upper C 1 upper D 1 right-arrow 2nd Column upper B 1 upper A 2 upper C 1 upper D 1 right-arrow 3rd Column upper B 2 upper A 1 upper C 1 upper D 1 right-arrow 4th Column upper B 2 upper A 2 upper C 1 upper D 1 right-arrow 5th Column Blank 2nd Row 1st Column upper B 1 upper A 1 upper C 1 upper D 2 right-arrow 2nd Column upper B 1 upper A 2 upper C 1 upper D 2 right-arrow 3rd Column upper B 2 upper A 1 upper C 1 upper D 2 right-arrow 4th Column upper B 2 upper A 2 upper C 1 upper D 2 right-arrow 5th Column Blank 3rd Row 1st Column upper B 1 upper A 1 upper C 2 upper D 1 right-arrow 2nd Column upper B 1 upper A 2 upper C 2 upper D 1 right-arrow 3rd Column upper B 2 upper A 1 upper C 2 upper D 1 right-arrow 4th Column upper B 2 upper A 2 upper C 2 upper D 1 right-arrow 5th Column Blank 4th Row 1st Column upper B 1 upper A 1 upper C 2 upper D 2 right-arrow 2nd Column upper B 1 upper A 2 upper C 2 upper D 2 right-arrow 3rd Column upper B 2 upper A 1 upper C 2 upper D 2 right-arrow 4th Column upper B 2 upper A 2 upper C 2 upper D 2 EndLayout

Note for each combination of the nested effects in turn, combinations of A and B appear. The A effect changes fastest because it is rightmost in the cross list. Then B changes next fastest, and D changes next fastest. The C effect changes most slowly because it is leftmost in the nested list.

Last updated: March 05, 2026