Announcement

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

  • Hi Fernando (and Others) - I have one treatment time-period (so, not staggered) but outcome variable for multiple time period before and after treatment. I am assuming I can still use CSDID without violating anything? It runs fine for an event analysis. Thanks for any replies.

    Comment


    • Hi Fernando!
      I want to estimate the overall treatment effect of being treated by aggregating the ATT(g,t) for the first seven years of treatment.

      This is done by the code estat cevent, window(0 7)

      My question is how to describe this aggregation process for the reader. From my understanding the aggregation puts more weight on ATT(g,t)'s with larger group sizes. Is that correct?

      Thank you in advance!

      Best,
      Katarina

      Comment


      • That is it exactly
        cevent is a weighted average of all attgts within the event restriction, where the weight is equal to the size of the treated group at time T.
        hth

        Comment


        • Thanks a lot!

          In addition, I would like to plot the group-specific effects graphically, which I have managed to do through the following commands which I found on your website.

          estat attgt
          csdid_plot, group(1999) name(m1,replace) title("Group 1999")
          csdid_plot, group(2000) name(m2,replace) title("Group 2000")
          csdid_plot, group(2005) name(m3,replace) title("Group 2005")
          csdid_plot, group(2008) name(m4,replace) title("Group 2008")
          graph combine m1 m2 m3 m4, xcommon scale(0.8)

          However, I would only like to have a certain time period (five years prior to treatment and five years afterwards) in the graphs. Is it possible to restrict the number of years displayed in the graphs?

          Best,
          Katarina

          Comment


          • Not with csdid, I never gave it that capability
            however you could do that using csdid2 (search on my website for how to install it and shoot me an email for an example)
            f

            Comment


            • Here the example


              Code:
              use http://pped.org/bacon_example.dta, clear
              net install csdid2, from("https://friosavila.github.io/stpackages") replace
              csdid2 asmrh, ivar(stfips) tvar(year) trtvar(post)
              ** plots
              estat event, revent(-10/15)
              estat plot
              **
               estat event, rgroup(1971/1973) revent(-10/15)
              estat plot
              estat event, rgroup(1974/1999) revent(-10/15)
              estat plot
              The first just restricts revent (like what window does) to show from -10/15
              the second and third do this but restricting groups to only those 1971/1973 or 1974/1999

              HTH
              F

              Comment


              • That works great for visualization.

                However, the commands csdid and csdid2 produce completely different estimates with the same independent, dependent and control variables (using the dripw method).

                The command I've been using to calculate the aggregated effect for the first seven years of treatment for both is:

                estat cevent, window (0 7)

                I can see that csdid uses more observations than csdid2, as there are a lot of x's when using the csdid2 command. How should one interpret the differences? I thought that the commands were doing the same thing.

                Best,
                Katarina

                Comment


                • They are
                  however it’s possible you are overfitting the model.
                  if you tabúlate year gvar , the lowest number there is your effective sample
                  you can’t use more covariates than that
                  also csdid and csdid2 deal differently with perfect prediction and collinearity

                  Comment


                  • One more thing.
                    for csdid2, the syntax is a bi different
                    estat cevent, revent(0/7)
                    infact, this should give you the same as
                    estat simple, revent(0/7)
                    Otherwise, you can always restrict the years and cohorts with csdid2 to produce any of the aggregates
                    rcalendar() is used to restrict years or periods to use, providing the list of years required
                    rgroup() Restricts the cohorts to be used
                    revent() restricts using the relative event estimates

                    They can all be combined.
                    F

                    Comment


                    • Dear FernandoRios
                      Thanks so much for the package. I have been successsfully using for a bunch of projects!

                      I came across weird output today and it made me confuses. It won't estimate pre-avg despite 2/3 of the database containing observations where group<year.
                      I get signficant results estimated for most groups post-treatment but I cannot get the pre-trends through any of the commands.
                      My panel runs between 2001-2018

                      Thanks for any help!
                      Best regards,
                      Bruno


                      ps: it doesn't help if i drop gvar=2001, 2002


                      Code:
                       estat event, post
                      ATT by Periods Before and After treatment
                      Event Study:Dynamic effects
                      ------------------------------------------------------------------------------
                                   |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
                      -------------+----------------------------------------------------------------
                           Pre_avg |          0  (omitted)
                          Post_avg |   242.6196   44.69852     5.43   0.000     155.0121    330.2271
                               Tp0 |    593.025   94.40495     6.28   0.000     407.9947    778.0554
                               Tp1 |   333.8989   65.79105     5.08   0.000     204.9508     462.847
                               Tp2 |   250.1199    50.0625     5.00   0.000     151.9992    348.2406
                               Tp3 |   230.7664   50.67889     4.55   0.000     131.4376    330.0952
                               Tp4 |   191.3726   43.84647     4.36   0.000     105.4351    277.3101
                               Tp5 |   166.6206   48.55805     3.43   0.001     71.44861    261.7927
                               Tp6 |   198.4311   55.49219     3.58   0.000      89.6684    307.1938
                               Tp7 |   143.9248   34.45236     4.18   0.000      76.3994    211.4502
                               Tp8 |   181.1064   37.44504     4.84   0.000     107.7155    254.4974
                               Tp9 |   228.2272   57.57879     3.96   0.000     115.3749    341.0796
                              Tp10 |   207.0282   49.78942     4.16   0.000     109.4427    304.6137
                              Tp11 |   217.3486   58.39899     3.72   0.000     102.8887    331.8085
                              Tp12 |   245.0774   64.07057     3.83   0.000     119.5014    370.6534
                              Tp13 |    282.223   89.35845     3.16   0.002     107.0837    457.3624
                              Tp14 |   244.1576   68.63956     3.56   0.000     109.6266    378.6887
                              Tp15 |   168.5863   81.73992     2.06   0.039     8.379043    328.7937
                      ------------------------------------------------------------------------------
                      
                      . estat pretrend
                      Pretrend Test. H0 All Pre-treatment are equal to 0
                      chi2(0) =     0.0000
                      p-value  =          .
                      
                       estat event, window(-7 7)
                      ATT by Periods Before and After treatment
                      Event Study:Dynamic effects
                      ------------------------------------------------------------------------------
                                   |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
                      -------------+----------------------------------------------------------------
                           Pre_avg |          0  (omitted)
                          Post_avg |   263.5199   43.45473     6.06   0.000     178.3502    348.6896
                               Tp0 |    593.025   94.40495     6.28   0.000     407.9947    778.0554
                               Tp1 |   333.8989   65.79105     5.08   0.000     204.9508     462.847
                               Tp2 |   250.1199    50.0625     5.00   0.000     151.9992    348.2406
                               Tp3 |   230.7664   50.67889     4.55   0.000     131.4376    330.0952
                               Tp4 |   191.3726   43.84647     4.36   0.000     105.4351    277.3101
                               Tp5 |   166.6206   48.55805     3.43   0.001     71.44861    261.7927
                               Tp6 |   198.4311   55.49219     3.58   0.000      89.6684    307.1938
                               Tp7 |   143.9248   34.45236     4.18   0.000      76.3994    211.4502
                      ------------------------------------------------------------------------------
                      
                      
                      
                      
                       tab gvar2
                      
                            gvar2 |      Freq.     Percent        Cum.
                      ------------+-----------------------------------
                             2001 |      1,887       20.15       20.15
                             2002 |      1,105       11.80       31.94
                             2003 |      1,530       16.33       48.28
                             2004 |        714        7.62       55.90
                             2005 |        816        8.71       64.61
                             2006 |        238        2.54       67.15
                             2007 |        408        4.36       71.51
                             2008 |         85        0.91       72.41
                             2009 |        323        3.45       75.86
                             2010 |        289        3.09       78.95
                             2011 |        204        2.18       81.13
                             2012 |        102        1.09       82.21
                             2013 |        221        2.36       84.57
                             2014 |        170        1.81       86.39
                             2015 |        221        2.36       88.75
                             2016 |        238        2.54       91.29
                             2017 |        119        1.27       92.56
                             2018 |        204        2.18       94.74
                             2019 |         51        0.54       95.28
                             2020 |        136        1.45       96.73
                             2021 |        136        1.45       98.19
                             2022 |        170        1.81      100.00
                      ------------+-----------------------------------
                            Total |      9,367      100.00
                      
                      g d_unt =1 if gvar2<ano
                      
                      
                            d_unt |      Freq.     Percent        Cum.
                      ------------+-----------------------------------
                                1 |      6,067      100.00      100.00
                      ------------+-----------------------------------
                            Total |      6,067      100.00
                      Last edited by Bruno pantaleao; 31 Oct 2023, 17:08.

                      Comment


                      • FAQ 101 Can you Tabulate year and gvar2?

                        Comment


                        • Code:
                          . tab  ano gvar2
                          
                                     |                                          gvar2
                                 ANO |      2001       2002       2003       2004       2005       2006       2007       2008 |     Total
                          -----------+----------------------------------------------------------------------------------------+----------
                                2001 |       111         65         90         42         48         14         24          5 |       551 
                                2002 |       111         65         90         42         48         14         24          5 |       551 
                                2003 |       111         65         90         42         48         14         24          5 |       551 
                                2004 |       111         65         90         42         48         14         24          5 |       551 
                                2005 |       111         65         90         42         48         14         24          5 |       551 
                                2006 |       111         65         90         42         48         14         24          5 |       551 
                                2007 |       111         65         90         42         48         14         24          5 |       551 
                                2008 |       111         65         90         42         48         14         24          5 |       551 
                                2009 |       111         65         90         42         48         14         24          5 |       551 
                                2010 |       111         65         90         42         48         14         24          5 |       551 
                                2011 |       111         65         90         42         48         14         24          5 |       551 
                                2012 |       111         65         90         42         48         14         24          5 |       551 
                                2013 |       111         65         90         42         48         14         24          5 |       551 
                                2014 |       111         65         90         42         48         14         24          5 |       551 
                                2015 |       111         65         90         42         48         14         24          5 |       551 
                                2016 |       111         65         90         42         48         14         24          5 |       551 
                                2017 |       111         65         90         42         48         14         24          5 |       551 
                                2018 |       111         65         90         42         48         14         24          5 |       551 
                                2019 |       111         65         90         42         48         14         24          5 |       551 
                                2020 |       111         65         90         42         48         14         24          5 |       551 
                                2021 |       111         65         90         42         48         14         24          5 |       551 
                          -----------+----------------------------------------------------------------------------------------+----------
                               Total |     2,331      1,365      1,890        882      1,008        294        504        105 |    11,571 
                          
                          
                                     |                                          gvar2
                                 ANO |      2009       2010       2011       2012       2013       2014       2015       2016 |     Total
                          -----------+----------------------------------------------------------------------------------------+----------
                                2001 |        19         17         12          6         13         10         13         14 |       551 
                                2002 |        19         17         12          6         13         10         13         14 |       551 
                                2003 |        19         17         12          6         13         10         13         14 |       551 
                                2004 |        19         17         12          6         13         10         13         14 |       551 
                                2005 |        19         17         12          6         13         10         13         14 |       551 
                                2006 |        19         17         12          6         13         10         13         14 |       551 
                                2007 |        19         17         12          6         13         10         13         14 |       551 
                                2008 |        19         17         12          6         13         10         13         14 |       551 
                                2009 |        19         17         12          6         13         10         13         14 |       551 
                                2010 |        19         17         12          6         13         10         13         14 |       551 
                                2011 |        19         17         12          6         13         10         13         14 |       551 
                                2012 |        19         17         12          6         13         10         13         14 |       551 
                                2013 |        19         17         12          6         13         10         13         14 |       551 
                                2014 |        19         17         12          6         13         10         13         14 |       551 
                                2015 |        19         17         12          6         13         10         13         14 |       551 
                                2016 |        19         17         12          6         13         10         13         14 |       551 
                                2017 |        19         17         12          6         13         10         13         14 |       551 
                                2018 |        19         17         12          6         13         10         13         14 |       551 
                                2019 |        19         17         12          6         13         10         13         14 |       551 
                                2020 |        19         17         12          6         13         10         13         14 |       551 
                                2021 |        19         17         12          6         13         10         13         14 |       551 
                          -----------+----------------------------------------------------------------------------------------+----------
                               Total |       399        357        252        126        273        210        273        294 |    11,571 
                          
                          
                                     |                               gvar2
                                 ANO |      2017       2018       2019       2020       2021       2022 |     Total
                          -----------+------------------------------------------------------------------+----------
                                2001 |         7         12          3          8          8         10 |       551 
                                2002 |         7         12          3          8          8         10 |       551 
                                2003 |         7         12          3          8          8         10 |       551 
                                2004 |         7         12          3          8          8         10 |       551 
                                2005 |         7         12          3          8          8         10 |       551 
                                2006 |         7         12          3          8          8         10 |       551 
                                2007 |         7         12          3          8          8         10 |       551 
                                2008 |         7         12          3          8          8         10 |       551 
                                2009 |         7         12          3          8          8         10 |       551 
                                2010 |         7         12          3          8          8         10 |       551 
                                2011 |         7         12          3          8          8         10 |       551 
                                2012 |         7         12          3          8          8         10 |       551 
                                2013 |         7         12          3          8          8         10 |       551 
                                2014 |         7         12          3          8          8         10 |       551 
                                2015 |         7         12          3          8          8         10 |       551 
                                2016 |         7         12          3          8          8         10 |       551 
                                2017 |         7         12          3          8          8         10 |       551 
                                2018 |         7         12          3          8          8         10 |       551 
                                2019 |         7         12          3          8          8         10 |       551 
                                2020 |         7         12          3          8          8         10 |       551 
                                2021 |         7         12          3          8          8         10 |       551 
                          -----------+------------------------------------------------------------------+----------
                               Total |       147        252         63        168        168        210 |    11,571 
                          
                          
                          . 
                          
                          
                          
                          .

                          Comment


                          • Pk the problem is not having a comparison group
                            so two options
                            a) recode the treated in 2022 as 0 ( not treated through the window of time
                            b) use notyet option
                            hth

                            Comment


                            • Hi Fernando,

                              Thanks a lot for the csdid package. It's really powerful.

                              I have a question regarding the timing setup. My panel covers 2012 to 2015 and includes individuals who got first treatment between those years, as well as those who never received treatment.

                              Given this, my time variable spans from 2012 to 2015, and the gvar variable encompasses the values: 0, 2012, 2013, 2014, and 2015.

                              From my understanding so far, it seems I should exclude those treated in 2012, classifying them as always-treated, since there's no pre-treatment period for them. This adjustment would mean gvar would have values of: 0, 2013, 2014, and 2015. In this way I got event study estimates for periods [-2,2]. Is this configuration accurate?

                              I am also wondering why it is not [-3,2], since for group 2015 they have a period -3 (2012). Interestingly, when I include those treated in 2012 in the regression (gvar=2012), I can obtain event estimates for [-3,2].

                              Code:
                              csdid outcome `control', ivar(id) time(year) gvar(first_treat) method(dripw) notyet
                              
                              estat event
                              Thanks for any help!

                              Best regards,
                              Zunyuan
                              Last edited by Zunyuan Zheng; 03 Nov 2023, 15:54.

                              Comment


                              • Can you show me what are you getting
                                and also tab year gvar?

                                Comment

                                Working...
                                X