Skip to main content
Edited example contrast matrix to give more interesting comparisons.
Source Link
Ashe
  • 1.1k
  • 13
  • 27
     [,1] [,2] [,3] [,4] [,5] [,6] [,7]
[1,]    1    3    3    1    10    10    20
[2,]    0   -1    0    0    0    0    01
[3,]    0   -1    0    0    01    0   -1
[4,]    0   -1    0    0   -1    0    0
[5,]    0    0   -1   -1 0    0    0    01
[6,]    0    0   -1    0    0    01   -1
[7,]    0    0   -1    01    0   -1    0

If this matrix is transposed and, solved, and the first column removed to create a contrast matrix, the resulting coefficients would be the following comparisons:

  1. Intercept is the baseline mean value (a-alpha)
  2. Coefficient 1: Difference between baseline and average of all severity levels of b
  3. Coefficient 2: Difference between baseline and average of all severity levels of c
  4. Coefficient 3: Difference between baseline and the mildestmost severe form of c (c-betadelta)
  5. Coefficient 4: Difference between baseline and the moderate and most severe formforms of b (b-delta)
  6. Coefficient 5: Difference between baseline and the moderate and most severe formforms of c (c-delta)
  7. Coefficient 6: Difference between baselinemean of both mild forms and the averagemean of the middle severity for both b and cmoderate forms.
     [,1] [,2] [,3] [,4] [,5] [,6] [,7]
[1,]    1    3    3    1    1    1    2
[2,]    0   -1    0    0    0    0    0
[3,]    0   -1    0    0    0    0   -1
[4,]    0   -1    0    0   -1    0    0
[5,]    0    0   -1   -1    0    0    0
[6,]    0    0   -1    0    0    0   -1
[7,]    0    0   -1    0    0   -1    0

If this matrix is transposed and solved, the resulting coefficients would be the following comparisons:

  1. Intercept is the baseline mean value (a-alpha)
  2. Coefficient 1: Difference between baseline and average of all b
  3. Coefficient 2: Difference between baseline and average of all c
  4. Coefficient 3: Difference between baseline and the mildest form of c (c-beta)
  5. Coefficient 4: Difference between baseline and the most severe form of b (b-delta)
  6. Coefficient 5: Difference between baseline and the most severe form of c (c-delta)
  7. Coefficient 6: Difference between baseline and the average of the middle severity for both b and c.
     [,1] [,2] [,3] [,4] [,5] [,6] [,7]
[1,]    1    3    3    1    0    0    0
[2,]    0   -1    0    0    0    0    1
[3,]    0   -1    0    0    1    0   -1
[4,]    0   -1    0    0   -1    0    0
[5,]    0    0   -1    0    0    0    1
[6,]    0    0   -1    0    0    1   -1
[7,]    0    0   -1    1    0   -1    0

If this matrix is transposed, solved, and the first column removed to create a contrast matrix, the resulting coefficients would be the following comparisons:

  1. Intercept is the baseline mean value (a-alpha)
  2. Coefficient 1: Difference between baseline and average of all severity levels of b
  3. Coefficient 2: Difference between baseline and average of all severity levels of c
  4. Coefficient 3: Difference between baseline and the most severe form of c (c-delta)
  5. Coefficient 4: Difference between the moderate and most severe forms of b
  6. Coefficient 5: Difference between the moderate and most severe forms of c
  7. Coefficient 6: Difference between mean of both mild forms and the mean of the moderate forms.
Source Link
Ashe
  • 1.1k
  • 13
  • 27

After some pondering, I have an answer to my own question (to which I welcome feedback). I think the most straight-forward way to handle this is to create a new factor that is a cross-combination of the two factors of interest. And so, the data would look like this:

ID   Factor A  Factor B   Score    Cross-Factor
1      a        alpha       0.1       a-alpha
2      a        alpha       0.2       a-alpha
3      b        beta        0.3       b-beta
4      b        gamma       0.4       b-gamma
5      b        delta       0.5       b-delta
6      c        beta        0.6       c-beta
7      c        gamma       0.7       c-gamma
8      c        delta       0.8       c-delta

The model would then include a single factor with 7 levels. I can interpret the factor relative to the a-alpha level using contrasts to extract the change from baseline to whatever combination of the cross-factor I'm interested in, or between means of other level comparisons. In fact, I could set up the following contrast matrix using the method outlined on the UCLA page, as one example of a contrast matrix.

Original Matrix

     [,1] [,2] [,3] [,4] [,5] [,6] [,7]
[1,]    1    3    3    1    1    1    2
[2,]    0   -1    0    0    0    0    0
[3,]    0   -1    0    0    0    0   -1
[4,]    0   -1    0    0   -1    0    0
[5,]    0    0   -1   -1    0    0    0
[6,]    0    0   -1    0    0    0   -1
[7,]    0    0   -1    0    0   -1    0

If this matrix is transposed and solved, the resulting coefficients would be the following comparisons:

  1. Intercept is the baseline mean value (a-alpha)
  2. Coefficient 1: Difference between baseline and average of all b
  3. Coefficient 2: Difference between baseline and average of all c
  4. Coefficient 3: Difference between baseline and the mildest form of c (c-beta)
  5. Coefficient 4: Difference between baseline and the most severe form of b (b-delta)
  6. Coefficient 5: Difference between baseline and the most severe form of c (c-delta)
  7. Coefficient 6: Difference between baseline and the average of the middle severity for both b and c.