Switchback Experiment Design and Analysis

Summary

A switchback experiment treats an entire market (a city, a marketplace, a set of SKUs) as one unit and randomizes it between treatment and control over time. Because everyone shares the same condition at any instant, cross-unit interference disappears; what replaces it is carryover: past assignments affect current outcomes. Bojinov, Simchi-Levi & Zhao (2020; Management Science 2023) assume only that carryover lasts at most periods, target the lag- effect of sustained treatment versus sustained control, estimate it with a Horvitz–Thompson estimator, and solve a minimax design problem. Results: fair coins are optimal (Theorem 1) and the optimal design re-randomizes once every periods, with first and last blocks of length (Theorem 2). Inference is design-based: an exact Fisher randomization test, or a finite-population CLT with a conservative variance estimate (Theorem 3).

Overview

Switchbacks are “among the most prevalent designs used in the technology sector”. A ride-hailing platform testing a pricing algorithm cannot split drivers, because treated and control drivers serve the same riders; a retailer testing a promotion algorithm cannot split SKUs, because promoted items cannibalise the others. Both are used as motivating applications (Sec. 1). The second use case is a small number of heterogeneous units (N-of-1 trials, algorithmic trading venues), where alternating treatments within a unit identifies a unit-level effect.

Compared with the structural approach of Johari et al. in Interference and Marketplace Experiments, this paper makes no outcome-model assumptions. Potential outcomes are fixed and the assignment path is the only randomness, exactly as in Randomization Inference - Overview. The three difficulties it addresses are: (i) the variance is governed by the number of assignments, not the number of users; (ii) carryover; (iii) super-population inference is meaningless for a single unit.

Main Content

Setup and estimand

Time is , the assignment path is and potential outcomes are .

Assumptions on the potential outcomes ^def-switchback-assumptions

  1. Non-anticipation: ; outcomes do not depend on future assignments. This is guaranteed by design, since the platform, not the units, controls future treatment.
  2. -carryover: there is a fixed with ; only the last assignments matter, so write . Example: the effect of surge pricing dissipates in one to two hours.
  3. Bounded outcomes: (used for the minimax problem and the variance bound).

Lag- causal effect of consecutive treatments (Eq. 1)

With this is the average effect of permanently deploying the policy versus never deploying it: the time-series version of the global treatment effect.

Regular switchback experiment (Definition 1) ^def-regular-switchback

Choose randomization points and probabilities . At each flip a coin with and hold that assignment through period . The design is the induced distribution over the feasible paths.

Estimation

Horvitz–Thompson estimator is unbiased (Eq. 4, Proposition 1) ^thm-ht-unbiased

Under Assumptions 1-2 and any regular switchback with , .

Only periods whose whole window is all-treated or all-control contribute: these are the observations that actually reveal or . Periods just after a switch are contaminated by carryover and are discarded, a data-driven “washout”. The inverse probabilities are known by design; under fair coins they are , where is the number of coin flips the window spans, which avoids the instability of extreme-weight Horvitz–Thompson estimators.

Optimal design

The criterion is minimax risk over bounded potential outcomes; because is unbiased, risk equals variance.

Fair coins and optimal switching frequency (Theorems 1-2) ^thm-optimal-switchback

Under Assumptions 1-3:

  1. Any optimal design has .
  2. The optimal randomization points solve the subset-selection problem

If , (flip every period). If and with ,

The trade-off is direct. Too many switch points make long all-treated or all-control windows rare, so few periods are usable and their weights are large. Too few leave only a handful of independent coin flips. The optimum is to flip once per carryover length, with longer first and last blocks. For , : , i.e. blocks of length 4, 2, 2, 4. Two practical corollaries:

  • Granularity does not matter, physical time does (Example 7). If carryover lasts two hours, the design flips every two hours whether a period is defined as 30 minutes () or an hour (). Periods should be shorter than the carryover: with one-hour periods and one-minute carryover, orders of magnitude of usable data are thrown away (Sec. 6).
  • Robustness at small (Example 8). The optimal designs for and are and , almost identical.

Inference

