Sequential Synthetic Difference-in-Differences (Sequential SDiD)

Contents

Sequential Synthetic Difference-in-Differences (Sequential SDiD)#

Overview#

Sequential Synthetic Difference-in-Differences (Sequential SDiD, arXiv:2404.00164v2, Arkhangelsky & Samkov, 2025) is an event-study estimator for staggered-adoption designs that remains robust when the parallel-trends assumption fails. It adapts the canonical SDiD of Arkhangelsky et al. (2021) by operating on cohort-level aggregates and sequentially imputing treated cells with their estimated counterfactuals so that bias from early cohorts does not cascade into later ones.

The estimator is asymptotically equivalent to an infeasible oracle OLS regression that knows the unobserved interactive fixed effects (Proposition 3.1 of the paper), giving it the first formal efficiency guarantees for an SC-type method. Five structural differences distinguish Sequential SDiD from the canonical SDID estimator already in mlsynth:

  • It works on aggregated cohort outcomes \(Y_{a, t} = n_a^{-1} \sum_{i:\,A_i = a} Y_{i, t}\) rather than unit-level data, with cohort shares \(\pi_a = n_a / n\) carrying the unit-count information.

  • Weights satisfy only the simplex sum constraint \(\sum \omega = 1\) — non-negativity is dropped.

  • The unit-weight penalty is the population-share-scaled \(\eta^{2} \sum_j \omega_j^2 / \pi_j\); the time-weight penalty is \(\eta^{2} \sum_l \lambda_l^2\).

  • Donors for cohort \(a\) are restricted to later-adopting cohorts \(j > a\) (including the never-treated cohort), not the universe of controls.

  • Cohort-by-horizon effects are estimated in a sequential cascade: each \(\hat\tau_{a, k}^{\,SSDiD}\) is computed, then the treated cell \(Y_{a, a + k}\) is overwritten with \(Y_{a, a + k} - \hat \tau_{a, k}^{\,SSDiD}\) so subsequent (a', k') steps see an imputed panel free of treatment contamination.

When to Use This Estimator#

Event studies with staggered adoption – units switching on at different dates – are the workhorse design of applied micro. The modern estimators built for them (Callaway & Sant’Anna 2020, de Chaisemartin & d’Haultfœuille 2020, Sun & Abraham 2020, Borusyak et al. 2024) fixed the heterogeneous-effects bug in two-way fixed effects, but they still rest on parallel trends: absent treatment, treated and comparison cohorts would have moved together. When unobserved interactive fixed effects (latent unit factors loading on latent time factors) drive selection into treatment, parallel trends fails and those estimators are biased – exactly the regime Sequential SDiD (Arkhangelsky & Samkov 2025) targets.

Its bet is to model the confounder. Within a linear interactive-fixed- effects model, Sequential SDiD is proven asymptotically equivalent to the infeasible oracle OLS that knows the latent factors (Prop. 3.1). That equivalence buys three things at once: robustness to parallel-trends violations of the IFE type, asymptotic normality with standard inference, and the first formal efficiency guarantee for an SC-type estimator. The sequential imputation – estimate the earliest cohort, subtract its effect, reuse the cleaned panel for later cohorts – gives a cohesive analysis of the whole event study, in contrast to per-cohort SC methods (Partially Pooled SCM (PPSCM), Cattaneo et al. 2021) that treat each adoption cohort as a separate problem.

Reach for Sequential SDiD when#

  • You have a staggered-adoption event study and you suspect parallel trends fails because of unobserved confounders that look like interactive fixed effects (selection on latent trends, not just levels).

  • Adoption cohorts are reasonably large. The method averages outcomes within each cohort and leans on a law of large numbers to kill idiosyncratic noise; this is the estimator’s core requirement and its main limitation.

  • You want valid, standard inference (asymptotic normality) and a defensible efficiency claim, plus a dynamic event-study path of cohort-by-horizon effects.

  • You are in the fixed-:math:`T`, large-:math:`N` regime typical of county/firm/individual panels aggregated into a handful of adoption cohorts.

Do not use Sequential SDiD when#

Mathematical Formulation#

Setup#

Let \(Y_{i, t}\) denote the outcome of unit \(i\) at period \(t \in \{1, \dots, T\}\), and \(A_i\) the (possibly infinite) adoption period of unit \(i\). Cohorts are indexed by adoption period \(a\); the never-treated cohort uses \(A_i = +\infty\). For each cohort the implementation computes

