# Design declaration: estimating a city launch without an A/B test

Written and sealed before any result was computed. Its sha256 is in `DESIGN.sha256`, and a test fails if this file
changes. Any change after the first results run is a new, declared version written below the seal line, scored beside
this one, with this version's misses still reported.

## Question

A ride-hailing marketplace launches a change in one whole city at once: a driver incentive, the same pay for every
driver, or an app feature switched on for everyone. Nobody can be randomized, so there is no A/B test. How well can the
launch's effect on weekly completed trips be estimated, by which method, and with what honest interval?

## Data (synthetic, so no customer data is shared)

A seeded simulation of 20 cities over 156 weeks. City 0 launches at week 130, so there are 130 weeks before the launch
and 26 weeks after. Cities 1 to 3 are its neighbours (same region); cities 4 to 19 sit in three other regions of five,
five and six cities.

Log weekly trips without the launch, for city c in week t:

    log Y0[c,t] = mu[c] + g[c] * t/52 + A[c] * s(t) + lam[c] * F[t] + R[region(c), t] + e[c,t]

- `mu`: log of a base size drawn log-uniform between 30,000 and 300,000 weekly trips; city 0 is fixed at 100,000.
- `g`: yearly growth, drawn Normal(0.12, 0.03); city 0 is fixed at 0.12.
- `s(t) = -sin(2 pi t/52) + 0.3 sin(4 pi t/52)`: one shared yearly season with a second harmonic. `A[c]` is the city's
  amplitude, drawn Uniform(0.10, 0.20); city 0 is fixed at 0.15. The launch falls where the season turns up, as
  launches often do.
- `F`: a national factor, a random walk with weekly steps of standard deviation 0.006; loading `lam[c]` drawn
  Uniform(0.8, 1.2).
- `R`: one factor per region, AR(1) with coefficient 0.95 and innovations of standard deviation 0.012.
- `e`: city noise, AR(1) with coefficient 0.5 and innovations of standard deviation 0.02.

The launch multiplies city 0's trips by 1.06 in every week after it: a planted effect of **+6.0%**. The estimand is the
lift over the 26 weeks after launch, sum(Y1) / sum(Y0) - 1, which the simulation knows exactly. Observed trips are
rounded to whole trips.

## Scenarios (200 replications each, every draw fresh per replication)

| id | name | what changes from the seasonal base case |
|---|---|---|
| S0 | flat | no season (A = 0) and no growth (g = 0) in any city: the positive control |
| S1 | seasonal | the model above as written: the base case |
| S2 | city shock | S1, plus a one-off +15% in city 0 in weeks 140 to 145 that the launch did not cause (an event) |
| S3 | spillover | S1, plus the three neighbours lose 5% of trips in every week after launch (drivers and riders drawn into city 0) |
| S4 | few comparisons | S1, but only 3 comparison cities exist, drawn per replication from cities 4 to 19 |
| S5 | pre-trend mismatch | S1, but city 0 grows 0.30 a year while the others keep Normal(0.12, 0.03) |

## Methods (each gives the lift over the 26 weeks after launch)

- **M1 Naive before and after.** Mean weekly trips in the 26 weeks after launch over the mean in the 26 weeks before,
  minus 1. Interval: 90% percentile bootstrap, 1,000 resamples of weeks within each window.
- **M2 Comparison-city growth.** City 0's growth (the same two 26-week windows) divided by the average growth of the
  comparison cities, minus 1.
- **M3 Difference-in-differences.** On log trips over the full 130 weeks before and the 26 after: city 0's change in
  mean minus the comparison cities' average change, turned back into a percentage. With one launched city this equals
  a two-way fixed effects regression. Diagnostic: a pre-trend flag when the slope of the gap between city 0 and the
  comparison average over the last 52 weeks before launch exceeds 3 points a year in absolute value.
- **M4 Forecast as the counterfactual.** Least squares on city 0's own 130 weeks of log trips: intercept, linear trend
  and three yearly Fourier pairs, projected over the 26 weeks after. Lift = sum(actual) / sum(exp(forecast)) - 1.
- **M5 Synthetic control.** Weights on the comparison cities, non-negative and summing to one, chosen to match city 0's
  demeaned log trips over the 130 weeks before; the counterfactual is city 0's pre-launch mean plus the weighted
  comparison cities' demeaned log trips.
- **M5b Synthetic control without neighbours.** M5 with the same-region cities removed from the pool, as a team would
  do when it suspects spillover. Run in every scenario; in S4 the pool has no neighbours, so it equals M5.

Intervals for M2 to M5b: **placebo in space.** Run the same method on each comparison city as if it had launched (city 0
left out of the pool), where the true effect is zero (in S3 the neighbours carry their real loss, as they would in real
data). The 90% interval is the estimate minus the 95th and 5th percentiles of the placebo estimates (linear
interpolation).

Declared alternative interval for M4, **M4t (backtests in time):** pretend city 0 launched at weeks 78, 80, ..., 104
(14 backtests), fit on the weeks before each, forecast the next 26, and take the errors; the interval is the estimate
minus their 95th and 5th percentiles. M4t has the same point estimate as M4.

## Self-check and pass bars

The self-check is each method's estimate against the planted effect across 200 replications per scenario: bias (mean
error, in percentage points), RMSE, and coverage of the 90% interval (share of replications whose interval contains
+6.0%).

A method **recovers** the effect in a scenario when |bias| <= 1.5 points and coverage is between 80% and 98%.

Mechanical checks: the simulation's own lift equals 6.0% to 1e-9 in every replication; the same seed gives byte-identical
data; each method run on a noise-free S0 panel returns 6.0% to 1e-6.

## Predictions (scored after the run, misses reported)

1. S0: M2, M3, M4, M5 and M5b recover. M1 has |bias| <= 1.5 but coverage below 80% (its bootstrap ignores shocks shared
   by weeks).
2. S1: M1 bias above +20 points. M2, M3, M4, M5 and M5b recover.
3. S2: no method recovers; every method's bias is above +1.5 points (the event is read as launch effect).
4. S3: M5 bias above +1.5 points (its best matches are the neighbours, which lost trips). M5b and M4 recover. M2 and M3
   recover with a positive bias below 1.5 points.
5. S4: M2, M3, M5 and M4 (placebo interval) keep |bias| <= 1.5 points but cover below 80%; M4t covers 80% or more.
6. S5: only M4 and M4t recover; M2, M3 and M5 bias above +5 points; the M3 pre-trend flag fires in at least 90% of
   replications.

## Business value (declared assumptions, not results)

A city with 100,000 weekly trips; the incentive costs US$9,000 a week; each extra trip is worth US$1.00 of contribution.
Weekly value = lift x 100,000 x US$1.00 - US$9,000, valued at the true lift and at each method's mean S1 estimate, and
scaled to 10 cities for 52 weeks.

## Seed

Master seed 4242. Replication r of scenario k uses `numpy.random.default_rng([4242, k, r])`.
