car.py), the significance tests (stats.py) and the report’s charts (charts.py).
The big idea
car.py takes each stock and each event occurrence, fits the market model on the 120 trading days that end right before day −5, and sums the abnormal returns over days −5..+5. It works on whole numpy arrays at once, not day by day, so if its numbers equal the stream’s, both are right.
stats.py asks, for each event type (and for online vs store retailers): could the average CAR be zero and we just got unlucky? It runs four tests, because each answers that question under different assumptions:
It also fits a trend for each event type: each year’s average CAR against the year, to see whether an effect grows or fades.
Words you will meet
p-value
p-value
If the true average were zero, the chance of seeing an average at least this far from zero. Small (below 0.05) means “unlikely to be luck”.
Confidence interval
Confidence interval
A range that would contain the true average in 95% of repeated studies. If it excludes zero, the effect is significant at 5%.
Clustering
Clustering
Treating related observations as one group. All 38 retailers share each Black Friday; a market-wide shock that day hits all of them, so they are not 38 independent pieces of evidence.
car_z
car_z
A window’s CAR divided by its expected spread (the residual standard deviation × √days), so windows of volatile and calm stocks can be compared.
The picture: The batch event study (src/eventstudy/)
The full diagram and its guide explain every box.Read these files in this order
1
src/eventstudy/init.py
See the file. Read it
2
src/eventstudy/car.py
Batch event study: one cumulative abnormal return (CAR) per stock per event. This is the “answer key” the streaming job is compared against (decision 0004). Read it
3
src/eventstudy/stats.py
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. Read it
4
src/eventstudy/charts.py
Final charts for the report (task #10), made from the batch event study’s outputs. Read it
5
scripts/export_results.py
Gather the final results into docs/results/ for the report, the slides and the video (decision 0013). Read it
Questions you should be able to answer
Why is the clustered test the main one?
Why is the clustered test the main one?
Without clustering, 38 retailers × 10 years look like 380 independent windows and p-values come out far too small. Clustering by event date counts each date once, which is honest about how much evidence there really is.
Why does the estimation window end before day −5?
Why does the estimation window end before day −5?
So the event cannot leak into its own baseline. If the model were fitted on days that include the event, an event effect would partly become “normal” and the abnormal return would shrink.
What did the study find?
What did the study find?
With 38 retailers, store retailers’ mean CAR over all events is about +1.1% (clustered p ≈ 0.03), Halloween is negative for online retailers (about −3.6%, p ≈ 0.04), and Black Friday is positive for stores (about +2.5%, p ≈ 0.09). The Results page has every number, from the latest run.
Ideas to improve it
- Use a Fama-French three-factor model instead of the one-factor market model.
- Correct the p-values for testing many event types at once (Holm or Benjamini-Hochberg).