three-way-interaction between two continuous and one binary variable using OLS stata

I'm facing difficulties in interpreting a three-way-interaction term. I'm using OLS and the three-way-interaction term is significant. Y is the response variable (continuous), X the predictor (independent) variable (continuous) and Z and W being moderator variables one is continuous and one binary. I would like to plot this interaction as calculating the effect on the dependent variable seems very hard.

I included all the variables in my regression (additionally there are more control variables included) The three-way-interaction term is significant. However, the other coefficients differ in significance, so that most of them are statistically insignificant.
$$Y = b_0 + b_1X + b_2Z + b_3W + b_4XZ + b_5XW + b_6ZW + b_7XZW$$ Does this influence the interpretation of the results?

I would really appreciate if someone could provide some codes in stata to plot this three-way-interaction term and help me interpret it. Thank you!

Linear regression                                      Number of obs =    9788
F( 41,  1969) =   17.33
Prob > F      =  0.0000
R-squared     =  0.1922
Root MSE      =  .06508

(Std. Err. adjusted for 1970 clusters in gvkey)
----------------------------------------------------------------------------------------------
|               Robust
fd_ROA |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-----------------------------+----------------------------------------------------------------
fd_log_cpi_compXFirm_MTBXSOX |  -.0076598   .0031574    -2.43   0.015     -.013852   -.0014677
fd_log_cpi_compXFirm_MTB |   .0021326   .0015181     1.40   0.160    -.0008447    .0051099
Firm_MTB_SOX |   .0025044   .0015647     1.60   0.110    -.0005642     .005573
fd_log_cpi_comp_SOX |   .0027981   .0067599     0.41   0.679    -.0104592    .0160554
SOX_incl |  -.0018292   .0039705    -0.46   0.645     -.009616    .0059576
fd_log_cpi_comp_w |   .0022321   .0039062     0.57   0.568    -.0054286    .0098928
• Could you show your obtained results -- N, standardized and unstandardized coefficients, standard errors, and p-values. Also, have you checked your predictors for collinearity? – rolando2 Jan 4 '15 at 19:16
• i added it to my question – Katharina Jan 4 '15 at 20:03

Suppose you have two continuous regressors (weight and miles per gallon) and one binary regressor (foreign manufacturer). The outcome is car price and you are interested in the effect of weight on price. You can get a sense of the interactions like this:

sysuse auto
reg price c.mpg##c.weight##i.foreign
margins, dydx(weight) at(foreign = (0 1) mpg =(10(10)40) weight = (2000(1000)3000))
marginsplot, bydimension(foreign weight)

Note that you can calculate interactions on the fly using factor variable notation. This ensures that Stata understands how all the variables are related in calculating derivative.

The expected price is

$$E[p \vert w,m,f]=\beta_0 + \beta_1 w + \beta_2 m + \beta_3 f +\beta_4 w\cdot m+\beta_5 w \cdot f +\beta_6m\cdot f + \beta_7 w\cdot m \cdot f$$

The derivative with respect to weight (aka the conditional marginal effect of weight) is

$$\frac{\partial E[p \vert w,m,f]}{\partial w}= \beta_1 + \beta_4 m+\beta_5 \cdot f + \beta_7 m \cdot f,$$

which is a linear function of foreign and mpg.

The margins command calculates this derivative evaluated at various combinations of foreign and mpg that I have selected, and marginsplot produces a graph of the derivative of the expected price with respect to weight for light and heavy domestic and foreign cars at various values of mileage. You could also have other regressors in the model, in which case the marginal effect would average over their effects: For instance, let's look at the first panel. For a very efficient light domestic car, an additional pound has negligible effect on the price. For an inefficient one, it adds \$6.50 to the price tag.

If you are interested in formally testing that these derivatives are different at various values of mpg, you can calculate contrasts of margins like this:

margins r.foreign, dydx(weight) at(mpg = (10(10)40))
marginsplot

This tests the null that the derivative of expected price with respect to weight is the same for foreign and domestic casts at various values of mpg. It also gives you an overall test that all four differences are jointly zero. It probably makes sense to make some adjustment for multiple comparisons, though I have not done that here.

A really nice introduction to these commands is Michael N. Mitchell's Interpreting and Visualizing Regression Models Using Stata. Chapter 13 deals with continuous by continuous by categorical interactions.