estimate_mean_did_effects

distributional_did.estimate_mean_did_effects(
    ds: pl.DataFrame,
    outcome: ColumnName,
    treatment_group: ColumnName | TrtGroupConfig,
    time: ColumnName,
    unit: ColumnName,
    qs: ArrayLike = MEDIAN,
    *,
    weights: ColumnName | None = None,
    n_anticipation_periods: int = 0,
    base_period: BasePeriod = BasePeriod.UNIVERSAL,
    control_group: ControlGroup = ControlGroup.NEVER_TREATED,
    bootstrap_config: BootstrapConfig | int = 1000,
)

Estimate treatment effects with mean difference-in-differences.

The counterfactual distribution of untreated potential outcomes for the treated group is the treated group’s pre-treatment distribution shifted by the change in the control group’s mean. This implies the usual parallel trends assumption, so the average treatment effect on the treated is identified, but it is stronger: it also requires that only the location of the distribution shifts, not its shape. The quantile treatment effects that follow, Q(Y | treated, post) - Q(Y | treated, pre) - delta, are a mechanical consequence of that shape restriction: they vary across quantiles only because the treated group’s own distribution moves over time, which the assumption leaves unrestricted. Their shape therefore says nothing about how treatment effects vary, and only the average effect rests on the identifying assumption. Returns the group, event-study, overall and group-time effects.

Parameters

Name Type Description Default
ds polars.DataFrame Panel data in long format. required
outcome ColumnName Name of the outcome column. required
treatment_group ColumnName or TrtGroupConfig Column holding the first treatment period of a unit. A plain string treats the column as already coded with inf for never-treated units; a TrtGroupConfig maps a custom never-treated value to inf. required
time ColumnName Name of the time period column. required
unit ColumnName Name of the unit identifier column. required
qs array_like Quantiles in (0, 1) at which to estimate the effects. 0.5
weights ColumnName Name of a column with sampling weights. None
n_anticipation_periods int Number of periods before treatment in which units may anticipate it. 0
base_period BasePeriod Pre-treatment period used for the comparisons. BasePeriod.UNIVERSAL
control_group ControlGroup Comparison group used for the counterfactual. ControlGroup.NEVER_TREATED
bootstrap_config BootstrapConfig or int Bootstrap settings, or the number of replications. 1000

Returns

Name Type Description
DistributionalDidResults The group, event-study, overall and group-time effects.

See Also

estimate_distributional_did_effects Relaxes the location-shift restriction by restricting the dependence between the change and the initial level instead, which identifies distributional effects.

References

Thuysbaert, Bram. “Distributional Comparisons in Difference in Differences Models.” Working paper, 2007 (as in qte::mdid).

Heckman, James, Hidehiko Ichimura and Petra Todd. “Matching as an Econometric Evaluation Estimator: Evidence from Evaluating a Job Training Programme.” Review of Economic Studies 64(4), pp. 605-654, 1997.

Abadie, Alberto. “Semiparametric Difference-in-Differences Estimators.” Review of Economic Studies 72(1), pp. 1-19, 2005.