# interpreting interaction between two categorical variables in OLS [duplicate]

In the model, I test the influence of promotional display d and product category categ on demand lnunits. d and categ are both categorical with 3 and 8 values, respectively. The interaction terms are quite hard to interpret because I keep hearing mixed opinions. One of the struggles is to understand what is the reference point for those interactions. Please keep in mind that I have other variables in my model like price and coupon.

Here is the Stata output. Many thanks.

------------------------------------------------------------------------------
lnunits |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------

d_1 |    .538603   .0131227    41.04   0.000      .512883    .5643231
d_2 |   .5951712    .018547    32.09   0.000     .5588198    .6315227
categ_2 |   .2278076   .0028202    80.78   0.000     .2222801    .2333351
categ_3 |   .1023514   .0032537    31.46   0.000     .0959742    .1087285
categ_4 |   .1399831   .0037105    37.73   0.000     .1327107    .1472555
categ_5 |   .1444258   .0034629    41.71   0.000     .1376388    .1512129
categ_6 |    .160837   .0069592    23.11   0.000     .1471972    .1744768
categ_7 |  -.0247559   .0048092    -5.15   0.000    -.0341817   -.0153302
categ_8 |  -.0537664   .0053687   -10.01   0.000    -.0642889   -.0432439
d_1*categ_2 |  -.0192817   .0140681    -1.37   0.170    -.0468547    .0082912
d_1*categ_3 |  -.1128736   .0149039    -7.57   0.000    -.1420847   -.0836624
d_1*categ_4 |  -.1781499   .0144119   -12.36   0.000    -.2063967   -.1499031
d_1*categ_5 |  -.0292207    .014499    -2.02   0.044    -.0576382   -.0008032
d_1*categ_6 |  -.3774382   .0322873   -11.69   0.000      -.44072   -.3141563
d_1*categ_7 |  -.4808987   .0447347   -10.75   0.000    -.5685771   -.3932202
d_1*categ_8 |  -.3655917   .0294069   -12.43   0.000    -.4232283   -.3079551
d_2*categ_2 |  -.0491836    .019872    -2.48   0.013     -.088132   -.0102353
d_2*categ_3 |  -.1950968   .0215043    -9.07   0.000    -.2372445    -.152949
d_2*categ_4 |  -.2917762   .0201624   -14.47   0.000    -.3312938   -.2522586
d_2*categ_5 |  -.0425442   .0208411    -2.04   0.041     -.083392   -.0016964
d_2*categ_6 |  -.4628832   .0433818   -10.67   0.000    -.5479099   -.3778565
d_2*categ_7 |   -.582086   .0540387   -10.77   0.000        -.688   -.4761721
d_2*categ_8 |   -.424297   .0363369   -11.68   0.000    -.4955161    -.353078
_cons |   1.923285    .008153   235.90   0.000     1.907306    1.939265
--


d_1*categ_2 |  -.0192817   .0140681    -1.37   0.170    -.0468547    .0082912


Is the effect being measured with respect to

d_0*categ_1


or

d_0*categ_2


or

d_1*categ_1


?

## marked as duplicate by Andy, Sven Hohenstein, Xi'an, mpiktas, Christoph HanckOct 23 '15 at 13:07

• This question has been asked and answered several times on this site. If you search for "categorical interaction interpretation" you will find answers. For example: stats.stackexchange.com/questions/161993/… stats.stackexchange.com/questions/85393/… stats.stackexchange.com/questions/157154/… stats.stackexchange.com/questions/24246/… – StatsStudent Oct 23 '15 at 6:52
• I saw these answers, and other ones too. I don't think they cover what I was looking for. Some are either too example-specific, others are too broad and a bit confusing. – Olga Oct 23 '15 at 7:16
• By default R sets the reference category to the first level of the categorical variable. Interactions where either of the first level is at it's lowest level are set to zero and I think this is the case with STATA too (SAS sets the last level to 0 by default) as you can see in your output. The easiest way to see this is to write out the model for a few different cases. – StatsStudent Oct 23 '15 at 7:21
• Please see the edited version of the question. – Olga Oct 23 '15 at 7:22

The best way to understand interactions is to write out the model that you are fitting. By default, R parameterizes models such that the first level of every categorical variable is set to zero in the model specification (so I'm assuming the categorical value of d are $d=0, 1, 2$). So, when promotional play, $d$, is at level $d=0$, and product category is at level $categ=1$ then the model can be written as:

$E(Y)=\beta_0+\beta_{d0}+\beta_{categ1}+\beta_{categ1,d0}$

This is estimated by:

$E(Y)=1.923285+0+0+0$ or

$E(Y)=1.923285$, which is just the intercept.

If $d=0$, but $categ=2$ then:

$E(Y)=\beta_0+\beta_{d0}+\beta_{categ2}+\beta_{categ2,d0}$ or $E(Y)=1.923285+0+.2278076+0=2.151093$.

Now, look at when $d=1$ and $categ=2$ then:

$E(Y)=\beta_0+\beta_{d1}+\beta_{categ2}+\beta_{categ2,d1}$ or $E(Y)=1.923285+.538603+.2278076-.0192817=2.670414$.