Simple DiD settings

The difference-in-differences design is the go-to research design in contemporary econometrics to examine the effects of some regulatory intervention, a new accounting standard, or any other event. In the most basic form, this design can be implemented with a simple two-by-two matrix that displays the average values of the outcome variable for four groups split by two dimensions: (i) a treatment dimension that indicates whether the observation belongs to the treatment group affected by the shock or to the control group not affected by the shock, and (ii) a time dimension that indicates whether the observation is from the period before or after the shock.

In our illustration, for an international sample of firm-year observations around the mandatory adoption of IFRS in 2005, we can examine pre- and post-IFRS average stock illiquidity of firms in countries that are subject to IFRS adoption (ifrs==1) versus those that are not (ifrs==0).

In the following code, we use the tabulate command for such a sample to display the average of an illiquidity variable named zeroreturn:

use "data_ifrs_liq.dta",clear
sum year zeroreturn

gen post=0 if year<2005
replace post=1 if year>2005

// Matrix:

tabulate ifrs post, summarize(zeroreturn) means
tabulate year ifrs, summarize(zeroreturn) means
    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
        year |    120,361    2004.827    4.362174       1997       2012
  zeroreturn |    120,361    .2529683    .2416692   .0040161   .9585062

(64,098 missing values generated)

(55,038 real changes made)

                            Means of zeroreturn

           |        post
      ifrs |         0          1 |     Total
-----------+----------------------+----------
         0 | .23238348  .21638861 | .22415495
         1 | .42692598  .32413876 | .38461387
-----------+----------------------+----------
     Total | .27632782  .23379685 | .25529639

                            Means of zeroreturn

           |        ifrs
      year |         0          1 |     Total
-----------+----------------------+----------
      1997 | .26316084  .40436974 | .29443972
      1998 | .26435275  .41703674 | .30416961
      1999 | .23038658  .43127403 | .28014852
      2000 |  .2377778   .4109584 | .27814002
      2001 | .24320788  .42387623 |  .2857064
      2002 | .23410513  .45509432 | .28343205
      2003 | .21828692  .44823993 | .26681914
      2004 | .19536001  .41468009 | .23724099
      2005 |  .1905788  .37712961 | .22436797
      2006 | .18036518   .3250164 | .20567873
      2007 | .17165488  .30147589 |  .1938751
      2008 | .20508533  .32021188 | .22403615
      2009 | .24238386  .34643473 |  .2590272
      2010 | .24348337  .33805393 | .25822946
      2011 | .23819951  .31802251 | .25028696
      2012 | .24446376  .32334254 | .25616878
-----------+----------------------+----------
     Total | .22159004  .38408544 | .25296829

From the values displayed in the four cells that are separated by ifrs and post, we can calculate the difference-in-difference as the change in average outcomes (i.e., the change from post==0 to post==1) for the treatment (ifrs==1) group minus the change in average outcomes for the control group (ifrs==0).

Alternatively, we can also recover this difference-in-difference estimate by estimating a linear regression with interactions. Specifically, consider the following model for firm \(i\) in year \(t\), where each firm is located in country \(c\). We can use this model to estimate the effects of country-level IFRS adoption on some outcome variable \(y\):

\[ y_{i c t}=\beta_0+\beta_1 I F R S_c+\beta_2 P O S T_t+\beta_3 I F R S_c \times P O S T_t+\varepsilon_{i c t} \]

Using the same sample of firm-year observations, the simplest way we can estimate this difference-in-difference model is by regressing the outcome variable on the two indicator variables and their interaction.

gen post_ifrs=post*ifrs
reg zeroreturn ifrs post post_ifrs, cluster(countryid)
(9,060 missing values generated)


Linear regression                               Number of obs     =    111,301
                                                F(3, 20)          =      80.52
                                                Prob > F          =     0.0000
                                                R-squared         =     0.0779
                                                Root MSE          =      .2327

                             (Std. err. adjusted for 21 clusters in countryid)
------------------------------------------------------------------------------
             |               Robust
  zeroreturn | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
-------------+----------------------------------------------------------------
        ifrs |   .1945425   .0436291     4.46   0.000     .1035337    .2855513
        post |  -.0159949   .0164295    -0.97   0.342    -.0502663    .0182766
   post_ifrs |  -.0867924   .0179522    -4.83   0.000      -.12424   -.0493447
       _cons |   .2323835   .0237324     9.79   0.000     .1828786    .2818883
------------------------------------------------------------------------------

