*! version 2.0.0 February 23, 2024

Title

sdid -- Synthetic difference-in-differences estimation, inference, and visualization

Syntax

sdid depvar groupvar timevar treatment [if] [in], vce(vcetype) [options]

vce(vcetype) vcetype may be bootstrap, jackknife, or placebo.

covariates(varlist, [type]) Allows for the inclusion of covariates in the calculation of the synthetic counterfactual.
Optional type can be specified, as either "optimized" (the default) or "projected", which is preferable in certain circumstances.

seed(#) set random-number seed to #.

reps(#) repetitions for bootstrap and placebo inference.

method(type) Allows for an estimation method to be requested. type can be "sdid" (which is estimated by default), "did" (for standard difference-in-differencs) or "sc" (for standard synthetic control).

graph if this option is specified, graphs will be displayed in the style of figure 1 from Arkhangelsky et al. (2021).

g1on If graphing is requested, this option activates the unit-specific weight graph.

g1_opt(graph options) option to modify the appearance of the unit-specific weight graph.

g2_opt(graph options) option to modify the appearance of the outcome trend graphs.

graph_export(string, type) option allowing for generated graphs to be saved to the disk.

msize(markersizestyle) markersizestyle allows you to modify the size of the marker for graph 1.

unstandardized In the case of "optimized" covariates, by default covariates will be standardized as z-scores,
unless the unstandardized option is specified.

mattitles Requests that weights returned in matrices are accompanied by the name
of the groupvar corresponding to each weight.

Description

sdid implements the synthetic difference-in-differences estimation procedure, along with a range of inference and graphing procedures as described in Arkhangelsky et al. (2021).
Synthetic difference-in-differences is based on a panel (group by time) set-up, in which certain units are treated and
remaining units are untreated. The sdid procedure calculates a treatment effect as the pre- versus post-
difference-in-difference
between treated units and synthetic control units, where synthetic control units are chosen as an optimally weighted function
of untreated units (unit-specific weights) and pre-treatment times (time-specific weights). The sdid command exactly implements
the procedures described in Arkhangelsky et al. (2021). The exact estimation procedure implemented by sdid is described in their Algorithm 1.
Further discussion of this procedure and its implementation in Stata is available in "Synthetic Difference-in-Differences Estimation" (Clarke et al., 2023).

Much of Arkhangelsky et al. (2021) focuses on cases with a single time period of adoption, however their Appendix A lays out the
estimation procedure in cases of staggered-adoption designs, where treated units can adopt treatment at different moments of
time, while control units never adopt. sdid seamlessly estimates treatment effects in cases with both single-time periods of treatment and
multiple-time periods of treatment. In the latter case, rather than calculating a single unit and time-specific weight vector,
an optimal unit and time-specific weight vector is calculated for each adoption period. The reported average treatment effect
on the treated (ATT) in the staggered adoption design is the weighted estimand described in Arkhangelsky et al. (2021), Appendix A. Additionally,
adoption-period specific estimates and their standard errors are returned after estimation.

Inference in sdid is based on bootstrap, jackknife, or placebo procedures. Each procedure is clustered by groupvar,
and follows the precise algorithms laid out in Arkhangelsky et al. (2021). Specifically, bootstrap inference follows Algorithm 2,
jackknife inference follows Algorithm 3, and placebo inference follows Algorithm 4. The suitability of each inference procedure
depends on the precise data structure. For example, bootstrap and jackknife procedures are not appropriate with single treated
units, while placebo inference requires at 1 more control than treated unit. Inference procedures are provided as standard for
both single-treatment and staggered adoption designs. In the case of staggered-adoption designs, resample inference is conducted
over the entire ATT, so provides a valid standard error for the headline treatment effect (under the large sample conditions
laid out in Arkhangelsky et al. (2021).) In very large databases, bootstrap procedures may be computationally expensive, in
which case jackknife will provide a more (computationally) feasible inference procedure.

sdid additionally allows for the inclusion of covariates in a number of ways, and, if requested, provides graphical
output documenting optimal weights, as well as matched treatment and synthetic control trends underlying the synthetic
difference-in-differences framework. Details related to covariates and graphical options are described at more length below.

Options

Main

vce(vcetype) is a required option. This may be either bootstrap, jackknife, or placebo, where in each case inference
proceeds following the specified method. In the case of bootstrap, this is only permitted if greater than one unit is treated.
In the case of jackknife, this is only permitted if greater than one unit is treated in each treatment period (if multiple
treatment periods are considered). In the case of placebo, this requires at least one more control than treated unit to allow
for permutations to be constructed. In each case, inference follows the specific algorithm laid out in Arkhangelsky et al. (2021).

covariates(varlist, [type]) Covariates should be included as a varlist, and if specified,
treatment and control units will be adjusted based on covariates in the synthetic difference-in-differences procedure. Optionally,
type may be specified, which indicates how covariate adjustment will occur. If the type is indicated as "optimized" (the default)
this will follow the method described in Arkhangelsky et al. (2021), footnote 4, where SDID is applied to the residuals of all units
after regression adjustment. However, this has been observed to be problematic at times (refer to Kranz, 2021), and is also
sensitive to optimization if covariates have high dispersion. Thus, an alternative type is implmented ("projected"), which consists
of conducting regression adjustment based on parameters estimated only in untreated groups.
This type follows the procedure proposed by Kranz, 2021 (xsynth in R), and is observed to be more stable in some implementations (and at times, considerably faster).
sdid will run simple checks on the covariates indicated and return an error if covariates are constant, to avoid multicolineality.
However, prior to running sdid, you are encouraged to ensure that covariates are not perfectly
multicolinear with other covariates and state and year fixed effects, in a simple two-way fixed
effect regression. If perfectly multi-colinear covariates are included sdid will execute
without errors, however where type is "optimized", the procedure may be sensitive to the
inclusion of redundant covariates.

seed(#) seed define for pseudo-random numbers.

reps(#) repetitions for bootstrap and placebo se. Default is 50 repetitions. Larger values should be preferred where possible.

method(type) this option allows for alternative estimation methods to be performed. Allowed types are "sdid" (synthetic difference-in-differences)
"did (standard difference-in-differences) or "sc" (standard synthetic control).
If this option is not included, sdid is assumed by default.

graph if this option is specified, graphs will be displayed showing unit and time weights as well as outcome trends as per figure 1 from Arkhangelsky et al. (2021).

g1on this option activates the unit-specific weight graph. By default g1 is off, as this graph can take considerable time to generate where a large number of control units are present.

g1_opt(graph options) option to modify the appearance of the unit-specific weight graph.
These options adjust the underlying scatter plot, so should be consistent with twoway scatter plots.

g2_opt(graph options) option to modify the appearance of the outcome trend graphs.
These options adjust the underlying line plot, so should be consistent with twoway line plots.

graph_export(string, type) Graphs will be saved as weightsYYYY and trendsYYYY for each of the unit-specific weights and outcome trends respectively, where YYYY refers to each treatment adoption period.
Two graphs will be generated for each treatment adoption period. If this option is specified, type must be specified, which refers to a valid Stata graph type (eg ".eps", ".pdf", and so forth).
Optionally, a stub can be specified, in which case this will be prepended to exported graph names.

msize(size of marker) allows you to modify the size of the marker for graph 1.

unstandardized if controls are included and the "optimized" method is specified, controls will be standardized as Z-scores prior to finding optimal weights. This avoids problems with optimization when control variables have very
high dispersion. If unstandardized is specified, controls will simply be entered in their original units.
This option should be used with care.

mattitles Requests labels to be added to the returned e(omega) weight matrix providing names (in string) for the unit variables which generate the synthetic control group in each case.
If mattitles is not indicated, the returned weight matrix (e(omega)) will store these
weights with a final column providing the numerical ID of units, where this numerical ID is either
taken from the unit variable (if this variable is a numerical format), or arranged in alphabetical
order based on the unit variable, if this variable is in string format.

Stored results

sdid stores the following in e():

Scalars

e(ATT) ATT

e(se) Standard error

e(reps) Number of bootstrap/placebo replications

e(N_clust) Number of clusters

Macros

e(cmd) sdid

e(cmdline) command as typed

e(depvar) name of dependent variable

e(vce) vcetype specified in vce()

e(clustvar) name of cluster variable

Matrices

e(tau) tau estimator for each adoption time-period, along with its standard error

e(lambda) lambda weights (time-specific weights)

e(omega) omega weights (unit-specific weights)

e(adoption) adoption times

e(beta) beta vector of corresponding to covariates (only returned when the covariates option is indicated)

e(series) control and treatment series of the graphs (only returned when the graph option is indicated)

e(difference) difference between treatment and control series (only returned when the graph option is indicated)

Examples

Load data on quotas, women in parliament and maternal mortality (a balanced panel version) from Bhalotra et al., (2020).

. webuse set www.damianclarke.net/stata/

. webuse quota_example.dta, clear

Run SDID estimator without covariates and bootstrap standard error.

. sdid womparl country year quota, vce(bootstrap) seed(1213)

Run SDID estimator using covariates in projected way.

. drop if lngdp==.

. sdid womparl country year quota, vce(bootstrap) seed(1213) covariates(lngdp, projected)

Example with one time adoption and some graphics options. Load data from Abadie et al., (2010).

. webuse prop99_example.dta, clear

. sdid packspercapita state year treated, vce(placebo) seed(1213) graph g1_opt(xtitle("")) g2_opt(ylabel(0(50)150))

References

A. Abadie, A. Diamond and J. Hainmueller. 2010. Synthetic Control Methods for Comparative Case Studies: Estimating the Effect of California’s Tobacco Control Program. Journal of the American Statistical.

D. Arkhangelsky, S. Athey, D. Hirshberg, G. Imbens and S. Wager. 2021. Synthetic Difference in Differences.
American Economic Review.

S. Bhalotra, D. Clarke, J. Gomes, and A. Venkataramani. 2020. Maternal Mortality and Women's Political Participation.
Centre for Economic Policy Research Discussion Paper.

D. Clarke, D Pailañir, S. Athey and G. Imbens. 2023. Synthetic Difference-in-Differences Estimation.
IZA Discussion Paper.

S. Kranz. 2022. Synthetic Difference-in-Differences with Time-Varying Covariates.
Working paper.

Author

Damian Clarke, Universidad de Chile.
Email dclarke@fen.uchile.cl

Daniel Pailañir, Universidad de Chile.
Email dpailanir@fen.uchile.cl