Hi everybody,

I have Stata 11 - and I want to plot an interaction effect between a cont. variable and a dummy variable. I may be extremely stupid - but I can't find how to do that.

I mean all I want is the fitted regression line for my cont. variable depending whether my dummy is 0 or 1.

Can anyone help please?

Thomas

Today I received tremendous help on this and want to share the solution with you - just in case you are a Stata rookie like me.

**Imagine, our model looks like this:**
DV = alpha + ß1 predictor1(cont.) + ß2 predictor2(dummy) + ß3 predictor1*predictor2+ controls.

We want to

** visualize the interaction effect**.

This means in essence that we want to visualize the effect of predictor1 on the DV under two conditions: first, for predictor2 = 0 and second for predictor2 = 1, holding all other variables constant.

In essence,

**we want two regression lines**. One visualizes the effect of predictor1 on our DV, given predictor2=0. And the other one visualizes the effect, given predictor2=1.

For this, we

** run the regression** of the full model, including predictor1, predictor2, the interaction, and the controls.

Then we

**check the range** of predictor1, e.g. by using the codebook command. In my case, it is [-2.9;2.9].

Then we use this command:

*margins, at(predictor1=(-2.93(.5)2.93) predictor2=0) vsquish*
- predictor1 = my main predictor, continuous

- predictor2 = my main predictor, dummy

- .5 sets the increment and can be adjusted of course

- vsquish just makes sure that the table looks nice

This gives a

**table with the predicted DV values**, for each predictor1 value, given predictor2 = 0 and the other variables are set to their means (=neutralized).

Then we

**enter the command again, but with predictor2 =1**:

*margins, at(predictor1=(-2.93(.5)2.93) predictor2=1) vsquish*
**So, we get 2 tables with values for our two regression lines. Now we can plot them:**
If you have Stata 12, use the command marginsplot

If you have a lower version, copy these tables to excel and do it from there.

If the two lines have

**different slopes**, this visualizes the interaction effect.

best

Thomas