Skip to content

statspai.bunching

bunching

Bunching Estimator for kink/notch analysis.

Estimates behavioural responses to policy thresholds (tax kinks, regulatory notches) by comparing the observed distribution of a running variable to a counterfactual polynomial distribution.

References

Kleven, H. J. & Waseem, M. (2013). Using Notches to Uncover Optimization Frictions and Structural Elasticities. QJE, 128(2), 669-723. [@kleven2013using]

Chetty, R., Friedman, J. N., Olsen, T., & Pistaferri, L. (2011). Adjustment Costs, Firm Responses, and Micro vs. Macro Labor Supply Elasticities. QJE, 126(2), 749-804. [@chetty2011adjustment]

BunchingEstimator

Bunching estimator for kink/notch designs.

Parameters:

Name Type Description Default
data DataFrame
required
running_var str
required
threshold float
required
bin_width float
None
n_bins int
50
poly_order int
7
bunch_region tuple
None
exclude_region tuple
None
dt float
None
design str
'kink'
n_bootstrap int
200
alpha float
0.05
random_state int
42

fit

fit() -> CausalResult

Run bunching estimation.

NotchResult

Result container for notch bunching analysis.

Attributes:

Name Type Description
excess_bunching float

Excess mass B in the bunching region (below the notch).

missing_mass float

Missing mass H above the notch (the "hole").

marginal_buncher float

Upper bound of the dominated region (x*).

elasticity float or None

Structural elasticity estimate (if notch_size provided).

se_bunching float

Bootstrap standard error of excess bunching.

se_elasticity float or None

Bootstrap standard error of elasticity (if notch_size provided).

pvalue float

P-value for H0: excess_bunching = 0.

ci tuple of (float, float)

Confidence interval for excess bunching.

notch_point float

Location of the notch.

bin_centers ndarray

Bin centres of the histogram.

observed ndarray

Observed bin counts.

counterfactual ndarray

Counterfactual polynomial counts.

n_obs int

Number of observations.

causal_result CausalResult

Full CausalResult object for interoperability.

summary

summary() -> str

Return a formatted summary table.

plot

plot(figsize=(10, 6), title=None)

Plot observed histogram with counterfactual overlay.

Returns:

Type Description
(fig, ax) : matplotlib figure and axes

GeneralBunchingResult dataclass

Output of high-order bunching design.

KinkUnifiedResult dataclass

Joint RDD + RKD + Bunching estimate at a common cutoff.

general_bunching

general_bunching(data: DataFrame, running: str, cutoff: float = 0.0, bandwidth: float = 1.0, bin_width: Optional[float] = None, polynomial_order: int = 4, alpha: float = 0.05, n_boot: int = 200, seed: int = 0) -> GeneralBunchingResult

High-order bunching design with bias correction.

Parameters:

Name Type Description Default
data DataFrame
required
running str

Running variable (e.g. earnings).

required
cutoff float
0.0
bandwidth float
1.0
bin_width float

Defaults to bandwidth / 25.

None
polynomial_order int

Order of the counterfactual polynomial fit.

4
alpha float
0.05
n_boot int
200
seed int
0

Returns:

Type Description
GeneralBunchingResult