Announcement

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

  • Difference-in-difference (DID) analysis in Stata

    Hello Stata experts,

    I am quite new to the use of Stata. Luckily I found this forum because I have a specific question and hope that you can help me with that. I use panel data (6 years, 400 groups) and would like to run a DID analysis (after 3 years there is a reform - so I want to compare 3 years before and 3 years after). However, I do not know how I should proceed. The information I found so far (forums, tutorials etc) is only superficial - I am always missing the practical execution part. Therefore, please could you help me set up a rudimentary DID procedure in Stata? Ultimately I want to interpret the effect of the reform on my dependent variable (yvar).

    That is how far I got. Obviously the important part is missing, but as I said, I do not know how to go on ...

    Code:
    gen treatment = new == 1
        gen after_reform = year > 2005
        gen interaction = treatment*after_reform
        regr yvar treatment reform interaction, robust
    Thank you very much. Best, Ronald
    Last edited by Ronald Biefinger; 22 Oct 2014, 14:16. Reason: DID

  • #2
    Your code looks fine, there isn't anything else to differences in differences. You should cluster your standard errors by group.
    Jorge Eduardo Pérez Pérez
    www.jorgeperezperez.com

    Comment


    • #3
      Thank you for your comment. But why should I use the "cluster" instead of the "robust" option? Would appreciate a clarification, thanks.

      Comment


      • #4
        You should use the cluster option because in differences in differences analysis errors may be correlated within group over time. The robust option in reg only corrects for heteroskedasticity but otherwise considers errors are independent across observations.
        Jorge Eduardo Pérez Pérez
        www.jorgeperezperez.com

        Comment


        • #5
          So the code should be regr yvar treatment reform interaction, vce (cluster id)?
          Does it correct for heteroskedasticity this way as well? Thank you.

          Comment


          • #6
            Yes, that should be the code, and it is robust to heteroskedasticity. The only assumption is independence across clusters.
            Jorge Eduardo Pérez Pérez
            www.jorgeperezperez.com

            Comment

            Working...
            X