estimate_nonlinear_did_for_panel
nonlinear_did.estimate_nonlinear_did_for_panel(
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,
counterfactual_model: CounterfactualModel = CounterfactualModel.CIC,
bootstrap_config: BootstrapConfig | int = 1000,
)Estimate nonlinear difference-in-differences effects for panel data.
Implements the changes-in-changes (CiC) and quantile difference-in-differences (QDiD) estimators with the aggregations of Callaway and Li. 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 |
| counterfactual_model | CounterfactualModel |
Model used to construct the counterfactual distribution. | CounterfactualModel.CIC |
| bootstrap_config | BootstrapConfig or int |
Bootstrap settings, or the number of replications. | 1000 |
Returns
| Name | Type | Description |
|---|---|---|
NonlinearDidResults |
The group, event-study, overall and group-time effects. |