\[Y_{a, t} \;=\; \frac{1}{n_a} \sum_{i:\, A_i = a} Y_{i, t}, \qquad \pi_a = \frac{n_a}{n}.\]

Under Assumption 2.2 of the paper, the aggregate outcomes inherit the interactive-fixed-effects structure

\[Y_{a, t} \;=\; \alpha_a + \beta_t + \theta_a^\top \psi_t + \mathbb{1}\{a \le t\}\,\tau_{a, t - a} + \epsilon_{a, t},\]

where \(\theta_a^\top \psi_t\) captures unobserved confounders that break parallel trends. Aggregation drives \(\epsilon_{a, t}\) to zero under the paper’s “large cohort” asymptotics, leaving the IFE structure identifiable.

Algorithm 1#

For each horizon \(k = 0, 1, \dots, K\) (outer loop) and each treated cohort \(a = a_{\min}, \dots, a_{\max}\) (inner loop), Sequential SDiD runs three steps.

Step 1: Solve two regularized QPs. Both QPs are equality-constrained convex quadratic programs (no non-negativity). The unit-weight QP is

\[\hat\omega^{(a, k)}, \hat\omega_0 \;=\; \arg\min_{\sum_{j > a} \omega_j = 1} \quad \sum_{l < a + k} \left( \omega_0 + \sum_{j > a} \omega_j Y_{j, l} - Y_{a, l} \right)^{\!2} \;+\; \eta^2 \sum_{j > a} \frac{\omega_j^2}{\pi_j},\]

and the time-weight QP is

\[\hat\lambda^{(a, k)}, \hat\lambda_0 \;=\; \arg\min_{\sum_{l < a + k} \lambda_l = 1} \quad \sum_{j > a} \left( \lambda_0 + \sum_{l < a + k} \lambda_l Y_{j, l} - Y_{j, a + k} \right)^{\!2} \;+\; \eta^2 \sum_{l < a + k} \lambda_l^{\,2}.\]

Both are solved in closed form via their KKT linear systems in mlsynth.utils.seq_sdid_helpers.weights.

Step 2: Weighted double-difference.

\[\hat\tau_{a, k}^{\,SSDiD} \;=\; \left( Y_{a, a + k} - \sum_{j > a} \hat\omega_j^{(a, k)} \, Y_{j, a + k} \right) \;-\; \sum_{l < a + k} \hat\lambda_l^{(a, k)} \left( Y_{a, l} - \sum_{j > a} \hat\omega_j^{(a, k)} \, Y_{j, l} \right).\]

This is the same SDID-style contrast as the canonical estimator, just evaluated on cohort-level aggregates.

Step 3: Sequential imputation.

\[Y_{a, a + k} \;:=\; Y_{a, a + k} \;-\; \hat\tau_{a, k}^{\,SSDiD}.\]

The treated cell is replaced with its estimated counterfactual in place in the panel matrix. When the outer loop advances to a longer horizon or the inner loop advances to a later cohort, subsequent QPs use this imputed panel — which is the mechanism that prevents bias from cascading through the estimator.

Pooled Event Study#

Cohort-specific effects are aggregated into a single event-study trajectory via Equation 2.5 of the paper:

\[\hat\tau_k^{\,SSDiD}(\mu) \;=\; \sum_{a \in [a_{\min}, a_{\max}]} \mu_a \hat\tau_{a, k}^{\,SSDiD}, \qquad \mu_a = \frac{\pi_a}{\sum_{a' \in [a_{\min}, a_{\max}]} \pi_{a'}}.\]

The default mu is proportional to cohort shares (i.e. larger cohorts get more weight), recovering the unit-uniform interpretation common in the DiD literature. The result lives on SeqSDIDEventStudy.tau.

The \(\eta \to \infty\) Limit#

Remark 2.2 of the paper notes that as \(\eta \to \infty\), the unit- weight QP’s penalty \(\sum \omega_j^2 / \pi_j\) forces \(\omega_j \propto \pi_j\) (each unit in the donor pool gets equal weight), and the time-weight QP’s penalty \(\sum \lambda_l^{\,2}\) forces \(\lambda_l = 1 / (a + k - 1)\) (uniform). The resulting estimator is a sequential DiD imputation estimator closely related to Borusyak, Jaravel, and Spiess (2024). The mlsynth implementation exposes this mode via SequentialSDIDConfig.mode:

  • mode = "ssdid": paper’s main estimator with finite eta (default).

  • mode = "sdid_imputation": forces the \(\eta \to \infty\) limit internally and returns the sequential-DiD-style result.

