moderndid.wboot_twfe_panel#
- moderndid.wboot_twfe_panel(y, d, post, x, i_weights, n_bootstrap=1000, random_state=None)[source]#
Compute bootstrap estimates for Two-Way Fixed Effects DiD with panel data.
This function implements a bootstrapped Two-Way Fixed Effects (TWFE) difference-in-differences estimator for panel data with 2 periods and 2 groups. This is the traditional DiD regression approach using OLS with treatment-period interaction.
- Parameters:
- y
numpy.ndarray A 1D array representing the outcome variable for each unit-time observation. Should be stacked with pre-period observations followed by post-period observations.
- d
numpy.ndarray A 1D array representing the treatment indicator (1 for treated, 0 for control) for each unit-time observation.
- post
numpy.ndarray A 1D array representing the post-treatment period indicator (1 for post, 0 for pre) for each unit-time observation.
- x
numpy.ndarray A 2D array of covariates (including intercept if desired) with shape (n_observations, n_features). Should be stacked to match y, d, and post.
- i_weights
numpy.ndarray A 1D array of individual observation weights for each unit-time observation.
- n_bootstrap
int Number of bootstrap iterations. Default is 1000.
- random_state
int,RandomStateinstanceorNone Controls the random number generation for reproducibility.
- y
- Returns:
numpy.ndarrayA 1D array of bootstrap ATT estimates with length n_bootstrap.
See also
wboot_reg_panelRegression-based bootstrap for DiD with panel data.
wboot_drdid_imp_panelDoubly-robust bootstrap for DiD with panel data.