1
$\begingroup$

I have a model with two categorical variables. Each one has three levels. Iv1 has a natural reference category so I would like to use dummy coding, and compare level 2 to level 1, and level 3 to level 1. Iv2 is sequential and I would like to compare level 2 to level 1, and level 3 to level 2.

R automatically creates contrasts that then look like this:

For Iv1:

  i ii
1 0  0
2 1  0
3 0  1

For Iv2:

         i        ii
1 -0.6666667 -0.3333333
2  0.3333333 -0.3333333
3  0.3333333  0.6666667

Is there anything wrong with using these two kinds of contrasts, and including an interaction between them?

$\endgroup$

1 Answer 1

2
$\begingroup$

No problem with these two kinds of coding. For lv1, it is clear the coefficient for i is the effect of level 2 vs level 1 and the coefficient for ii is the effect of level 3 vs level 1. If you want the comparison between level 2 and 3, then use the difference of two coefficient.

For lv2, the coefficient for i is the effect of level 2 vs level 1 and the coefficient for ii is the effect of level 3 vs level 2. If you want the comparison between level 1 and 3, then use the difference of two coefficient.

If the interaction is included in the model, there will be 9 regression coefficients in the model. It equals the number of cells in your design (3 levels in lv1 times 3 levels in lv2 = 9 cells). Then if you want to compare any pair of cells, just plug in the code for each cell and get the difference between them.

$\endgroup$
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.