Skip to main content
src/eventstudy/stats.py · chapter The batch event study, file 3 · 189 lines · open in the repository

What it does

Significance tests on the batch CARs: is the average CAR around an event really different from zero, does it differ between online and store retailers, and does it change over the years? Reads the output of src/eventstudy/car.py. Why several tests (each answers “could this average be 0 and we just got unlucky?”):
  • t-test: the classic test on the mean CAR. Assumes every window is independent.
  • Wilcoxon signed-rank: the same question without assuming a bell curve, so a few extreme CARs (a meme-stock day, March 2020) cannot drive the result alone.
  • BMP (Boehmer, Musumeci and Poulsen): a t-test on standardized CARs (car_z), so a volatile stock counts as much as a calm one. Here car_z does not include BMP’s small correction for the error in estimating alpha and beta, so read it as “BMP-style”.
  • Clustered by event date: the main test. All 10 retailers share each Black Friday, so their CARs move together (a market-wide shock hits all of them at once) and are not 10 independent pieces of evidence. Clustering treats each event date as one group; the confidence interval comes from this test.
Trend: for each event type, the average CAR of each year’s occurrence regressed on the year. The slope is the change in CAR per year. Run from anywhere after car.py: python3 src/eventstudy/stats.py Output: data/results/batch_car_summary.csv and batch_car_trend.csv (contracts: batch_car_summary, batch_car_trend)

What is inside

  • SUMMARY · line 39
  • TREND · line 40
  • ALL · line 41: label for “every event type” or “every retailer”
  • clustered_mean_test(car, cluster) · line 44: Mean of car with a standard error clustered by cluster (here, day 0).
  • one_sample_p(x, test) · line 65: p-value of a test of “the average is 0”, NaN with too few values.
  • summary_row(event_type, group, w) · line 73
  • difference_row(event_type, groups, w) · line 88: First group minus second (e.g. online minus store), paired by event occurrence.
  • trend_row(event_type, w) · line 113: Average CAR of each occurrence regressed on its year (ordinary least squares).
  • build_tables(cars, retailers) · line 130
  • main() · line 162

Connections

Uses: src/common/contracts.py, src/common/settings.py, src/common/study.py, src/eventstudy/car.py Used by: src/eventstudy/charts.py, scripts/export_results.py, src/hosting/snapshot.py, src/hosting/publish_hf.py, tests/test_eventstudy.py

Source

src/eventstudy/stats.py