moderndid.drdid_rc#

moderndid.drdid_rc(y, post, d, covariates, i_weights=None, boot=False, boot_type='weighted', nboot=999, influence_func=False, trim_level=0.995)[source]#

Compute the locally efficient doubly robust DiD estimator for the ATT with repeated cross-section data.

Implements the locally efficient doubly robust difference-in-differences (DiD) estimator for the Average Treatment Effect on the Treated (ATT) defined in [1]. This is the estimator based on the efficient influence function, which is derived in Section 2.3 of [1]. The estimator is given by

\[\begin{split}\tau_{2}^{dr,rc} = \tau_{1}^{dr,rc} + \left(\mathbb{E}[\mu_{1,1}^{rc}(X) - \mu_{0,1}^{rc}(X) | D=1] - \mathbb{E}[\mu_{1,1}^{rc}(X) - \mu_{0,1}^{rc}(X) | D=1, T=1]\right) \\ - \left(\mathbb{E}[\mu_{1,0}^{rc}(X) - \mu_{0,0}^{rc}(X) | D=1] - \mathbb{E}[\mu_{1,0}^{rc}(X) - \mu_{0,0}^{rc}(X) | D=1, T=0]\right),\end{split}\]

where \(\tau_{1}^{d r, r c}\) is given by

\[\tau_{1}^{dr,rc} = \mathbb{E}\left[\left(w_{1}^{rc}(D,T) - w_{0}^{rc}(D,T,X;\pi)\right) \left(Y - \mu_{0,Y}^{rc}(T,X)\right)\right].\]

This estimator uses a logistic propensity score model and linear regression models for the outcome.

The propensity score parameters are estimated using maximum likelihood, and the outcome regression coefficients are estimated using ordinary least squares.

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).

dnumpy.ndarray

A 1D array of group indicators (1 if treated in post-treatment, 0 otherwise).

covariatesnumpy.ndarray

A 2D array of covariates for propensity score and outcome regression. 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.

bootbool, default=False

Whether to use bootstrap for inference.

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

Type of bootstrap to perform.

nbootint, default=999

Number of bootstrap repetitions.

influence_funcbool, default=False

Whether to return the influence function.

trim_levelfloat, default=0.995

The trimming level for the propensity score.

Returns:
DRDIDRCResult

A NamedTuple containing the ATT estimate, standard error, confidence interval, bootstrap draws, and influence function.

See also

drdid_imp_local_rc

Improved and locally efficient DR-DiD estimator for repeated cross-section data.

drdid_imp_rc

Improved, but not locally efficient, DR-DiD estimator for repeated cross-section data.

drdid_trad_rc

Traditional (not locally efficient or improved) doubly robust DiD estimator.

References

[1] (1,2)

Sant’Anna, P. H., & 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 arXiv preprint: https://arxiv.org/abs/1812.01723