# difference-in-difference regression run as quantile regression

The usual regression equation used to estimate difference-in-difference is the following:

y i t = β 0 + β 1 Treat + β 2 After + β 3 ( Treat  ⋅  After ) + η ( Year Fixed Effects ) + γ C i t + ϵ i t

Is it possible run the above regression as a panel data quantile regression to observe the effect of the policy treat*after on different quantiles?

There are several commands in Stata that can do this, as the examples below show (though I cannot get the SEs to match exactly with user-written diff and native bsqreg). The help files for these commands contain references to the relevant literature. Wooldridge's Econometric Analysis of Cross Section and Panel Data, (2nd edition) covers various approaches to quantile regression with panel data, including the Mundlak-Chamberlain device approximation.

In short, for the point estimate of 2.75 additional full-time equivalent workers on the 75th quantile, all these methods agree, and the regression you propose is valid. The tricky part is how to calculate the standard errors correctly. I like the user-written qreg2 approach since it takes into account the dependence over time for each observation (whereas diff and bsqreg do not). Another approach would be to block bootstrap quantile regression like this:

capture program drop bootqreg
prog bootqreg
qreg fte i.treated##i.t bk kfc roys, q(.75)
end
bs, reps(10) cluster(id): bootqreg


Here's the Stata output using the Card and Krueger minimum wage dataset:

. use http://fmwww.bc.edu/repec/bocode/c/CardKrueger1994.dta, clear
(Dataset from Card&Krueger (1994))

. diff fte, t(treated) p(t) qdid(0.75) cov(bk kfc roys) bs reps(10)
QUANTILE DIFFERENCE-IN-DIFFERENCES WITH COVARIATES

(running bsqreg on estimation sample)

Bootstrap replications (10)
----+--- 1 ---+--- 2 ---+--- 3 ---+--- 4 ---+--- 5
..........

DIFFERENCE-IN-DIFFERENCES ESTIMATION RESULTS
Number of observations in the DIFF-IN-DIFF: 801
Before         After
Control: 78             77          155
Treated: 326            320         646
404            397
Bootstrapped Standard Errors

--------------------------------------------------------
Outcome var.   | fte     | S. Err. |   |t|   |  P>|t|
----------------+---------+---------+---------+---------
Before          |         |         |         |
Control      | 23.750  |         |         |
Treated      | 22.250  |         |         |
Diff (T-C)   | -1.500  | 2.136   | -0.70   | 0.482
After           |         |         |         |
Control      | 21.250  |         |         |
Treated      | 22.500  |         |         |
Diff (T-C)   | 1.250   | 1.539   | 0.81    | 0.417
|         |         |         |
Diff-in-Diff    | 2.750   | 1.641   | 1.68    | 0.094*
--------------------------------------------------------
R-square:    0.12
* Values are estimated at the .75 quantile
**Inference: *** p<0.01; ** p<0.05; * p<0.1

. bsqreg fte i.treated##i.t bk kfc roys, q(0.75) reps(10)
(fitting base model)

Bootstrap replications (10)
----+--- 1 ---+--- 2 ---+--- 3 ---+--- 4 ---+--- 5
..........

.75 Quantile regression, bootstrap(10) SEs          Number of obs =        801
Raw sum of deviations 2379.938 (about 22)
Min sum of deviations 2102.125                    Pseudo R2     =     0.1167

------------------------------------------------------------------------------
fte |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
treated |
NJ  |       -1.5    1.41028    -1.06   0.288    -4.268317    1.268317
1.t |       -2.5   1.946507    -1.28   0.199    -6.320908    1.320908
|
treated#t |
NJ#1  |       2.75   1.965148     1.40   0.162    -1.107499    6.607499
|
bk |       1.75   1.538623     1.14   0.256     -1.27025     4.77025
kfc |        -10   1.335675    -7.49   0.000    -12.62187   -7.378128
roys |        -.5   1.313393    -0.38   0.704    -3.078132    2.078132
_cons |      23.75   2.185972    10.86   0.000     19.45903    28.04097
------------------------------------------------------------------------------

. /* qreg2 does not play nice with factor variable notation since it is an older command */
. xi: qreg2 fte i.treated*i.t bk kfc roys, q(0.75) cluster(id)
i.treated         _Itreated_0-1       (naturally coded; _Itreated_0 omitted)
i.t               _It_0-1             (naturally coded; _It_0 omitted)
i.treated*i.t     _ItreXt_#_#         (coded as above)

.75 Quantile regression
R-squared = .18595557
Number of obs = 801
Objective function = 2.6243758

Standard errors adjusted for 409 clusters in id
------------------------------------------------------------------------------
fte |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
_Itreated_1 |       -1.5   2.620994    -0.57   0.567    -6.637055    3.637055
_It_1 |       -2.5   2.514373    -0.99   0.320     -7.42808     2.42808
_ItreXt_1_1 |       2.75   2.667881     1.03   0.303     -2.47895     7.97895
bk |       1.75   1.575922     1.11   0.267     -1.33875     4.83875
kfc |        -10   1.622303    -6.16   0.000    -13.17966   -6.820344
roys |        -.5   2.005569    -0.25   0.803    -4.430844    3.430844
_cons |      23.75   2.514293     9.45   0.000     18.82208    28.67792
------------------------------------------------------------------------------

Parente-Santos Silva test for intra-cluster correlation
Ho: No intra-cluster correlation

T   =   5.730
P>|T|  =   0.000

• Thanks for your answer, Dimitriy. Does the quantile difference-in-difference estimator have a causal impact interpretation? Do we need to make any additional assumptions to make a causal statement? Intuitively, the treatment may have an impact on the entire distribution and the individual in the 75th percentile may be in the 90th percentile as an effect of the policy. – AlessandroT Jul 11 '18 at 9:17
• Take a look at this paper as an example: Meyer, B.D., Viscusi, W.K., Durbin, D.L., 1995. Workers’ Compensation and Injury Duration: Evidence from a Natural Experiment. The American Economic Review 85, 322–340. This working paper by Callaway and Tong lays out the assumptions: economics.virginia.edu/sites/economics.virginia.edu/files/…. – Dimitriy V. Masterov Jul 16 '18 at 17:21