Inference (Section 2.3)#

Inference uses the Bayesian bootstrap of Rubin (1981) and Chamberlain & Imbens (2003). At each bootstrap iteration:

  1. Draw independent weights \(\xi_i \sim \mathrm{Exp}(1)\) for every underlying unit (not cohort).

  2. Reconstruct cohort-level outcomes as weighted means:

    \[Y_{a, t}(\xi) \;=\; \frac{\sum_{i:\, A_i = a} Y_{i, t} \xi_i}{\sum_{i:\, A_i = a} \xi_i}.\]
  3. Re-run Algorithm 1 on the perturbed panel.

  4. Record the pooled event-study vector.

Standard errors are sample standard deviations of the bootstrap replicates, and confidence intervals are Wald-type at SequentialSDIDConfig.alpha. The full replicate matrix is retained on SeqSDIDEventStudy.bootstrap_draws in case quantile-based intervals are preferred downstream.

Limitations#

The paper’s formal guarantees require large adoption cohorts — cohort sizes that grow with the sample so the aggregation kills the idiosyncratic noise. The algorithm still runs on single-treated-unit panels (e.g., the Proposition 99 dataset), but with only one treated cohort and one never-treated cohort the time-weight QP becomes effectively underdetermined; the practical recommendation is to use canonical SDID for those panels and reserve Sequential SDiD for genuine staggered designs with multiple sizable cohorts.

Core API#

Sequential Synthetic Difference-in-Differences (Sequential SDiD) estimator.

Implements:

Arkhangelsky, D., & Samkov, A. (2025). “Sequential Synthetic Difference in Differences.” arXiv:2404.00164v2.

The estimator targets event-study designs with staggered treatment adoption and remains robust when the parallel-trends assumption is violated by interactive fixed effects. It operates on cohort-level aggregates rather than unit-level data, sequentially imputes treated outcomes with their estimated counterfactuals, and uses unconstrained-sum weights with a population-share-scaled L2 penalty.

Output is a typed mlsynth.utils.seq_sdid_helpers.structures.SeqSDIDResults container exposing:

  • cohort_effects cohort-by-horizon point estimates

    tau_hat_{a, k}^SSDiD

  • event_study the pooled horizon-k effects

    tau_hat_k^SSDiD(mu) with bootstrap CIs

  • inference bootstrap configuration summary

  • raw_event_study the non-bootstrap point-estimate vector

class mlsynth.estimators.seq_sdid.SequentialSDID(config: SequentialSDIDConfig | dict)#

Bases: object

Sequential Synthetic Difference-in-Differences estimator.

Parameters:

config (SequentialSDIDConfig or dict) – Configuration object. See mlsynth.config_models.SequentialSDIDConfig.

Returns:

SeqSDIDResults – Typed container with cohort-by-horizon effects, the pooled event-study trajectory, and Bayesian-bootstrap SE / CI.

Notes

The two-way fixed-effects representation underlying canonical SDiD requires parallel trends; Sequential SDiD relaxes this by modelling interactive fixed effects directly. The theoretical guarantees in the paper require that adoption cohorts be relatively large; on single-treated-unit panels the algorithm still runs but the formal efficiency results don’t apply.

References

Arkhangelsky, D., & Samkov, A. (2025). “Sequential Synthetic Difference in Differences.” arXiv:2404.00164v2.

Examples

>>> import pandas as pd
>>> from mlsynth import SequentialSDID
>>> df = pd.read_csv("...")
>>> res = SequentialSDID({
...     "df": df, "outcome": "y", "treat": "treated",
...     "unitid": "unit", "time": "year",
...     "n_bootstrap": 200, "eta": 0.0, "display_graphs": False,
... }).fit()
>>> res.event_study.tau
fit() SeqSDIDResults#

Run Algorithm 1 + bootstrap inference and return the typed result.

Configuration#

