Announcement

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

  • DiD with fixed effects

    I have a dataset that looks like this, where town is the town id, t is time period, treatment is a dummy indicating if the town was treated or not, after is an indicator for when treatment started in t, and y is the outcome:
    Click image for larger version

Name:	data.JPG
Views:	1
Size:	39.6 KB
ID:	1596494


    I am trying to set up a panel DiD regression with town and t fixed effects. Is this the correct way to set up that panel regression (DiD with town and year fixed effects) in stata or am I missing something?
    xtset town t
    xtreg: xtreg y i.after##i.treatment, fe robust


    Any help would be very much appreciated since I am not very familiar with DiD models using fe and I have been unlucky so far finding an answer in the forum. Thank you!




  • #2
    Yes, this is a reasonable approach, assuming that, as in the example you show, it is always true that treatment begins in period 6 for all towns.

    If that is not the case, then it should be:
    Code:
    xtset town t
    xtreg y i.treatment#i.after /*note single #*/ i.t, fe
    which gives a generalized difference-in-differences estimator.

    You may also want to consider whether you need cluster robust variance estimation (-vce(cluster town)-) and whether there are other variables that should be included in the model. But the basic framework is that.

    In the future, when showing data examples, please use the -dataex- command to do so. If you are running version 16 or a fully updated version 15.1 or 14.2, -dataex- is already part of your official Stata installation. If not, run -ssc install dataex- to get it. Either way, run -help dataex- to read the simple instructions for using it. -dataex- will save you time; it is easier and quicker than typing out tables. It includes complete information about aspects of the data that are often critical to answering your question but cannot be seen from tabular displays or screenshots. It also makes it possible for those who want to help you to create a faithful representation of your example to try out their code, which in turn makes it more likely that their answer will actually work in your data.


    Comment


    • #3
      Dear Clyde,

      Thank you so much for the careful response and for the tips on how to post in the future. I truly appreciate your help with this and I wish you a great day ahead!

      Comment

      Working...
      X