Announcement

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

  • Difference in difference analysis

    Dear Stata forum, I am fairly new to STATA but am trying to carry out a DID analysis. I have watched some videos on Youtube and read the manual but still cannot fully understand how to set up the dataset. For context, I have carried out an experiment on campus for a class project over a period of two months. The aim of the project is to decrease the consumption of beef products. I have 1 control group (a cafe) and a treatment group (another cafe). I have data before and during the treatment. My variables include time (of the day), date, quantity of beef products sold. See below an example as to how I have coded the data so far:
    Date Treatment Cafe Quantitybeef
    0...........0............ 0........... 21
    0.......... 0............ 0........... 25
    1...........0............ 0........... etc
    1...........0............ 0
    0.......... 0............ 1
    0...........0............ 1
    1...........1.............1
    1...........1.............1

    I have used the stata command: didregress (Quantitybeef) (Treatment), group(Café) time(Date). However I am getting some strange results. Please could you provide some feedback on the best way to carry out a DID analysis in STATA given my context? Note, I have also tried carrying out the following code: reg Quantitybeef Treatment##Date.
    Many thanks for your help.
    Last edited by Samuel baker; 17 Aug 2023, 03:14.

  • #2
    Basis DID is:

    y = b0 + b1*post + b2*treated + d*post*treated

    post is the treatment period == 1
    treated is the group that is treated, which == 1 for all period if the group is treated (0 otherwise)
    post*treated is = 1 for the treated group during the treatment period

    I think, in this data,

    date == post
    Treatment == post*treated

    To keep the dicta proper,

    Code:
    g post = Date
    egen treated = max(Treatment), by(Cafe)
    reg Quantitybeef post treated c.post#c.treated

    Comment

    Working...
    X