Overview
This page explains what Oxygen computes, and why it is done this way rather than the obvious way. Each section starts in plain words. The formulas sit in folded sections for readers who want them, and nothing else on the page depends on them.The core idea: compare changes, not levels
Treated and control units are rarely the same size. A big store sells more than a small one whether or not it ran a promo. So comparing their sales directly says little. Instead, Oxygen asks how much each unit changed:- For each unit, take its average outcome per day before the switch and after it (leaving out the anticipation buffer and washout).
- Subtract: that unit’s change is after − before. Each unit is now one number.
- Compare the average change of the treated units with the average change of the control units. The difference is the effect.
The staggered promo's first wave, one dot per shopper. The never-switched shoppers changed by −$0.80 on average, the wave-1 shoppers by +$15.40. The effect is the gap, +$16.30. Notice the spread: one treated shopper fell by $52, which is why the result comes with a range.
Why one number per unit matters
A store’s sales on Tuesday look a lot like its sales on Monday. If you analysed every store-day as a separate observation, the analysis would treat 56 days of one store as 56 independent pieces of evidence, when in reality they are closer to one. It would then be far too confident, and declare “significant” results routinely where there is nothing. Collapsing each unit to one number avoids this entirely. The evidence is counted in units, not days. That is also why a chain of 6 stores has an effective sample of 6 however long it runs, and why the time to find that out is at pricing, not after the run.The formulas: one switch date
The formulas: one switch date
i, with the outcome averaged over the retained days of each
window:estimate ± t_crit · se, where t_crit uses Welch–Satterthwaite degrees of
freedom and the registered significance level, corrected for the number of
outcomes registered together (Šidák: 1 − (1 − α)^(1/k) per outcome). With
one registered outcome there is no correction at all, which is the reward
for writing the plan down first. Units are matched to groups by name,
never by position, so the groups can never be silently swapped.With design.one_date_test: permutation a one-date design is instead tested
like staggered waves (below), as a single wave: for a handful of treated units
beside many controls, where Welch’s degrees of freedom come from the treated
units alone.Blocks and matched pairs shape the draw on this path: they make a lopsided
split impossible. The analysis then compares the two groups as wholes. Under
blocked assignment that comparison is still unbiased, and its uncertainty is,
if anything, on the cautious side, so the benefit of blocking shows up as the
disastrous draws removed rather than as a narrower interval.Staggered rollouts: each wave against units still waiting
With several waves, each wave is analysed on its own windows, against only the units that are still untouched for the whole of that wave’s after window: units that never switch, plus units whose own switch (and anticipation buffer) comes after it. The wave results are then averaged, weighted by how many units each wave has. The obvious alternative, one big regression over everyone with an “already switched” flag, quietly uses units that switched earlier as controls for later waves. When the effect differs between waves, that can give some units negative weight and even flip the sign of the answer. Estimating wave by wave against clean controls avoids the problem by construction.How the staggered result is tested
Waves share control units, so their results are not independent, and there is no honest textbook formula for the uncertainty. Instead Oxygen uses a randomisation test, which asks the question directly:If the change did nothing, and we had shuffled which units went in which wave, how often would we see a result at least this large?It reshuffles the units across the actual wave structure, keeping the calendar fixed and staying within blocks, and recomputes the result each time. If the real result is more extreme than almost all shuffles, it is significant. Because this mirrors exactly how the units were assigned, it needs no assumptions about the shape of the data. Each result is first divided by its own uncertainty, worked out the way Welch’s test does it, before it is compared with the shuffles. Without that step the test is fooled when the changed units are naturally noisier than the rest, say a promotion on the busiest products, or when the effect differs a lot from unit to unit and the groups are of unequal size. In those cases it called a change “clear” 30–55% of the time when there was none. With it, that happens about 5% of the time, as the significance level promises.
The staggered promo, tested. Grey: the effect the analysis reports for 2,000 random reassignments of which shoppers were in wave 1, wave 2 or neither, as if the promo did nothing. Teal: the real result, +$12.30. Only 51 shuffles (orange) are as far from zero, so p ≈ 0.026.
Example: how the range is found
Example: how the range is found
The formulas: staggered estimate and test
The formulas: staggered estimate and test
g when it never switches, or when its own
switch − anticipation falls on or after the end of wave g’s after
window. A wave with fewer than 2 units, fewer than 2 clean controls, or a
window under the coverage floor is dropped and reported.The p-value. Within each block, unit labels are reshuffled across
the block’s permutation groups: one group per observed switch day, plus
the never-switched pool (a dropped wave keeps its own group). The number
of distinct relabellings is the multinomial count over those groups,
multiplied across blocks. Up to 20,000 relabellings are
enumerated exactly; above that, 2,000 seeded shuffles are drawn and the
p-value is (1 + #{|null| ≥ |observed|}) / (1 + B). The decision is
p ≤ α.The smallest possible p-value is 1 / (number of relabellings). If
that is already above α, no result could ever be significant, and the
design is refused at pricing. For example, two units per group gives only
6 relabellings, which can never reach 5%.The interval is built by test inversion: a candidate effect τ
is kept if, after removing τ from every treated observation in
proportion to how much of its window was treated, the test does not reject.
Each end of the interval is found separately by doubling and then
bisection; if no candidate is ever rejected on a side, that side is
reported as unbounded. The tempting shortcut, estimate ± critical value of the shuffles, is not used: on real effects it comes out about three
times too wide.Switchbacks: a coin per pair
In a switchback, each pair of consecutive periods has one “on” and one “off” half, chosen by a coin. For each period, Oxygen takes the fleet’s average outcome per unit-day over the period’s days after the washout. Each pair gives on − off, and the effect is the average of the pair differences. The test asks: if the change did nothing, and the coins had landed the other way in some pairs, how often would the average be this large? That is a sign-flip test: every combination of flipped pairs is tried.The switchback example: four pairs, all positive (+14.4, +8.4, +12.6, +10.1), average +$11.40. Of the 16 ways the four coins could have fallen, only 'all on weeks higher' and 'all off weeks higher' are this extreme, so p = 2/16 = 0.125.
The formulas: switchback
The formulas: switchback
P pairs there are 2^P sign patterns (enumerated exactly up to
20,000, else 2,000 sampled). Because the patterns come in mirror-image
couples, the smallest attainable p-value is 2 / 2^P. At α = 0.05 that
needs at least 6 pairs (2/64 ≈ 0.031); 5 pairs give 0.0625. At α = 0.2,
4 pairs suffice (0.125). A pair with a period below the coverage floor is
dropped. The interval inverts the same test: candidate τ is subtracted from
every pair difference and kept while the test does not reject.Groups of units
When units are grouped, for example by region, each group’s day is the sum of its members’ outcome on that day, and the analysis runs on groups exactly as it would on units. The effect is then per group-day, and the sample size is the number of groups.Missing days and coverage
A difference in differences compares the same calendar days across units. So a day that is missing for any unit is dropped for all units. Windows are then measured in calendar days, not in surviving rows: a “56-day” window with 14 days missing is not stretched to 70 days to make up the count. If a window’s share of days with data falls below the coverage floor, it is refused rather than quietly shortened, because the measurement would no longer be the one that was planned. At week, month or hour grain everything above holds with “period” in place of “day”: a week missing for any unit is dropped for all, and a window counts calendar weeks. Each period is numbered consecutively, so the analysis is the same at every grain. On a measure that adds up, with data on every day, the effect per unit-week is 7 times the effect per unit-day over the same days.Compliance: why the effect gets watered down
Every unit is analysed in the group it was assigned to (intention to treat). If the change only landed at some treated units, or leaked to some controls, the measured effect is a blend of units that got the change and units that did not.The formula: restated detectable effect
The formula: restated detectable effect
c_t and control leakage c_c, the measured effect
is roughly (c_t − c_c) × the change’s own effect. So the design’s promise is
restated as MDE ÷ (c_t − c_c): at 67% net compliance, a design that could
detect 17.5 could only have detected a full-strength effect of about 26.A promo worth $15 that landed at only 7 of 10 shoppers reads about $10.50: the three missed shoppers still count as treated.
The parallel-trends pre-check
The method assumes treated and control units would have moved together without the change. Oxygen tests this on the before window, where nothing had changed: it splits the before window into two halves and runs the same analysis as if the change had happened at the midpoint. A significant fake effect means the groups were already drifting apart. Staggered designs run the check per wave. The check can only find a problem; it cannot prove there is none. A short before window gives it little power, which is one more reason to choose a generous one.The local shock example. The before window's halves (grey, then orange) disagree because the treated shoppers jumped by $70 at the midpoint. The fake effect between the halves is +$55.90, nearly four standard errors: Diverged.
Cannibalisation: why the floor is wide
The neighbouring measure is analysed with the same method. To say how small a loss could have gone unnoticed, Oxygen prices the neighbour’s own detectable effect on history from before the first switch (400 replays), so the change itself cannot inflate it. That is the “not excluded above X” floor.The slope: outcome per unit of driver
When a driver is set, the experiment measures two effects: on the driver (how far the lever pushed it) and on the outcome. Their ratio is the slope: dollars of outcome per unit of driver.The formulas: Wald ratio and Anderson–Rubin interval
The formulas: Wald ratio and Anderson–Rubin interval
β is kept when the unchanged
estimator, run on outcome − β · driver, does not find an effect. The set
of kept values is the interval (an Anderson–Rubin set). When the lever barely
moved the driver, the set runs to infinity and is reported as unbounded,
which is the honest answer. The driver’s own effect is tested at the
registered α as a diagnostic; it is not a registered outcome, so it does not
change the correction for multiple outcomes.Totals and projections
The estimate is an unweighted average effect per unit per day. Three ways of adding it up have very different standing:What none of this can fix
- Results at other units. The effect at the treated units need not hold elsewhere.
- Parallel trends. Checked, never proven.
- Effects that differ between units. The detectable effect assumes one effect for everyone. When it varies a lot, true power at the promised effect is lower than advertised.
- Small samples. The sample is the number of units, groups or pairs, not unit-days.