class mlsynth.config_models.SequentialSDIDConfig(*, df: ~pandas.DataFrame, outcome: str, treat: str, unitid: str, time: str, display_graphs: bool = True, save: bool | str = False, counterfactual_color: ~typing.List[str] = <factory>, treated_color: str = 'black', eta: ~typing.Annotated[float, ~annotated_types.Ge(ge=0)] = 0.0, mode: ~typing.Literal['ssdid', 'sdid_imputation'] = 'ssdid', K: ~typing.Annotated[int | None, ~annotated_types.Ge(ge=0)] = None, a_min: int | None = None, a_max: int | None = None, n_bootstrap: ~typing.Annotated[int, ~annotated_types.Ge(ge=0)] = 500, alpha: ~typing.Annotated[float, ~annotated_types.Gt(gt=0.0), ~annotated_types.Lt(lt=1.0)] = 0.05, seed: int = 1400)#

Configuration for the Sequential Synthetic Difference-in-Differences estimator.

Implements Arkhangelsky & Samkov (2025, arXiv:2404.00164v2). Operates on cohort-level aggregates and is robust to violations of parallel trends induced by interactive fixed effects. Inherits the standard df / outcome / treat / unitid / time panel interface from BaseEstimatorConfig.

K: int | None#
a_max: int | None#
a_min: int | None#
alpha: float#
eta: float#
mode: Literal['ssdid', 'sdid_imputation']#
model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'forbid'}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

n_bootstrap: int#
seed: int#

Helper Modules#

Cohort-level aggregation for Sequential SDiD.

Reuses mlsynth.utils.datautils.dataprep() to identify treated / never-treated units and their adoption periods, then aggregates the unit-level outcomes into the cohort-level Y_{a,t} panel that Algorithm 1 consumes.

mlsynth.utils.seq_sdid_helpers.setup.prepare_seq_sdid_inputs(df: DataFrame, outcome: str, treat: str, unitid: str, time: str, a_min: int | None = None, a_max: int | None = None, K: int | None = None) SeqSDIDInputs#

Aggregate the panel into cohort-level outcomes Y_{a,t} and shares.

Parameters:
  • df, outcome, treat, unitid, time (standard mlsynth panel inputs.)

  • a_min, a_max (int, optional) – Earliest / latest treated cohort (1-based time index) to estimate. Default: span all treated cohorts in the data.

  • K (int, optional) – Maximum event-time horizon. Default: T - a_max so every estimable effect fits inside the panel.

Closed-form QP solvers for the Sequential SDiD weights.

Both weight problems in Algorithm 1 are equality-constrained convex quadratic programs with the simplex sum constraint and no non-negativity constraint. We solve them via the KKT linear system rather than handing them to cvxpy — the bootstrap calls these tens of thousands of times, and the linear system is small (~ N_cohort + 1 unknowns).

mlsynth.utils.seq_sdid_helpers.weights.solve_time_qp(Y_pre_donors: ndarray, y_event_donors: ndarray, eta: float) Tuple[ndarray, float]#

Solve the Sequential SDiD time-weight QP for one (a, k) step.

Optimization (paper Algorithm 1, line 5):

min over (lambda, lambda_0)
    sum_{j > a} (lambda_0 + sum_l lambda_l Y_{j, l} - Y_{j, a + k})^2
    + eta^2 * sum_l lambda_l^2
s.t.  sum_l lambda_l = 1.
Parameters:
  • Y_pre_donors (np.ndarray) – Donor outcomes in the pre-event window, shape (T_pre, J).

  • y_event_donors (np.ndarray) – Donor outcomes at event time a + k, shape (J,).

  • eta (float) – Non-negative regularization parameter.

Returns:

  • lambda_w (np.ndarray) – Optimal time weights, shape (T_pre,), summing to 1.

  • lambda_0 (float) – Optimal intercept.

mlsynth.utils.seq_sdid_helpers.weights.solve_unit_qp(Y_pre_donors: ndarray, y_pre_treated: ndarray, pi_donors: ndarray, eta: float) Tuple[ndarray, float]#

Solve the Sequential SDiD unit-weight QP for one (a, k) step.

Optimization (paper Algorithm 1, line 5):

min over (omega, omega_0)
    sum_{l < a + k} (omega_0 + sum_j omega_j Y_{j, l} - Y_{a, l})^2
    + eta^2 * sum_j omega_j^2 / pi_j
