# How do I graphically represent the effect of a dummy variable?

Say I had a multiple regression model with two independent variables and one dummy variable, and I wanted to demonstrate the effect the dummy variable has on the dependent variable (and the other two explanatory variables), how can I graphically show the relationship? Is it okay to produce two graphs where each has a different explanatory variable on the x-axis (as such)? I'm just confused as most examples only involve one explanatory variable (thus involves one graph) and I feel like by regressing two different models (with different x-axis), I'm not really achieving my goal (which is to demonstrate the effect of the dummy variable on the dependent variable with regards to the entire model).

You can just plot the marginal effects from your model, which should produce something like this:

In a linear model, these are just the coefficients from the regression that tell you the change in price associated with a one-unit change in each control variable, holding the others constant. The figure also shows the 95% CI from the regression table.

Here's the code. Note that I rescaled the units of mpg and weight variables to make the graph a bit easier to read.

sysuse auto, clear
replace mpg = mpg/100
replace weight = weight/1000
reg price i.foreign c.mpg c.weight
margins, dydx(*)
marginsplot, horizontal xline(0)

• Consider also an added variables plot (in Stata, check out avplots or favplots from SSC). May 17 '20 at 6:58