Exact test (Sec. 4.1, Algorithm 1). Under the sharp null for all windows and , the observed outcomes would have occurred under any path. Draw fresh paths from the design, recompute holding fixed, and report . This is a Fisher randomization test whose reference distribution is the switchback design itself; no time-series model is needed despite arbitrary autocorrelation in the outcomes.

Asymptotic test for the average effect (Sec. 4.2). For the weak null (compare Sharp vs Weak Null Hypotheses), let be block sums under the optimal design with . Lemma 2 gives the exact variance, which involves unobservable cross-products ; Corollary 1 bounds it by a quantity with the unbiased estimator

Finite-population CLT (Theorem 3) ^thm-switchback-clt

Fix , let , use the optimal design, and assume (Assumption 4; implied by potential outcomes bounded away from zero). Then as ,

Replacing the variance by gives the conservative test , , and conservative confidence intervals.

Misspecified carryover (Sec. 4.3). If , then and everything remains valid, merely less efficient. If , the exact test is still valid for the sharp null, but is biased for ; asymptotic normality holds around (Corollary 2). Err on the side of a larger .

Identifying (Sec. 4.4). Run optimal designs with on two comparable units or on two well-separated epochs. Under both estimate , so is asymptotically standard normal; rejection says carryover is longer than . Combine with a search over . The authors warn that each such test needs .

Planning the horizon (Sec. 6). With fixed, the sample size is , the number of coin flips. Choose from simulated rejection-rate curves given a signal-to-noise guess, as in a power analysis. With several markets, run the optimal design independently in each and pool.

Examples

Design and analysis sketch.

import numpy as np
 
def optimal_points(T, m):                    # Theorem 2, requires T = n*m with n >= 4
    n = T // m
    return [1] + [k * m + 1 for k in range(2, n - 1)]
 
def sample_path(T, points, rng):             # fair coin at each randomization point
    w, bounds = np.empty(T, int), points + [T + 1]
    for a, b in zip(bounds[:-1], bounds[1:]):
        w[a - 1:b - 1] = rng.integers(0, 2)
    return w
 
def ht_estimate(y, w, points, m):
    T = len(y)
    block = np.searchsorted(points, np.arange(1, T + 1), side="right")
    est = 0.0
    for t in range(m, T):
        k = len(set(block[t - m:t + 1]))     # coin flips spanned, so Pr(window) = 2**-k
        win = w[t - m:t + 1]
        if win.all():       est += y[t] * 2**k
        elif not win.any(): est -= y[t] * 2**k
    return est / (T - m)
 
def randomization_pvalue(y, w, points, m, rng, draws=5000):   # Algorithm 1
    obs = ht_estimate(y, w, points, m)
    null = [ht_estimate(y, sample_path(len(y), points, rng), points, m) for _ in range(draws)]
    return np.mean(np.abs(null) >= abs(obs))

Simulation (own illustration). , , outcome with , so the sustained-treatment effect is . Over 20,000 assignment paths:

Design and estimatorMeanSD
Optimal , Horvitz–Thompson1.992.57
Flip every period, Horvitz–Thompson1.962.93
Optimal design, naive difference in means of treated vs control periods1.260.36

The naive contrast is precise but biased by 37%, because it counts periods just after a switch whose outcomes still carry the previous regime. Horvitz–Thompson is unbiased under either design and the optimal design has lower variance, but the absolute variance is large: the estimator weights levels of , so a secular trend ( here) inflates it. In practice one centres the outcomes or uses regression adjustment, and above all lengthens . This is the bias-variance price of switchbacks noted by Larsen et al. (Sec. 6), who also mention fixed “burn-in” periods after each switch as the simpler common practice.

Marketing reading. A national TV or paid-social test with a single market is a switchback. Adstock is the carryover, so should be set from the adstock half-life and flights re-randomized about once per ; on/off pulsing weekly when carryover lasts three weeks estimates a badly attenuated effect. See Q - Carryover Dynamics and the Timing of Sequential Media Experiments. The design-based analysis contrasts with the model-based time-series counterfactual of the TBR estimator, which relies on stable control geos instead of repeated randomization.

Connections

See Also