Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to best combine/compare a multitude of conditional marginal effect plots

    I'm doing a marginal analysis on my fixed effects model and looking for best practice to compare conditional marginal effects. I would like to do this visually first. I want to inspect marginal effects of my continuous treatment variable at different percentiles given some levels of a factor variable (which comes from interaction in the model). I am looking for different marginal effects at the low and high end of my treatment variable moderated by a factor.

    In Brüderl/Ludwig, Panel Analysis, April 2019 https://www.google.com/url?sa=t&rct=...jnqtXTzPPwME3v

    I found the key term conditional effect plot which shows "AME of X conditional on values of Z to answer the question how AME of X change over values of Z".

    My best guess so far is to combine all elements in one plot as adjusted predictions which show different levels of my treatment and the interaction with my factor at ones. But I would rather like to plot marginal effects instead of/in addition to adjusted predictions.

    Code:
    * Load data
    use http://www.stata-press.com/data/r13/nlswork
    describe
    
    * Set panel structure
    xtset idcode year
    
    * Fixed effect model
    xtreg ln_wage c.wks_ue##i.occ_code c.wks_ue##c.wks_ue##i.occ_code, fe
    
    // Marginal analysis
    
    * Average marginal effects  
    margins, dydx(wks_ue)
    
    * Conditional marginal effect
    margins, dydx(wks_ue) at (occ_code = 3 wks_ue = 10)
    
    * Conditional marginal effect plot
    margins, dydx(wks_ue) at((mean)wks_ue occ_code = (1 2 3))
    marginsplot
    
    * Repeat conditional marginal effect plot over a list?!
    margins, dydx(wks_ue) at((p5)wks_ue occ_code = (1 2 3))
    marginsplot
    margins, dydx(wks_ue) at((p50)wks_ue occ_code = (1 2 3))
    marginsplot
    margins, dydx(wks_ue) at((p95)wks_ue occ_code = (1 2 3))
    marginsplot
    
    * What is not working unfortunately
    * margins, dydx(wks_ue) at((p5 p10 p50 p75)wks_ue occ_code = (1 2 3))
    * marginsplot
    
    * My best guess: Adjusted Predictions of different levels of my treatment and interaction factor
    margins occ_code, at(wks_ue=(0(10)70))
    marginsplot
    Thank you

  • #2
    You didn't get a quick answer. You will increase your chances of a useful answer by following the FAQ on asking questions – provide Stata code in code delimiters, readable Stata output, and sample data using dataex.

    The answer to your margins problem where you have a comment "what is not working unfortunately" is quite simple. Simply do summary wks_ue if e(sample),d and you will have the descriptive statistics on that variable. Then you can write it out at whatever values you want just like you've done for OCC.

    Three-way interactions can be hard to work with. Instead of offering three values for each of the interacting variables, I would go to two which reduces the complexity of the output. Since everything is linear they will have most of the information you need.

    I had a similar problem with a student paper this week and what we did was have v1 at two values and only do the margins for a given value v2, do the marginsplot, save that plot (copying and pasting into Word works). Then switch the value of v2, and do it again. Then you will have two plots each with two lines. Note that the vertical scale may differ across the two.

    Actually, if you only use two values for each of the interacting variables, you end up with simply four values for dydx and you can easily see the differences. If you post from the margin statement you can easily do tests.

    While many some prefer dydx margins, many of us prefer straight predictions.

    Comment

    Working...
    X