Announcement

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

  • Diff-in-diff with balanced panel: adding fixed effects does not change coefficients?

    Hi everyone,

    I'm trying to run a differences-in-differences model in Stata. My dependent variable is order volumes, each observation is 1 store, and my panel is strongly balanced (20 quarters for each store, 6K control stores, 4K treated stores). I am running the following regression:

    reghdfe orders treat post treat_post, noabsorb cluster(chain)

    If I then add fixed effects (time-, individual-, or anything else), my coefficients on treat, post, and treat_post do not change at all. E.g., the following regressions all give identical coefficients with identical standard errors:

    reghdfe orders treat treat_post, absorb(date) cluster(chain)

    reghdfe orders post treat_post, absorb(store_id_number) cluster(chain)

    reghdfe orders treat_post, absorb(date store_id_number) cluster(chain)


    In my understanding, the coefficient on treat_post should change each time, since I am including different fixed effects? What am I doing wrong, and what could be going on?

  • #2
    reghdfe is from https://github.com/sergiocorreia/reghdfe (FAQ Advice #12). In both specifications, the treatment effect is represented by the coefficient on the interaction term (treat \(\times\) post). If you were to add unit and time fixed effects to the first specification, the variables treat and post would become collinear with these fixed effects and would consequently drop out. This is because a unit is either in the treatment group or the control group for the entire sample period, and the post-treatment periods are common across all units. However, the treatment indicator (interaction term) is not collinear with the unit and time effects. You'd want to define a single treatment indicator (=1 if unit \(i\) at time \(t\) was subject to the treatment, and zero otherwise) and add unit and time effects. Here is an illustrative example:

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input float(id time earnings treat post)
     1 1 184.53838 1 0
     1 2   89.7459 1 0
     1 3 229.79747 1 0
     1 4  325.4863 1 1
     1 5  342.3039 1 1
     2 1 143.84065 1 0
     2 2 197.97125 1 0
     2 3  177.1405 1 0
     2 4  184.2767 1 1
     2 5  325.8765 1 1
     3 1 143.65779 1 0
     3 2  99.30865 1 0
     3 3 239.55896 1 0
     3 4 301.33337 1 1
     3 5  255.1791 1 1
     4 1  212.6027 1 0
     4 2  209.5945 1 0
     4 3 249.65703 1 0
     4 4   218.441 1 1
     4 5  308.5818 1 1
     5 1 119.58028 1 0
     5 2  214.3825 1 0
     5 3  255.0502 1 0
     5 4 131.67732 1 1
     5 5 286.93588 1 1
     6 1     172.6 0 0
     6 2  195.8285 0 0
     6 3 216.65375 0 0
     6 4 241.81277 0 1
     6 5  371.8659 0 1
     7 1 111.30932 0 0
     7 2  189.1861 0 0
     7 3  197.6435 0 0
     7 4 195.06694 0 1
     7 5  420.0563 0 1
     8 1 135.54262 0 0
     8 2 65.894615 0 0
     8 3 223.36026 0 0
     8 4  156.0698 0 1
     8 5   389.637 0 1
     9 1  98.48895 0 0
     9 2  159.3057 0 0
     9 3  283.3184 0 0
     9 4 267.56104 0 1
     9 5 278.01526 0 1
    10 1 145.59119 0 0
    10 2  170.1276 0 0
    10 3 299.12158 0 0
    10 4  214.8591 0 1
    10 5  324.0184 0 1
    end
    
    reghdfe earnings ib0.treat##ib0.post, noabsorb nocons
    reghdfe earnings ib0.treat##ib0.post, absorb(id time) nocons
    
    *SINGLE TREATMENT INDICATOR
    gen treatment=treat*post
    reghdfe earnings treatment, absorb(id time) nocons
    Res.:

    Code:
    . reghdfe earnings ib0.treat##ib0.post, noabsorb nocons
    (MWFE estimator converged in 1 iterations)
    
    HDFE Linear regression                            Number of obs   =         50
    Absorbing 1 HDFE group                            F(   3,     46) =       8.17
                                                      Prob > F        =     0.0002
                                                      R-squared       =     0.3476
                                                      Adj R-squared   =     0.3050
                                                      Within R-sq.    =     0.3476
                                                      Root MSE        =    67.7272
    
    ------------------------------------------------------------------------------
        earnings | Coefficient  Std. err.      t    P>|t|     [95% conf. interval]
    -------------+----------------------------------------------------------------
         1.treat |   6.830314   24.73049     0.28   0.784    -42.94959    56.61022
          1.post |   108.2981   27.64953     3.92   0.000     52.64249    163.9537
                 |
      treat#post |
            1 1  |  -24.71738   39.10234    -0.63   0.530    -103.4263    53.99156
    ------------------------------------------------------------------------------
    
    . 
    . reghdfe earnings ib0.treat##ib0.post, absorb(id time) nocons
    (MWFE estimator converged in 2 iterations)
    note: 1bn.treat is probably collinear with the fixed effects (all partialled-out values are close to zero; tol = 1.0e-09)
    note: 1bn.post is probably collinear with the fixed effects (all partialled-out values are close to zero; tol = 1.0e-09)
    
    HDFE Linear regression                            Number of obs   =         50
    Absorbing 2 HDFE groups                           F(   1,     35) =       0.68
                                                      Prob > F        =     0.4142
                                                      R-squared       =     0.7095
                                                      Adj R-squared   =     0.5934
                                                      Within R-sq.    =     0.0191
                                                      Root MSE        =    51.8059
    
    ------------------------------------------------------------------------------
        earnings | Coefficient  Std. err.      t    P>|t|     [95% conf. interval]
    -------------+----------------------------------------------------------------
         1.treat |          0  (omitted)
          1.post |          0  (omitted)
                 |
      treat#post |
            1 1  |  -24.71738   29.91015    -0.83   0.414    -85.43821    36.00345
    ------------------------------------------------------------------------------
    
    Absorbed degrees of freedom:
    -----------------------------------------------------+
     Absorbed FE | Categories  - Redundant  = Num. Coefs |
    -------------+---------------------------------------|
              id |        10           0          10     |
            time |         5           1           4     |
    -----------------------------------------------------+
    
    . 
    . 
    . 
    . *SINGLE TREATMENT INDICATOR
    
    . 
    . gen treatment=treat*post
    
    . 
    . reghdfe earnings treatment, absorb(id time) nocons
    (MWFE estimator converged in 2 iterations)
    
    HDFE Linear regression                            Number of obs   =         50
    Absorbing 2 HDFE groups                           F(   1,     35) =       0.68
                                                      Prob > F        =     0.4142
                                                      R-squared       =     0.7095
                                                      Adj R-squared   =     0.5934
                                                      Within R-sq.    =     0.0191
                                                      Root MSE        =    51.8059
    
    ------------------------------------------------------------------------------
        earnings | Coefficient  Std. err.      t    P>|t|     [95% conf. interval]
    -------------+----------------------------------------------------------------
       treatment |  -24.71738   29.91015    -0.83   0.414    -85.43821    36.00345
    ------------------------------------------------------------------------------
    
    Absorbed degrees of freedom:
    -----------------------------------------------------+
     Absorbed FE | Categories  - Redundant  = Num. Coefs |
    -------------+---------------------------------------|
              id |        10           0          10     |
            time |         5           1           4     |
    -----------------------------------------------------+

    Comment

    Working...
    X