Daniel-Pailanir / sdid

Synthetic Difference in Differences for Stata
GNU General Public License v3.0
74 stars 37 forks source link

Cohort Treatment and Covariate SE #45

Closed mldoucette1 closed 1 year ago

mldoucette1 commented 1 year ago

Hello Daniel,

Thanks so much for this Stata code, it is excellent! I had two questions: 1) Is it possible to identify the SE associated with each treatment year's ATT. For example, I run a staggered treatment timing model, call the e(tau) matrix and see the ATT associated with each treatment cohort/year. Is there a way to make inference to each group? 2) Similar question to the question above: In single or staggered adoption setting with covariates, is it possible to identify the SE associated with covariates?

Thanks again! Mitch Doucette Assistant Scientist, Johns Hopkins University mdoucet3@jhu.edu

Daniel-Pailanir commented 1 year ago

Hi Mitch,

1.- Yesterday I updated the sdid.ado to calculate the SE for any time of adoption. You can reinstall the command from github and it will access these values in the e(tau) post estimate sdid. At the moment a test version is available for bootstrap inference. Another way to get these SEs is to basically run the sdid command for any treatment period, as long as you have more than two units treated at each adoption time (for bootstrap).

For example, you can run an sdid manually like this:

webuse set www.damianclarke.net/stata/
matrix taus_se = J(2,2,.)
local i=1
local ty 2002 2003

foreach t of local ty {
    webuse quota_example.dta, clear
    egen m=min(year) if quota==1, by(country)
    egen mm=mean(m), by(country)
    keep if mm==`t' | mm==.
    if `t'==2002 | `t'==2003 {
        local stderr bootstrap
    }
    else local stderr placebo

    sdid womparl c year quota, vce(`stderr') reps(50) seed(1234)
    matrix taus_se[`i',1] = e(ATT)
    matrix taus_se[`i',2] = e(se)
    local ++i
}
matlist taus_se

             |        c1         c2 
-------------+----------------------
          r1 |  6.967746   .5372676 
          r2 |  13.95226    8.64151 

Or using the new e(tau) matrix:

webuse quota_example.dta, clear
egen m=min(year) if quota==1, by(country)
egen mm=mean(m), by(country)
keep if mm==2002 | mm==2003 | mm==.
sdid womparl c year quota, vce(bootstrap) reps(50) seed(1234)
matlist e(tau)

             |       Tau   Std.Err.       Time 
-------------+---------------------------------
          r1 |  6.967746   .5587125       2002 
          r2 |  13.95226   9.045572       2003 

2.- For covariates it depends on the process you use. If you are using the projected option, the easiest way is to run a pre-regression and get the SE directly. For example:

drop if lngdp==.
sdid womparl c year quota, vce(noinference) covariates(lngdp, projected)
matlist e(beta)

             |        c1 
-------------+-----------
       lngdp |  .0999577 

areg womparl lngdp i.year if mm==., abs(c)