Intervention analysis for a known event
Today let's work out whether something that happened on a known date actually changed a number you track every day, or whether the change you are looking at was there anyway.
Fernglen Tea Co. is a direct-to-consumer tea subscription retailer. For 100 days it tracked its daily new signups, and on day 61 it raised its subscription price from $18 to $24. The 60 days before the price rise averaged 96.08 signups a day. The 40 days after averaged 92.08.
Here is the whole 100-day series, colored by whether the day fell before or after the price rise.
Signups do dip a little right where the color changes at day 61. But the series was already bouncing up and down before the price ever moved, day to day and week to week. So the question this lesson answers is: how much of that dip is the price rise, and how much is just the series doing what it always does?
Why a plain before/after average is not enough
96.08 minus 92.08 is 4.01. It is tempting to call that 4.01-signup drop the price rise's effect and move on. But Fernglen's signups were never a flat, featureless number to begin with, and some of that gap could just as easily come from how the series already behaves.
Build the series the way it was actually generated, and you can see exactly what else is mixed into that gap.
weekly adds a day-of-week swing that was there every single day, before the price rise and after it alike, peaking on Saturday. ar_err is noise with a memory: a day that comes in high tends to be followed by another day that also comes in high, instead of every day being its own fresh, unrelated draw. Both of those were baked into signups on purpose, on top of the real -6 signups a day that the price rise itself was built to cause.
So the -4.01 gap you just computed is a mix of three things: the weekly pattern landing slightly differently across the two periods, the noise's own memory nudging each period's average up or down, and whatever the price rise actually did. Separating those three, and reading the price rise's own share out on its own, needs a regressor that tells the model exactly when the price rise happened.