Announcement

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

  • I am sorry, I made a mistake. Will update you shortly!

    Comment


    • Yes, now, I am indeed getting the same coefficients and plotted values. Thank you very much for your help!

      Best wishes,
      Gabor

      Comment


      • Dear FernandoRios .
        I have unbalanced panel data from 1990-2012. However, my first treatment cohort is g1994 and the last treatment cohort is g2005. I have two questions. Also i do not have never-treated units in the sample. I use not-yet treated as comparison. I assume parallel trends hold unconditionally
        When I run the csdid command -
        Code:
         
         csdid ln(y) , ivar(id) time(year) gvar(first_treat) notyet method(dripw) saverif(A1)
        1) It calculates ATT(g,t) for all the groups (perfect), but the ATT's for every group from 2005 onwards is omitted. For example if we have g2000, Then t_1999_2002 means ATT for g2000 two years after the treatment using g-1 = 1999 as a base period for this group. The comparison units for this group at t=2002 are g2003, g2004, g2005 (groups not yet treated by t=2002). Similarly, to calculate ATT in t_1999_2004 for the same group, the comparison group at t=2004 is g2005 (groups not yet treated by t=2005). Once we wish to calculate ATT at t_1999_2005 for the same group, we do not have any comparison group at t=2005. Because all units got eventually treated by 2005 (g2005 is last treated group), So this ATT combination is OMITTED , similarly t_1999_2005...............t_1999_2012 etc. are all omitted. If on the other hand we have fixed sample of never-treated units, we can possibly be able to calculate all the ATT's for each time period.

        I believe that is the reason that ATT's at time >= 2005 in each group are omitted. Please correct me if i am wrong.

        2) The outcome here displays a waring that panel is not balanced, will use observations with Pair balanced (observed at t0 and t1).

        Does this mean a similar thing of what Callaway and Sant'Anna call Balanced Groups - balance the sample by (i) only including groups that are exposed to the treatment for at least a certain number of time periods and (ii) only look at dynamic effects in those time periods. Since the composition of groups change at each event time , like at e=0 we may have all the 10 groups, the ATTs are averaged over, at e=1 we may have 7 groups only , at e= 3 we may have 5 groups we average ATTs etc. So does this waring me that it balances groups at event-time.

        I am sure my understanding of it may not be correct. Please confirm whether i am right or not. Please help me to understand the intuitive logic what observations are deleted and what does this Pair Balance mean. Any example ?

        Thanks,
        (Ridwan)

        Comment


        • Hi Ridwa
          1) you are correct. The reason why there are no ATTGTs estimated after 2005 is because there are no longer feasible comparisons groups after that year. Or as you correctly point out, All groups are treated.
          2) there are many ways to think about balance in CS.
          the one they describe and you point out is balance in terms of cohorts and treatment periods.
          The one i point at in the warning is about local balance.
          Recall that csdid is just a series of drdid put together. And each drdid (when panel estimators are called for) requires balanced panel of 2 groups and 2 periods. That is what my command is telling you.
          Thus, say you have a control for periods 1 2 3 4, but treated for periods 1 4. you have an unbalanced panel, but will be locally balanced when looking at periods 1 and 4.
          HTH

          Comment


          • Thanks FernandoRios for confirming .
            This was really helpful.

            regards,
            (Ridwan)

            Comment


            • Dear Fernando,


              Thank you so much for the csdid code: it is great!

              I was just wondering what the coefficients Pre_avg and Post_avg in the output are. As an example, when using the dataset https://friosavila.github.io/playingwithstata/drdid/mpdta.dta, the following line

              csdid lemp lpop , ivar(countyreal) time(year) gvar(first_treat) method(dripw)

              yields the output below
              ............
              Difference-in-difference with Multiple Time Periods

              Number of obs = 2,500
              Outcome model : least squares
              Treatment model: inverse probability
              ------------------------------------------------------------------------------
              | Coefficient Std. err. z P>|z| [95% conf. interval]
              -------------+----------------------------------------------------------------
              g2004 |
              t_2003_2004 | -.0145297 .0221292 -0.66 0.511 -.057902 .0288427
              t_2003_2005 | -.0764219 .0286713 -2.67 0.008 -.1326166 -.0202271
              t_2003_2006 | -.1404483 .0353782 -3.97 0.000 -.2097882 -.0711084
              t_2003_2007 | -.1069039 .0328865 -3.25 0.001 -.1713602 -.0424476
              -------------+----------------------------------------------------------------
              g2006 |
              t_2003_2004 | -.0004721 .0222234 -0.02 0.983 -.0440293 .043085
              t_2004_2005 | -.0062025 .0184957 -0.34 0.737 -.0424534 .0300484
              t_2005_2006 | .0009606 .0194002 0.05 0.961 -.0370631 .0389843
              t_2005_2007 | -.0412939 .0197211 -2.09 0.036 -.0799466 -.0026411
              -------------+----------------------------------------------------------------
              g2007 |
              t_2003_2004 | .0267278 .0140657 1.90 0.057 -.0008404 .054296
              t_2004_2005 | -.0045766 .0157178 -0.29 0.771 -.0353828 .0262297
              t_2005_2006 | -.0284475 .0181809 -1.56 0.118 -.0640814 .0071864
              t_2006_2007 | -.0287814 .016239 -1.77 0.076 -.0606091 .0030464
              ------------------------------------------------------------------------------
              Control: Never Treated

              See Callaway and Sant'Anna (2021) for details


              Then, running the line

              estat event

              yields the following table
              ATT by Periods Before and After treatment
              Event Study:Dynamic effects
              ------------------------------------------------------------------------------
              | Coefficient Std. err. z P>|z| [95% conf. interval]
              -------------+----------------------------------------------------------------
              Pre_avg | -.0000442 .0075204 -0.01 0.995 -.014784 .0146955
              Post_avg | -.0803539 .0189576 -4.24 0.000 -.1175101 -.0431978
              Tm3 | .0267278 .0140657 1.90 0.057 -.0008404 .054296
              Tm2 | -.0036165 .0129283 -0.28 0.780 -.0289555 .0217226
              Tm1 | -.023244 .0144851 -1.60 0.109 -.0516343 .0051463
              Tp0 | -.0210604 .0114942 -1.83 0.067 -.0435886 .0014679
              Tp1 | -.0530032 .0163465 -3.24 0.001 -.0850417 -.0209647
              Tp2 | -.1404483 .0353782 -3.97 0.000 -.2097882 -.0711084
              Tp3 | -.1069039 .0328865 -3.25 0.001 -.1713602 -.0424476
              ------------------------------------------------------------------------------


              I have looked for the exact definition of Pre_avg and Post_avg in the help files but I do not seem to find how these coefficients are computed... Would you mind elaborating on that?

              Thank you in advance for your help!

              Comment


              • Hi Georgina
                the post and Pre averages are precisely that. the simple averages of all post periods (tpX) or pre periods (tmX), that give equal weight to each period.
                For example, you should be able to estimate that simply by typing something like
                nlcom 0.25*(_b[tp0]+_b[tp1]+_b[tp2]+_b[tp3])
                HTH

                Comment


                • Dear FernandoRios ,

                  Thanks a lot for this program, it´s a great resource!

                  What is the current version available on SSC and has this been updated this spring? I´m asking because I´m having a problem with rerunning old code. I see that my csdid-ado file was updated when I recently updated the user-written programs I have installed. However, now I cannot replicate an old result using the csdid command.

                  Specifically, I have an unbalanced panel and with the new (?) version the command drops/disregards many year-by-year comparisons. As such, the coefficient for "Pre_avg" after running "estate event" is 0 (omitted). This hasn´t been the case before as there were more comparisons being estimated and there were also coefficients for pre-tretment periods. In fact, for some reason, now there are only coefficients estimated for the first group (g). Do you know what might be going on here?

                  Thanks a lot for your help!
                  Last edited by Leon Schmidt; 06 Jul 2022, 09:35.

                  Comment


                  • Oh, I see. Thank you so much!! That certainly helps!... I should definitely have guessed that...

                    But I have a follow-up question. The reason I was so interested in those coefficients is the following.

                    Suppose I am interested in a treatment's anticipating and persistent effects. Let me denote with the leads and lags of unit first being treated, with k the number of periods since treatment took place.

                    The TWFE model would look something like



                    Since I have statistical power issues, I considered the alternative specification to the one above, namely



                    where takes the value of 1 for all years before the treatment, and for all years after it.


                    I am interested in getting the coefficients and . Are these part of the post-estimation output from csdid?





                    Comment


                    • Yes, setting aside the twfe problems, the pre and post averages are equivalent to the coefficients you are interested in.
                      With perhaps slightly different weighting schemes than what you would get running tat regression.

                      Comment


                      • Dear FernandoRios ,

                        Do you have any advice for me regarding my post (#158)?

                        I'll copy it below for convenience.

                        Thanks a lot!

                        Copied post:

                        Thanks a lot for this program, it´s a great resource!

                        What is the current version available on SSC and has this been updated this spring? I´m asking because I´m having a problem with rerunning old code. I see that my csdid-ado file was updated when I recently updated the user-written programs I have installed. However, now I cannot replicate an old result using the csdid command.

                        Specifically, I have an unbalanced panel and with the new (?) version the command drops/disregards many year-by-year comparisons. As such, the coefficient for "Pre_avg" after running "estate event" is 0 (omitted). This hasn´t been the case before as there were more comparisons being estimated and there were also coefficients for pre-tretment periods. In fact, for some reason, now there are only coefficients estimated for the first group (g). Do you know what might be going on here?

                        Thanks a lot for your help!

                        Comment


                        • Hi Leon,
                          Sorry for not answering this earlier, I simply didn't notice the post!
                          so 1) the last version on csdid is 1.57, whereas for drdid it should be 1.67

                          For your second point, I may need additional information. can you provide some snapshots of your results?
                          if you have too many cohorts or time periods, just show the first few cohorts.

                          Could you also show a tab between year and gvar?
                          Thank you
                          F

                          Comment


                          • Dear Fernando,

                            I am trying to create a dynamic CSDID plot using the universal base category.

                            When I run the following command, the plotting works well - but the base category is t-1 instead of g-1 (using your earlier notation).
                            Code:
                            csdid `var' , ivar(OBJECTID) time(year) gvar(treat_year)
                            estat event, 
                            csdid_plot, style(rarea) legend(off)
                            When I run, however:
                            Code:
                            csdid `var' , ivar(OBJECTID) time(year) gvar(treat_year) long2
                            estat event, 
                            csdid_plot, style(rarea) legend(off)
                            to adjust the base category, I am getting the following output:
                            Click image for larger version

Name:	Screenshot 2022-07-07 at 03.43.09.png
Views:	1
Size:	373.4 KB
ID:	1672508

                            Could you please explain how to implement this correctly? (I am using the estat event, setup following your 23 Jun 2022 recommendation.)
                            Thank you very much!
                            Best,
                            Gabor



                            Comment


                            • To add: the following error message also appears after calling 'estat, event' with the 'long2' option specified beforehand:
                              Code:
                               csdid_event():  3301  subscript invalid
                                 <istmt>:     -  function returned error

                              Comment


                              • Hi Gabor
                                this is quite odd. Can you send me an email with the data so I can explore what is going on?
                                there is very little I can say with the information you are providing
                                also, just to make sure, can you make sure you have the latest drdid?
                                fernando

                                Comment

                                Working...
                                X