help diff
-------------------------------------------------------------------------------
Title
diff -- Differences in differences estimation
Syntax
diff outcome_var [if] [in] [weight] ,[ options]
Description
diff performs several differences in differences (diff-in-diff)
estimations of the treatment effect of a given outcome variable from a
pooled base line and follow up dataset: Single Diff-in-Diff, Diff-in-Diff
controlling for covariates, Kernel-based Propensity Score Matching
diff-in-diff, and the Quantile Diff-in-Diff.
Options
options description
-------------------------------------------------------------------------
Model - Required
period(varname) Indicates the dummy period variable (0: base line;
1: follow up).
treated(varname) Indicates the dummy treated variable (0: controls;
1:treated).
Optional
cov(varlist) Specifies the pre-treatment covariates of the
model. When option kernel is selected these
variables are used to generate the propensity
score.
kernel Performs the Kernel-based Propensity Score Matching
diff-in-diff. This option generates _weights that
contains the weights derived from the kernel
density function, _ps when the Propensity Score
is not specified and _wght_varname with the
weighted outcome variable. This option requires
the id(varname) of each individual.
id(varname) Option kernel requires the supply of the
identification variable.
bw(#) Supplied bandwidth of the kernel. The default is
the optimum bw estimated by Stata. See [R]
kdensity
ktype(kernel) Specifies the kernel function; the default is
epanechnikov. See [R] kdensity
qdid(quantile) Performs the Quantile Difference in Differences
estimation at the specified quantile from 0.1 to
0.9 (quantile 0.5 performs the QDID at the
medeian). You may combine this option with kernel
and cov options. qdid does not support weights
nor robust standard errors. This option uses [R]
qreg and [R] bsqreg for bootstrapped standard
errors
pscore(varname) Supplied Propensity Score.
logit Specifies logit estimation of the Propensity Score.
The default is Probit.
SE/Robust
cluster(varname) Calculates clustered Std. Errors by varname.
robust Calculates robust Std. Errors.
bs performs a Bootstrap estimation of coefficients and
standard errors.
reps(int) Specifies the number of repetitions when the bs is
selected. The default are 50 repetitions.
Balancing test
test Performs a balancing t-test of difference in means
of the specified covariates between control and
treated groups in period == 0. The option test
combined with kernel performs the balancing
t-test with the weighted covariates. See [R]
ttest
Reporting
report Displays the inference of the included covariates
or the estimation of the Propensity Score when
option kernel is specified.
nostar Removes the inference stars from the p-values.
-------------------------------------------------------------------------
Example
Install diff and/or check for updates.
ssc inst diff, replace
1. Diff-in-Diff with no covariates.
We use the dataset form Card & Krueger (1994)*.
net get diff
use cardkrueger1994, clear
diff fte, t(treated) p(t)
For bootstrapped std. err.:
diff fte, t(treated) p(t) bs rep(50)
2. Diff-in-Diff with covariates.
diff fte, t(treated) p(t) cov(bk kfc roys)
diff fte, t(treated) p(t) cov(bk kfc roys) report
diff fte, t(treated) p(t) cov(bk kfc roys) report bs
3. Kernel Propensity Score Matching Diff-in-Diff.
diff fte, t(treated) p(t) cov(bk kfc roys) kernel id(id)
diff fte, t(treated) p(t) report kernel id(id) ktype(gaussian) pscore(
> _ps)
diff fte, t(treated) p(t) bs kernel id(id) bw(0.006) pscore(_ps)
4. Quantile Diff-in-Diff.
diff fte, t(treated) p(t) qdid(0.25)
diff fte, t(treated) p(t) qdid(0.50)
diff fte, t(treated) p(t) qdid(0.75)
diff fte, t(treated) p(t) qdid(0.50) cov(bk kfc roys)
diff fte, t(treated) p(t) qdid(0.50) cov(bk kfc roys) kernel id(id)
diff fte, t(treated) p(t) qdid(0.50) cov(bk kfc roys) kernel id(id) bs
> reps(100)
5. Balancing test of covariates.
diff fte, t(treated) p(t) cov(bk kfc roys wendys) test
diff fte, t(treated) p(t) cov(bk kfc roys wendys) test id(id) kernel
Saved results
diff saves the following list of scalars in r():
r(mean_c0) mean of output_var of the control group in period t=0
r(mean_t0) mean of output_var of the treated group in period t=0
r(diff0) difference of the mean of output_var between treated
and control groups in period t=0
r(mean_c1) mean of output_var of the control group in period t=1
r(mean_t1) mean of output_var of the treated group in period t=1
r(diff1) difference of the mean of output_var between treated
and control groups in period t=1
r(diffdiff) differences in differences - Treatment Effect
r(se_c0) Standard Error of the mean of output_var of the control
group in period t=0
r(se_t0) Standard Error of the mean of output_var of the treated
group in period t=0
r(se_d0) Standard Error of the difference of output_var between
the treated and control groups in t=0
r(se_c1) Standard Error of the mean of output_var of the control
group in period t=1
r(se_t1) Standard Error of the mean of output_var of the treated
group in period t=1
r(se_d1) Standard Error of the difference of output_var between
the treated and control groups in t=0
r(se_dd) Standard Error of the difference in difference
References
Card, D., Krueger, A. "Minimum Wages and Employment: A Case Study of the
Fast-Food Industry in New Jersey and Pennsylvania". The American
Economic Review, Vol. 84, No. 4 (Sep., 1994), pp. 772-793.
Heckman, J., Ichimura, H., Todd, P. "Matching As an Econometric
Evaluation Estimator". The Review of Economic Studies, Vol. 65, No. 2
(Apr., 1998), pp. 261-294.
Meyer, B., Viscusi, W., . "Workers' Compensation and Injury Duration:
Evidence from a Natural Experiment". The American Economic Review,
Vol. 85, No.3 (Jun., 1995), pp. 322-340.
Author
Juan M. Villa
Office of Strategic Planning and Development Effectiveness
Inter-American Development Bank (not responsible)
juanmiguelv@iadb.org
Update: November - 2010
*Acknowledgements to Kit Baum for valuable comments.