Hello everyone,
I am going through the Stata 13 syntax code for creating interaction effects (margins). Previously, I have used user-created code for estimating marginal effects and the accompanying standard errors taken from Franzese/Kam 2007 (Modeling and Interpreting Interactive Hypotheses in Regression Analysis). Since this procedure is quite cumbersome and time-intensive, I am trying to switch to the stata routines, especially since there are more readily available plots.
What I want to obtain is the following: Estimate a TSCS model (xtpcse, corr(ar1)), estimate and plot 3 two-way interactions (one between two continous variables, two between one continous and one dichotomous variable and plot the marginal effect alongside a histogram, which displays the distribution of the cases in order to gauge the substantive effects) and finally estimate and plot a three-way interaction between two continous and one dichotomos (dummy) variable.
Here is my code from an example code (simple regression model), which I use to illustrate my example:
reg zup_tota mlg corporat c.mlg#c.corporat gdpchang
summ mlg
local min1 = r(min)
local max1 = r(max)
local interval1 = round( (`max1'-`min1')/100, 0.01)
local range1 ""`min1'(`interval1')`max1'""
local at1 ""mlg = ("`range1'")""
margins, dydx(corporat) at ( `at1' ) vsquish
matrix t=r(table)'
capture: drop line* at*
svmat t, names(line)
egen at1 = fill(""`range1'"")
replace at1 = . if line1==.
graph twoway (histogram mlg, yaxis(2) color(gs12) ) (line line1 at1, yaxis(1) lpattern(solid) lwidth(medthick) )
(rline line5 line6 at1, yaxis(1) lpattern(dash) ),
graph export marginsplot_d_Success1_p1Gdgg_p1Gdvp.emf, replace
This is the code for a two-way continous variable interaction alongside a plot with a histogram.
How would I go about an interaction effect with a dichotomous (dummy) variable? I wouldn't need a plot of a marginal effect along a moderating variable, since the dummy variable only has two possible manifestations.
I think a plot similar to the one in the appendix would be best, how can I implement that in Stata 13 in light of the code I already have above? If I have that, I can continue with the code on the three-way interaction.
Any help is greatly appreciated!
I am going through the Stata 13 syntax code for creating interaction effects (margins). Previously, I have used user-created code for estimating marginal effects and the accompanying standard errors taken from Franzese/Kam 2007 (Modeling and Interpreting Interactive Hypotheses in Regression Analysis). Since this procedure is quite cumbersome and time-intensive, I am trying to switch to the stata routines, especially since there are more readily available plots.
What I want to obtain is the following: Estimate a TSCS model (xtpcse, corr(ar1)), estimate and plot 3 two-way interactions (one between two continous variables, two between one continous and one dichotomous variable and plot the marginal effect alongside a histogram, which displays the distribution of the cases in order to gauge the substantive effects) and finally estimate and plot a three-way interaction between two continous and one dichotomos (dummy) variable.
Here is my code from an example code (simple regression model), which I use to illustrate my example:
reg zup_tota mlg corporat c.mlg#c.corporat gdpchang
summ mlg
local min1 = r(min)
local max1 = r(max)
local interval1 = round( (`max1'-`min1')/100, 0.01)
local range1 ""`min1'(`interval1')`max1'""
local at1 ""mlg = ("`range1'")""
margins, dydx(corporat) at ( `at1' ) vsquish
matrix t=r(table)'
capture: drop line* at*
svmat t, names(line)
egen at1 = fill(""`range1'"")
replace at1 = . if line1==.
graph twoway (histogram mlg, yaxis(2) color(gs12) ) (line line1 at1, yaxis(1) lpattern(solid) lwidth(medthick) )
(rline line5 line6 at1, yaxis(1) lpattern(dash) ),
graph export marginsplot_d_Success1_p1Gdgg_p1Gdvp.emf, replace
This is the code for a two-way continous variable interaction alongside a plot with a histogram.
How would I go about an interaction effect with a dichotomous (dummy) variable? I wouldn't need a plot of a marginal effect along a moderating variable, since the dummy variable only has two possible manifestations.
I think a plot similar to the one in the appendix would be best, how can I implement that in Stata 13 in light of the code I already have above? If I have that, I can continue with the code on the three-way interaction.
Any help is greatly appreciated!
Comment