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).


1 Answer 1


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

enter image description here

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)
  • $\begingroup$ Consider also an added variables plot (in Stata, check out avplots or favplots from SSC). $\endgroup$
    – Nick Cox
    Commented May 17, 2020 at 6:58

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.