moderndid.ipw_rc#
- moderndid.ipw_rc(y, post, d, ps, i_weights, trim_ps=None)[source]#
Compute the inverse propensity weighted (IPW) estimator for repeated cross-sections.
This function implements the inverse propensity weighted (IPW) estimator from [1] for repeated cross-sections. The weights are not normalized to sum to 1, e.g., the estimator is of the Horwitz-Thompson type.
The IPW estimator for the ATT in repeated cross-sections is given by
\[\tau^{ipw, rc} = \frac{1}{\mathbb{E}[D]} \mathbb{E}\left[ \left(\frac{D - \hat{\pi}(X)}{1 - \hat{\pi}(X)}\right) \left(\frac{T - \lambda}{\lambda(1-\lambda)}\right) Y\right]\]where \(D\) is the treatment status, \(T\) is the time period (1 for post-treatment, 0 for pre-treatment), \(Y\) is the outcome, \(X\) are covariates, \(\hat{\pi}(X)\) is an estimator of the propensity score \(\pi(X) = P(D=1|X)\), and \(\lambda = P(T=1)\) is the probability of being in the post-treatment period.
- Parameters:
- y
numpy.ndarray A 1D array representing the outcome variable for each unit.
- post
numpy.ndarray A 1D array representing the post-treatment period indicator (1 for post, 0 for pre) for each unit.
- d
numpy.ndarray A 1D array representing the treatment indicator (1 for treated, 0 for control) for each unit.
- ps
numpy.ndarray A 1D array of propensity scores (estimated probability of being treated, \(P(D=1|X)\)) for each unit.
- i_weights
numpy.ndarray A 1D array of individual observation weights for each unit.
- trim_ps
numpy.ndarrayorNone A 1D boolean array indicating which units to keep after trimming. If None, no trimming is applied (all units are kept).
- y
- Returns:
floatThe IPW ATT estimate for repeated cross-sections.
See also
wboot_ipw_rcBootstrap inference for IPW DiD.
References
[1]Abadie, A. (2005). Semiparametric difference-in-differences estimators. The Review of Economic Studies, 72(1), 1-19. https://www.jstor.org/stable/3700681