moderndid.wboot_twfe_rc#

moderndid.wboot_twfe_rc(y, post, d, x, i_weights, n_bootstrap=1000, random_state=None)[source]#

Compute bootstrap estimates for Two-Way Fixed Effects DiD with repeated cross-sections.

Implements a bootstrapped Two-Way Fixed Effects (TWFE) difference-in-differences estimator for repeated cross-sections with 2 periods and 2 groups. This is the traditional DiD regression approach using OLS with treatment-period interaction.

Parameters:
ynumpy.ndarray

A 1D array representing the outcome variable for each unit.

postnumpy.ndarray

A 1D array representing the post-treatment period indicator (1 for post, 0 for pre) for each unit.

dnumpy.ndarray

A 1D array representing the treatment indicator (1 for treated, 0 for control) for each unit.

xnumpy.ndarray

A 2D array of covariates (including intercept if desired) with shape (n_units, n_features).

i_weightsnumpy.ndarray

A 1D array of individual observation weights for each unit.

n_bootstrapint

Number of bootstrap iterations. Default is 1000.

random_stateint, RandomState instance or None

Controls the random number generation for reproducibility.

Returns:
numpy.ndarray

A 1D array of bootstrap ATT estimates with length n_bootstrap.

See also

wboot_twfe_panel

TWFE bootstrap for panel data.

wboot_reg_rc

Regression-based bootstrap for repeated cross-sections.