Project: did the promo work?
Last updated
For the last two weeks of February 2024, the Lipa and Tanauan stores sold rice at ₱2 off a kilo. The owners want to know: did it work, and by how much? It sounds like a simple before-and-after. In this project you'll see why that isn't enough, compare the promo stores with the others, put a shuffle test and a bootstrap interval on the result, control for rain and weekends with a regression, and write a short answer that says how sure it is and what it can't tell.
By the end of this lesson you can
- Explain why a before-and-after comparison is weak evidence
- Compare a change at treated and untreated stores (difference in differences)
- Back a finding with a shuffle test, a bootstrap interval and a regression
- Write up a result with its size, its uncertainty and its limits
Plan it
From 16 to 29 February 2024, Lipa and Tanauan sold rice at ₱44 a kilo instead of ₱46. The owners chose those two stores; Batangas and Rosario kept the usual price. The file data/clean/rice_promo.csv has the rice sold at each store each day in January and February, with a promo column.
Write the plan before looking at results (8.7):
| Question | How much more rice did the promo stores sell during the promo than they would have without it? |
| Measure | Kilos a day, as an index: each store's kilos as a percentage of its own January average, so a small store and a big one count the same |
| Comparison | Promo stores against the others, before and during the promo |
| Evidence | A shuffle test, a bootstrap interval, and a regression controlling for rain and weekends |
| Limits to report | The stores weren't chosen at random; only two promo stores; two weeks |
Every notebook starts with the same setup cell: it adds each store's rain, promo_store, period ("before" or "promo"), weekend and the index.
Before and after, and why that's weak
The obvious comparison first. Run the cells.
At Lipa and Tanauan, rice went from 31.0 kg a day in the two weeks before to 36.5 during the promo: up 18%. It's tempting to stop here.
A before-and-after comparison credits the promo with everything that changed between the two fortnights: the weather, paydays at the end of the month, a fiesta, a competitor closing. It has no way to separate them. That's why the second half of the cell looks at the stores without the promo over the same days: 34.0 and 34.2 kg. Their sales barely moved, so whatever else happened in late February doesn't seem to have lifted rice everywhere. That's the comparison to build on.
Promo stores against the others
Compare the change at the promo stores with the change at the other stores over the same time. Whatever affected all four stores cancels out; what's left is the promo, plus whatever affected only the promo stores. This is called a difference in differences. Run the cells.
| before | during | change | |
|---|---|---|---|
| Batangas and Rosario | 99.5 | 100.0 | +0.5 |
| Lipa and Tanauan | 99.7 | 116.4 | +16.7 |
The difference in differences is 16.2 index points: during the promo, the promo stores sold about 16% of a January day more than the change at the other stores would suggest.
The chart is the check that matters most. Before 16 February, the two lines move together, week by week. That's the assumption the method rests on: without the promo, the promo stores would have kept moving with the others. If the lines had been drifting apart already, the "effect" could just be that drift continuing.
A shuffle test and a bootstrap interval
Could a jump of 16.2 points be luck? Turn each day into one number, the gap between the promo stores' index and the others', and compare the 14 promo days' gaps with the 46 days before. Run the cells.
- Shuffle test (8.6): dealing the 60 daily gaps into new piles of 46 and 14, 10,000 times, never once gave a change as big as 16.2; the biggest was 14.9. So .
- Bootstrap interval (8.5): resampling the days in each period gives a 95% interval of 9.2 to 23.7 points.
One caution: days next to each other aren't fully independent (a busy week is busy for several days), and both methods treat them as if they were. The interval is probably a little too narrow. That's worth a sentence in the write-up.
A regression with rain and weekends
Rain lowers sales (8.6) and weekends raise them (8.10). If the promo fortnight happened to be drier, or had more weekends, at the promo stores, that could be mistaken for the promo. A regression can hold them fixed (8.11). Run the cells.
promo_store * periodputs inpromo_store,periodand their interaction,promo_store[T.True]:period[T.promo]: the extra change at promo stores during the promo. That's the difference in differences, now with rain and weekends held fixed: 15.98 points, 95% interval 7.7 to 24.3.- Rain costs 0.51 points per mm and a weekend adds 22.8 points, as expected.
Three methods, one answer: about 16 points, with an interval from about 8 to 24. When different reasonable methods agree, the finding is sturdier than any one of them alone.
A careful write-up
Add a Markdown cell at the end of the notebook, written for the owners. Lead with the answer, give its size and uncertainty, then the limits. For example:
The rice promo probably raised sales by about 16%. During the two weeks at ₱44 a kilo, Lipa and Tanauan sold about 16% more rice than their own January average, compared with no change at Batangas and Rosario over the same days. The likely range is about 8% to 24%. Rain and weekends don't explain it.
How sure: the two groups of stores moved together before the promo, and the jump is far bigger than day-to-day ups and downs (no reshuffling of the days came close). But the stores weren't chosen at random, there were only two of them, and it lasted two weeks. Something else that happened only at Lipa and Tanauan in late February would look the same.
Next: whether ₱2 off a kilo paid for itself depends on the margin on rice, which isn't in this data. To be surer, run it again with the stores chosen by coin flip (8.12), for longer.
Notice what the write-up doesn't say: "p < 0.0001, so the promo works". The p-value only says the jump wasn't luck; the size, the interval and the limits are what the owners can act on.
Finished
Run the notebook from the top. The difference in differences, the shuffle test, the bootstrap and the regression should all point to about 16 points.
One more thing you can check, because this data was made for the course: the promo stores' rice was raised by 12% during the promo. Every interval you computed (9.2 to 23.7 and 7.7 to 24.3) contains it, and the point estimates overshot by a few points, which is the kind of error two stores and two weeks give. With real data you never get to see the true answer, which is why the interval matters.
Look at what you used:
- A plan written first (8.7), with a measure defined before looking.
- A comparison group (8.11): the stores without the promo, to remove what changed everywhere.
- A shuffle test and a bootstrap (8.5, 8.6): how surprising the jump is, and a range for its size.
- A regression with controls (8.10): the same estimate with rain and weekends held fixed.
- An honest write-up: size, uncertainty, limits, and what would make it surer.
Stage 9 takes these tools to the questions owners ask every month: how is the business doing, compared with what, and what should we do next?
Sources
Every example on this page was run with Python 3.14, and its output and error messages are copied from it. These pages cover the same ground in more depth.
- statsmodels: Fitting models using R-style formulas: formulas with interactions, a * b
- Card and Krueger, Minimum Wages and Employment: A Case Study of the Fast-Food Industry in New Jersey and Pennsylvania, NBER Working Paper 4509, 1993 (published in the American Economic Review, 1994): a famous difference-in-differences study: stores that changed against stores that didn't
- Efron, Bootstrap Methods: Another Look at the Jackknife, Annals of Statistics 7(1), 1979: the bootstrap