s.t.  sum_j omega_j = 1.
Parameters:
  • Y_pre_donors (np.ndarray) – Pre-event outcomes of later-adopting cohorts, shape (T_pre, J) where T_pre = a + k - 1 and J is the number of donor cohorts (j > a).

  • y_pre_treated (np.ndarray) – Pre-event outcomes of the treated cohort, shape (T_pre,).

  • pi_donors (np.ndarray) – Cohort shares pi_j for the donor cohorts, shape (J,).

  • eta (float) – Non-negative regularization parameter.

Returns:

  • omega (np.ndarray) – Optimal unit weights, shape (J,), summing to 1.

  • omega_0 (float) – Optimal intercept.

Algorithm 1: Sequential SDiD outer / inner loop.

Iterates over k = 0, 1, ..., K (outer) and treated cohorts a = a_min, ..., a_max (inner). At each (k, a) step the routine solves the two regularized QPs, computes the weighted double-difference tau_{a,k}, and overwrites Y_{a, a+k} with its estimated counterfactual Y_{a, a+k} - tau_{a,k}. Later steps therefore see a panel where every previously-estimated treated cell has been replaced by its imputed counterfactual — this is the sequential cascade that gives the estimator its name.

mlsynth.utils.seq_sdid_helpers.algorithm.pooled_event_study(cohort_effects: Dict[Tuple[int, int], SeqSDIDCohortEffect], pi: ndarray, cohort_periods: ndarray, a_min: int, a_max: int, K: int) ndarray#

Aggregate per-cohort effects into horizon-k pooled estimates.