The results suggest that firms that were subject to the IFRS-shock experienced a change in illiquidity that was significantly lower than the change in illiquidity of the control firms. This result is consistent with results in the literature that suggest IFRS adoption was associated with improvements in stock liquidity.

What is important to add here is that the coefficient of-0.0868 on the interaction term is exactly the same number as we would get from calculating the difference-in-difference from the two-by-two matrix displayed above. The benefit of the regression over the tabulation is that we now also obtain an estimate of the standard error associated with the difference-in-difference estimator.

A variant of this type of regression that is often estimated in practice is one in which the main effects IFRS and POST are “subsumed” by unit and time fixed effects. Specifically, in the same example, the IFRS indicator can be replaced either by country- of firm-fixed effects, while the POST variable can be replaced by year fixed effects. Using the reghdfe program, we can absorb both firm- and year-fixed effects as follows. Here, firms are identified by variable gvkey and the interaction between IFRS and POST is again captured by the variable post_ifrs that we created above.

First we illustrate the results we obtain on adding time and country fixed effects.

reg zeroreturn i.year i.countryid ifrs post post_ifrs, cluster(countryid)
reg zeroreturn i.year i.countryid post_ifrs, cluster(countryid) 
note: ifrs omitted because of collinearity.
note: post omitted because of collinearity.

Linear regression                               Number of obs     =    111,301
                                                F(14, 20)         =          .
                                                Prob > F          =          .
                                                R-squared         =     0.2874
                                                Root MSE          =     .20459

                             (Std. err. adjusted for 21 clusters in countryid)
------------------------------------------------------------------------------
             |               Robust
  zeroreturn | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
-------------+----------------------------------------------------------------
        year |
       1998  |  -.0006483   .0046122    -0.14   0.890    -.0102691    .0089725
       1999  |  -.0352385   .0236309    -1.49   0.152    -.0845316    .0140546
       2000  |   -.032459    .021329    -1.52   0.144    -.0769504    .0120325
       2001  |  -.0241229   .0292886    -0.82   0.420    -.0852177     .036972
       2002  |  -.0239004   .0344396    -0.69   0.496      -.09574    .0479393
       2003  |  -.0387805   .0373613    -1.04   0.312    -.1167148    .0391538
       2004  |  -.0591383   .0456521    -1.30   0.210    -.1543669    .0360903
       2006  |  -.0718861   .0506407    -1.42   0.171    -.1775208    .0337485
       2007  |  -.0828033   .0375718    -2.20   0.039    -.1611766     -.00443
       2008  |  -.0515585   .0458215    -1.13   0.274    -.1471405    .0440234
       2009  |  -.0165657   .0358965    -0.46   0.649    -.0914445    .0583132
       2010  |  -.0170998   .0298396    -0.57   0.573    -.0793442    .0451445
       2011  |   -.024269   .0328281    -0.74   0.468    -.0927472    .0442092
       2012  |  -.0179488   .0372099    -0.48   0.635    -.0955674    .0596697
             |
   countryid |
          2  |   .1446156   .0008542   169.30   0.000     .1428338    .1463974
          6  |   .1056278   .0025726    41.06   0.000     .1002615    .1109941
         12  |   .1818235   .0025161    72.26   0.000      .176575     .187072
         18  |   .2483825   .0011592   214.27   0.000     .2459644    .2508005
         24  |     .18966   .0119885    15.82   0.000     .1646525    .2146675
         25  |   .1597764   .0110417    14.47   0.000     .1367439     .182809
         26  |   .1663577   .0100518    16.55   0.000     .1453901    .1873254
         29  |   .4185767   .0112388    37.24   0.000      .395133    .4420204
         32  |  -.1293801   .0186327    -6.94   0.000    -.1682472   -.0905131
         34  |    .351265   .0109491    32.08   0.000     .3284255    .3741045
         35  |  -.1604796   .0119335   -13.45   0.000    -.1853725   -.1355867
         36  |  -.0086126   .0085571    -1.01   0.326    -.0264624    .0092373
         37  |  -.1222561   .0102385   -11.94   0.000    -.1436133    -.100899
         38  |   .1378336   .0109803    12.55   0.000     .1149292     .160738
         42  |    .215822   .0102241    21.11   0.000     .1944949    .2371492
         44  |   .0753867   .0136506     5.52   0.000      .046912    .1038614
         45  |  -.0899285    .014831    -6.06   0.000    -.1208654   -.0589917
         47  |  -.0355286   .0128306    -2.77   0.012    -.0622927   -.0087644
         48  |   .1340392   .0142955     9.38   0.000     .1042193    .1638591
         49  |  -.0536608   .0085926    -6.24   0.000    -.0715847   -.0357369
             |
        ifrs |          0  (omitted)
        post |          0  (omitted)
   post_ifrs |   -.089237   .0166074    -5.37   0.000    -.1238795   -.0545945
       _cons |   .2508545    .024029    10.44   0.000     .2007308    .3009782
