Announcement

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

  • Diff in Diff for a matched sample

    Hello everyone,

    I am working on my thesis and would like to check if my Diff in Diff code is correct:


    Dependent Variable: I have one dummy and one continuous.
    Independant Variable: dummy variable
    Controls: CONTROL1 and CONTROL2
    Fixed Effect: Country, Industry and Year
    Clustering: at firm level (ID)

    I used the below code for my entire sample, and I am getting non-significant results and result contradicting prior research.
    I would appreciate it if you could tell me if this code is wrong:

    * Generate panel variable
    egen panel = group(COUNTRY INDUSTRY YearEnded)

    * Set panel data structure
    xtset panel

    * Fixed effects regression with reghdfe
    reghdfe DEPVAR_DUMMY i.INDVAR_DUMMY CONTROL1 CONTROL2, absorb(YearEnded INDUSTRY COUNTRY) vce(cluster ID)
    reghdfe DEPVAR_CONT i.INDVAR_DUMMY CONTROL1 CONTROL2, absorb(YearEnded INDUSTRY COUNTRY) vce(cluster ID)

    ----------------------- copy starting from the next line -----------------------
    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input str12 ID str25 COUNTRY int YearEnded float(INDVAR_DUMMY INDUSTRY DEPVAR_DUMMY DEPVAR_CONT CONTROL1 CONTROL2 panel)
    "AT0000A0E9W5" "AUSTRIA" 2011 1 4 0 .018158501 1.4508354e-06   -.6408805  1
    "AT0000A0E9W5" "AUSTRIA" 2012 1 4 0 .010819887 1.6463787e-06    .4787839  2
    "AT0000A00XX9" "AUSTRIA" 2013 1 4 0  .05179885 2.9177265e-06 -.015922926  3
    "AT0000A0E9W5" "AUSTRIA" 2013 1 4 0  .15087678 3.2949536e-06  -.54731053  3
    "AT0000A0E9W5" "AUSTRIA" 2014 1 4 0 .029307505  3.016278e-06  -.13406444  4
    "AT0000A0E9W5" "AUSTRIA" 2015 1 4 0 .024541363 2.0785521e-06   .10426443  5
    "AT0000A0E9W5" "AUSTRIA" 2016 1 4 0   .5931679 2.8788706e-06    .4271086  6
    "AT0000808209" "AUSTRIA" 2016 1 5 0  .04755795 .000011926285  -.08508099 10
    "AT0000A0E9W5" "AUSTRIA" 2017 1 4 0   .0381135 1.4186143e-06    .7145636  7
    "AT0000946652" "AUSTRIA" 2019 1 4 0  .07355142  9.947606e-07   .03514466  8
    "AT0000946652" "AUSTRIA" 2020 1 4 0   .1449236 1.0177748e-06  -.08289425  9
    "GRS371113002" "GREECE"  2011 1 4 0 .008094379 4.0178547e-06  -.07783944 11
    "CH0198251305" "GREECE"  2012 1 4 1   .0792848 1.0669667e-07   .06715062 12
    "GRS470003013" "GREECE"  2014 1 5 1  .02390172 1.8760026e-06   -.0395707 14
    "GRS260333000" "GREECE"  2015 1 5 0  .09092028 1.0553861e-07 .0004985356 15
    "GRS316003003" "GREECE"  2016 1 5 0 .068146005   2.74039e-06 -.016552616 16
    "GRS239003007" "GREECE"  2016 1 6 0  .02118119  3.472284e-06  -.02756531 19
    "GRS371113002" "GREECE"  2017 1 4 0  .07979685  6.022467e-06    .1616823 13
    "GRS316003003" "GREECE"  2017 1 5 0  .01215596  2.850361e-06   .08140419 17
    "GRS239003007" "GREECE"  2017 1 6 1   .0341728  3.277052e-06    .1990406 20
    "GRS239003007" "GREECE"  2019 1 6 1   .0488752 2.7273386e-06   -.1038168 21
    "GRS495003006" "GREECE"  2021 1 5 0  .13253261 5.6650543e-07    .1369414 18
    "AT0000A18XM4" "AUSTRIA" 2011 0 4 0   .1162596   2.56354e-06   .14337115  1
    "AT0000764626" "AUSTRIA" 2012 0 4 0  .13983518 2.9506366e-06   .06047976  2
    "AT0000762406" "AUSTRIA" 2013 0 4 0  .09486791 2.2260608e-06  -.16968694  3
    "AT0000922554" "AUSTRIA" 2013 0 4 1  .13533801 1.7568974e-06   .24266697  3
    "AT0000A00XX9" "AUSTRIA" 2014 0 4 1 .023363186  2.655334e-06  -.23707242  4
    "AT0000762406" "AUSTRIA" 2015 0 4 0  .02863175 2.2083325e-06   .41082165  5
    "AT0000762406" "AUSTRIA" 2016 0 4 1  .06054421  2.295456e-06  -.09278757  6
    "AT00000VIE62" "AUSTRIA" 2016 0 5 1  .07729094 4.8099065e-07  .021511994 10
    "AT0000785555" "AUSTRIA" 2017 0 4 0   .0987419  9.170525e-07   .14288542  7
    "AT0000837307" "AUSTRIA" 2019 0 4 0  .08285154  8.395476e-07   -.1201961  8
    "AT0000785555" "AUSTRIA" 2020 0 4 0 .010106214  1.268421e-06    .2317951  9
    "GRS300103009" "GREECE"  2011 0 4 0   .1570957  2.975871e-06    .1953435 11
    "GRS074083007" "GREECE"  2012 0 4 1   .0589695 2.3579595e-07  .019381227 12
    "GRS316003003" "GREECE"  2014 0 5 0  .04671111 1.9960487e-06  -.08188433 14
    "GRS496003005" "GREECE"  2015 0 5 0  .05448818  7.223308e-07  .032065466 15
    "GRS513003004" "GREECE"  2016 0 5 0 .036939748   2.79546e-06 -.033706553 16
    "GRS096003009" "GREECE"  2016 0 6 0 .032032546 2.1950693e-06  -.00739915 19
    "GRS074083007" "GREECE"  2017 0 4 0  .07480128  3.400548e-07   .07312657 13
    "GRS470003013" "GREECE"  2017 0 5 0  .06763208  2.629779e-06   .08179094 17
    "GRS096003009" "GREECE"  2017 0 6 0 .032597233 2.2640754e-06    .1620873 20
    "GRS403003007" "GREECE"  2019 0 6 0   .0821615 1.7852096e-06   .02309672 21
    "GRS359353000" "GREECE"  2021 0 5 0  .00430444  5.049148e-07  .032421682 18
    end
    ------------------ copy up to and including the previous line ------------------

    Listed 44 out of 44 observations







  • #2
    Maysam:
    1) how can you have two dependent variables?
    2) what is the treatment variable that separate controls (0) from the treated (1) group?
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      Hello Carlo Lazzaro ,
      Please see below:

      For question 1, I have two proxies for my dependent variable) I can either test my hypothesis through a dummy variable or through a continuous variable) so my analysis will include two different tests (a hypothetical example is old versus young or age as a number)
      For question 2, the treatment variable is the independent variable .INDVAR_DUMMY (in my study it is a dummy variable for whether a firm changed branch or no so treatment group is those who changed branches versus control group who are those firms that did not change)

      Looking forward to your support

      Comment


      • #4
        Maysam:
        I would take a look at -xtdidregress- to check if your model is correctly specified.
        Kind regards,
        Carlo
        (Stata 19.0)

        Comment


        • #5
          Nothing you've mentioned so far indicates your code is not correct. There's no reason even to suggest something is wrong with your data. The most I get is "Well this result wasn't significant and to contradicts prior work." Well okay, but so? Are your predictions negative when they should be positive (that is, did a company fire -500 employees last year)? Does the model predict 9000 doctors visits when the average is like, 2? Nothing you've mentioned suggests that there's a real issue here, beyond misspecification as Carlo said.

          Comment

          Working...
          X