moderndid.drdid_panel#

moderndid.drdid_panel(y1, y0, 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 panel data.

Implements the locally efficient doubly robust difference-in-differences (DiD) estimator for the Average Treatment Effect on the Treated (ATT) defined in equation (3.1) in [1]. The estimator is given by

\[\widehat{\tau}^{dr,p} = \mathbb{E}_{n}\left[\left(\widehat{w}_{1}^{p}(D) - \widehat{w}_{0}^{p}(D,X;\widehat{\gamma})\right) \left(\Delta Y - \mu_{0,\Delta}^{p}(X;\widehat{\beta}_{0,0}^p, \widehat{\beta}_{0,1}^p)\right)\right].\]

This estimator uses a logistic propensity score model and a linear regression model for the outcome evolution among the comparison units.

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

Parameters:
y1numpy.ndarray

A 1D array of outcomes from the post-treatment period.

y0numpy.ndarray

A 1D array of outcomes from the pre-treatment period.

dnumpy.ndarray

A 1D array of group indicators (=1 if treated, =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:
DRDIDPanelResult

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

See also

drdid_imp_panel

Improved and locally efficient doubly robust DiD estimator for panel data.

Notes

This estimator makes use of a logistic propensity score model for the probability of being in the treated group, and of a linear regression model for the outcome evolution among the comparison units.

References

[1]

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