------------------------------------------------------------------------------


Linear regression                               Number of obs     =    111,301
                                                F(14, 20)         =          .
                                                Prob > F          =          .
                                                R-squared         =     0.2874
                                                Root MSE          =     .20459

                             (Std. err. adjusted for 21 clusters in countryid)
------------------------------------------------------------------------------
             |               Robust
  zeroreturn | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
-------------+----------------------------------------------------------------
        year |
       1998  |  -.0006483   .0046122    -0.14   0.890    -.0102691    .0089725
       1999  |  -.0352385   .0236309    -1.49   0.152    -.0845316    .0140546
       2000  |   -.032459    .021329    -1.52   0.144    -.0769504    .0120325
       2001  |  -.0241229   .0292886    -0.82   0.420    -.0852177     .036972
       2002  |  -.0239004   .0344396    -0.69   0.496      -.09574    .0479393
       2003  |  -.0387805   .0373613    -1.04   0.312    -.1167148    .0391538
       2004  |  -.0591383   .0456521    -1.30   0.210    -.1543669    .0360903
       2006  |  -.0718861   .0506407    -1.42   0.171    -.1775208    .0337485
       2007  |  -.0828033   .0375718    -2.20   0.039    -.1611766     -.00443
       2008  |  -.0515585   .0458215    -1.13   0.274    -.1471405    .0440234
       2009  |  -.0165657   .0358965    -0.46   0.649    -.0914445    .0583132
       2010  |  -.0170998   .0298396    -0.57   0.573    -.0793442    .0451445
       2011  |   -.024269   .0328281    -0.74   0.468    -.0927472    .0442092
       2012  |  -.0179488   .0372099    -0.48   0.635    -.0955674    .0596697
             |
   countryid |
          2  |   .1446156   .0008542   169.30   0.000     .1428338    .1463974
          6  |   .1056278   .0025726    41.06   0.000     .1002615    .1109941
         12  |   .1818235   .0025161    72.26   0.000      .176575     .187072
         18  |   .2483825   .0011592   214.27   0.000     .2459644    .2508005
         24  |     .18966   .0119885    15.82   0.000     .1646525    .2146675
         25  |   .1597764   .0110417    14.47   0.000     .1367439     .182809
         26  |   .1663577   .0100518    16.55   0.000     .1453901    .1873254
         29  |   .4185767   .0112388    37.24   0.000      .395133    .4420204
         32  |  -.1293801   .0186327    -6.94   0.000    -.1682472   -.0905131
         34  |    .351265   .0109491    32.08   0.000     .3284255    .3741045
         35  |  -.1604796   .0119335   -13.45   0.000    -.1853725   -.1355867
         36  |  -.0086126   .0085571    -1.01   0.326    -.0264624    .0092373
         37  |  -.1222561   .0102385   -11.94   0.000    -.1436133    -.100899
         38  |   .1378336   .0109803    12.55   0.000     .1149292     .160738
         42  |    .215822   .0102241    21.11   0.000     .1944949    .2371492
         44  |   .0753867   .0136506     5.52   0.000      .046912    .1038614
         45  |  -.0899285    .014831    -6.06   0.000    -.1208654   -.0589917
         47  |  -.0355286   .0128306    -2.77   0.012    -.0622927   -.0087644
         48  |   .1340392   .0142955     9.38   0.000     .1042193    .1638591
         49  |  -.0536608   .0085926    -6.24   0.000    -.0715847   -.0357369
             |
   post_ifrs |   -.089237   .0166074    -5.37   0.000    -.1238795   -.0545945
       _cons |   .2508545    .024029    10.44   0.000     .2007308    .3009782
------------------------------------------------------------------------------

Now, let’s absorb the fixed effects.

areg zeroreturn ifrs post post_ifrs, cluster(countryid) absorb(gvkey)
areg zeroreturn i.year i.countryid ifrs post post_ifrs, cluster(countryid) absorb(gvkey)
reghdfe zeroreturn post_ifrs, cluster(countryid) absorb(countryid year)
reghdfe zeroreturn post_ifrs, cluster(countryid) absorb(gvkey year)
reghdfe zeroreturn ifrs post post_ifrs, cluster(countryid) absorb(gvkey year)
note: ifrs omitted because of collinearity

