Announcement

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

  • Specifying Comparisions in DID models

    Is it possible in DID regression to compare only certain treated units to certain controls?

    Consider this example
    Code:
    net from "https://raw.githubusercontent.com/jgreathouse9/FDIDTutorial/main" net install fdid, replace
      net get fdid, replace
      // Reinstall fdid so you have the most recent version
      clear *
      qui u basque
      // Import basque
      replace treat = 1 if id==12 & year >=1976
      // Pretend Extremadura (a unit that'll never be a donor) was treated
      cls
    Suppose I wish to compare Basque only to Cataluna and Aragon, and I only wish to compare Extremadura, I don't know, Andalusia and La Rioja.


    Is there any way via the context of a single regression estimator (perhaps using interaction terms?) to specify such a model? I would expect the relevant coefficients to correspond to the DID estimate for each treated unit using ONLY the pre-specified comparison units for each treated unit. Is this something that's readily solvable? Edit: I'm not in the U.S., so I'm away from my laptop, that's why I can't provide any code I've tried myself.

  • #2
    why wouldn't it be the standard DID model. The issue would be getting sensible SE with so few units and a single treated unit.

    Comment


    • #3
      the updated version of fdid is giving me a "variable te not found" error.

      I don't see it being created before it's use.

      Comment


      • #4
        Originally posted by Jared Greathouse View Post
        Is it possible in DID regression to compare only certain treated units to certain controls?
        Standard DID is a regular regression model, so that would correspond to estimating each regression separately. Could you estimate them jointly? Yes.

        Code:
        webuse hospdd, clear
        didregress (satis) (procedure) if (inrange(hospital, 1, 12)|inrange(hospital, 35, 46)), group(hospital) time(month)
        didregress (satis) (procedure) if !(inrange(hospital, 1, 12)|inrange(hospital, 35, 46)), group(hospital) time(month)
        
        gen group1= (inrange(hospital, 1, 12)|inrange(hospital, 35, 46))
        xtset hospital
        xtreg satis i.group1#(c.procedure i.month) o1.group#o1.month,fe cluster(hospital)
        Res.:

        Code:
        . didregress (satis) (procedure) if (inrange(hospital, 1, 12)|inrange(hospital, 35, 46)), group(hospital) time(month)
        
        Treatment and time information
        
        Time variable: month
        Control:       procedure = 0
        Treatment:     procedure = 1
        -----------------------------------
                     |   Control  Treatment
        -------------+---------------------
        Group        |
            hospital |        12         12
        -------------+---------------------
        Time         |
             Minimum |         1          4
             Maximum |         1          4
        -----------------------------------
        
        Difference-in-differences regression                     Number of obs = 4,056
        Data type: Repeated cross-sectional
        
                                       (Std. err. adjusted for 24 clusters in hospital)
        -------------------------------------------------------------------------------
                      |               Robust
                satis | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
        --------------+----------------------------------------------------------------
        ATET          |
            procedure |
        (New vs Old)  |   .8373083   .0416418    20.11   0.000     .7511657     .923451
        -------------------------------------------------------------------------------
        Note: ATET estimate adjusted for group effects and time effects.
        
        .
        . didregress (satis) (procedure) if !(inrange(hospital, 1, 12)|inrange(hospital, 35, 46)), group(hospital) time(month)
        
        Treatment and time information
        
        Time variable: month
        Control:       procedure = 0
        Treatment:     procedure = 1
        -----------------------------------
                     |   Control  Treatment
        -------------+---------------------
        Group        |
            hospital |        16          6
        -------------+---------------------
        Time         |
             Minimum |         1          4
             Maximum |         1          4
        -----------------------------------
        
        Difference-in-differences regression                     Number of obs = 3,312
        Data type: Repeated cross-sectional
        
                                       (Std. err. adjusted for 22 clusters in hospital)
        -------------------------------------------------------------------------------
                      |               Robust
                satis | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
        --------------+----------------------------------------------------------------
        ATET          |
            procedure |
        (New vs Old)  |     .86466      .0502    17.22   0.000     .7602632    .9690567
        -------------------------------------------------------------------------------
        Note: ATET estimate adjusted for group effects and time effects.
        
        . xtreg satis i.group1#(c.procedure i.month) o1.group#o1.month,fe cluster(hospital)
        
        Fixed-effects (within) regression               Number of obs     =      7,368
        Group variable: hospital                        Number of groups  =         46
        
        R-squared:                                      Obs per group:
             Within  = 0.1233                                         min =         88
             Between = 0.1352                                         avg =      160.2
             Overall = 0.1317                                         max =        232
        
                                                        F(14, 45)         =      76.20
        corr(u_i, Xb) = 0.0599                          Prob > F          =     0.0000
        
                                            (Std. err. adjusted for 46 clusters in hospital)
        ------------------------------------------------------------------------------------
                           |               Robust
                     satis | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
        -------------------+----------------------------------------------------------------
        group1#c.procedure |
                        0  |     .86466   .0494247    17.49   0.000     .7651135    .9642064
                        1  |   .8373083   .0411018    20.37   0.000      .754525    .9200916
                           |
              group1#month |
               0#February  |  -.0205574   .0328075    -0.63   0.534    -.0866351    .0455204
                  0#March  |   .0043268   .0309915     0.14   0.890    -.0580932    .0667469
                  0#April  |  -.0147784   .0301772    -0.49   0.627    -.0755585    .0460016
                    0#May  |  -.0292926    .032824    -0.89   0.377    -.0954034    .0368183
                   0#June  |  -.0109112   .0259441    -0.42   0.676    -.0631653    .0413429
                   0#July  |  -.0189196   .0368698    -0.51   0.610    -.0931792      .05534
                1#January  |          0  (omitted)
               1#February  |  -.0006665   .0199154    -0.03   0.973    -.0407781    .0394452
                  1#March  |   .0363743   .0209755     1.73   0.090    -.0058726    .0786212
                  1#April  |   .0081816   .0320265     0.26   0.800    -.0563231    .0726863
                    1#May  |    .008918   .0321917     0.28   0.783    -.0559194    .0737554
                   1#June  |   .0040179   .0263931     0.15   0.880    -.0491406    .0571764
                   1#July  |  -.0028064   .0288327    -0.10   0.923    -.0608784    .0552656
                           |
                     _cons |   3.444675   .0112798   305.39   0.000     3.421956    3.467394
        -------------------+----------------------------------------------------------------
                   sigma_u |  .66162184
                   sigma_e |  .72415904
                       rho |  .45496395   (fraction of variance due to u_i)
        ------------------------------------------------------------------------------------
        
        .
        Last edited by Andrew Musau; 15 Aug 2024, 17:50.

        Comment


        • #5
          George Ford can you post the code that reproduces this issue? I'll look at it on Sunday when I return to Atlanta. Is this a staggered adoption setting or single treatment setup?
          Last edited by Jared Greathouse; 15 Aug 2024, 21:57.

          Comment


          • #6
            I rebooted and it worked.

            It's looking good. Nice work.

            Comment


            • #7
              Thank you! Not done just quite yet, though. Wooldridge sent me his slides on how to do the event study (you know, across cohorts, by using OLS to predict the treatment effect using i.treatment as a predictor, using the bootstrap/exact inference to obtain the standard error for tau by each time period).

              The challenging part will be aggregating this up to the ATT across all cohorts. He mentioned to me that to do this yours need to estimate (i think) the intra-cohort covariance matrix to adjust for variability within each cohort. Even the ATT is something of a debate. We could just take the raw empirical average, but Clarke weights the ATT for each cohort by ATT*(number of periods in the cohort/number of periods in the cohort). But even then, there's slight variations we could do, such as Hollingsworth Wing and Freedman who weight by the number of units in each cohort over the total N, among other weights they propose.


              Of course, the original question has nada to do with this. I was just trying to see if I could specify the comparison group in the usual way via interaction terms. But either way, thank you, I'm quite happy with the progress. I think extending it to the dynamic setting would make it not just more likely to publish, but more useful for a wider variety of situations, too. George Ford

              Comment


              • #8
                Can you borrow from SDID? It generates a period specific se.

                Comment


                • #9
                  Yep that's exactly the idea!!! In this case using small N/exact inference. Presumably one could also do placebo inference as SDID does in a similar manner

                  Comment

                  Working...
                  X