Skip to content

NickCH-K/did

Repository files navigation

did

THIS PACKAGE IS LARGELY OUTDATED. INSTEAD SEE DRDID AND CSDID

NOTE: DUE TO AN RCALL UPDATE, SOME ELEMENTS OF THE AGGTE FUNCTION HAVE BROKEN IN WAYS THAT ARE VERY DIFFICULT TO FIX. UNTIL RCALL IS UPDATED AGAIN, AGGTE MAY NOT WORK. INSTEAD, AFTER RUNNING att_gt, DO rcall: aggte(CS_Model)

A Stata package that acts as a wrapper for Callaway and Sant'Anna's R did package. This makes heavy use of the rcall package by Haghish.

This package is fully functional, although it is also relatively untested and there may remain some bugs. Thankfully, since all the calculation is done in the R package, those bugs are more likely to give you no results than to give you wrong ones.

Functions included in this package:

  • did which does nothing but remind you to read the help file
  • didsetup to set up the appropriate packages so you can run the did R package
  • mpdta to load the mpdta example data from the did package
  • att_gt to estimate group-time treatment effects
  • aggte to estimate treatment effects aggregated to the group and/or time level
  • ggdid to produce graphs of either att_gt or aggte output
  • conditional_did_pretest to perform an integrated moments test of the conditional parallel trends assumption

You can install did with

net install did, from("https://raw.githubusercontent.com/NickCH-K/did/master/") replace

Make sure the R language is installed on your computer. Then run didsetup in Stata.

Citation

If you use this package, some citations are in order! BibTeX entries at at the bottom of this readme.

You should definitely cite the Callaway and Sant'Anna paper that describes the estimator used in this package:

Callaway, Brantly and Pedro H.C. Sant'Anna. "Difference-in-Differences with Multiple Time Periods." Forthcoming at the Journal of Econometrics, 2020.

The published version of the paper can be found here, and the ungated working paper is here.

You may also want to cite the Callaway and Sant'Anna R package that performs the estimation:

Callaway, Brantly and Pedro H.C. Sant'Anna. "did: Difference in Differences." R package version 2.0.0. https://bcallaway11.github.io/did/.

Finally, should you also cite this package, which acts purely as a Stata wrapper for their R package which actually does all the work? I don't know! There's not really a citation standard for this sort of thing. I certainly wouldn't mind it though. A few more years until tenure review, just sayin'.

Huntington-Klein, Nick. "'did': Use the Callaway and Sant'Anna R package 'did' in Stata." Stata package version 0.2.0. https://github.com/NickCH-K/did.

And if you're really feeling it (citing a dependency? Alas and alack we have no guide), there's also the rcall package, which allows me to use R from Stata. This package could not be built without it.

Haghish, E. F. "Seamless interactive language interfacing between R and Stata." The Stata Journal 19.1 (2019): 61-82.

BibTeX entries for citations:

@article{callaway2020difference,
  title={Difference-in-differences with Multiple Time Periods},
  author={Callaway, Brantly and Sant'Anna, Pedro H.C.},
  journal={Journal of Econometrics},
  year={2020},
  publisher={Elsevier}
}

@Misc{,
    title = {did: Difference in Differences},
    author = {Callaway, Brantly and Sant'Anna, Pedro H.C.},
    year = {2020},
    note = {R package version 2.0.0},
    url = {https://bcallaway11.github.io/did/},
 }
  
@Misc{,
    title = {'did': Use the Callaway and Sant'Anna R package 'did' in Stata},
    author = {Huntington-Klein, Nick},
    year = {2021},
    note = {Stata package version 0.2.0},
    url = {https://github.com/NickCH-K/did},
} 

@article{haghish2019seamless,
  title={Seamless Interactive Language Interfacing between R and Stata},
  author={Haghish, E.F.},
  journal={The Stata Journal},
  volume={19},
  number={1},
  pages={61--82},
  year={2019},
  publisher={SAGE Publications Sage CA: Los Angeles, CA}
}

About

A Stata package that acts as a wrapper for Callaway and Sant'anna's R did package

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published