# Marketplace experiment designs

In a simulated city where a driver incentive kept 70% of its pull from one period to
the next, the most precise way to test it, a region switchback with 3-period blocks, measured half the real
gain, and a fixed ship rule shipped the change in 14% of simulated cities
instead of 93%. That memory is a setting I chose, and it decides the result: in a
declared sweep the same test shipped the gain in 82% of cities at 30% and 3% at
80%. Longer blocks fixed most of the miss at a price in precision, so I would measure how long an effect lingers
before choosing block length. Planned interim checks with stricter early thresholds ended switchback tests after
61% of the planned time on average with the same
power, but that power was near 100%, where a loss could not show, and runs that stopped early overstated the gain.

The city is simulated: every rider, driver and ride is generated here. It stands in for driver-supply tests in a
ride-hailing market, so no company or rider data is shared. One city with settings I chose shows how each design
fails, not how often designs fail in a real market.

Open [the report](report.html) for the answer, the evidence, what I would use when, a rollout plan and what it is
worth. [DECISIONS.md](DECISIONS.md) has the design choices, [DESIGN.md](DESIGN.md) the simulator's assumptions and
[analysis.ipynb](analysis.ipynb) the executed notebook.

## What ran

Each situation runs 500 simulated cities of 16 regions and
64 drivers, 12,000 result rows in all. Four
analyses run on the same cities: driver A/B, the same A/B with CUPED (a pre-test adjustment), region clusters and a
region/time switchback. Five situations are distinct: no interference, spillovers between drivers and a lingering
effect (carryover), each with a real effect, plus two with no effect. The study declares
6 situations, but with no effect there is nothing to carry over, so the carryover no-effect run
equals the no-interference one city for city, and every table shows it once (*). The outcome is completed rides across the city
in the 16 scored slots of a 24-slot test; without the incentive the city completes about 3,871.

Each city is also simulated with every driver on the incentive and with none, sharing every random draw; the
difference is that city's full-rollout effect ("policy truth" below). The policy gap is the mean estimate minus that
effect. With interference the gap includes the design measuring a different quantity, so it is not bias in the
design's own comparison. "Reject zero" is the false-win rate with no effect and power with a real one.

| Scenario | Design | Policy truth | Policy gap | Coverage | Reject zero |
|---|---|---:|---:|---:|---:|
| No interference: effect | Driver A/B | 572.3 | -1.0 | 95.2% | 43.6% |
| No interference: effect | A/B with CUPED | 572.3 | -2.2 | 94.0% | 94.0% |
| No interference: effect | Region cluster | 572.3 | -7.1 | 95.8% | 28.2% |
| No interference: effect | Region/time switchback | 572.3 | 7.2 | 96.6% | 99.4% |
| Spillovers: effect | Driver A/B | 655.8 | 235.2 | 90.8% | 68.0% |
| Spillovers: effect | A/B with CUPED | 655.8 | 234.0 | 76.6% | 99.4% |
| Spillovers: effect | Region cluster | 655.8 | 126.8 | 94.8% | 50.4% |
| Spillovers: effect | Region/time switchback | 655.8 | 128.4 | 85.6% | 99.6% |
| Carryover: effect | Driver A/B | 522.7 | -0.6 | 95.4% | 37.4% |
| Carryover: effect | A/B with CUPED | 522.7 | -1.8 | 94.2% | 91.2% |
| Carryover: effect | Region cluster | 522.7 | -6.7 | 95.6% | 25.4% |
| Carryover: effect | Region/time switchback | 522.7 | -259.8 | 44.8% | 54.6% |
| No interference or carryover: null* | Driver A/B | 0.0 | -0.7 | 95.2% | 4.8% |
| No interference or carryover: null* | A/B with CUPED | 0.0 | -1.8 | 94.4% | 5.6% |
| No interference or carryover: null* | Region cluster | 0.0 | -8.6 | 95.4% | 4.6% |
| No interference or carryover: null* | Region/time switchback | 0.0 | 7.5 | 95.8% | 4.2% |
| Spillovers: null | Driver A/B | 0.0 | 5.5 | 95.0% | 5.0% |
| Spillovers: null | A/B with CUPED | 0.0 | 4.3 | 94.6% | 5.4% |
| Spillovers: null | Region cluster | 0.0 | -11.7 | 95.8% | 4.2% |
| Spillovers: null | Region/time switchback | 0.0 | 2.2 | 95.2% | 4.8% |

\* Also the carryover no-effect result. results.json keeps both entries; they differ only in their bootstrap
variance bounds.

<img src="assets/policy-gap.png" alt="Policy gap with Monte Carlo intervals">
<img src="assets/coverage.png" alt="Coverage of paired policy truth">
<img src="assets/rejection.png" alt="Null rejection and positive-effect power">
<img src="assets/cuped.png" alt="CUPED variance change">

All estimates, variances and Monte Carlo intervals are in [results.json](results.json); every run is in
[scenarios.csv](scenarios.csv).

## Declared sensitivity run

