Effect of lack of balance in the predictor levels on the interpretation of nested effects


The full-rank methods for coding nested effects in the CATMOD and LOGISTIC procedures (and GENMOD procedure beginning with SAS 9) assume that there is balanced replication of levels. That is, for the nested effect B(A), the coding of the design variables assumes that the number of levels of B is constant across all levels of A. Unexpected results with implications for parameter interpretation can occur when balance does not exist.

Beginning with SAS 8 for PROC LOGISTIC and with SAS 9 for PROC GENMOD and CATMOD, you can choose the coding method for categorical predictors. The coding method that is used in PROC LOGISTIC and PROC GENMOD is controlled by the PARAM= option in the CLASS statement. In PROC CATMOD, it is controlled by the PARAM= option in the MODEL statement. Effects coding (PARAM=EFFECT) is the default in PROC LOGISTIC and PROC CATMOD. Indicator ("dummy") coding (PARAM=GLM) is the default in PROC GENMOD. The effects and reference coding (PARAM=REF) methods are full-rank methods. The dummy coding method is less than full-rank.

Beginning with SAS 9, the design matrix in PROC CATMOD is displayed if the DESIGN option is specified in the MODEL statement. Also beginning with SAS 9, you can see the complete design matrix that is used in PROC LOGISTIC by specifying the OUTDESIGN= option in the PROC LOGISTIC statement and then examining the resulting data set.

Effects Coding

Suppose variable A has two levels. Also suppose in level 1 of A (A=1), variable B has three levels, and in level 2 of A (A=2), B has only the first two of its levels. When you use the following statements in PROC LOGISTIC, design variables are created as though B has three levels in both levels of A (that is, as though the levels are balanced):

   class a b;
   model y = a b(a);

This results in the following effects-coded design variables:

   A        B(A)
  ---  -------------
   1    1  0    0  0    A=1,B=1
   1    0  1    0  0    A=1,B=2
   1   -1 -1    0  0    A=1,B=3

     -1    0  0    1  0    A=2,B=1
     -1    0  0    0  1    A=2,B=2

Because of the unobserved A=2, B=3 level, PROC LOGISTIC detects and reports the linear dependency among these design variables and sets the parameter that is associated with the last column to zero. As a result, B(A) has three degrees of freedom and the next-to-last B(A) parameter estimates the difference between the two observed B levels in A=2. This parameter interpretation is the same that is imposed by dummy coding, which is effectively what the effects coding has become in A=2 due to the unobserved last level, B=3. However, this interpretation differs from the usual effects-coding interpretation that applies to the first two B(A) parameters, which compare each of levels B=1 and B=2 to the average of the B effects in level 1 of A. In general, if there were more levels of B within A=2, the B(A=2) parameters would carry dummy coding interpretations (the difference between each level and the last) rather than effects coding interpretations (the difference between each level and the average of all levels).

You might prefer that the B(A) columns be coded in this way:

   A      B(A)
  ---  ----------
   1    1  0    0     A=1,B=1
   1    0  1    0     A=1,B=2
   1   -1 -1    0     A=1,B=3

     -1    0  0    1     A=2,B=1
     -1    0  0   -1     A=2,B=2

With this coding there are no linear dependencies and the last parameter estimates the difference between B=1 and the average effect of the two observed B levels in A=2. Because there are only two levels, this is equivalent to saying that it estimates half the effect difference between the two B levels in A=2. To obtain this coding you need to create the above three B(A) design variables in your data set and then specify them in the MODEL statement instead of B(A). To prevent them from being recoded, do not list them in the CLASS statement in PROC LOGISTIC. In PROC CATMOD, list them in the DIRECT statement to prevent recoding.

Suppose now a level other than the last level was unobserved. The following design variable coding results if level A=2,B=2 is unobserved:

   A        B(A)
  ---  -------------
   1    1  0    0  0    A=1,B=1
   1    0  1    0  0    A=1,B=2
   1   -1 -1    0  0    A=1,B=3

     -1    0  0    1  0    A=2,B=1
     -1    0  0   -1 -1    A=2,B=3

The coding within A=2 is not equivalent to dummy coding as before. In this case, the next-to-last parameter estimates two-thirds of the difference between B=1 and the average effect of the two B levels in A=2. So, the interpretation of the parameter is proportional to, but not exactly, the usual difference from the average effects-coding interpretation.

Reference Coding

For reference coding (PARAM=REF), the design matrix that results from the missing reference level is shown below. Again, a linear dependency is detected and the last B(A) parameter is set to zero. The first two B(A) parameters compare B=1 and B=2 to B=3, both within A=1. The next-to-last B(A) parameter compares B=1 to B=2 in A=2. So in this case, the reference-coded parameters retain their difference from the reference level interpretation, but the reference level changes across levels of A.

   A            B(A)
  ---     ---------------
   1      1   0     0   0    A=1,B=1
   1      0   1     0   0    A=1,B=2
   1      0   0     0   0    A=1,B=3

      0      0   0     1   0    A=2,B=1
      0      0   0     0   1    A=2,B=2

If A=2,B=2 is missing instead of A=2,B=3, then the design variables are as follows:

   A            B(A)
  ---     ---------------
   1      1   0     0   0    A=1,B=1
   1      0   1     0   0    A=1,B=2
   1      0   0     0   0    A=1,B=3

      0      0   0     1   0    A=2,B=1
      0      0   0     0   0    A=2,B=3

The next-to-last parameter retains its usual interpretation as the estimated difference in the effects of B=1 and B=3 in A=2.

Dummy Coding

The result is similar with dummy coding (PARAM=GLM). With dummy coding, a design variable is created for each observed level, which always results in an overparameterized model. To make parameters estimable, some parameters are set to zero. In this case, the A=1, B=3 parameter and, as before, the A=2, B=2 parameter, are set to zero. (Also, the A=2 parameter in the A effect is set to zero.) The same parameters are estimated with the same interpretation as under reference coding.

   A                B(A)
 -----      -------------------
 1   0      1   0   0     0   0    A=1,B=1
 1   0      0   1   0     0   0    A=1,B=2
 1   0      0   0   1     0   0    A=1,B=3

    0   1      0   0   0     1   0    A=2,B=1
    0   1      0   0   0     0   1    A=2,B=2

If A=2,B=2 is missing instead of A=2,B=3, then the design variables are as follows:

   A                B(A)
-----      -------------------
1   0      1   0   0     0   0    A=1,B=1
1   0      0   1   0     0   0    A=1,B=2
1   0      0   0   1     0   0    A=1,B=3

   0   1      0   0   0     1   0    A=2,B=1
   0   1      0   0   0     0   1    A=2,B=3

The next-to-last parameter retains its usual interpretation as the estimated difference in the effects of B=1 and B=3 in A=2.

Conclusions

Because unbalanced replication of levels has less impact on the interpretation of nested effect parameters under reference or dummy coding, it might be preferable to use one of these coding methods for such models when there is lack of balance. With these coding methods, the difference from reference level interpretation of parameter estimates persists, but the identity of the reference level might change across levels of the nesting factor (A, above). With effects coding, if the last level of the nested factor (B, above) is not observed in some levels of the nesting factor, then the interpretation of parameters changes to a dummy coding interpretation in those levels. To maintain the difference from the average effect interpretation requires separate effects coding within the levels of the nesting factor as shown above.