Announcement

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

  • Coefplot with lincom estimates

    Hi,

    I am trying to create a coefplot to visualize heteregenous treatment effects by subgroups. I am able to do so if I run a regression per subgroup (see example 1). However, I would like for the figure to show identical results as my regression table, where the analysis is instead based on regressions with interaction for treatment and subgroup (see example 2). I have attempted xlincom, returning list, storing scalars etc., but somehow I am not managing to create the coding for the coefplot correctly. It seems to be returning the first xlincom estimate correctly (unsure about the standard error bars), but not the next xlincom estimates. Does anyone know what code could work? Thanks so much!

    T (treatment dummy). Male, conservative, lowinc and belowage are also dummies (0/1)

    Example 1 (working)

    preserve
    eststo clear
    eststo: reg DV i.T study1_r1 study1_r2 [pw=weight] if male==1
    eststo: reg DV i.T study1_r1 study1_r2 [pw=weight] if male==0
    eststo: reg DV i.T study1_r1 study1_r2 [pw=weight] if conservative==1
    eststo: reg DV i.T study1_r1 study1_r2 [pw=weight] if conservative==0
    eststo: reg DV i.T study1_r1 study1_r2 [pw=weight] if lowinc==1
    eststo: reg DV i.T study1_r1 study1_r2 [pw=weight] if lowinc==0
    eststo: reg DV i.T study1_r1 study1_r2 [pw=weight] if belowage==1
    eststo: reg DV i.T study1_r1 study1_r2 [pw=weight] if belowage==0
    local level=(1 - 2*ttail(e(df_r), 1))*100

    forvalues i = 1 / 1 {
    coefplot (est1 \ est2, bcolor(green%100)) (est3 \ est4, bcolor(red%100)) (est5 \ est6, bcolor(navy%100)) (est7 \ est8, bcolor(purple%100)), legend(off) citop ciopts(recast(rcap)) horizontal level(`level') xline(0) xlabel(-0.25(0.05)0.05) finten(40) drop(study1_r1 study1_r2 _cons) recast(bar) barwidth(0.8) aseq swapnames coeflabels(est1 = "Male" est2 = "Female" est3 = "Republican" est4 = "Non-Republican" est5 = "Low inc." est6 = "High inc." est7 = "Low age" est8 = "High age")
    }
    restore


    Example 2 (not working):

    preserve
    eststo clear
    eststo: reg DV T male male_T study1_r1 study1_r2 [pw=weight]
    eststo: xlincom T + male_T, post
    eststo: reg DV T conservative conservative_T study1_r1 study1_r2 [pw=weight]
    eststo: xlincom conservative + conservative_T, post
    eststo: reg DV T lowinc lowinc_T study1_r1 study1_r2 [pw=weight]
    eststo: xlincom T + lowinc_T, post
    eststo: reg DV T belowage belowage_T study1_r1 study1_r2 [pw=weight]
    eststo: xlincom T + belowage_T, post
    local level=(1 - 2*ttail(e(df_r), 1))*100

    forvalues i = 1 / 1 {
    coefplot (est1 \ est2, bcolor(green%100)) (est3 \ est4, bcolor(red%100)) (est5 \ est6, bcolor(navy%100)) (est7 \ est8, bcolor(purple%100)), legend(off) citop ciopts(recast(rcap)) horizontal level(`level') xline(0) xlabel(-0.25(0.05)0.05) finten(40) drop(study1_r1 study1_r2 _cons) recast(bar) barwidth(0.8) aseq swapnames coeflabels(est1 = "Male" est2 = "Female" est3 = "Republican" est4 = "Non-Republican" est5 = "Low inc." est6 = "High inc." est7 = "Low age" est8 = "High age")
    }
    restore

  • #2
    coefplot and xlincom are from SSC (FAQ Advice #12). You probably need to indicate that you are plotting a multiple equations model, but there is not much to go here from your codes and description. Best if you provide a reproducible example taking a small sample of your data. See the referenced FAQ Advice for more.

    Comment

    Working...
    X