Announcement

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

  • Diff-in-Diff

    I am trying to do a diff-in-diff analysis on the effect of endorsement on a product. This is what my data set looks like:

    dates times price YeezyShoe date_of_purchase Yandhi_Release Ye_Release Kanye_Chicago
    April 2, 2019 3:55PM 128 0 21641 0 0 0

    At the moment, I have these commands in order to create treatment date ranges:
    gen date_of_purchase = date(dates, "MDY")
    gen byte Yandhi_Release=inrange(date_of_purchase,td(29sep20 18),td(3october2018))
    gen byte Ye_Release=inrange(date_of_purchase,td(01june2018) ,td(05june2018))
    gen byte Kanye_Chicago=inrange(date_of_purchase,td(15august 2018), td(19august2018))

    If the shoe is endorsed, YeezyShoe=1, and if the shoe is the control shoe, it is YeezyShoe=0.

    This is what my current diff-in-diff regression looks like; however, I am having a hard time isolating this effect and formulating a regression.

    gen treatXafter = Yandhi_Release * YeezyShoe

    reg __ YeezyShoe Yandhi_Release treatXafter

  • #2
    Except for some typos (like a blank space between 20 and 18 in -gen byte Yandhi_Release =;...-) the code looks OK. While I think you would be better off doing this with factor variable notation, what you have looks to me like it should work once you fill in the outcome variable in your -reg- command. So what exactly is your question? If you are unsure how to interpret your results, then post the results and ask about them.

    Comment


    • #3
      Thank you so much! I filled it in with price. Now I am looking to analyze frequency. However, the count function is giving quite a few errors. This is what I have so far:

      * Diff-in-Diff for Yandhi Release*
      gen treatXafter = Yandhi_Release * YeezyShoe

      reg price YeezyShoe Yandhi_Release treatXafter

      *Frequency of Purchase*
      gen date_freq = .
      sort date_of_purchase
      }

      forvalue i =21327(1)21641 {
      by date_of_purchase: count
      by date_of_purchase: replace date_freq=r(N) if date_of_purchase=i

      }

      by date_of_purchase: count
      by date_of_purchase: replace date_freq=count if date_of_purchase=i

      by dates: replace date_freq=count if dates

      Comment


      • #4
        Your question is, again, very unclear. First, -count- is not a function, it's a command. Next "it's giving a lot of errors" conveys no information: what errors is it giving? Is it throwing error messages? Is it producing output you think is wrong? When a command "isn't working" you need to show exactly what it is doing--by copy/pasting the command(s) and the output directly from Stata's Results window here into the Forum editor, surrounded by code delimiters, and doing so without editing it in any way. You need to show exactly what happened. In addition, if it isn't blatantly obvious why what you're getting is not what you want, you should explain what it is you want and how it differs from what you got. Remember that those who want to help you cannot see your computer screen and also cannot read your mind.

        Before you post back, be sure to read the entire Forum FAQ for excellent advice on how to ask clear questions that people might be able to answer, and how to most helpfully show information that is relevant to your questions.

        Comment

        Working...
        X