diff_diff.DurationDiD#

class diff_diff.DurationDiD[source]#

Bases: BaseEstimator

Duration difference-in-differences (Deaner & Ku 2026) for absorbing outcomes.

Two-group, common-timing design: treatment is a FIXED 0/1 group indicator, outcome is a binary absorbing spell-ended indicator on a balanced, equally spaced numeric time grid, and last_pre_period is the last untreated date. The counterfactual treated survival is imputed from the control group under a restriction on the untreated hazards:

  • method="cd" (common dynamics): the untreated hazards differ by a constant additive gap c (Equation 2.3); fitted as the weighted mean of the pre-treatment average-hazard gaps (Equations 3.2-3.4).

  • method="ph" (proportional hazards): the untreated hazards are proportional, ratio c (Equation 2.4); fitted as the weighted mean of the pre-treatment cumulative-increment ratios (Theorem 1).

The reported effect at each post-treatment date is the absorption ATT E[Y_it - Y_it(0) | treated] (positive = more cumulative exit); the headline att is its uniform average over the post-treatment dates. Inference is the Appendix B whole-individual pooled bootstrap with centered absolute-deviation pointwise and simultaneous (max-|t|) bands, plus the Algorithm 2 fixed-anchor pre-treatment specification test.

Parameters:
  • method ({"cd", "ph"}, default="cd") – Untreated-hazard restriction.

  • n_bootstrap (int, default=1000) – Whole-individual bootstrap draws. 0 returns point estimates with NaN inference; otherwise at least 2.

  • alpha (float, default=0.05) – Significance level for every band and the pretest.

  • seed (int, optional) – Seed for numpy.random.default_rng.

Notes

Identification requires binary absorbing outcomes, a fixed population, no anticipation before the common intervention, unaffected controls, and the chosen hazard restriction on the UNTREATED hazards (not on outcome levels). Bootstrap validity additionally assumes independence across individuals with arbitrary serial dependence within each history. Covariates, staggered adoption, censoring, survey weights and cluster dependence are not supported in this version. Fitting dates default to every eligible pre-treatment date after the baseline with equal weights; fit(pre_periods=..., pre_period_weights=...) selects a subset and nonnegative weights (see fit()).

Methods

__init__([method, n_bootstrap, alpha, seed])

fit(data, outcome, unit, time, treatment, *, ...)

Fit the estimator on a balanced long individual panel.

get_params([deep])

Get estimator parameters (sklearn-compatible).

set_params(**params)

Set estimator parameters (sklearn-compatible, transactional).

__init__(method='cd', n_bootstrap=1000, alpha=0.05, seed=None)[source]#
Parameters:
classmethod __new__(*args, **kwargs)#