moderndid.twfe_did_rc#
- moderndid.twfe_did_rc(y, post, d, covariates=None, i_weights=None, boot=False, boot_type='weighted', nboot=999, influence_func=False)[source]#
Compute linear two-way fixed effects DiD estimator for the ATT with repeated cross-sections.
Implements the linear two-way fixed effects (TWFE) estimator for the ATT with repeated cross-section data, as illustrated in [1]. The estimator is based on the regression model from equation (2.5) of [1] as
\[Y_{it} = \alpha_1 + \alpha_2 T_i + \alpha_3 D_i + \tau^{fe}(T_i \cdot D_i) + \theta' X_i + \varepsilon_{it}.\]- Parameters:
- y
numpy.ndarray A 1D array of outcomes from both pre and post-treatment periods.
- post
numpy.ndarray A 1D array of post-treatment dummies (1 if observation belongs to post-treatment period, 0 if observation belongs to pre-treatment period).
- d
numpy.ndarray A 1D array of group indicators (1 if observation is treated in the post-treatment period, 0 otherwise).
- covariates
numpy.ndarray, optional A 2D array of covariates to be used in the regression estimation. We will always include an intercept.
- i_weights
numpy.ndarray, optional A 1D array of weights. If None, then every observation has equal weight. Weights are normalized to have mean 1.
- bootbool, default=False
Whether to compute bootstrap standard errors.
- boot_type{“weighted”, “multiplier”}, default=”weighted”
Type of bootstrap to be performed (not relevant if boot = False).
- nboot
int, default=999 Number of bootstrap repetitions (not relevant if boot = False).
- influence_funcbool, default=False
Whether to return the influence function.
- y
- Returns:
TWFEDIDRCResultA NamedTuple containing the TWFE DiD point estimate, standard error, confidence interval, bootstrap draws, and influence function.
Warning
This estimator generally does not recover the ATT. We encourage users to adopt alternative specifications.
See also
reg_did_rcOutcome regression DiD for repeated cross-sections.
drdid_imp_rcImproved doubly robust DiD for repeated cross-sections.
ipw_did_rcInverse propensity weighted DiD for repeated cross-sections.
References
[1] (1,2)Sant’Anna, P. H. C. and Zhao, J. (2020), “Doubly Robust Difference-in-Differences Estimators.” Journal of Econometrics, Vol. 219 (1), pp. 101-122. https://doi.org/10.1016/j.jeconom.2020.06.003