Simultaneous bands

Callaway-Sant’Anna’s multiplier bootstrap: a simultaneous 95% band over the event study, then a pre-trend test of the event-time averages.

from diff_stream import did_callaway_santanna
from diff_stream.simulate import simulate_conditional_panel

data = simulate_conditional_panel(1200, 8, seed=72)
fit = did_callaway_santanna(
    "y ~ x + z",
    data,
    panel=("id", "time"),
    cohort="first_treat",
    anticipation=2,
    multiplier_bootstrap_reps=999,
    multiplier_bootstrap_seed=42,
    n_threads=2,
)
event_study = fit.aggregate()
print(event_study.multiplier_confint())
print(fit.pretrend_test(level="event_time"))

Output:

shape: (9, 6)
┌─────────────┬───────────┬────────────┬────────────────┬───────────┬──────────┐
│ Coefficient ┆ Estimate  ┆ Std. Error ┆ critical_value ┆ 2.5%      ┆ 97.5%    │
│ ---         ┆ ---       ┆ ---        ┆ ---            ┆ ---       ┆ ---      │
│ str         ┆ f64       ┆ f64        ┆ f64            ┆ f64       ┆ f64      │
╞═════════════╪═══════════╪════════════╪════════════════╪═══════════╪══════════╡
│ event::-6   ┆ -0.050573 ┆ 0.119378   ┆ 2.786443       ┆ -0.383212 ┆ 0.282066 │
│ event::-5   ┆ 0.091045  ┆ 0.077301   ┆ 2.786443       ┆ -0.124351 ┆ 0.306441 │
│ event::-4   ┆ -0.023792 ┆ 0.058621   ┆ 2.786443       ┆ -0.187136 ┆ 0.139551 │
│ event::-3   ┆ -0.014676 ┆ 0.057551   ┆ 2.786443       ┆ -0.175038 ┆ 0.145685 │
│ event::-2   ┆ -0.03149  ┆ 0.056922   ┆ 2.786443       ┆ -0.190099 ┆ 0.127119 │
│ event::-1   ┆ -0.009403 ┆ 0.061178   ┆ 2.786443       ┆ -0.179873 ┆ 0.161067 │
│ event::0    ┆ 1.179594  ┆ 0.070263   ┆ 2.786443       ┆ 0.98381   ┆ 1.375378 │
│ event::1    ┆ 1.253377  ┆ 0.085148   ┆ 2.786443       ┆ 1.016118  ┆ 1.490637 │
│ event::2    ┆ 1.553445  ┆ 0.126954   ┆ 2.786443       ┆ 1.199696  ┆ 1.907195 │
└─────────────┴───────────┴────────────┴────────────────┴───────────┴──────────┘
{'statistic': 1.7511526213983974, 'pvalue': 0.7814060664720052, 'df1': 4, 'df2': None, 'distribution': 'chi2', 'level': 'event_time', 'coefficients': ['event::-6', 'event::-5', 'event::-4', 'event::-3'], 'horizons': [-6, -5, -4, -3], 'cells': [{'cohort': 6, 'time': 2}, {'cohort': 6, 'time': 3}, {'cohort': 7, 'time': 2}, {'cohort': 7, 'time': 3}, {'cohort': 7, 'time': 4}, {'cohort': 8, 'time': 2}, {'cohort': 8, 'time': 3}, {'cohort': 8, 'time': 4}, {'cohort': 8, 'time': 5}], 'n_restrictions': 4, 'anticipation': 2, 'reference_event_time': -3, 'null': 'all selected clean pre-treatment effects equal zero', 'base_period': 'varying'}