Announcement

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

  • Export the ATT from csdid (using outreg2)

    EDIT: made several changes to try to clarify what I meant.

    Hi everyone,

    My question is the following. I want to use the "csdid" command to generate event study estimates as well as the ATT estimate and p-value that is obtained through the command's "agg(simple)" option. I want to send them to a regression table and then plot them in a graph.
    The current replication code:

    Code:
    use "https://friosavila.github.io/playingwithstata/drdid/mpdta.dta", clear
    
    csdid lemp lpop , ivar(countyreal) time(year) gvar(first_treat) method(dripw) rseed(1) long2 agg(simple)
    mat reg_tab = r(table)
    local att_coef = string(round(reg_tab[1,1],0.001),"%9.3f")
    display `att_coef'
    local att_pval = string(round(reg_tab[4,1],0.001),"%9.3f")
    display `att_pval'
    
    csdid lemp lpop , ivar(countyreal) time(year) gvar(first_treat) method(dripw) rseed(1) long2 agg(event)
    outreg2 using "table2.xls", bdec(3) sdec(3) adec(3) nocons label replace ///
        addtext(Year FEs, Y, Municipality FEs, Y, Individual FEs, Y) ///
        addstat(ATT coef,`att_coef',ATT p-value,`att_pval') nonotes
    estimates store depvar_qp
    
    coefplot depvar_qp, ///
             drop(_cons Tm4 Pre_avg Post_avg) yline(0) xline(2.5) vertical ///
             ytitle(Regression coefficient) ylabel(-0.2(0.1)0.2, format(%9.1f)) ///
             xtitle(Years relative to treatment) ///
             coeflabels(Tm3 = "-3" Tm2 = "-2" Tp0 = "0" Tp1 = "1" Tp2= "2" Tp3= "3") ///
             text(0.15 5 "{bf:ATT = } `att_coef' (`att_pval')", placement(c) box fcolor(none))
    graph export "figure2.png", replace
    However, two problems:

    1) Is there a way to do this while running csdid only once? this is consequential because in reality I am using a very large dataset and each specification takes many hours to run.

    2) Why does "outreg2" not allow me to drop variables/parameters like "Tm4", but "coefplot" does?
    Last edited by Sergio Pinto; 12 Oct 2024, 11:42.

  • #2
    Code:
    csdid lemp lpop , ivar(countyreal) time(year) gvar(first_treat) method(dripw) rseed(1) long2 agg(attgt)
    estat simple
    estat event

    Comment


    • #3
      For this
      you can "save" the RIF, next time you do the analysis. Alternatively, you can also save it as you would do other commands
      est sto
      est save (ster file).

      If your data is large, try csdid2 (see on my repository)
      F

      Comment

      Working...
      X