Announcement

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

  • Difference-in-difference with same group but three time periods

    Hello Statalist community.

    I have a question regarding a difference-in-difference regression I want to run. I assume that it is rater trivial, however, I have not yet been able to confidently solve my problem.

    In my research I am investigating the impact of a policy, which came into effect in 2005. The diff-in-diff regression I developed for the overall assessment his the following:

    (1) Pit = alpha ETSi + beta post + gamma ETSi * post + deltai + epsilont + zeta,

    where Pit is the patent output for a firm i in year t; ETSi is a dummy equal to one for a firm that becomes regulated in 2005; post is dummy equal to one for the post-treatment period; and ETSi * post is the interaction effect; deltai measures any firm fixed effects; epsilont measures common shock to firms; and zeta is the error term. The main coefficient of interest is gamma, which measures the policy effect onto the patent output of firms.

    Now I want to extend this formula to assess a policy refinement which came into action in 2008 and am wondering how to extend the model. I am interested in particular in assessing:
    1. The impact of phase 1 of the policy (2005-2007)
    2. The impact of phase 2 of the policy (2008-2012)
    3. The phase difference, i.e. is there a significant difference in the impact of phase 1 versus phase 2
    I have read quite some articles and posts now, but in each of them the extension of the diff-in-diff always considered multiple time periods (>2) and multiple groups (>2). In my case I study the same groups (=2) over multiple periods (=3; period 1 is the pre-phase, period 2 is phase 1 and period 3 is phase 2).

    My question is now: How do I extend this model? Can I just add a dummy and another interaction term (e.g. phase1 and phase2 for the first and second period as depicted below)?

    (2) Pit = alpha ETSi + beta phase1 + etaphase 2 + gamma ETSi * phase1 +theta ETSi * phase2 + iota ETSi * phase1 * phase2+ deltai + epsilont + zeta

    I assume that this is not possible but also do not know how to further continue. Any help would be appreciated!

    Thank you
    Lennart

  • #2
    Your equation in (2) is close, but not quite correct. There is no role for a phase1*phase2 interaction here. Putting it in terms of Stata code rather than modling equations, replace post with a new variable, phase taking on values of 0 (before 2005), 1 (2005-2008) and 2 (2009 and after). Then it's
    Code:
    regression_command  i.ets##i.phase
    You may want to use a Poisson model if patent output is a count variable.

    Your output will include ets#1.phase and ets#2.phase which will show you the policy effects in the two phases. If you need to estimate the incremental effect of phase 2 over phase 1, -lincom 1.ets#2.phase - 1.ets#1.phase- will do that.

    Comment


    • #3
      Hey Clyde.

      Thanks dor your fast reply and your input. I have, however, one question regarding the "no role for a phase1*phase2 interaction". If I am not mistaking this is exactly the term I need in order to tell if there is a significant difference between the two phases or not?

      I see that one can do that in the stata command you posted, but from an research perspective the "ETSi * phase1 * phase2"-interaction does provide insight, doesn't it?

      Comment


      • #4
        If I am not mistaking this is exactly the term I need in order to tell if there is a significant difference between the two phases or not?

        That is not correct. The difference in effect of ETS between phases1 and phase2 can be calculated after the regression with -lincom 1.ETS#2.phase - 1.ETS#1.phase-.

        Comment


        • #5
          Thank you Clyde!

          Comment


          • #6
            Hello Clyde.

            I actually have a follow-up question. When investigating the impact of ETS on regulated with focus on phase1 and phase2 does it make a difference if I consider two separate models;
            • one in the form of Pit = constant + alpha ETSi + beta phase1 + gamma ETSi * phase1 + error term;
            • and one as Pit = constant + alpha ETSi + beta phase2 + gamma ETSi * phase2 + error term
            as opposed to the initial (now slightly adapted) model:
            • Pit = constant alpha ETSi + beta phase1 + etaphase 2 + gamma ETSi * phase1 +theta ETSi * phase2 + error term?
            I have already tried running the two approaches on my data, and do get different results. However, I am unsure on how to proceed/ which model to use. From a gut feeling I would go with model 2. But I do not have the rationale yet. Here are the outputs:

            1. Model 1: Phase 1
            Code:
            . xtreg ff.logny02a i.phase1##i.regulated c.logfixedassets i.nace i.country i.year, re vce(robust)
            note: 2007.year omitted because of collinearity
            
            Random-effects GLS regression                   Number of obs     =      2,558
            Group variable: id                              Number of groups  =        292
            
            R-sq:                                           Obs per group:
                 within  = 0.0052                                         min =          3
                 between = 0.3718                                         avg =        8.8
                 overall = 0.2381                                         max =         13
            
                                                            Wald chi2(50)     =   14796.50
            corr(u_i, X)   = 0 (assumed)                    Prob > chi2       =     0.0000
            
                                                   (Std. Err. adjusted for 292 clusters in id)
            ----------------------------------------------------------------------------------
                             |               Robust
                 F2.logny02a |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
            -----------------+----------------------------------------------------------------
                    1.phase1 |   .0133674   .0134595     0.99   0.321    -.0130126    .0397475
                 1.regulated |   .0124237     .01965     0.63   0.527    -.0260897     .050937
                             |
            phase1#regulated |
                        1 1  |  -.0149683   .0073278    -2.04   0.041    -.0293305    -.000606
                             |
              logfixedassets |   .0062946   .0046155     1.36   0.173    -.0027516    .0153408
                             |
                        nace |
                          8  |   .0295195    .025145     1.17   0.240    -.0197637    .0788027
                          9  |   .0226541   .0221285     1.02   0.306     -.020717    .0660252
                         10  |   .0007359   .0194477     0.04   0.970    -.0373809    .0388528
                         11  |   .0751407   .0490337     1.53   0.125    -.0209636     .171245
                         13  |   .0206943   .0190202     1.09   0.277    -.0165846    .0579731
                         16  |  -.0367831   .0424824    -0.87   0.387    -.1200471    .0464809
                         17  |  -.0030339   .0078935    -0.38   0.701    -.0185049    .0124371
                         19  |   .0309622   .0232717     1.33   0.183    -.0146495    .0765738
                         20  |   .0052618   .0223821     0.24   0.814    -.0386062    .0491298
                         21  |   .0344537   .0249212     1.38   0.167     -.014391    .0832984
                         22  |   .0205479   .0220331     0.93   0.351    -.0226362     .063732
                         23  |   .0330384   .0291113     1.13   0.256    -.0240187    .0900955
                         24  |   .0048146   .0283774     0.17   0.865     -.050804    .0604332
                         27  |   1.499641   .1594019     9.41   0.000     1.187219    1.812063
                         35  |    .053705   .0359129     1.50   0.135    -.0166829     .124093
                         46  |     .05452   .0378229     1.44   0.149    -.0196114    .1286514
                         52  |    .027551    .020165     1.37   0.172    -.0119717    .0670737
                             |
                     country |
                         BE  |   .0600135   .0475906     1.26   0.207    -.0332625    .1532895
                         CZ  |   .0203294   .0171228     1.19   0.235    -.0132307    .0538896
                         DE  |   .1488191   .1248899     1.19   0.233    -.0959606    .3935988
                         DK  |    .067431   .0500688     1.35   0.178    -.0307021    .1655641
                         ES  |   .0648726   .0495248     1.31   0.190    -.0321941    .1619394
                         FI  |   .0624471   .0522493     1.20   0.232    -.0399596    .1648539
                         FR  |   .1264882   .0707032     1.79   0.074    -.0120875    .2650639
                         GB  |   .0738953   .0472081     1.57   0.118    -.0186307    .1664214
                         GR  |   .0581177   .0539086     1.08   0.281    -.0475412    .1637765
                         HU  |   .0745943   .0546557     1.36   0.172     -.032529    .1817175
                         LT  |   .0115627   .0127002     0.91   0.363    -.0133293    .0364546
                         LU  |   .0169191   .0158623     1.07   0.286    -.0141704    .0480085
                         LV  |   .0738389   .0624951     1.18   0.237    -.0486492    .1963269
                         NL  |   .0666722    .046564     1.43   0.152    -.0245917     .157936
                         PL  |   .0415554   .0333119     1.25   0.212    -.0237347    .1068455
                         PT  |   .0519191   .0391955     1.32   0.185    -.0249026    .1287408
                         SE  |    .037953   .0294571     1.29   0.198    -.0197818    .0956878
                         SK  |   .0491304   .0481171     1.02   0.307    -.0451774    .1434381
                             |
                        year |
                       2001  |  -.0069882   .0119384    -0.59   0.558    -.0303869    .0164106
                       2002  |  -.0069867   .0111234    -0.63   0.530    -.0287882    .0148147
                       2003  |  -.0017081   .0069346    -0.25   0.805    -.0152996    .0118835
                       2004  |   .0020224   .0133974     0.15   0.880     -.024236    .0282807
                       2005  |  -.0077994   .0092659    -0.84   0.400    -.0259601    .0103614
                       2006  |  -.0072135    .010202    -0.71   0.480     -.027209     .012782
                       2007  |          0  (omitted)
                       2008  |   .0058695   .0112409     0.52   0.602    -.0161623    .0279012
                       2009  |   .0042375   .0120256     0.35   0.725    -.0193323    .0278074
                       2010  |   .0025588   .0100639     0.25   0.799    -.0171661    .0222838
                       2011  |   .0045512   .0098443     0.46   0.644    -.0147433    .0238456
                       2012  |   .0079563   .0107417     0.74   0.459     -.013097    .0290095
                             |
                       _cons |  -.1995044   .1358757    -1.47   0.142    -.4658159    .0668071
            -----------------+----------------------------------------------------------------
                     sigma_u |  .19064217
                     sigma_e |   .0908882
                         rho |  .81480449   (fraction of variance due to u_i)
            ----------------------------------------------------------------------------------
            2. Model 1: Phase 2
            Code:
            . xtreg ff.logny02a i.phase2##i.regulated c.logfixedassets i.nace i.country i.year, re vce(robust)
            note: 2012.year omitted because of collinearity
            
            Random-effects GLS regression                   Number of obs     =      2,558
            Group variable: id                              Number of groups  =        292
            
            R-sq:                                           Obs per group:
                 within  = 0.0068                                         min =          3
                 between = 0.3712                                         avg =        8.8
                 overall = 0.2377                                         max =         13
            
                                                            Wald chi2(50)     =    9986.76
            corr(u_i, X)   = 0 (assumed)                    Prob > chi2       =     0.0000
            
                                                   (Std. Err. adjusted for 292 clusters in id)
            ----------------------------------------------------------------------------------
                             |               Robust
                 F2.logny02a |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
            -----------------+----------------------------------------------------------------
                    1.phase2 |  -.0017015   .0085029    -0.20   0.841    -.0183669    .0149638
                 1.regulated |    .000952   .0183539     0.05   0.959     -.035021     .036925
                             |
            phase2#regulated |
                        1 1  |   .0205303   .0102606     2.00   0.045       .00042    .0406407
                             |
              logfixedassets |    .006275   .0045192     1.39   0.165    -.0025824    .0151325
                             |
                        nace |
                          8  |   .0291419    .025348     1.15   0.250    -.0205394    .0788231
                          9  |   .0234723   .0229718     1.02   0.307    -.0215516    .0684961
                         10  |   .0010609   .0198651     0.05   0.957    -.0378739    .0399957
                         11  |   .0760429   .0492811     1.54   0.123    -.0205463    .1726322
                         13  |   .0202157   .0194505     1.04   0.299    -.0179067     .058338
                         16  |  -.0386286   .0425466    -0.91   0.364    -.1220184    .0447611
                         17  |  -.0029827   .0088106    -0.34   0.735    -.0202511    .0142856
                         19  |   .0318966   .0238646     1.34   0.181    -.0148771    .0786703
                         20  |   .0057222   .0228053     0.25   0.802    -.0389754    .0504199
                         21  |   .0339805   .0255763     1.33   0.184    -.0161481    .0841091
                         22  |   .0189264   .0225559     0.84   0.401    -.0252825    .0631352
                         23  |   .0326295   .0294844     1.11   0.268    -.0251588    .0904179
                         24  |   .0036279   .0289046     0.13   0.900    -.0530241    .0602798
                         27  |   1.498735   .1598873     9.37   0.000     1.185362    1.812109
                         35  |   .0536399   .0361805     1.48   0.138    -.0172725    .1245523
                         46  |   .0538329   .0379173     1.42   0.156    -.0204836    .1281495
                         52  |   .0277806   .0200447     1.39   0.166    -.0115063    .0670675
                             |
                     country |
                         BE  |   .0600684   .0479082     1.25   0.210      -.03383    .1539668
                         CZ  |   .0202702   .0179222     1.13   0.258    -.0148567    .0553971
                         DE  |   .1479962   .1248056     1.19   0.236    -.0966183    .3926106
                         DK  |   .0673784   .0508163     1.33   0.185    -.0322197    .1669766
                         ES  |   .0644111   .0496621     1.30   0.195    -.0329248    .1617471
                         FI  |   .0621114   .0526378     1.18   0.238    -.0410568    .1652796
                         FR  |   .1258693   .0709777     1.77   0.076    -.0132445    .2649831
                         GB  |   .0738029   .0478931     1.54   0.123    -.0200659    .1676718
                         GR  |   .0580609   .0541062     1.07   0.283    -.0479852     .164107
                         HU  |   .0747999   .0552713     1.35   0.176    -.0335299    .1831297
                         LT  |   .0115837   .0140885     0.82   0.411    -.0160291    .0391966
                         LU  |   .0183527   .0175732     1.04   0.296    -.0160902    .0527955
                         LV  |   .0718745   .0621992     1.16   0.248    -.0500337    .1937827
                         NL  |   .0651952   .0467231     1.40   0.163    -.0263804    .1567709
                         PL  |   .0407594   .0334929     1.22   0.224    -.0248856    .1064043
                         PT  |   .0506911   .0391788     1.29   0.196    -.0260981    .1274802
                         SE  |   .0375301   .0299911     1.25   0.211    -.0212514    .0963115
                         SK  |   .0496877   .0487384     1.02   0.308    -.0458377    .1452132
                             |
                        year |
                       2001  |   -.006089   .0119186    -0.51   0.609     -.029449    .0172711
                       2002  |  -.0062894   .0111076    -0.57   0.571      -.02806    .0154812
                       2003  |  -.0004765   .0070985    -0.07   0.946    -.0143894    .0134364
                       2004  |   .0038283   .0135206     0.28   0.777    -.0226715    .0303281
                       2005  |   -.000165   .0126669    -0.01   0.990    -.0249917    .0246617
                       2006  |   .0001751   .0104946     0.02   0.987    -.0203939    .0207442
                       2007  |   .0072316   .0114886     0.63   0.529    -.0152857    .0297489
                       2008  |  -.0017259   .0114739    -0.15   0.880    -.0242144    .0207626
                       2009  |  -.0036681   .0115081    -0.32   0.750    -.0262235    .0188873
                       2010  |  -.0048666   .0101063    -0.48   0.630    -.0246746    .0149413
                       2011  |  -.0032675   .0107629    -0.30   0.761    -.0243624    .0178274
                       2012  |          0  (omitted)
                             |
                       _cons |  -.1945269   .1334879    -1.46   0.145    -.4561584    .0671045
            -----------------+----------------------------------------------------------------
                     sigma_u |  .19052864
                     sigma_e |  .09081714
                         rho |  .81486076   (fraction of variance due to u_i)
            ----------------------------------------------------------------------------------
            3. Model 2: Two phases
            Code:
            . xtreg ff.logny02a i.phase1##i.regulated i.phase2##i.regulated c.logfixedassets i.nace i.country i.year, re
            note: 2007.year omitted because of collinearity
            note: 2012.year omitted because of collinearity
            
            Random-effects GLS regression                   Number of obs     =      2,558
            Group variable: id                              Number of groups  =        292
            
            R-sq:                                           Obs per group:
                 within  = 0.0070                                         min =          3
                 between = 0.3712                                         avg =        8.8
                 overall = 0.2377                                         max =         13
            
                                                            Wald chi2(51)     =     162.25
            corr(u_i, X)   = 0 (assumed)                    Prob > chi2       =     0.0000
            
            ----------------------------------------------------------------------------------
                 F2.logny02a |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
            -----------------+----------------------------------------------------------------
                    1.phase1 |   .0101241   .0127084     0.80   0.426    -.0147838    .0350321
                 1.regulated |    .003628   .0232477     0.16   0.876    -.0419366    .0491927
                             |
            phase1#regulated |
                        1 1  |  -.0060237   .0095852    -0.63   0.530    -.0248104    .0127629
                             |
                    1.phase2 |  -.0007034   .0132624    -0.05   0.958    -.0266972    .0252904
                             |
            phase2#regulated |
                        1 1  |   .0177127   .0092287     1.92   0.055    -.0003752    .0358006
                             |
              logfixedassets |   .0061981   .0027125     2.29   0.022     .0008817    .0115144
                             |
                        nace |
                          8  |   .0290016   .2104337     0.14   0.890    -.3834409    .4414441
                          9  |   .0234776   .2232734     0.11   0.916    -.4141303    .4610855
                         10  |   .0008864   .1643965     0.01   0.996    -.3213248    .3230976
                         11  |   .0757249    .251711     0.30   0.764    -.4176196    .5690694
                         13  |   .0203562   .1783219     0.11   0.909    -.3291482    .3698606
                         16  |  -.0384261   .2122432    -0.18   0.856    -.4544151     .377563
                         17  |  -.0031096   .1527952    -0.02   0.984    -.3025828    .2963636
                         19  |    .031958   .1917307     0.17   0.868    -.3438272    .4077432
                         20  |   .0056104    .167111     0.03   0.973    -.3219212    .3331419
                         21  |    .034443   .2133158     0.16   0.872    -.3836483    .4525343
                         22  |   .0191236   .2152575     0.09   0.929    -.4027734    .4410206
                         23  |   .0325302   .1607851     0.20   0.840    -.2826028    .3476632
                         24  |   .0037336   .1731251     0.02   0.983    -.3355853    .3430525
                         27  |   1.499119   .2132399     7.03   0.000     1.081177    1.917062
                         35  |   .0536362   .1613746     0.33   0.740    -.2626522    .3699245
                         46  |   .0537964    .233071     0.23   0.817    -.4030145    .5106072
                         52  |   .0276606   .2158841     0.13   0.898    -.3954644    .4507856
                             |
                     country |
                         BE  |   .0600377   .1493318     0.40   0.688    -.2326473    .3527226
                         CZ  |   .0202464   .1678742     0.12   0.904    -.3087809    .3492738
                         DE  |   .1480938   .1424192     1.04   0.298    -.1310428    .4272303
                         DK  |   .0677375    .171891     0.39   0.694    -.2691627    .4046377
                         ES  |   .0644635   .1407608     0.46   0.647    -.2114226    .3403495
                         FI  |   .0622976   .1711685     0.36   0.716    -.2731864    .3977817
                         FR  |   .1259783   .1460605     0.86   0.388    -.1602951    .4122517
                         GB  |   .0740235   .2003499     0.37   0.712    -.3186551    .4667021
                         GR  |   .0581592   .1969004     0.30   0.768    -.3277586     .444077
                         HU  |    .074964   .1997593     0.38   0.707     -.316557    .4664851
                         LT  |   .0116591   .1935566     0.06   0.952    -.3677048     .391023
                         LU  |   .0182345   .1934972     0.09   0.925     -.361013    .3974821
                         LV  |   .0723337   .1733379     0.42   0.676    -.2674023    .4120698
                         NL  |   .0655655   .1517265     0.43   0.666     -.231813     .362944
                         PL  |   .0407992   .1415842     0.29   0.773    -.2367007    .3182992
                         PT  |   .0509181   .1698178     0.30   0.764    -.2819187    .3837549
                         SE  |   .0376538   .1561086     0.24   0.809    -.2683135    .3436211
                         SK  |     .04975   .1967363     0.25   0.800    -.3358461    .4353461
                             |
                        year |
                       2001  |  -.0063204   .0123494    -0.51   0.609    -.0305247    .0178839
                       2002  |  -.0064758   .0117849    -0.55   0.583    -.0295737    .0166222
                       2003  |  -.0007683   .0113831    -0.07   0.946    -.0230788    .0215422
                       2004  |   .0034138   .0111773     0.31   0.760    -.0184933    .0253208
                       2005  |  -.0076782   .0086933    -0.88   0.377    -.0247168    .0093604
                       2006  |  -.0071781   .0087441    -0.82   0.412    -.0243162      .00996
                       2007  |          0  (omitted)
                       2008  |   -.001685   .0098269    -0.17   0.864    -.0209455    .0175754
                       2009  |  -.0036274   .0099309    -0.37   0.715    -.0230916    .0158368
                       2010  |  -.0048517   .0097169    -0.50   0.618    -.0238964     .014193
                       2011  |   -.003239   .0101769    -0.32   0.750    -.0231855    .0167074
                       2012  |          0  (omitted)
                             |
                       _cons |  -.1941572   .2185391    -0.89   0.374    -.6224859    .2341715
            -----------------+----------------------------------------------------------------
                     sigma_u |  .19093497
                     sigma_e |  .09082892
                         rho |  .81546365   (fraction of variance due to u_i)
            ----------------------------------------------------------------------------------
            It would be great if you could help
            Thank you
            Lennart

            Comment

            Working...
            X