Linear regression, absorbing indicators            Number of obs     = 111,301
Absorbed variable: gvkey                           No. of categories =  11,134
                                                   F(2, 20)          =   27.18
                                                   Prob > F          =  0.0000
                                                   R-squared         =  0.8075
                                                   Adj R-squared     =  0.7861
                                                   Root MSE          =  0.1121

                             (Std. err. adjusted for 21 clusters in countryid)
------------------------------------------------------------------------------
             |               Robust
  zeroreturn | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
-------------+----------------------------------------------------------------
        ifrs |          0  (omitted)
        post |  -.0109342   .0122792    -0.89   0.384    -.0365483    .0146798
   post_ifrs |   -.100076   .0195148    -5.13   0.000    -.1407832   -.0593687
       _cons |   .2686985   .0052333    51.34   0.000     .2577822    .2796149
------------------------------------------------------------------------------

note: ifrs omitted because of collinearity.
note: post omitted because of collinearity.
note: 2.countryid omitted because of collinearity
note: 6.countryid omitted because of collinearity
note: 12.countryid omitted because of collinearity
note: 18.countryid omitted because of collinearity
note: 24.countryid omitted because of collinearity
note: 25.countryid omitted because of collinearity
note: 26.countryid omitted because of collinearity
note: 29.countryid omitted because of collinearity
note: 32.countryid omitted because of collinearity
note: 34.countryid omitted because of collinearity
note: 35.countryid omitted because of collinearity
note: 36.countryid omitted because of collinearity
note: 37.countryid omitted because of collinearity
note: 38.countryid omitted because of collinearity
note: 42.countryid omitted because of collinearity
note: 44.countryid omitted because of collinearity
note: 45.countryid omitted because of collinearity
note: 47.countryid omitted because of collinearity
note: 48.countryid omitted because of collinearity
note: 49.countryid omitted because of collinearity

Linear regression, absorbing indicators            Number of obs     = 111,301
Absorbed variable: gvkey                           No. of categories =  11,134
                                                   F(15, 20)         =  124.14
                                                   Prob > F          =  0.0000
                                                   R-squared         =  0.8184
                                                   Adj R-squared     =  0.7982
                                                   Root MSE          =  0.1089

                             (Std. err. adjusted for 21 clusters in countryid)
------------------------------------------------------------------------------
             |               Robust
  zeroreturn | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
-------------+----------------------------------------------------------------
        year |
       1998  |  -.0116766   .0068022    -1.72   0.102    -.0258657    .0025125
       1999  |  -.0507722    .019359    -2.62   0.016    -.0911543     -.01039
       2000  |   -.049606   .0192799    -2.57   0.018    -.0898231   -.0093889
       2001  |  -.0444193   .0278522    -1.59   0.126    -.1025179    .0136793
       2002  |  -.0471566   .0306915    -1.54   0.140     -.111178    .0168648
       2003  |  -.0628965   .0330108    -1.91   0.071    -.1317559    .0059628
       2004  |  -.0838732   .0409612    -2.05   0.054    -.1693168    .0015704
       2006  |  -.0928505   .0446475    -2.08   0.051    -.1859835    .0002826
       2007  |  -.1036812   .0309445    -3.35   0.003    -.1682304   -.0391321
       2008  |  -.0719034   .0399061    -1.80   0.087    -.1551461    .0113392
       2009  |  -.0353541   .0299029    -1.18   0.251    -.0977303    .0270222
       2010  |  -.0349401    .023678    -1.48   0.156    -.0843316    .0144513
       2011  |  -.0414005   .0269526    -1.54   0.140    -.0976227    .0148217
       2012  |  -.0338997    .031699    -1.07   0.298    -.1000227    .0322234
             |
   countryid |
          2  |          0  (omitted)
          6  |          0  (omitted)
         12  |          0  (omitted)
         18  |          0  (omitted)
         24  |          0  (omitted)
         25  |          0  (omitted)
         26  |          0  (omitted)
         29  |          0  (omitted)
         32  |          0  (omitted)
         34  |          0  (omitted)
         35  |          0  (omitted)
         36  |          0  (omitted)
         37  |          0  (omitted)
         38  |          0  (omitted)
         42  |          0  (omitted)
         44  |          0  (omitted)
         45  |          0  (omitted)
         47  |          0  (omitted)
         48  |          0  (omitted)
         49  |          0  (omitted)
             |
        ifrs |          0  (omitted)
        post |          0  (omitted)
   post_ifrs |  -.0991684   .0188044    -5.27   0.000    -.1383936   -.0599431
       _cons |   .3173257   .0268852    11.80   0.000      .261244    .3734073
