Announcement

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

  • drdid (Callaway and Sant’Anna 2021 DD)

    Dear StataList-ers!
    Help! I need somebody!

    I am applying a DID in multiple treatment groups and multiple time periods. I examine the before-after effect of prostitution liberalization and prohibition on sexual crime in treatment countries compared to controls. I look at 2 subsamples – one consists of the countries that liberalized and the controls; the other one includes the countries that implemented a ban and the controls.
    For the sake of simplicity, I’ll focus on the “liberalizing” sample. The key independent variable “Liberalization” is an indicator variable, which takes the value of one beginning in the year when a country liberalizes its policy, and zero otherwise. The dependent variable, “Rape Rate” measures the number of rape cases per 100,000 population recorded at the national level. Country and years fixed effects are included and standard errors are clustered by country. "Treated" equals one if a country liberalized prostitution during the sample period, and zero otherwise. The baseline regression is:

    Code:
    reg rape_rate prositution_liberalization controls i.year i.country, robust cluster (country)
    The editor noted that I had implemented a standard DID even though I had heterogeneity in timing of treatment (although as a robustness check, I performed a Bacon decomposition) and suggested I implement “something like the Callaway and Sant’Anna 2021 DD method that allows for treatment at different time periods.” How do I do this? I already read the drdid help but I am still struggling.

    Code:
    drdid re rape_rate prostitution_liberalization controls ivar(country) time(year)
    Here is a simple data example:

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input long country int year byte prostitution_liberalization double raperate_2 float treated double(ln_gdp unemploymentrate ln_population)
    5 2006 0                  0 0 10.209868431091309  4.533 13.519813537597656
    5 2007 0        2.475989777 0 10.354137420654297    3.9 13.538328170776367
    5 2008 0                  0 0 10.474204063415527  3.642 13.562336921691895
    5 2009 0                  0 0 10.376792907714844  5.417 13.588521957397461
    5 2010 0                3.3 0 10.335868835449219  6.292 13.616010665893555
    5 2011 0                3.4 0  10.38077163696289  7.908 13.640860557556152
    5 2012 0                2.2 0 10.274530410766602 11.883 13.667023658752441
    5 2013 0                1.6 0 10.237897872924805 15.917 13.671499252319336
    5 2014 0                1.2 0 10.218327522277832  16.17 13.662359237670898
    5 2015 0                1.7 0 10.052433967590332   14.9 13.649465560913086
    5 2016 0               2.59 0   10.0718355178833   12.7 13.651012420654297
    5 2017 0 2.3399999141693115 0 10.135930061340332   10.4 13.658625602722168
    6 1990 0                8.6 0   8.27312183380127    2.3  16.15366554260254
    6 1991 0                7.4 0 7.9651007652282715    2.3 16.148101806640625
    6 1992 0                6.9 0   8.11732292175293    3.3  16.14887237548828
    6 1993 0                7.4 0  8.276838302612305    4.3    16.150146484375
    6 1994 0                7.1 0  8.434235572814941    4.3 16.150951385498047
    6 1995 0               7.03 0  8.663568496704102      4 16.150869369506836
    6 1996 0               6.57 0  8.778613090515137    3.9  16.14972496032715
    6 1997 0               6.36 0  8.698987007141113    4.8 16.148540496826172
    6 1998 0  6.553398058252427 0  8.773215293884277  6.479  16.14756965637207
    6 1999 0  6.155339805825243 0  8.749526023864746  8.756  16.14664649963379
    6 2000 0 4.8543689320388355 0  8.701448440551758  8.824 16.145524978637695
    6 2001 0  5.496870109546166 0  8.796218872070313  8.166 16.141033172607422
    6 2002 0  6.401333202627194 0  8.991300582885742  7.313  16.13801383972168
    6 2003 0        6.333751237 0  9.187390327453613  7.812 16.137176513671875
    6 2004 0        6.734194859 0  9.366137504577637  8.321 16.137441635131836
    6 2005 0        5.831338513 0  9.498985290527344  7.927 16.137786865234375
    6 2006 0        5.166298267 0  9.627973556518555  7.148 16.140207290649414
    6 2007 0        6.176355805 0  9.818673133850098   5.32  16.14320182800293
    6 2008 0        5.097636113 0 10.030069351196289  4.392   16.1518611907959
    6 2009 0        4.597817856 0  9.890482902526856  6.662 16.159791946411133
    6 2010 0                5.3 0  9.893844604492188  7.279  16.16326904296875
    6 2011 0               6.09 0  9.985871315002441  6.711 16.165620803833008
    6 2012 0               6.06 0  9.889888763427734  6.978 16.167404174804687
    6 2013 0               5.67 0  9.899279594421387  6.953 16.168420791625977
    6 2014 0               6.43 0  9.890633583068848    6.1 16.168067932128906
    6 2015 0               5.56 0  9.782201766967773      5  16.17052459716797
    6 2016 0               6.15 0   9.82464599609375    3.5   16.1716365814209
    6 2017 0  5.650000095367432 0  9.921727180480957    2.4 16.174476623535156
    7 1990 0                9.5 1 10.199563026428223  7.167 15.451669692993164
    7 1991 0               10.3 1  10.20401382446289  7.867 15.453821182250977
    7 1992 0               10.8 1 10.294504165649414  8.608  15.45685863494873
    7 1993 0                9.6 1 10.225497245788574  9.533 15.460433959960938
    7 1994 0                9.2 1 10.308804512023926  7.733 15.463522911071777
    7 1995 0               8.42 1 10.473093032836914  6.758  15.46718692779541
    7 1996 0               7.37 1 10.481524467468262  6.317 15.473934173583984
    7 1997 0               8.23 1  10.39927864074707  5.242 15.478511810302734
    7 1998 0  7.885304659498208 1  10.41535758972168  4.883 15.482247352600098
    7 1999 1  8.967851099830796 1 10.417531967163086  5.108   15.4857759475708
    7 2000 1   9.31409295352324 1 10.333436012268066  4.317 15.488865852355957
    7 2001 1  9.199477514461654 1 10.333699226379395  4.508 15.492460250854492
    7 2002 1  9.304056568663938 1 10.411169052124023  4.642 15.496031761169434
    7 2003 1         8.76592329 1 10.608038902282715  5.433  15.49885082244873
    7 2004 1        10.40686779 1 10.747457504272461  5.517 15.501472473144531
    7 2005 1        8.764736752 1  10.79548168182373    4.8 15.504019737243652
    7 2006 1        9.682793877 1 10.859518051147461    3.9  15.50698184967041
    7 2007 1        8.995946339 1 10.976560592651367  3.767 15.510590553283691
    7 2008 1        7.203520557 1  11.07165813446045  3.458 15.515847206115723
    7 2009 1        6.371186022 1 10.971010208129883  5.992   15.5223388671875
    7 2010 1              16.37 1 10.968912124633789  7.475 15.526555061340332
    7 2011 1              15.09 1 11.030908584594727  7.567 15.531221389770508
    7 2012 1              14.64 1 10.976910591125488  7.542 15.534791946411133
    7 2013 1              14.05 1 11.021758079528809  7.008 15.538745880126953
    7 2014 1              13.99 1 11.043704986572266  6.533 15.543128967285156
    7 2015 1              16.54 1 10.878292083740234    6.2 15.548884391784668
    7 2016 1              29.42 1 10.888908386230469    6.1 15.557204246520996
    7 2017 1 31.360000610351563 1 10.938583374023438    5.3 15.564536094665527
    8 1990 0                3.4 0  8.141772270202637     .6   14.2669677734375
    8 1991 0                3.9 0  8.184234619140625    1.5 14.265151023864746
    8 1992 0                4.7 0   8.82204818725586    3.7  14.25690746307373
    8 1993 0                6.9 0  8.849539756774902    6.5 14.228483200073242
    8 1994 0                8.3 0  8.911251068115234    7.6 14.205491065979004
    8 1995 0               6.87 0  8.021053314208984    9.7 14.185745239257812
    8 1996 0               6.41 0  8.117531776428223     10 14.169816970825195
    8 1997 0               6.65 0    8.1942138671875    9.6 14.156256675720215
    8 1998 0   3.76947860287476 0  8.307038307189941    9.8  14.14702320098877
    8 1999 0 4.2547974644291715 0  8.323450088500977   12.2 14.137041091918945
    8 2000 0  5.332359386413441 0  8.311406135559082 14.602 14.152874946594238
    8 2001 0                5.5 0  8.411601066589356 13.009 14.146769523620605
    8 2002 0               6.56 0  8.577035903930664 11.227  14.14013385772705
    8 2003 0        7.914464609 0  8.878252029418945 10.342 14.134102821350098
    8 2004 0        8.973272256 0  9.088225364685059  10.14 14.127580642700195
    8 2005 0        13.30007571 0  9.243612289428711  8.031 14.122149467468262
    8 2006 0        11.38360671 0   9.44108772277832  5.912 14.116133689880371
    8 2007 0        9.084999103 0  9.716339111328125  4.592 14.110357284545898
    8 2008 0        11.92121567 0  9.803365707397461  5.455 14.107015609741211
    8 2009 0        9.242495504 0  9.597391128540039 13.549 14.104995727539063
    8 2010 0         6.03963792 0   9.59141731262207 16.707  14.10315990447998
    8 2011 0                6.9 0  9.767372131347656 12.325 14.100434303283691
    8 2012 0               10.8 0  9.765482902526856 10.023 14.097086906433105
    8 2013 0               10.2 0  9.855989456176758  8.628 14.093274116516113
    8 2014 0               11.2 0   9.90096378326416  7.013 14.089969635009766
    8 2015 0               12.3 0  9.750096321105957    6.2 14.089248657226563
    8 2016 0              11.55 0   9.78339672088623    6.4 14.090106964111328
    8 2017 0 11.399999618530273 0   9.88861083984375    5.7 14.090106964111328
    9 1990 0                7.6 0 10.253458976745605    3.2 15.419812202453613
    9 1991 0                7.5 0 10.146559715270996  6.606 15.424644470214844
    9 1992 0                7.3 0 10.014021873474121 11.725 15.430731773376465
    9 1993 0                7.2 0   9.77662181854248 16.357 15.435884475708008
    end
    label values country country
    label def country 5 "Cyprus", modify
    label def country 6 "CzechRepublic", modify
    label def country 7 "Denmark", modify
    label def country 8 "Estonia", modify
    label def country 9 "Finland", modify
    Thank You in advance!

  • #2
    Hi Vania
    Actually it is not drdid what you need, but csdid. (side note drdid is what works behind csdid)
    So, if you have both packages installed, the only thing you need to do is the following:
    Code:
    csdid rape_rate controls , ivar(country) time(year) gvar(xxx)
    So the only thing left to define here is your "gvar". WHich should be the first year treatment occured in the country. if you do not know how to create this variable, you can try with a command that was included in the last update:
    Code:
    egen gvar= prostitution_liberalization, tvar(year) ivar(country)
    All of this assumes that prostitution_liberalization=1 if the treatment is effectively in place, and 0 otherwise.

    HTH
    Fernando

    Comment


    • #3
      Hi Fernando,
      Thanks heaps - this is super helpful! I am very grateful.

      Unfortunately, when I try to generate the gvar (running your "egen"), I'm stumbling upon the following error: "unknown egen function prostitution_liberalization() r(133)." Any idea how to solve this? Alternatively, can I circumvent the egen function an just generate the gvar in a more 'profane' way (manually?). The gvar should = 0 for the never treated and = 1 for the first year of liberalization (2, 3, 4, for the following years), is this correct?

      Once again, thank You for the invaluable help! Best,
      Vanya

      Comment


      • #4
        Hey Vania, show the exact code you used for Stata to give the error please

        Comment


        • #5
          Hi Vania,
          So sorry, that was my typo.
          and I realized the program I had on ssc had a bug as well. So please use the one I'm adding here, and copy it into your ado/personal folder
          After doing so, the syntax should be

          Code:
          csgvar gvar= prostitution_liberalization, tvar(year) ivar(country)
          Attached Files

          Comment


          • #6
            Hi Fernando,
            No worries an thanks again for the help.

            Actually, I didn't have "personal" in "ado". I tried with
            Code:
            mkdir `"`c(sysdir_personal)'"'
            and then just copied your file into the C:\ado\personal.

            However, after running your
            Code:
             
             csgvar gvar= prostitution_liberalization, tvar(year) ivar(country)
            I am bumping into the following:
            unexpected end of file
            (error occurred while loading csgvar.ado)
            r(612);


            What am I doing wrong? Best,
            Vanya

            Comment


            • #7
              Here's what you want to do: download the user written adoedit command, and you can edit commands from the do file editor. You'll need to save and run the do file again so the changes will happen, but you likely don't need to have a personal directory.

              Comment


              • #8
                Thanks, Jared!

                That worked perfectly! Thank you both!

                Comment


                • #9
                  Hi Vania,
                  Im glad you worked this out.
                  and for future references (if anyone is looking at this problem)
                  in PC, one can always set a personal folder at " C:\ado\personal "

                  Comment


                  • #10
                    Hi Fernando,
                    Thank You for the help - it's truly invaluable to me! Much appreciated!

                    After generating the gvar, I ran the following:
                    Code:
                    csdid raperate_2 prostitution_liberalization ln_gdp ln_population unemploymentrate Womenper100men police_population migrant_population GII, ivar(country) time(year) gvar(gvar)
                    However, the outcome is:

                    Code:
                    Panel is not balanced
                    Will use observations with Pair balanced (observed at t0 and t1)
                    xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
                    xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
                    xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
                    xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
                    Difference-in-difference with Multiple Time Periods
                    
                                                                    Number of obs     =          0
                    Outcome model  : weighted least squares
                    Treatment model: inverse probability tilting
                    ------------------------------------------------------------------------------
                                 |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
                    -------------+----------------------------------------------------------------
                    g1995        |
                     t_1990_1991 |          0  (omitted)
                     t_1991_1992 |          0  (omitted)
                     t_1992_1993 |          0  (omitted)
                     t_1993_1994 |          0  (omitted)
                     t_1994_1995 |          0  (omitted)
                     t_1994_1996 |          0  (omitted)
                     t_1994_1997 |          0  (omitted)
                     t_1994_1998 |          0  (omitted)
                     t_1994_1999 |          0  (omitted)
                     t_1994_2000 |          0  (omitted)
                     t_1994_2001 |          0  (omitted)
                     t_1994_2002 |          0  (omitted)
                     t_1994_2003 |          0  (omitted)
                     t_1994_2004 |          0  (omitted)
                     t_1994_2005 |          0  (omitted)
                     t_1994_2006 |          0  (omitted)
                     t_1994_2007 |          0  (omitted)
                     t_1994_2008 |          0  (omitted)
                     t_1994_2009 |          0  (omitted)
                     t_1994_2010 |          0  (omitted)
                     t_1994_2011 |          0  (omitted)
                     t_1994_2012 |          0  (omitted)
                     t_1994_2013 |          0  (omitted)
                     t_1994_2014 |          0  (omitted)
                     t_1994_2015 |          0  (omitted)
                     t_1994_2016 |          0  (omitted)
                     t_1994_2017 |          0  (omitted)
                    -------------+----------------------------------------------------------------
                    What should I do? Indeed, my data is unbalanced - I have some missing years (in which there is no data on rape rate). How to proceed? Here is a data example too:

                    Code:
                    * Example generated by -dataex-. To install: ssc install dataex
                    clear
                    input long country int year float gvar double raperate_2 byte prostitution_liberalization double(ln_gdp ln_population unemploymentrate)
                    5 2006    0                  0 0 10.209868431091309 13.519813537597656  4.533
                    5 2007    0        2.475989777 0 10.354137420654297 13.538328170776367    3.9
                    5 2008    0                  0 0 10.474204063415527 13.562336921691895  3.642
                    5 2009    0                  0 0 10.376792907714844 13.588521957397461  5.417
                    5 2010    0                3.3 0 10.335868835449219 13.616010665893555  6.292
                    5 2011    0                3.4 0  10.38077163696289 13.640860557556152  7.908
                    5 2012    0                2.2 0 10.274530410766602 13.667023658752441 11.883
                    5 2013    0                1.6 0 10.237897872924805 13.671499252319336 15.917
                    5 2014    0                1.2 0 10.218327522277832 13.662359237670898  16.17
                    5 2015    0                1.7 0 10.052433967590332 13.649465560913086   14.9
                    5 2016    0               2.59 0   10.0718355178833 13.651012420654297   12.7
                    5 2017    0 2.3399999141693115 0 10.135930061340332 13.658625602722168   10.4
                    6 1990    0                8.6 0   8.27312183380127  16.15366554260254    2.3
                    6 1991    0                7.4 0 7.9651007652282715 16.148101806640625    2.3
                    6 1992    0                6.9 0   8.11732292175293  16.14887237548828    3.3
                    6 1993    0                7.4 0  8.276838302612305    16.150146484375    4.3
                    6 1994    0                7.1 0  8.434235572814941 16.150951385498047    4.3
                    6 1995    0               7.03 0  8.663568496704102 16.150869369506836      4
                    6 1996    0               6.57 0  8.778613090515137  16.14972496032715    3.9
                    6 1997    0               6.36 0  8.698987007141113 16.148540496826172    4.8
                    6 1998    0  6.553398058252427 0  8.773215293884277  16.14756965637207  6.479
                    6 1999    0  6.155339805825243 0  8.749526023864746  16.14664649963379  8.756
                    6 2000    0 4.8543689320388355 0  8.701448440551758 16.145524978637695  8.824
                    6 2001    0  5.496870109546166 0  8.796218872070313 16.141033172607422  8.166
                    6 2002    0  6.401333202627194 0  8.991300582885742  16.13801383972168  7.313
                    6 2003    0        6.333751237 0  9.187390327453613 16.137176513671875  7.812
                    6 2004    0        6.734194859 0  9.366137504577637 16.137441635131836  8.321
                    6 2005    0        5.831338513 0  9.498985290527344 16.137786865234375  7.927
                    6 2006    0        5.166298267 0  9.627973556518555 16.140207290649414  7.148
                    6 2007    0        6.176355805 0  9.818673133850098  16.14320182800293   5.32
                    6 2008    0        5.097636113 0 10.030069351196289   16.1518611907959  4.392
                    6 2009    0        4.597817856 0  9.890482902526856 16.159791946411133  6.662
                    6 2010    0                5.3 0  9.893844604492188  16.16326904296875  7.279
                    6 2011    0               6.09 0  9.985871315002441 16.165620803833008  6.711
                    6 2012    0               6.06 0  9.889888763427734 16.167404174804687  6.978
                    6 2013    0               5.67 0  9.899279594421387 16.168420791625977  6.953
                    6 2014    0               6.43 0  9.890633583068848 16.168067932128906    6.1
                    6 2015    0               5.56 0  9.782201766967773  16.17052459716797      5
                    6 2016    0               6.15 0   9.82464599609375   16.1716365814209    3.5
                    6 2017    0  5.650000095367432 0  9.921727180480957 16.174476623535156    2.4
                    7 1990 1999                9.5 0 10.199563026428223 15.451669692993164  7.167
                    7 1991 1999               10.3 0  10.20401382446289 15.453821182250977  7.867
                    7 1992 1999               10.8 0 10.294504165649414  15.45685863494873  8.608
                    7 1993 1999                9.6 0 10.225497245788574 15.460433959960938  9.533
                    7 1994 1999                9.2 0 10.308804512023926 15.463522911071777  7.733
                    7 1995 1999               8.42 0 10.473093032836914  15.46718692779541  6.758
                    7 1996 1999               7.37 0 10.481524467468262 15.473934173583984  6.317
                    7 1997 1999               8.23 0  10.39927864074707 15.478511810302734  5.242
                    7 1998 1999  7.885304659498208 0  10.41535758972168 15.482247352600098  4.883
                    7 1999 1999  8.967851099830796 1 10.417531967163086   15.4857759475708  5.108
                    7 2000 1999   9.31409295352324 1 10.333436012268066 15.488865852355957  4.317
                    7 2001 1999  9.199477514461654 1 10.333699226379395 15.492460250854492  4.508
                    7 2002 1999  9.304056568663938 1 10.411169052124023 15.496031761169434  4.642
                    7 2003 1999         8.76592329 1 10.608038902282715  15.49885082244873  5.433
                    7 2004 1999        10.40686779 1 10.747457504272461 15.501472473144531  5.517
                    7 2005 1999        8.764736752 1  10.79548168182373 15.504019737243652    4.8
                    7 2006 1999        9.682793877 1 10.859518051147461  15.50698184967041    3.9
                    7 2007 1999        8.995946339 1 10.976560592651367 15.510590553283691  3.767
                    7 2008 1999        7.203520557 1  11.07165813446045 15.515847206115723  3.458
                    7 2009 1999        6.371186022 1 10.971010208129883   15.5223388671875  5.992
                    7 2010 1999              16.37 1 10.968912124633789 15.526555061340332  7.475
                    7 2011 1999              15.09 1 11.030908584594727 15.531221389770508  7.567
                    7 2012 1999              14.64 1 10.976910591125488 15.534791946411133  7.542
                    7 2013 1999              14.05 1 11.021758079528809 15.538745880126953  7.008
                    7 2014 1999              13.99 1 11.043704986572266 15.543128967285156  6.533
                    7 2015 1999              16.54 1 10.878292083740234 15.548884391784668    6.2
                    7 2016 1999              29.42 1 10.888908386230469 15.557204246520996    6.1
                    7 2017 1999 31.360000610351563 1 10.938583374023438 15.564536094665527    5.3
                    8 1990    0                3.4 0  8.141772270202637   14.2669677734375     .6
                    8 1991    0                3.9 0  8.184234619140625 14.265151023864746    1.5
                    8 1992    0                4.7 0   8.82204818725586  14.25690746307373    3.7
                    8 1993    0                6.9 0  8.849539756774902 14.228483200073242    6.5
                    8 1994    0                8.3 0  8.911251068115234 14.205491065979004    7.6
                    8 1995    0               6.87 0  8.021053314208984 14.185745239257812    9.7
                    8 1996    0               6.41 0  8.117531776428223 14.169816970825195     10
                    8 1997    0               6.65 0    8.1942138671875 14.156256675720215    9.6
                    8 1998    0   3.76947860287476 0  8.307038307189941  14.14702320098877    9.8
                    8 1999    0 4.2547974644291715 0  8.323450088500977 14.137041091918945   12.2
                    8 2000    0  5.332359386413441 0  8.311406135559082 14.152874946594238 14.602
                    8 2001    0                5.5 0  8.411601066589356 14.146769523620605 13.009
                    8 2002    0               6.56 0  8.577035903930664  14.14013385772705 11.227
                    8 2003    0        7.914464609 0  8.878252029418945 14.134102821350098 10.342
                    8 2004    0        8.973272256 0  9.088225364685059 14.127580642700195  10.14
                    8 2005    0        13.30007571 0  9.243612289428711 14.122149467468262  8.031
                    8 2006    0        11.38360671 0   9.44108772277832 14.116133689880371  5.912
                    8 2007    0        9.084999103 0  9.716339111328125 14.110357284545898  4.592
                    8 2008    0        11.92121567 0  9.803365707397461 14.107015609741211  5.455
                    8 2009    0        9.242495504 0  9.597391128540039 14.104995727539063 13.549
                    8 2010    0         6.03963792 0   9.59141731262207  14.10315990447998 16.707
                    8 2011    0                6.9 0  9.767372131347656 14.100434303283691 12.325
                    8 2012    0               10.8 0  9.765482902526856 14.097086906433105 10.023
                    8 2013    0               10.2 0  9.855989456176758 14.093274116516113  8.628
                    8 2014    0               11.2 0   9.90096378326416 14.089969635009766  7.013
                    8 2015    0               12.3 0  9.750096321105957 14.089248657226563    6.2
                    8 2016    0              11.55 0   9.78339672088623 14.090106964111328    6.4
                    8 2017    0 11.399999618530273 0   9.88861083984375 14.090106964111328    5.7
                    9 1990    0                7.6 0 10.253458976745605 15.419812202453613    3.2
                    9 1991    0                7.5 0 10.146559715270996 15.424644470214844  6.606
                    9 1992    0                7.3 0 10.014021873474121 15.430731773376465 11.725
                    9 1993    0                7.2 0   9.77662181854248 15.435884475708008 16.357
                    end
                    label values country country
                    label def country 5 "Cyprus", modify
                    label def country 6 "CzechRepublic", modify
                    label def country 7 "Denmark", modify
                    label def country 8 "Estonia", modify
                    label def country 9 "Finland", modify
                    In this train of thought, shouldn't the gvar be zero (for the untreated) and one, two, three, etc. (for the treated, starting from the first year when treated) or I got it wrong?

                    Thanks heaps! Fruitful new week,
                    Vanya

                    Comment


                    • #11
                      Hi Vanya
                      1. I think you should have this installed but if not. Please make sure drdid is already in your computer.
                      2. Gvar should be zero for the never treated, but year when they were treated for the treated. For example, country 7 is treated in 1999.
                      3. THis is less obvious but, one has to be conscious about what happens behind csdid.
                      Specifically, It estimates a large number of 2x2 models.

                      Now if you type " tab year gvar "
                      you will see how many observations are there, per year and treatment group.
                      For the data you provided n the example, you have 2 observations in the control group, and 1 in the treatment group. Thus, it may just now be enough to estimate effects using Callaway and Sant'Anna (2021).
                      Perhaps a better alternative would be to use other methodologies like The imputation approach (see did_imputation), or the methodology suggested by Wooldridge (regression with interacted Year#Treatment period)
                      HTH
                      Fernando

                      Comment

                      Working...
                      X