Announcement

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

  • #31
    Hello,

    First off thank you so much for coding up this estimator. For the less adept econometricians among us, this is a real contribution.

    Second, I am running into the error from the photo attached using sample data. I think there is something wrong with the setup of the data, but im not sure which of the criteria for estimation I am violating. Any help would be greatly appreciated. I am attaching a sample dataset that generates the error as well.



    Thank you so much in advance for your aid, should you choose to bestow it.

    Best
    Ryan
    Attached Files

    Comment


    • #32
      couple of thoughts
      1. Your Treatment should not turn onand off.
      2. Construct the "gvar" using the following code:

      bysort panel_id:egen min=min(ym) if treatment==1
      bysort panel_id:egen gvar=max(min)
      replace gvar=0 if gvar==.

      3. When you cross tabulte ym with gvar, what you should see are blocks that look like this:


      year | 0 2004 2006 2007 | Total
      -----------+--------------------------------------------+----------
      2003 | 234 11 32 100 | 377
      2004 | 257 18 34 103 | 412
      2005 | 248 15 33 116 | 412
      2006 | 247 13 32 101 | 393
      2007 | 232 11 31 101 | 375
      -----------+--------------------------------------------+----------
      Total | 1,218 68 162 521 | 1,969



      But yours look like this:
      Sp for many of the cohorts, you did not observe them before treatment took place (only rarely), thus, i dont think you can identify their ATTs

      | gvar
      ym | 543 544 545 546 | Total
      -------------------------------------------------------------------
      541 | 12 4 4 2 | 3,014
      542 | 12 4 4 2 | 3,022
      543 | 70 4 4 2 | 3,041
      544 | 67 35 5 3 | 3,049
      545 | 67 35 61 3 | 3,068
      546 | 67 34 59 72 | 3,098
      547 | 67 34 59 72 | 3,118
      548 | 67 33 59 72 | 3,133
      549 | 65 33 59 71 | 3,124
      550 | 64 33 59 71 | 3,125
      551 | 63 32 59 70 | 3,129


      HTH

      Comment


      • #33
        Super helpful thanks! There are a handful of instances where we see a bond drop treatment for idiosyncratic reasons. I will exclude those.

        Edit: FYI, removal of treatment seemed to be driving the error. Thanks

        Best
        Ryan
        Last edited by Ryan Lewis; 03 Nov 2021, 13:53.

        Comment


        • #34
          Fernando,

          Thanks for this fantastic resource and for your willingness to engage with us as we figure out how to use it. I'm trying to export the coefficients from the event study output of CSDID (csdid_estat event) into esttab or another way of getting it into Latex. Do you have any advice on the best way to do this? I've tried to pull it from e(), but as near as I can tell e() is saving the att(g,t)s instead and I'm not sure how to convert that into something I can pass to esttab or otherwise export.

          Thanks so much,
          Daniel

          Comment


          • #35
            Easiest approach
            estat event, estore(eq1)
            then
            esttab eq1
            hth

            Comment


            • #36
              Thanks so much, Fernando. One more quick question: I'm trying to use csdid_estat to the wild bootstrap standard errors, but keep on getting the following message:

              Test will be based on asymptotic VCoV
              If you want aggregations based on WB, use option saverif() ad csdid_stats

              My code is as follows. What am I missing?

              Code:
              csdid nh1000 medicaidexpansion, time(year) g(cohort) clusters(stateid) wboot saverif(altnh)  ad csdid_stats replace
              csdid_estat event
              csdid_plot, style(rcap)
              
              estat event, estore(altnh) replace wboot
              Thanks so much,
              Daniel

              Comment


              • #37
                Sorry, one quick follow up re: use of estore - it appears that it's delivering different standard errors than the typical output. Any idea of why that might be the case?

                EDIT: Here is the output:
                HTML Code:
                . estat event, estore(eq2)
                ATT by Periods Before and After treatment
                Event Study:Dynamic effects
                ------------------------------------------------------------------------------
                             |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
                -------------+----------------------------------------------------------------
                         Tm6 |  -.2091852   1.467384    -0.14   0.887    -3.085206    2.666835
                         Tm5 |  -.0493733   .6769459    -0.07   0.942    -1.376163    1.277416
                         Tm4 |  -.0294394   .5314299    -0.06   0.956    -1.071023    1.012144
                         Tm3 |    .110176   .5292715     0.21   0.835     -.927177    1.147529
                         Tm2 |   .0460964   .5248195     0.09   0.930     -.982531    1.074724
                         Tm1 |  -.0146218   .5338497    -0.03   0.978    -1.060948    1.031704
                         Tp0 |   .1249182   .5333318     0.23   0.815     -.920393    1.170229
                         Tp1 |  -.4066044   .5755137    -0.71   0.480     -1.53459    .7213816
                         Tp2 |   -.443182   .5894438    -0.75   0.452    -1.598471    .7121066
                         Tp3 |  -.3890743   .5767345    -0.67   0.500    -1.519453    .7413045
                         Tp4 |  -.5589983   .6411245    -0.87   0.383    -1.815579    .6975827
                         Tp5 |   .1157063   1.087463     0.11   0.915    -2.015683    2.247095
                ------------------------------------------------------------------------------
                And here's what esttab is producing:

                HTML Code:
                ----------------------------
                                      (1)   
                                            
                ----------------------------
                Tm6                -0.209   
                                  (-0.14)   
                
                Tm5               -0.0494   
                                  (-0.07)   
                
                Tm4               -0.0294   
                                  (-0.06)   
                
                Tm3                 0.110   
                                   (0.21)   
                
                Tm2                0.0461   
                                   (0.09)   
                
                Tm1               -0.0146   
                                  (-0.03)   
                
                Tp0                 0.125   
                                   (0.23)   
                
                Tp1                -0.407   
                                  (-0.71)   
                
                Tp2                -0.443   
                                  (-0.75)   
                
                Tp3                -0.389   
                                  (-0.67)   
                
                Tp4                -0.559   
                                  (-0.87)   
                
                Tp5                 0.116   
                                   (0.11)   
                ----------------------------
                N                           
                ----------------------------
                t statistics in parentheses
                * p<0.05, ** p<0.01, *** p<0.001

                Comment


                • #38
                  Originally posted by Daniel Wasserman View Post
                  Thanks so much, Fernando. One more quick question: I'm trying to use csdid_estat to the wild bootstrap standard errors, but keep on getting the following message:

                  Test will be based on asymptotic VCoV
                  If you want aggregations based on WB, use option saverif() ad csdid_stats

                  My code is as follows. What am I missing?

                  Code:
                  csdid nh1000 medicaidexpansion, time(year) g(cohort) clusters(stateid) wboot saverif(altnh) ad csdid_stats replace
                  csdid_estat event
                  csdid_plot, style(rcap)
                  
                  estat event, estore(altnh) replace wboot
                  Thanks so much,
                  Daniel
                  Hi Daniel
                  So, just using estat will always produce asymptotic standard errors.
                  If what you want are Wildbootstrap standard errors what you need to do is:

                  Code:
                  use altnh, clear
                  csdid_stats event, wboot estore(event)
                  For your second question, you are not producing standard errors, you were producing t-statistics.
                  For the former you would do:

                  Code:
                  esttab event, se

                  Comment


                  • #39
                    I am trying to run the csdid command. There was no problem running it for part of the data. But for the other part, it gives the results <year not a valid name. Looking for solutions. The exact same command runs for one part of the estimation.

                    Comment


                    • #40
                      Hi Priya
                      Make sure you ahve the latest versions of the commands
                      Also, if you can give more information about the error.
                      For example, can you tell me what you get when you do
                      tab year gvar
                      (Or whichever variable name you are using)
                      Thanks

                      Comment


                      • #41
                        The discussion in this forum is extremely helpful. Thank you all! I have a quick question, can we include time-varying controls such as state GDP or unemployment rates in the CSDID model as we do in regular TWFE DiD? My sense is that CSDiD assumes, such characteristics to be time constant among treated and non-treated. Am I missing something? Is there any guide on how to interpret the results/output from CSDID?

                        Comment


                        • #42
                          For guide on interpretation, you may do well in checking the original paper. There have been a few papers that have been using the method as well.
                          Regarding time varying controls.
                          yes, but with a caveat.
                          If you have panel data: You can add time-varying variables, however only the last pretreatment period data will be used for the estimation of treatment effects. If you look at the default outcome, you will see something like:
                          g20004
                          t_2003_2007
                          This means, that ATTGT is for a group 2004 (first time you see a group being treated). And t_2003_2007 means that one is using data for 2003 (pre-) and 2007 (post-).
                          If this is done using panel data estimators, only values from 2003 were used in this case.

                          If you are using repeated crossection, you are using both 2003 and 2007 values. However, you are also implicitly assuming whatever change you observe in characteristics is strictly exogenous.

                          HTH
                          F​​​​​​​

                          Comment


                          • #43
                            Hello, I am using Stata 17. I have repeated cross-section data and am running a csdid with not yet treated as a control group.

                            I was able to run it successfully for one set of data and got all the results I wanted. I was unable to run the same for another set of data. It gave an error saying >year invalid name. I decided I should reinstall csdid. Now it gives me completely different errors, even with the first set. Now I have no results!!
                            I have 4 groups which are basically states. The first treatment period is 2007. My data runs from 2003.

                            csdid y x1 x2 x3 x4 x5 x6 [iweight = fnlwgt], notyet time(year) gvar(group) cluster(state)
                            Gvar max value is 4 and there are no periods available before that treatment
                            Verify that Gvar is correctly defined
                            request may not be combined with by
                            r(190);

                            Comment


                            • #44
                              can you show me what happens if you
                              tab year group

                              Comment


                              • #45
                                Hello Fernando, first I'd like to thank you for the package csdid on stata, it's a great contribution to the community.

                                I'm here because i'm having doubts about running csdid in case of an unbalanced panel. I have panel data where I follow individuals for 4 quarters in 2012 - 2019. Some individuals don't appear in all quarters, so I have an unbalanced panel. When I try to run it in csdid stata, the command says "Panel is not balanced
                                Will use observations with Pair balanced (observed at t0 and t1)"
                                .

                                So, I'd like to know what would be the equivalent R option (allow_unbalanced_panel = TRUE) in stata's csdid, could you help me please? (in the attached dta I left only 2012 and 2013 as an example, because the file was too big).


                                My code:
                                Code:
                                use panel_test.dta, clear
                                
                                egen time_calendar = group(ano trim)
                                
                                xtset id time_calendar // panel
                                
                                gen nao_emp_Chefe_lag = l.nao_emp_Chefe
                                gen treat=1 if nao_emp_Chefe_lag==0 & nao_emp_Chefe==1
                                gen treat_aux=time_calendar if treat==1
                                bysort id: egen first_treat=min(treat_aux)
                                
                                
                                replace first_treat=0 if first_treat==.
                                csdid pea nao_emp_Chefe, ivar(id) time(time_calendar) gvar(first_treat)
                                Attached Files
                                Last edited by Isabella Helter; 05 Dec 2021, 20:48.

                                Comment

                                Working...
                                X