A second run, declared in [data/sensitivity-protocol.json](data/sensitivity-protocol.json) before it ran, tests two
assumptions behind the switchback results. Outputs: [sensitivity.json](sensitivity.json),
[sensitivity-ar1.csv](sensitivity-ar1.csv) and [sensitivity-blocks.csv](sensitivity-blocks.csv).

Memory sweep. A third declared run, [data/carryover-sweep-protocol.json](data/carryover-sweep-protocol.json),
reruns the switchback with a lingering effect at memories from 0 to 90% and six block and washout settings. Outputs:
[carryover-sweep.json](carryover-sweep.json) and [carryover-sweep.csv](carryover-sweep.csv).

Persistent shocks. Demand shocks that carry 0.8 of their size into the next slot (an AR(1)
process) left the switchback's spread at 0.95 times its main-run value (bootstrap interval
0.87 to 1.04); no design moved by more than about 6%. Its precision comes mainly from
comparing each region with itself. Larger or longer-lived shocks were not tested.

Block length with a lingering effect. The test stays 24 slots long with the first slot of every block discarded; each
block length has its own scored slots and effect. Independent shocks:

| Block length | Policy truth | Policy gap | Share missed | SD | Coverage | Power |
|---|---:|---:|---:|---:|---:|---:|
| 2 slots | 392.2 | -232.0 | 59.1% | 92.8 | 43.0% | 32.6% |
| 3 slots | 522.7 | -259.8 | 49.7% | 116.0 | 44.8% | 54.6% |
| 4 slots | 588.3 | -267.6 | 45.5% | 121.7 | 49.2% | 66.8% |
| 6 slots | 654.5 | -226.4 | 34.6% | 129.4 | 63.0% | 88.0% |
| 12 slots | 722.5 | -107.0 | 14.8% | 200.1 | 91.8% | 81.8% |

Longer blocks shrink the miss but widen the spread. Even 12-slot blocks miss part of the effect, so block length
should follow an estimate of how long the effect lingers.

## Declared decision and sequential run

A third run, declared in [data/decision-protocol.json](data/decision-protocol.json) before it ran, reads the same
cities twice more. Outputs: [decision.json](decision.json), [decision-runs.csv](decision-runs.csv),
[sequential.json](sequential.json), [sequential-runs.csv](sequential-runs.csv) and [looks.csv.gz](looks.csv.gz).

What a team would decide. A fixed ship, stop or keep-testing rule, the one from the experiment readout study, turns each design's final estimate into a decision. Units are net gain in rides
per 1,000 driver slots after the incentive's assumed cost of 100. Ship when the chance of a net gain above 100 is at
least 95% and the expected loss from shipping is at most 25; stop in the mirror case. Two interference checks from the
ride log come first (rides served by another driver at most 1%, rides matched across regions at most 5%). Prior SD
500; a wrong ship has a true net gain at or below 100, a wrong stop above it:

| Scenario | Design | Ship | Stop | Keep testing | Wrong ship | Wrong stop | Ship without checks |
|---|---|---:|---:|---:|---:|---:|---:|
| No interference: effect | Driver A/B | 17.6% | 0.4% | 82.0% | 0.0% | 0.4% | 17.6% |
| No interference: effect | A/B with CUPED | 73.0% | 0.0% | 27.0% | 0.0% | 0.0% | 73.0% |
| No interference: effect | Region cluster | 15.8% | 0.4% | 83.8% | 0.0% | 0.4% | 15.8% |
| No interference: effect | Region/time switchback | 92.6% | 0.0% | 7.4% | 0.0% | 0.0% | 92.6% |
| Carryover: effect | Driver A/B | 13.0% | 0.6% | 86.4% | 0.0% | 0.6% | 13.0% |
| Carryover: effect | A/B with CUPED | 62.4% | 0.0% | 37.6% | 0.0% | 0.0% | 62.4% |
| Carryover: effect | Region cluster | 12.6% | 0.8% | 86.6% | 0.0% | 0.8% | 12.6% |
| Carryover: effect | Region/time switchback | 13.8% | 1.6% | 84.6% | 0.0% | 1.6% | 13.8% |
| Spillovers: effect | Driver A/B | 0.0% | 0.0% | 100.0% | 0.0% | 0.0% | 39.4% |
| Spillovers: effect | A/B with CUPED | 0.0% | 0.0% | 100.0% | 0.0% | 0.0% | 96.4% |
| Spillovers: effect | Region cluster | 0.0% | 0.0% | 100.0% | 0.0% | 0.0% | 30.2% |
| Spillovers: effect | Region/time switchback | 0.0% | 0.0% | 100.0% | 0.0% | 0.0% | 98.6% |
| No interference: null* | Driver A/B | 0.2% | 7.6% | 92.2% | 0.2% | 0.0% | 0.2% |
| No interference: null* | A/B with CUPED | 0.4% | 19.2% | 80.4% | 0.4% | 0.0% | 0.4% |
| No interference: null* | Region cluster | 1.0% | 10.2% | 88.8% | 1.0% | 0.0% | 1.0% |
| No interference: null* | Region/time switchback | 0.8% | 23.0% | 76.2% | 0.8% | 0.0% | 0.8% |
| Spillovers: null | Driver A/B | 0.0% | 0.0% | 100.0% | 0.0% | 0.0% | 0.6% |
| Spillovers: null | A/B with CUPED | 0.0% | 0.0% | 100.0% | 0.0% | 0.0% | 1.4% |
| Spillovers: null | Region cluster | 0.0% | 0.0% | 100.0% | 0.0% | 0.0% | 0.8% |
| Spillovers: null | Region/time switchback | 0.0% | 0.0% | 100.0% | 0.0% | 0.0% | 1.0% |