------------------------------------------------------------------------------

(MWFE estimator converged in 4 iterations)

HDFE Linear regression                            Number of obs   =    111,301
Absorbing 2 HDFE groups                           F(   1,     20) =      28.88
Statistics robust to heteroskedasticity           Prob > F        =     0.0000
                                                  R-squared       =     0.2874
                                                  Adj R-squared   =     0.2872
                                                  Within R-sq.    =     0.0071
Number of clusters (countryid) =         21       Root MSE        =     0.2046

                             (Std. err. adjusted for 21 clusters in countryid)
------------------------------------------------------------------------------
             |               Robust
  zeroreturn | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
-------------+----------------------------------------------------------------
   post_ifrs |   -.089237   .0166059    -5.37   0.000    -.1238764   -.0545976
       _cons |   .2624257   .0013267   197.81   0.000     .2596583    .2651931
------------------------------------------------------------------------------

Absorbed degrees of freedom:
-----------------------------------------------------+
 Absorbed FE | Categories  - Redundant  = Num. Coefs |
-------------+---------------------------------------|
   countryid |        21          21           0    *|
        year |        15           1          14     |
-----------------------------------------------------+
* = FE nested within cluster; treated as redundant for DoF computation

(dropped 364 singleton observations)
(MWFE estimator converged in 6 iterations)

HDFE Linear regression                            Number of obs   =    110,937
Absorbing 2 HDFE groups                           F(   1,     20) =      30.90
Statistics robust to heteroskedasticity           Prob > F        =     0.0000
                                                  R-squared       =     0.8175
                                                  Adj R-squared   =     0.7978
                                                  Within R-sq.    =     0.0260
Number of clusters (countryid) =         21       Root MSE        =     0.1089

                             (Std. err. adjusted for 21 clusters in countryid)
------------------------------------------------------------------------------
             |               Robust
  zeroreturn | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
-------------+----------------------------------------------------------------
   post_ifrs |  -.0991684    .017839    -5.56   0.000    -.1363798   -.0619569
       _cons |   .2628359   .0014286   183.98   0.000     .2598559    .2658158
------------------------------------------------------------------------------

Absorbed degrees of freedom:
-----------------------------------------------------+
 Absorbed FE | Categories  - Redundant  = Num. Coefs |
-------------+---------------------------------------|
       gvkey |     10770       10770           0    *|
        year |        15           1          14     |
-----------------------------------------------------+
* = FE nested within cluster; treated as redundant for DoF computation

(dropped 364 singleton observations)
(MWFE estimator converged in 7 iterations)
note: ifrs is probably collinear with the fixed effects (all partialled-out val
> ues are close to zero; tol = 1.0e-09)
note: post is probably collinear with the fixed effects (all partialled-out val
> ues are close to zero; tol = 1.0e-09)

HDFE Linear regression                            Number of obs   =    110,937
Absorbing 2 HDFE groups                           F(   1,     20) =      30.90
Statistics robust to heteroskedasticity           Prob > F        =     0.0000
                                                  R-squared       =     0.8175
                                                  Adj R-squared   =     0.7978
                                                  Within R-sq.    =     0.0260
Number of clusters (countryid) =         21       Root MSE        =     0.1089

                             (Std. err. adjusted for 21 clusters in countryid)
------------------------------------------------------------------------------
             |               Robust
  zeroreturn | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
-------------+----------------------------------------------------------------
        ifrs |          0  (omitted)
        post |          0  (omitted)
   post_ifrs |  -.0991684    .017839    -5.56   0.000    -.1363798   -.0619569
       _cons |   .2628359   .0014286   183.98   0.000     .2598559    .2658158
------------------------------------------------------------------------------

Absorbed degrees of freedom:
-----------------------------------------------------+
 Absorbed FE | Categories  - Redundant  = Num. Coefs |
-------------+---------------------------------------|
       gvkey |     10770       10770           0    *|
        year |        15           1          14     |
-----------------------------------------------------+
* = FE nested within cluster; treated as redundant for DoF computation

The final difference-in-difference coefficient of-0.0992 supports the same conclusion as before that IFRS adoption is associated with improved stock liquidity. Compared with the simple estimation performed earlier, we can see that inclusion of the firm- and year-fixed effects indeed causes the main effects of post and ifrs to drop out of the estimation, because these are perfectly collinear with the fixed effects. Also, we can see the substantial increase in explanatory power(\(R^2\))as a result of the inclusion of the fixed effects instead of the simple main effect variables.