moderndid.ddd_rc#

moderndid.ddd_rc(y, post, subgroup, covariates, i_weights=None, est_method='dr', boot=False, boot_type='multiplier', biters=1000, influence_func=False, alpha=0.05, trim_level=0.995, random_state=None)[source]#

Compute the 2-period doubly robust DDD estimator for the ATT with repeated cross-section data.

Implements the triple difference-in-differences estimator from [1] for repeated cross-section data. Unlike panel data where the same units are observed in both periods, repeated cross-sections have different samples in each period.

The target parameter is the Average Treatment Effect on the Treated (ATT)

\[ATT(2, 2) = \mathbb{E}[Y_2(2) - Y_2(\infty) \mid S=2, Q=1],\]

where \(S=2\) denotes units in the treatment-enabling group and \(Q=1\) denotes eligibility for treatment.

For repeated cross-sections, the estimator follows the approach of [2], extending the DDD framework from [1]. Unlike panel data where outcomes are differenced within units, RCS fits separate outcome regression models for each (subgroup, time period) cell. The doubly robust DDD estimand combines three DiD comparisons

\[\begin{split}\widehat{ATT}_{\mathrm{dr}}(2,2) &= \mathbb{E}_n\left[ \left(\widehat{w}_{\mathrm{trt}}^{S=2,Q=1} - \widehat{w}_{\mathrm{comp}}^{S=2,Q=0}\right) \left(Y - \widehat{m}_{Y}^{S=2,Q=0}(X,T)\right)\right] \\ &+ \mathbb{E}_n\left[ \left(\widehat{w}_{\mathrm{trt}}^{S=2,Q=1} - \widehat{w}_{\mathrm{comp}}^{S=\infty,Q=1}\right) \left(Y - \widehat{m}_{Y}^{S=\infty,Q=1}(X,T)\right)\right] \\ &- \mathbb{E}_n\left[ \left(\widehat{w}_{\mathrm{trt}}^{S=2,Q=1} - \widehat{w}_{\mathrm{comp}}^{S=\infty,Q=0}\right) \left(Y - \widehat{m}_{Y}^{S=\infty,Q=0}(X,T)\right)\right],\end{split}\]

where each outcome model \(\widehat{m}_{Y}^{S=s,Q=q}(X,T)\) is fit separately for pre and post periods within each subgroup, as units are not tracked across periods in repeated cross-sections.

Parameters:
ynumpy.ndarray

A 1D array of outcomes from both pre- and post-treatment periods.

postnumpy.ndarray

A 1D array of post-treatment dummies (1 if post-treatment, 0 if pre-treatment).

subgroupnumpy.ndarray

A 1D array of subgroup indicators (1, 2, 3, or 4) for each observation, corresponding to the four cells of the \(S \times Q\) partition:

  • 4: \(S=g, Q=1\) (Treated AND Eligible - target group)

  • 3: \(S=g, Q=0\) (Treated BUT Ineligible)

  • 2: \(S=g_c, Q=1\) (Eligible BUT Untreated)

  • 1: \(S=g_c, Q=0\) (Untreated AND Ineligible)

covariatesnumpy.ndarray

A 2D array of pre-treatment covariates \(X\) for propensity score and outcome regression models. An intercept must be included if desired.

i_weightsnumpy.ndarray, optional

A 1D array of observation weights. If None, weights are uniform. Weights are normalized to have a mean of 1.

est_method{“dr”, “reg”, “ipw”}, default “dr”

Estimation method to use:

  • “dr”: Doubly robust (propensity score + outcome regression)

  • “reg”: Regression adjustment only (\(ATT_{ra}\))

  • “ipw”: Inverse probability weighting only (\(ATT_{ipw}\))

bootbool, default False

Whether to use bootstrap for inference.

boot_type{“multiplier”, “weighted”}, default “multiplier”

Type of bootstrap. Multiplier bootstrap uses Rademacher weights on the influence function; weighted bootstrap re-estimates with exponential weights.

bitersint, default 1000

Number of bootstrap repetitions.

influence_funcbool, default False

Whether to return the influence function.

alphafloat, default 0.05

Significance level for confidence intervals.

trim_levelfloat, default 0.995

Trimming level for propensity scores.

random_stateint, Generator, or None, default None

Controls random number generation for bootstrap reproducibility.

Returns:
DDDRCResult

A NamedTuple containing:

  • att: The DDD point estimate

  • se: Standard error

  • uci, lci: Confidence interval bounds

  • boots: Bootstrap draws (if requested)

  • att_inf_func: Influence function (if requested)

  • did_atts: Individual DiD ATT estimates for each comparison

  • subgroup_counts: Number of observations in each subgroup

  • args: Estimation arguments

See also

ddd_panel

Two-period DDD estimator for panel data.

ddd_mp_rc

Multi-period DDD estimator for repeated cross-section data.

References

[1] (1,2)

Ortiz-Villavicencio, M., & Sant’Anna, P. H. C. (2025). Better Understanding Triple Differences Estimators. arXiv preprint arXiv:2505.09942. https://arxiv.org/abs/2505.09942

[2]

Sant’Anna, P. H. C., & Zhao, J. (2020). Doubly robust difference-in-differences estimators. Journal of Econometrics, 219(1), 101-122. https://doi.org/10.1016/j.jeconom.2020.06.003