With spillovers every run fails the interference checks and goes back for redesign, although shipping would have been
right here; no check can see carryover.

Stopping early. Each run is read after 6, 12, 18 and 24 of its 24 slots. Adjusted thresholds use Lan-DeMets
O'Brien-Fleming-type spending, 2.5% per side (z 4.333, 2.963, 2.359, 2.014); unadjusted checks use the usual 5% bar every time; time
used is the mean share of the 24 slots run before stopping:

| Scenario | Design | Fixed: rejected | Adjusted: rejected | Adjusted: time used | Unadjusted: rejected | Unadjusted: time used |
|---|---|---:|---:|---:|---:|---:|
| No interference: effect | Driver A/B | 43.6% | 41.6% | 91.1% | 53.8% | 65.6% |
| No interference: effect | A/B with CUPED | 94.0% | 94.2% | 63.8% | 96.0% | 36.1% |
| No interference: effect | Region cluster | 28.2% | 27.0% | 95.0% | 37.6% | 75.5% |
| No interference: effect | Region/time switchback | 99.4% | 99.4% | 60.6% | 99.6% | 32.9% |
| Carryover: effect | Driver A/B | 37.4% | 34.2% | 93.6% | 42.8% | 76.8% |
| Carryover: effect | A/B with CUPED | 91.2% | 90.8% | 71.4% | 92.6% | 47.3% |
| Carryover: effect | Region cluster | 25.4% | 23.8% | 96.5% | 30.0% | 83.1% |
| Carryover: effect | Region/time switchback | 54.6% | 52.4% | 91.0% | 65.0% | 71.1% |
| Spillovers: effect | Driver A/B | 68.0% | 66.6% | 80.5% | 74.4% | 50.3% |
| Spillovers: effect | A/B with CUPED | 99.4% | 99.4% | 53.1% | 99.4% | 28.6% |
| Spillovers: effect | Region cluster | 50.4% | 47.4% | 89.0% | 61.4% | 59.6% |
| Spillovers: effect | Region/time switchback | 99.6% | 99.8% | 53.3% | 100.0% | 28.3% |
| No interference: null* | Driver A/B | 4.8% | 3.8% | 99.5% | 8.2% | 94.8% |
| No interference: null* | A/B with CUPED | 5.6% | 5.6% | 99.6% | 12.4% | 93.8% |
| No interference: null* | Region cluster | 4.6% | 4.4% | 99.6% | 7.4% | 95.8% |
| No interference: null* | Region/time switchback | 4.2% | 4.0% | 99.6% | 9.4% | 96.0% |
| Spillovers: null | Driver A/B | 5.0% | 4.2% | 99.2% | 8.0% | 95.6% |
| Spillovers: null | A/B with CUPED | 5.4% | 4.8% | 99.5% | 10.6% | 94.8% |
| Spillovers: null | Region cluster | 4.2% | 3.8% | 99.8% | 8.4% | 95.3% |
| Spillovers: null | Region/time switchback | 4.8% | 5.2% | 99.5% | 10.6% | 95.5% |

Runs that stop early overstate the effect, and checking the ship rule at every look without an adjustment raises its
no-effect ships.

## Reproduce

Use Python 3.12 and uv. Install the exact lockfile once:

    uv sync --frozen

Then run:

    uv run python -m sim.run --seed 7

The command checks that the declared source files are unchanged, generates the simulated cities, compares all designs,
checks the full census and the declared statistical bounds, runs the declared sensitivity, decision and sequential
runs with their own checks, writes results and charts, executes [analysis.ipynb](analysis.ipynb) and builds
[report.html](report.html). Notebook execution needs permission to bind a loopback port. No API credentials,
downloaded dataset or paid service is needed, and after the first install the run is offline (UV_OFFLINE=1 enforces
it). To rebuild only the charts, this README and the page from the stored results, without simulating:

    uv run python -m sim.render --no-notebook

Run the analytic, causal and statistical reference tests separately:

    uv run python -m pytest tests -q

## Limits

The model leaves out trip duration, rider waiting, prices, demand response and drivers joining or leaving, and its
greedy matcher is not an optimized dispatch system. Spillovers and carryover are separate situations. Every spillover
comes from spare capacity, so a market where an incentive mostly moves rides between drivers is not tested. Carryover
has a geometric tail, and discarding one slot does not erase it. Intervals are stress-tested against the full-rollout
effect; they are not interference-robust intervals. Monte Carlo intervals describe simulation uncertainty under these
assumptions, not uncertainty about a real market. CUPED's large variance cut here reflects stable driver differences
built into the simulator.

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