Announcement

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

  • Graph of event study for multiple regressions using eventdd package

    Using the following command and using the data, you can use an event study graph for only one set of regressions, but I want to create the same graph for multiple regressions. So, I can show how for different groups the treatment is behaving differently ( like for low-education and high education people the treatment will have a different impact). With the following code, there will be one set of regression for either: low-education or high education. But, I want to edit the following code so that I can show in the same graph how both groups are behaving since the effect of treatment and before treatment. Right now my graph looks like this ( the attached image )

    BUT I WANT TO EDIT MY CURRENT CODE SO THAT FOR MULTIPLE GROUPS I CAN USE THE SAME REGRESSION TO PRODUCE THE GRAPH I'M GOING TO ATTACH IN THE COMMENT.

    Code:
    *** ssc install eventdd
    
    use "http://www.damianclarke.net/stata/bacon_example.dta", clear
    gen timeToTreat = year - _nfd
    eventdd asmrs pcinc asmrh cases i.year i.stfips, timevar(timeToTreat) method(ols, cluster(stfips))
    
    *Then storing the estimates
    
    estimates store leads_lags
    
    #delimit ;
    
    coefplot leads_lags, keep(lead5 lead4 lead3 lead2 lead1 lag_0 lag1 lag2 lag3 lag4 lag5plus)
    vertical title( "{stSerif:{bf:Figure 1. {it:Trends in On-Premises Alcohol Licenses}}}", color(black) size(large))
             xtitle("{stSerif:Years Since Law Came into Effect}") xscale(titlegap(2)) xline(6, lcolor(black))
    yline(-.2 0 .2 .4 .6, lwidth(vvvthin) lpattern(dash) lcolor(black))
    note("{stSerif:{it:Notes}. OLS coefficient estimates (and their 95% confidence intervals) are reported. The dependent}"
         "{stSerif:variable is equal to the number of on-premises liquor licences per 1,000 population in county {it:c}}"
         "{stSerif: and year {it:t}. The controls include year fixed effects and the data cover the period 1977-2011.}", margin(small))
    graphregion(fcolor(white) lcolor(white) lwidth(vvvthin) ifcolor(white) ilcolor(white)  
    ilwidth(vvvthin)) ciopts(lwidth(*3) lcolor(black)) mcolor(black) ;
    
    #delimit cr
    
    graph export "Anderson_Fig1_v1.png", as(png) replace
    Attached Files
    Last edited by Tariq Abdullah; 28 Feb 2022, 21:34.

  • #2
    This is the graph I want to create for multiple groups to show the different intensities of treatment by tweaking my command above but I'm not sure how. Any help or suggestions or guideline?
    Attached Files

    Comment


    • #3
      Hi Tariq,

      This post may give you a start. Look for suggestion by Nick in #8. You need to adapt the code to your data, but the idea is that you need to compute coefficients (e.g., V-Low achievers ... NV-High achievers) and their associated 95% CI for each year and then store these estimates using eststo or other commands. Once you have done that step and can apply Nick's code.

      https://www.statalist.org/forums/for...he-same-figure

      Comment


      • #4
        WoW ! Super helpful. I understand now what I need to do! Much obliged

        Comment


        • #5
          It seems that we could not plot multiple results by eventdd?

          Comment


          • #6
            Use the following code. It'll give you event study for multiple sample

            Code:
            webuse set www.damianclarke.net/stata/
            
            webuse bacon_example.dta, clear
            
            gen timeToTreat = year - _nfd
            
             eventdd asmrs pcinc asmrh cases i.year, timevar(timeToTreat) method(fe, cluster(stfips)) graph_op(ytitle("Suicides per 1m Women") xlabel(-20(5)25))
            
            
             matrix results = e(leads) \ e(lags)
            
            svmat results, names(event1)

            Comment


            • #7
              Hi Tariq Abdullah . Can you please give a detailed code on how to graph event study coefficients from multiple sample in one graph
              Last edited by Battle Orc; 04 Jun 2023, 22:45.

              Comment


              • #8
                Hello Battle Orc,

                For reference, we have recently incorporated extended functionality in eventdd which allows for event studies to be estimated and plotted over multiple some other variable. In the below code, I am providing an example of this. It should now be relatively simple to do what you are after using the over() option.

                Code:
                net install eventdd, from("https://raw.githubusercontent.com/damiancclarke/eventdd/master") replace
                
                webuse set www.damianclarke.net/stata/
                webuse quota_example.dta, clear
                
                * Generate indicator for GDP in bottom quartile to use for partitioning event study
                sum lngdp, d
                gen GDPp25 = lngdp<r(p25)
                
                * Generate time to adoption
                gen timeToTreat = year-quotaYear
                
                * Plot event study
                eventdd lnmmrt i.year, timevar(timeToTreat) method(hdfe, absorb(country) cluster(country)) lags(10) leads(10) accum over(GDPp25) jitter(0.2) graph_op(ytitle("ln(Maternal Mortality)") legend(pos(6) order(2 "Point Estimate (GDP {&ge} 25 p)" 5 "Point Estimate (GDP < 25 p)" 1 "95% CI") rows(1)) ylabel(, format("%04.2f"))) coef_op(g1(ms(Sh)) g2(ms(Oh))) ci(rarea, g1(color(gs12%30)) g2(color(gs12%50)))
                This generates the following output. If you would like to see further documentation, please refer to the github page here.
                Click image for larger version

Name:	quotasByGDP.png
Views:	1
Size:	91.6 KB
ID:	1736516


                Comment

                Working...
                X