{
 "version": 1,
 "name": "Round 7: a geo test that checks itself, and what conversion lag does to its read",
 "declared": "Before any code of this round existed and before any test, check, break, lift read or score of this round was computed on any seed. The commit records the date.",
 "known_before_declaration": "The published results of rounds 1 to 6, including round 2's world files: in all 9 worlds the geo test went to paid search, ran 10 weeks (8 in world 6, index 5) on 40 regions split 20 and 20, with 26 weeks before it, and its true paid search parameters (weekly carryover 0.04 to 0.26, half-saturation 1.01 to 1.99). Rough arithmetic on the lag shapes below (written in the design note): with a gamma lag of shape 2, a test of 70 days books about 96% of its caused value by readout when the mean lag is 3 days, about 58% at 30 days and about 32% at 60 days. No test, check or read of this round had been simulated on any seed.",
 "unchanged": "Every earlier round's code, random streams, data, results and pages, apart from one link sentence on the entry page. Round 2's world files are read, never rewritten, and no model is refitted.",
 "seed": 20261008,
 "streams": "numpy default_rng(SeedSequence([20261008, 7, world, rep, k])): k = 1 assignment, 2 booking noise of new revenue, 3 negative-control noise, 4 daily spend noise, 5 the lag history sample, 6 break timing and the shocked regions. Every cell of a world uses the same streams for the same rep, so the cells differ only by their break. One more stream, SeedSequence([20261008, 7, world, 999]), continues round 2's demand past its last week. No earlier round uses a stream that starts [20261008, 7].",
 "money": "Simulated US dollars at face value. Lifts are in US$ thousands a week, like round 2's geo test.",
 "question": "On round 2's company, regions and nine worlds, run round 2's geo test on paid search many times at daily resolution and break it on purpose in four stated ways. Which daily check flags each break, how fast, and how often does it flag a healthy test? How far does the lift read drift when a break goes unflagged? And what does reading the test before its conversions have arrived do to the lift and its 90% interval?",
 "worlds": {
  "source": "Round 2's nine worlds, media-mix-runs/world-0.json to world-8.json, read unchanged. mediamix.world.build(20261008, w) regenerates each world; the run refuses a world whose regenerated weekly revenue or regenerated geo test (mediamix.world.geo_test on the world file's channel) differs from the world file.",
  "regions": "Round 2's 40 regions and their revenue shares (the first draw of round 2's geo stream). Each rep draws a new random split of the 40 regions into 20 held-out regions (paid search switched off) and 20 live regions.",
  "test_length": "Round 2's planned weeks for that world (geo_test.weeks), times 7 days. The planned readout is the end of the last test day.",
  "pre_period": "Round 2's 26 weeks before the test (weeks 131 to 156 of the observed series), 182 days."
 },
 "daily_model": {
  "value_by_day": "Conversion value is generated by the day the conversion happens and booked later (the lag below). Before the test, a region's daily value is its share times one seventh of round 2's weekly national value (baseline plus every channel's true contribution, as observed). In and after the test, the baseline is US$181.2K times round 2's demand for that week over 7; paid social, display, events and retargeting run at their mean spend with round 2's contribution rule carried from the observed history, over 7; paid search follows the daily rule below, per arm.",
  "paid_search_daily": "Relative spend r(t) per arm (1 = plan). Daily carryover alpha_day = alpha^(1/7) with round 2's true weekly alpha, a normalized geometric kernel of 728 days, days before the test at r = 1. Daily value = beta / 7 times hill(adstock, K) with round 2's true beta and K, times the region's share.",
  "demand_extension": "Round 2's demand covers 12 weeks past the observed series. Weeks beyond are needed only for reads that wait after the test; they continue round 2's AR(1) demand from its last state with the extension stream, same trend and season.",
  "booking_noise": "Each region's booked revenue each day gets independent normal noise with sd = 0.03 times US$181.2K times sqrt(share) / sqrt(7), so a week's noise matches round 2's.",
  "after_the_test": "Search returns to plan in the held-out regions the day after the test ends. Booked revenue keeps arriving."
 },
 "lag": {
  "shape": "Days from conversion to booking follow a gamma distribution with shape 2 and the cell's mean, rounded down to whole days, cut at 540 days and renormalized.",
  "healthy_mean_days": 3,
  "sweep_mean_days": [3, 7, 14, 30, 60, 90],
  "history_sample": "The team knows its lag only from a sample of 400 past conversions with their conversion and booking days, drawn from the cell's true lag."
 },
 "truth": "The true lift is the value paid search causes at plan per week of the test: 7 times the mean over the test days of the national daily value with search at plan everywhere minus with search off everywhere (daily rule above), with no break and counted by conversion day. It is the same in every cell of a world.",
 "read": {
  "planned": "At the planned readout: per region, mean booked revenue over the test days minus the mean over the pre-period days, times 7; the live regions' sum over their share minus the held-out regions' sum over their share (round 2's estimator at daily resolution). Standard error by round 2's formula sigma_hat * sqrt((1/w + 1/26) * (1/s_live + 1/s_held)) with w = test weeks and sigma_hat from the pre-period weekly sums of booked revenue, as in round 2. 90% interval: estimate plus or minus 1.645 standard errors.",
  "waited": "Lag cells only. The team waits W more days after the test, W the smallest whole number of days at which the estimated share still to arrive (check 4's formula at the read day) is below 5%, capped at 182. The gap is summed over the test days plus W (each day's live-minus-held gap against the pre-period's mean gap) and divided by the test weeks. Its standard error is (D + W) / D times round 2's formula with w = (D + W) / 7. Truth as above, so the read also picks up the small extra loss while search's carryover rebuilds after the test.",
  "drift": "Read over truth minus 1."
 },
 "checks": {
  "rule": "Each check runs at launch (day 0) where stated and at the end of every test day on data up to that day. A flag is recorded and never acted on: every run is read at its planned readout. Days to flag = first flag day minus break start day plus 1; a check that flags at launch on a break present from launch counts as 'at launch'.",
  "C1_balance": "Launch only. The gap between the arms' pre-period weekly booked revenue, each over its share, regressed on week (26 weeks, ordinary least squares). Flag when the slope's two-sided p-value is below 0.05.",
  "C2_held_out_spend": "Daily from day 1. The held-out regions' reported search spend over the last min(3, t) days, relative to what plan would spend there with search on. Flag above 5%.",
  "C3_pacing": "Daily from day 1. The live regions' reported search spend over the last min(3, t) days relative to plan. Flag below 80% or above 120%.",
  "C4_still_to_arrive": "At launch and daily. From the 400-conversion history sample's empirical lag curve F, the share of the test's conversion value still to arrive at the planned readout: 1 - (1/D) * sum over test days d of F(D - d) (value spread evenly over the test). Flag above 10%.",
  "C5_negative_control": "Daily from day 7. Revenue from existing customers in the same regions, which search cannot move: each region's share times US$181.2K times round 2's demand over 7 a day, times the region's shock factor, with noise sd 0.02 times US$181.2K times sqrt(share) / sqrt(7); booked the same day. Round 2's estimator and standard error on this revenue, from launch to day t (w = t / 7). Flag when |estimate / standard error| > 3."
 },
 "spend": {
  "live": "Actual and reported daily relative spend in the live regions: plan times the pacing factor times exp(N(0, 0.08^2) - 0.0032).",
  "held_out": "Actual and reported daily relative spend in the held-out regions: 0.01 times exp(N(0, 0.5^2) - 0.125) on a healthy test (location matching is never perfect), plus the leak when one runs. It counts in the daily search rule like any spend."
 },
 "breaks": {
  "start_day": "Uniform whole day from 8 to 21 of the test, drawn per rep (stream 6), the same for every break of a rep.",
  "healthy": "No break, lag mean 3 days.",
  "leak": "From the start day, the held-out regions also get 10% of the planned spend (a campaign running without the regional exclusion).",
  "pacing": "From the start day, the live regions spend 70% of plan (a pacing change in one arm).",
  "shock": "From the start day, 6 regions drawn at random from the 40 (stream 6) lose 20% of their conversion value and of their existing-customer revenue (a regional demand shock).",
  "long_lag": "The lag mean is 60 days from launch (the lag60 cell of the sweep; the history sample shows it). Lag cells 7, 14, 30 and 90 have no other break.",
  "lag_of_other_breaks": "3 days."
 },
 "replications": 400,
 "cells": ["healthy", "leak", "pacing", "shock", "lag7", "lag14", "lag30", "lag60", "lag90"],
 "worked_example": "The world with the median true lift (fifth of nine, ties to the lower world index); in it, the lowest rep of the shock cell in which C5 flagged before readout, or rep 0 if none did. Shown day by day: the gap, the negative-control z, the flags.",
 "predictions": {
  "P1": {"text": "On healthy tests, at least one check flags at some point from launch to readout in at most 15% of runs, in every world.", "note": "C1 alone flags about 5% by construction: in this generator the regions share one trend."},
  "P2": {"text": "On healthy tests, the planned read's 90% interval holds the true lift in at least 80% of runs, in every world."},
  "P3": {"text": "C2 flags the leak within 3 days of its start in at least 95% of leak runs, in every world."},
  "P4": {"text": "C3 flags the pacing change within 5 days of its start in at least 95% of pacing runs, in every world."},
  "P5": {"text": "C5 flags the regional demand shock before readout in at least 10% and at most 60% of shock runs, pooled over the nine worlds.", "note": "C1 to C4 cannot see the shock: it moves no spend, no lag and no pre-period revenue."},
  "P6": {"text": "Among shock runs, the median absolute drift of runs that no check flagged is smaller than that of runs C5 flagged, in at least 7 of 9 worlds (worlds where C5 never flags do not count as held)."},
  "P7": {"text": "With the 60-day lag, the planned read's median is below 50% of the true lift in every world, and its 90% interval holds the truth in at most 20% of runs, pooled."},
  "P8": {"text": "C4 flags at launch in at least 99% of 60-day-lag runs and in at most 1% of healthy runs, pooled."},
  "P9": {"text": "Waiting until the estimated share still to arrive is under 5% brings the 90% interval's coverage to at least 80% of runs, pooled, at lag means of 7, 14 and 30 days."},
  "P10": {"text": "Read anyway, the leak and the pacing change each give a negative median drift (the lift understated) in every world."}
 },
 "stopping": "One run of 400 reps per cell per world on the study seed, written into a new folder. No re-run with other settings is reported as a result; anything added after the results is labelled on the page.",
 "outputs": ["results-geo-checks.json", "geo-checks-summary.csv", "geo-lag-readout.csv", "geo-checks-runs.csv.gz"]
}