Implements tau_hat_k^SSDiD(mu) = sum_a mu_a * tau_hat_{a, k} with mu_a = pi_a / sum_{a' in [a_min, a_max]} pi_a', the cohort-share weighting recommended in the paper (Eq. 2.5).

Parameters:
  • cohort_effects (Dict[(int, int), SeqSDIDCohortEffect]) – Output of run_sequential_sdid().

  • pi (np.ndarray) – Cohort shares.

  • cohort_periods (np.ndarray) – 1-based time indices.

  • a_min, a_max (int) – Range of treated cohorts that participated in estimation.

  • K (int) – Maximum horizon.

Returns:

np.ndarray – Length-K + 1 array of pooled effects.

mlsynth.utils.seq_sdid_helpers.algorithm.run_sequential_sdid(Y_agg: ndarray, pi: ndarray, cohort_periods: ndarray, treated_cohort_indices: ndarray, a_min: int, a_max: int, K: int, eta: float, in_place_imputation: bool = True) Tuple[ndarray, Dict[Tuple[int, int], SeqSDIDCohortEffect]]#

Run Algorithm 1 of Arkhangelsky & Samkov (2025).

Parameters:
  • Y_agg (np.ndarray) – Cohort-level outcome matrix, shape (T, A).

  • pi (np.ndarray) – Cohort shares, length A, summing to 1 across the whole sample.

  • cohort_periods (np.ndarray) – 1-based time index of each cohort’s adoption period, length A. Never-treated cohorts use np.iinfo(np.int64).max.

  • treated_cohort_indices (np.ndarray) – Column indices into Y_agg (and pi) identifying the finitely-adopting cohorts.

  • a_min, a_max (int) – Earliest / latest cohort adoption-period index to estimate.

  • K (int) – Maximum horizon k to estimate.

  • eta (float) – Regularization parameter (>= 0). At eta -> infinity the unit weights collapse to omega_j proportional to pi_j and the time weights to 1 / (a + k - 1) (Remark 2.2 of the paper).

  • in_place_imputation (bool) – Whether to update Y_agg[a, a+k] in place with the estimated counterfactual. The paper’s Algorithm 1 does this; we expose the flag for diagnostics. Default: True. Y_agg is copied before modification, so the input is never mutated.

Returns:

  • Y_imputed (np.ndarray) – The (possibly imputed) Y_agg matrix.

  • cohort_effects (Dict[Tuple[int, int], SeqSDIDCohortEffect]) – Per-(cohort_period, k) point estimates plus the fitted weights.

Bayesian-bootstrap inference for Sequential SDiD (paper Section 2.3).

For each bootstrap iteration we:

  1. Draw xi_i ~ Exp(1) for every underlying unit (not cohort).

  2. Re-weight the cohort-level outcomes: Y_{a, t}(xi) = sum_{i: A_i = a} Y_{i, t} xi_i / sum_{i: A_i = a} xi_i.

  3. Re-run Algorithm 1 on the perturbed panel.

  4. Record the pooled event-study vector.

Wald-type SE/CI come from the sample standard deviation of the bootstrap replicate matrix. Bootstrap draws are also retained on the result object in case the user wants quantile-based intervals later.

mlsynth.utils.seq_sdid_helpers.inference.bayesian_bootstrap_event_study(df: DataFrame, outcome: str, treat: str, unitid: str, time: str, inputs, eta: float, n_bootstrap: int, seed: int) ndarray#

Return (n_bootstrap, K + 1) matrix of bootstrap-replicate event-study vectors.

The bootstrap reweighting follows Section 2.3 of Arkhangelsky & Samkov (2025): independent xi_i ~ Exp(1) are drawn for every unit, and the cohort-level outcomes are reconstructed as weighted means with those weights.

mlsynth.utils.seq_sdid_helpers.inference.wald_intervals(tau_hat: ndarray, bootstrap_draws: ndarray, alpha: float = 0.05) Tuple[ndarray, ndarray]#

Return (se, ci) Wald-type SE and confidence intervals.

se is the sample standard deviation of the bootstrap replicates; ci is the standard normal Wald interval centered at tau_hat.

Event-study chart for Sequential SDiD.

Plots tau_hat_k^SSDiD against the event-time horizon k, with the bootstrap Wald band as a shaded region. Reuses matplotlib directly to stay independent of the existing SDID_plot helper, which is wired for the canonical-SDID dict shape.

mlsynth.utils.seq_sdid_helpers.plotter.plot_seq_sdid(results: SeqSDIDResults, title: str = 'Sequential SDiD event study', save: bool | str | dict = False) None#

Render the event-study trajectory with the bootstrap CI band.

Typed result containers for Sequential SDiD.

All matrices follow mlsynth’s (T, N) orientation (rows = time, columns = cohort).

class mlsynth.utils.seq_sdid_helpers.structures.SeqSDIDCohortEffect(cohort_period: int, k: int, tau: float, omega: ndarray, lambda_w: ndarray)#

Single cohort-by-horizon estimate.

Parameters:
  • cohort_period (int) – 1-based time index of the cohort’s adoption period.

  • k (int) – Horizon (event-time offset), with k = 0 the first treated period.

  • tau (float) – Point estimate tau_{a,k}^SSDiD.

  • omega (np.ndarray) – Unit weights solving the (a, k) QP, aligned with the slice of Y_agg corresponding to later cohorts j > a.

  • lambda_w (np.ndarray) – Time weights solving the (a, k) QP, aligned with pre-event periods l < a + k.

cohort_period: int#
k: int#
lambda_w: ndarray#
omega: ndarray#
tau: float#
class mlsynth.utils.seq_sdid_helpers.structures.SeqSDIDEventStudy(horizons: ndarray, tau: ndarray, se: ndarray, ci: ndarray, bootstrap_draws: ndarray, alpha: float)#

Pooled horizon-k effects tau_hat_k^SSDiD(mu).

Parameters:
  • horizons (np.ndarray) – Length-K + 1 array of event-time horizons k = 0, 1, ..., K.

  • tau (np.ndarray) – Pooled effects aligned with horizons.

  • se (np.ndarray) – Bootstrap standard errors aligned with tau.

  • ci (np.ndarray) – Length-(K + 1, 2) array of Wald confidence intervals.

  • bootstrap_draws (np.ndarray) – Bootstrap replicate matrix of shape (B, K + 1), retained for downstream diagnostics or alternative quantile-based intervals.

  • alpha (float) – Significance level used for ci.

alpha: float#
bootstrap_draws: ndarray#
ci: ndarray#
horizons: ndarray#
se: ndarray#
tau: ndarray#
class mlsynth.utils.seq_sdid_helpers.structures.SeqSDIDInference(n_bootstrap: int, method: str, seed: int)#

Bayesian bootstrap inference summary.

method: str#
n_bootstrap: int#
seed: int#
class mlsynth.utils.seq_sdid_helpers.structures.SeqSDIDInputs(Y_agg: ndarray, pi: ndarray, cohort_periods: ndarray, cohort_labels: Sequence, treated_cohort_indices: ndarray, time_labels: ndarray, n_units: int, a_min: int, a_max: int, K: int)#

Aggregated cohort-level panel fed into Sequential SDiD.

Parameters:
  • Y_agg (np.ndarray) – Cohort-level outcome matrix of shape (T, A) where A is the number of distinct adoption cohorts (treated cohorts in ascending order followed by the never-treated cohort, if present).

  • pi (np.ndarray) – Cohort shares pi_a = n_a / n, length A, summing to 1 over the entire sample.

  • cohort_periods (np.ndarray) – Length-A array of cohort adoption periods (1-based time indices). The never-treated cohort is encoded as np.iinfo(np.int64).max and lives at index A - 1.

  • cohort_labels (Sequence) – Human-readable labels for each cohort (e.g. adoption year), aligned with cohort_periods.

  • treated_cohort_indices (np.ndarray) – Integer indices into Y_agg’s second axis identifying treated (i.e. finitely-adopting) cohorts.

  • time_labels (np.ndarray) – Original time labels, length T.

  • n_units (int) – Total number of underlying units.

  • a_min (int) – Earliest treated cohort to estimate (1-based time index).

  • a_max (int) – Latest treated cohort to estimate.

  • K (int) – Maximum event-time horizon to estimate.

K: int#
Y_agg: ndarray#
a_max: int#
a_min: int#
cohort_labels: Sequence#
cohort_periods: ndarray#
n_units: int#
pi: ndarray#
time_labels: ndarray#
treated_cohort_indices: ndarray#
class mlsynth.utils.seq_sdid_helpers.structures.SeqSDIDResults(inputs: SeqSDIDInputs, cohort_effects: Dict[Tuple[int, int], SeqSDIDCohortEffect], event_study: SeqSDIDEventStudy, inference: SeqSDIDInference, eta: float, mode: str, raw_event_study: ndarray)#

Public SequentialSDID.fit() return container.

Parameters:
  • inputs (SeqSDIDInputs) – Aggregated panel + cohort metadata.

  • cohort_effects (Dict[Tuple[int, int], SeqSDIDCohortEffect]) – Per-(cohort_period, k) effects.

  • event_study (SeqSDIDEventStudy) – Pooled horizon-k effects with bootstrap inference.

  • inference (SeqSDIDInference) – Bootstrap configuration summary.

  • eta (float) – Regularization parameter actually used.

  • mode (str) – "ssdid" (the paper’s main estimator) or "sdid_imputation" (the eta -> infinity Borusyak-style limit from Remark 2.2).

  • raw_event_study (np.ndarray) – Length-K + 1 non-bootstrapped pooled effect vector (the same numbers as event_study.tau; kept separately for clarity).

cohort_effects: Dict[Tuple[int, int], SeqSDIDCohortEffect]#
eta: float#
event_study: SeqSDIDEventStudy#
inference: SeqSDIDInference#
inputs: SeqSDIDInputs#
mode: str#
raw_event_study: ndarray#

Example#

import pandas as pd
from mlsynth import SequentialSDID

df = pd.read_csv("staggered_panel.csv")  # state-level panel with treat in {0, 1}

results = SequentialSDID({
    "df":           df,
    "outcome":      "log_wage",
    "treat":        "treated",
    "unitid":       "state",
    "time":         "year",
    "eta":          1.0,
    "K":            10,
    "n_bootstrap":  500,
    "alpha":        0.05,
    "display_graphs": True,
}).fit()

# Pooled event-study trajectory (Eq. 2.5 of the paper).
for k, tau, se in zip(results.event_study.horizons,
                      results.event_study.tau,
                      results.event_study.se):
    print(f"k = {k:>2}  tau = {tau:+.3f}  se = {se:.3f}")

# Cohort-by-horizon decomposition.
for (a, k), effect in results.cohort_effects.items():
    print(f"cohort a = {a}  horizon k = {k}  tau = {effect.tau:+.3f}")

# Bayesian-bootstrap replicate matrix (B x (K + 1)) — for quantile CIs
# or downstream diagnostics.
results.event_study.bootstrap_draws.shape

References#

Arkhangelsky, D., & Samkov, A. (2025). “Sequential Synthetic Difference in Differences.” arXiv:2404.00164v2.

Arkhangelsky, D., Athey, S., Hirshberg, D. A., Imbens, G. W., & Wager, S. (2021). “Synthetic Difference-in-Differences.” American Economic Review 111(12): 4088-4118.

Borusyak, K., Jaravel, X., & Spiess, J. (2024). “Revisiting Event-Study Designs: Robust and Efficient Estimation.” Review of Economic Studies.