Changing software should not change the economic question. Yet two implementations of the same difference-in-differences framework can produce different-looking estimates because their defaults refer to different causal parameters.
That is the first point to keep in mind when comparing xtswitchdid, the official StataNow command, with the community-contributed did_multiplegt_dyn. Both implement the framework developed by de Chaisemartin and D’Haultfœuille for estimating intertemporal treatment effects. They are not rival identification strategies. Their differences concern normalization, sample construction, available extensions, and the organization of estimation and postestimation.
The economic integration application on EconMacro provides a useful comparison. Its main specification requests raw effects. Consequently, the appropriate counterpart is did_multiplegt_dyn without the normalized option—not a comparison of the two commands’ default outputs.
1. The same causal question: a treatment path against the status quo
The application relates GDP growth to changes in economic integration, using institutional quality, INST, as a covariate. The treatment is
xtset imfcode period
generate double deia = D.eia
where eia measures the number of bilateral Economic Integration Agreement links. Thus, deia measures the annual change in those links.
Let \(b_g\) denote country \(g\)’s initial treatment and \(F_g\) its first treatment-change date. At exposure \(\ell\), the outcome is observed at
For a switcher-in, the country-specific causal effect can be written schematically as
The counterfactual is keeping treatment at its initial value. It need not mean receiving zero treatment or never participating in an agreement. Eligible controls share the switcher’s initial treatment and have not changed their treatment by the date of the relevant comparison.
Both commands allow multivalued treatment, reversals, heterogeneous effects, and effects of past treatment on current outcomes. Their causal interpretation nevertheless requires no anticipation and parallel trends for the relevant status-quo outcomes, with the appropriate conditional assumptions when covariates are included.
An event study anchored at the first switch does not ignore subsequent treatment changes. Those changes enter the treatment history whose combined effect is estimated. But the baseline implementations do not automatically turn every later switch into a separate experiment identifying its isolated effect.
The timing convention also matters. Exposure 1 is the switching year; Exposure 2 is one year later. Four effects therefore cover the switching year and the following three years, not four years after the switch.
2. The main trap: different normalization defaults
The commands’ defaults differ in a consequential way:
| Quantity requested | xtswitchdid |
did_multiplegt_dyn |
|---|---|---|
| Raw, nonnormalized effects | Specify raw |
Default |
| Normalized effects | Default | Specify normalized |
A raw effect concerns the observed treatment paths. A normalized effect rescales that effect by the accumulated incremental treatment dose. These are different estimands, not merely different labels in an output table.
For a switcher-in, define
This is the additional treatment received through exposure \(\ell\), relative to remaining at the baseline. If \(\delta_\ell\) denotes the aggregated raw effect and \(\overline A_\ell\) the corresponding average incremental dose, using the appropriate horizon-specific aggregation weights, then schematically
The normalized effect generally identifies a weighted average of contemporaneous and lagged treatment effects. It does not separately identify the coefficient on lag \(\ell-1\).
A discrepancy between the commands’ default estimates therefore need not indicate an implementation problem or an econometric disagreement. It may simply reflect a different question: the effect of the observed treatment histories versus an effect scaled by incremental treatment exposure.
3. Translating the Stata specification
The following commands assume that the application’s dataset is loaded and that sample and deia have already been constructed. The all-controls specification is
xtset imfcode period
xtswitchdid (growth INST) (deia) ///
if sample & period > 1989, ///
group(imfcode) ///
switchgroup(in) controlgroup(all) ///
neffects(4) raw ///
vce(cluster imfcode)
estat eventplot
estat ptrends
estat paths, pathlen(4)
estat total
The corresponding community-command specification is
* Install once, if needed:
* ssc install did_multiplegt_dyn
did_multiplegt_dyn growth imfcode period deia ///
if sample & period > 1989, ///
effects(4) placebo(4) ///
switchers(in) controls(INST) ///
cluster(imfcode) ///
design(0, console)
The absence of normalized is deliberate. The default control pool in did_multiplegt_dyn corresponds to controlgroup(all): eligible never-switchers and not-yet-switchers, subject to the baseline-treatment restriction.
The main correspondences are:
| Purpose | xtswitchdid |
did_multiplegt_dyn |
|---|---|---|
| Four exposure horizons | neffects(4) |
effects(4) |
| Switchers-in only | switchgroup(in) |
switchers(in) |
| All eligible controls | controlgroup(all) |
Default |
| Never-switcher controls only | controlgroup(never) |
only_never_switchers |
| Common switchers across effect horizons | commonswitchers |
same_switchers |
| Institutional-quality covariate | (growth INST) |
controls(INST) |
| Country-clustered inference | vce(cluster imfcode) |
cluster(imfcode) |
| Pretreatment placebos | estat ptrends |
placebo(4) |
| Treatment-path display | estat paths, pathlen(4) |
design(0, console) |
| Average total effect per treatment unit | estat total |
Main output |
The placebo row refers to the four-effect specification above. These are correspondences in purpose; the displays and retained samples need not be identical.
To translate the never-switcher/common-switcher specification, replace controlgroup(all) with controlgroup(never) and add commonswitchers in xtswitchdid. Add the following options to the community-command specification:
only_never_switchers same_switchers
For a normalized comparison, remove raw from xtswitchdid and add normalized to did_multiplegt_dyn, leaving the other choices unchanged.
These commands translate the specification; they do not establish numerical equality. No cross-command replication results are reported here. Such a comparison requires checking treatment histories and estimation samples, not just matching option names.
4. A return to zero is not necessarily an exit from integration
One of the treatment paths reported in the application is
deia: 0 17 0 0 0
Because deia is the first difference of eia, this path does not describe 17 links appearing and then disappearing. For an initial stock \(K\), it corresponds to
eia: K K+17 K+17 K+17 K+17
The links remain in place. The zeros indicate no additional net links in those years.
This distinction matters because the commands interpret changes in the variable supplied as treatment. They do not assign an institutional meaning to “switching out.” A fall in deia from 17 to zero is a reversal in the flow variable, not evidence that the country withdrew from its existing agreements.
Replacing deia with eia therefore changes more than the implementation. It changes initial-treatment matching, the status-quo counterfactual, and normalization.
The difference follows directly from the dose formula. For the one-off increase above, through exposure \(\ell\),
The flow specification counts the additional links introduced. The stock specification accumulates additional link-years. Even where a carefully matched comparison yields the same raw outcome contrast, its normalized interpretation can differ substantially.
A software comparison should keep deia unchanged. Comparing deia with eia is a separate economic exercise about the treatment definition.
5. What the reported growth effect means
The all-controls specification reports a raw Exposure 2 effect of approximately 0.0286, equivalent to 2.86 percentage points of annual GDP growth, one year after the first switch.
This is the average effect of the observed expansion histories among eligible switchers, relative to maintaining the initial treatment. It is not the effect of one additional agreement link. Nor should the aggregate estimate be divided by 17 merely because the path shown above is prominent: other countries can contribute different treatment doses and histories.
The average total effect is a third object. It aggregates outcome effects across the relevant post-switch observations and rescales them by incremental treatment doses. It is not simply an unweighted average of the displayed event-study coefficients. A cumulative effect per dose should not be interpreted as the same annual effect recurring indefinitely.
The application also reports a joint placebo-test \(p\)-value of approximately 0.824. The placebos are mirrored pretreatment comparisons: they reproduce the relevant comparison lengths before the first switch. They are not ordinary one-period regression leads.
Their nonrejection is reassuring, but it does not prove identification. Agreement between the two commands would likewise be a useful implementation check—not an independent test of their shared identifying assumptions.
6. Why matching the options may still leave different results
Missing observations can change the treatment history
By default, xtswitchdid applies listwise deletion before determining treatment timing. Its nolistwise option preserves observed treatment information when outcomes or covariates are missing and uses a more conservative procedure when missing treatment values obscure the first switch.
did_multiplegt_dyn has its own missing-treatment conventions, including the option drop_if_d_miss_before_first_switch. These settings should not be treated as interchangeable defaults.
Consider a country whose treatment changes in 1995 but whose institutional-quality observation is missing in that year. Dropping the observation before identifying switches can produce a different observed treatment history from retaining its treatment information while excluding it from outcome estimation.
Consequently, comparing total observation counts is not enough. A useful audit checks each country’s inferred baseline, first-switch date, and eligibility at each horizon. It separates the observations that identify the treatment history from those available for outcome comparisons.
For the same reason, passing one command’s e(sample) directly to the other is not automatically a valid harmonization strategy. Removing earlier observations may redefine the baseline or obscure a switch.
Returning to the baseline differs from crossing both sides of it
A treatment path can rise above its initial value and later return to it. That is different from a path that has moved both above and below the baseline. The Korea discussion in the original application concerns the latter situation.
Both commands’ standard treatment-path restrictions exclude the affected later comparisons after the path has crossed both sides of its initial value. The community command offers dont_drop_larger_lower to retain such observations, but this sacrifices the usual interpretation in terms of exposure to a weakly higher treatment dose. The option should not be used merely to make sample counts match.
Common switchers and placebos address different issues
The options commonswitchers and same_switchers hold the switching groups fixed across effect horizons. This makes a dynamic profile less sensitive to changes in which countries contribute to each coefficient. The Stata manual explicitly notes that common switchers do not imply a common set of controls.
The additional same_switchers_pl option in did_multiplegt_dyn requires availability of all requested effects and placebos for the switchers entering the placebo calculations. That is a further sample restriction, not another name for same_switchers.
Common-switcher restrictions address composition. Placebos assess observable implications of the identifying assumptions. Neither substitutes for the other.
7. Where the commands genuinely differ
The practical attraction of xtswitchdid is its integrated Stata workflow. Event-study plots, placebo tests, treatment-path tables, and total effects are available through estat. Path-specific estimation is also supported; it is not an exclusive feature of the community command. These are useful reporting advantages, but they do not constitute stronger identification.
did_multiplegt_dyn provides several research-oriented extensions. The normalized_weights option reports the weights on contemporaneous and lagged effects. The trends_lin option allows group-specific linear trends. The continuous(#) option addresses effectively continuous initial treatment values by imposing a polynomial model for status-quo outcome trends. It is not needed merely because post-switch treatment doses are nonbinary; the authors recommend bootstrap inference for this extension.
The documented reset(#) option can reuse later treatment spells after sufficiently long periods without a treatment change. It does so under an additional finite-lag restriction: treatment lags older than the specified length must not affect the outcome. It is therefore not a free way to recover every repeated episode while retaining unrestricted treatment dynamics.
Some apparent differences have counterparts. In particular, supergroup() in xtswitchdid restricts comparisons within broader groups, corresponding to the comparison restriction implemented through trends_nonparam() in did_multiplegt_dyn.
Both commands support analytical, group-clustered inference. Differences in standard errors should therefore not automatically be attributed to a supposed contrast between bootstrap and analytical inference.
8. Match the estimand before comparing the estimates
For the economic integration application, the relevant starting point is
xtswitchdid, raw ↔ did_multiplegt_dyn without normalized
Then hold fixed the treatment definition, sample window, switcher direction, control pool, covariate adjustment, and horizon-specific switcher composition. Check the treatment-history conventions before interpreting any numerical discrepancy. Compare raw effects, normalized effects, and inference separately.
The remaining questions are economic rather than software-specific. Does institutional quality capture a confounder, or can it also respond to integration? Do firms and households anticipate agreements before the measured switch? Do common integration episodes create dependence across countries?
Those questions matter more for causal credibility than choosing between two implementations of the same estimator family. did_multiplegt_dyn can provide a valuable replication and extension of the xtswitchdid analysis. It should not be presented as an independent identification strategy simply because it is a different command.
References
Saadaoui, J. “xtswitchdid with Stata.” EconMacro.
de Chaisemartin, C., and X. D’Haultfœuille. 2026. “Difference-in-Differences Estimators of Intertemporal Treatment Effects.” The Review of Economics and Statistics, 108(4), 863–880. Open-access manuscript.
StataCorp. “xtswitchdid—Difference in differences with switching treatments for panel data.” Stata Causal Inference and Treatment-Effects Estimation Reference Manual.
StataCorp. “xtswitchdid postestimation.” Stata Causal Inference and Treatment-Effects Estimation Reference Manual.
Credible Answers. “did_multiplegt_dyn: Stata and R documentation.” Software repository.
“DIDmultiplegtDYN reference manual.” CRAN.