# Judging a grocery promotion from household spend

A retailer sends a promotion to the households it picks, then judges it by how much more those households spent than
the rest. This study tests that habit on a public panel of 2,469 grocery households, every receipt for a year (2017),
with the 27 campaigns each household received. The main read is campaign 8, sent to 1,076 households for weeks 20 to
26. No holdout was kept, so five reads are put side by side: the naive read, matching on spend and visits before the
campaign, a difference in differences, the same on matched households, and a weighted mix of other households
(a synthetic control). A made-up campaign date, when nothing was sent, checks each read.

What it found: picked households outspent the rest by US$36.47 a week during the promotion and by US$40.22 before it.
Matching on spend and visits, then comparing the promotion weeks, still leaves US$14.31 and says send, but it finds
US$12.40 on the made-up date. Corrected for the spend gap its pairs leave, it finds US$3.83 and says keep testing, and
still US$4.79 on the made-up date. The three before-and-after reads put the lift between minus US$3.76 and US$2.40 a week,
and none of their intervals sits clear above zero. On the made-up date the highest of them, the difference in
differences on matched households, found US$3.81, about as much as on the real date, and the plain difference in
differences fails the check that the groups moved in step before. No read passes
both checks, so the self-serve readout caps any comparison that was not chosen at random at keep testing. Every money
figure rests on the margin and cost in `assumptions.json`. Leaving out the 565 picked households that had an earlier
campaign in the weeks before changes no call.

## Data

The 84.51° grocery panel published in the completejourney R package, version 2.0, licence CC0. The files are pinned to one commit
of the package's repository and checked by sha256; `data/sources.json` lists the URLs, the commit and the sha256 of
each download and each derived file. Spend is the data's `sales_value`; a visit is one basket; weeks are the data's
own `week` numbers.

## Rebuild

From this folder, with Python 3.12, NumPy, SciPy, pandas and pyreadr (Node for the readout test):

    python3 -I -B tools/get_data.py ~/.cache/promotion-lift-panel
    python3 -I -B tools/run_study.py main
    python3 -I -B tools/run_study.py placebo
    python3 -I -B tools/summarize.py
    python3 -I -B tools/describe.py
    python3 -I -B tools/run_change2.py
    python3 -I -B tools/run_change3.py
    python3 -I -B site/render.py
    python3 -I -B tests/test_study.py

The first command downloads the four files (about 13 MB) and writes the small tables in `data/`. `main` reads campaign
8, its five spend tiers and the second campaign (13). `placebo` runs the made-up date. `summarize.py` scores the
predictions and works out the money and the calls. `describe.py` adds the group means the readout page opens with;
it was added after the results. `run_change2.py` runs the checks declared in `CHANGES-r2.md` after the results:
intervals built for the two matching reads, the money check over all five reads and holdout sizes at smaller lifts.
`run_change3.py` runs the checks declared in `CHANGES-r3.md`: the real-date read without households that had an
earlier campaign, and matching corrected for the gap it leaves. The bootstrap seeds are fixed, so the results files
rebuild the same.

## Files

- `index.html`, `placebo.html`, `results.html`, `readout.html`, `method.html`: the pages. `readout.js` is the
  readout's logic; it runs in the page and sends nothing anywhere.
- `protocol-r1.json`, `predictions-r1.json`, `assumptions.json`: the design, the eleven predictions and the money
  assumptions, written before any group was compared. `CHANGES-r2.md` and `CHANGES-r3.md`: the checks added after
  the results, each declared before it ran.
- `data/`: weekly spend and visits per household, the campaign lists and the coupon redemptions.
- `results/`: every result file the pages read.
- `tools/`, `tests/`, `site/`: the code, the tests and the page builder.
- `vendor/`: the design system's files, copied unedited from one pinned release.

Some files are packed in promotion-lift-panel-data-1.zip; unzip it here to restore the full export, which the manifest lists file by file.
