moderndid.ipw_did_panel#

moderndid.ipw_did_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 inverse propensity weighted DiD estimator for the ATT with panel data.

Implements the inverse propensity weighted (IPW) estimator for the ATT with panel data, as proposed by [1] and discussed in [2]. The estimator is given by equation (2.4) in [2] as

\[\widehat{\tau}^{ipw,p} = \frac{1}{\mathbb{E}_{n}[D]} \mathbb{E}_{n} \left[\frac{D-\widehat{\pi}(X)}{1-\widehat{\pi}(X)}\left(Y_{1}-Y_{0}\right)\right].\]

IPW weights are not normalized to sum up to one, that is, the estimator is of the Horwitz-Thompson type.

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 in post-treatment, 0 otherwise).

covariatesnumpy.ndarray or None

A 2D array of covariates for propensity score estimation. An intercept must be included if desired. If None, leads to an unconditional DiD estimator.

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:
IPWDIDPanelResult

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

See also

ipw_did_rc

IPW DiD estimator for repeated cross-section data.

std_ipw_did_panel

Standardized version of Abadie’s IPW DiD estimator for panel data.

Notes

The IPW estimator is less robust than doubly robust methods as it relies solely on correct specification of the propensity score model. We recommend using doubly robust methods when there is uncertainty about model specification.

References

[1]

Abadie, A. (2005). Semiparametric difference-in-differences estimators. The Review of Economic Studies, 72(1), 1-19. https://doi.org/10.1111/0034-6527.00321

[2] (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