A switchback experiment is a randomized controlled design in which an entire unit, usually a geographic region or marketplace, alternates between treatment and control across successive time intervals, so that every observation within one interval shares the same condition. In experimentation on data from two-sided platforms, switchback testing is the standard answer to interference between units, the situation where assigning one user to a treatment changes the outcomes of users in the control group.
The design trades the large sample of user-level randomization for unbiased estimates under network effects. It is common in ride-hailing, food delivery, logistics, dynamic pricing and ad auctions, where drivers, couriers, inventory or budget form a shared resource pool that no user-level split can isolate.
Why user-level randomization fails in shared marketplaces
Classical A/B testing rests on the stable unit treatment value assumption (SUTVA), which states that one unit’s outcome depends only on its own assignment. In a delivery marketplace this assumption breaks: if a new dispatch algorithm sends more couriers to treated orders, control orders wait longer, and the measured difference overstates the true effect.
This bias is called interference or spillover, and in marketplaces it typically appears as cannibalization of supply. The treated group looks better partly because it borrows capacity from the control group. When the change ships to everyone, the borrowed capacity disappears and the expected gain shrinks or vanishes. A switchback experiment removes this channel by ensuring that, within an interval and region, all units receive the same condition.
How a switchback experiment assigns treatment over time
A switchback experiment divides the test period into randomization windows, typically 30 minutes to a few hours, and randomly assigns each region-window pair to treatment or control. The unit of randomization is therefore the time block, not the user, and the analysis compares aggregate metrics across blocks.
Designers choose a small set of parameters that together determine bias and variance. The table below summarizes the main ones.
| Parameter | Typical range | What it controls |
|---|---|---|
| Window length | 30 minutes to 4 hours | Carryover bias versus number of blocks |
| Clustering unit | City, zone or whole market | Spatial spillover between regions |
| Burn-in period | 5 to 30 minutes per window | Exclusion of transitional data |
| Assignment scheme | Simple random or balanced | Precision and time-of-day balance |
| Test duration | 1 to 4 weeks | Statistical power and weekly seasonality |
Many teams use stratified or balanced schedules, for example ensuring each hour of the week receives treatment equally often, so that daily and weekly seasonality does not correlate with assignment by chance.
Carryover effects and the choice of window length
The central risk of switchback testing is carryover, meaning that the condition in one window influences outcomes in the next. A pricing change may shift where drivers position themselves, and that repositioning persists after the system switches back to control.
Window length is the main lever against carryover. Longer windows dilute carryover because the contaminated transition forms a smaller share of each block, but they also produce fewer independent blocks and wider confidence intervals. Shorter windows raise power yet amplify bias. A practical rule is to set the window several times longer than the system’s recovery time, such as the typical trip or delivery duration.
The following table links common carryover sources to mitigation strategies.
| Carryover source | Example | Mitigation |
|---|---|---|
| Supply repositioning | Drivers move toward surge zones | Longer windows and burn-in exclusion |
| In-flight transactions | Orders dispatched before a switch | Attribute by creation time, drop boundary orders |
| User learning | Riders remember a lower price | Restrict to short-memory metrics |
| Queue state | Backlog built under one condition | Burn-in period sized to queue clearance |
Some teams estimate carryover directly by including the previous window’s assignment as a regression covariate. A significant lagged coefficient signals that the window is too short.
Analyzing switchback data correctly
Analysis must respect the block structure, because orders within a window are strongly correlated. Treating each order as an independent observation produces severely understated standard errors and false positives.
- Aggregate metrics to the window level, or use cluster-robust standard errors clustered by region-window.
- Include fixed effects for hour of day, day of week and region to absorb seasonality.
- Use randomization inference or permutation tests when the number of blocks is modest.
- Apply variance reduction such as CUPED with pre-period metrics at the block level.
Because the effective sample size is the number of blocks, not the number of transactions, a two-week test with one-hour windows in ten cities yields about 3,360 blocks. Power calculations and the minimum detectable effect should be based on that figure.
Switchback testing compared with related designs
Switchback testing is one of several designs that handle interference, and each sacrifices something different. The table compares it with neighboring approaches in experimentation.
| Design | Randomization unit | Handles interference | Main weakness |
|---|---|---|---|
| User-level A/B test | Individual user | No | Biased under shared supply |
| Switchback experiment | Region and time window | Yes, within windows | Carryover and low block count |
| Geographic cluster test | Region for whole test | Yes, across regions | Few clusters, regional imbalance |
| Difference-in-differences | Observational groups | Partially | Relies on parallel trends |
| Multi-armed bandit | User or request | No | Optimizes reward, not inference |
Geographic cluster tests keep each region in one condition for the whole period, which eliminates carryover but leaves only a few clusters. Switchback designs reuse the same regions many times, gaining many more effective observations while accepting some transition contamination.
Limitations and common mistakes
Switchback experiments cannot measure long-term effects such as retention or habit formation, because users experience both conditions within days. They are also unsuitable when the user experience must stay consistent, since a customer may see different prices an hour apart, which raises fairness and trust concerns.
Frequent errors include analyzing at the transaction level, choosing windows shorter than the system’s memory, ignoring spatial spillover between adjacent zones, and stopping early after peeking at block-level results. Teams should also run an A/A switchback first to verify that the pipeline produces calibrated false-positive rates.
In plain words
Imagine testing a new way to assign taxi drivers. If half the riders get the new method, the new method might simply steal drivers from the other half, which makes it look better than it is. A switchback experiment avoids this by giving everyone in a city the same version for one hour, then flipping a coin for the next hour.
After many hours, the company compares the hours with the new method against the hours without it. The key idea is simple: switch the whole system back and forth over time, so the two versions never compete for the same drivers at the same moment.
A real-world example
A food delivery platform wants to test a batching algorithm that lets one courier carry two orders at once. A user-level test is ruled out because batched orders would absorb couriers needed by unbatched ones. The data science team designs a switchback experiment across twelve metropolitan zones with one-hour windows over three weeks, using a balanced schedule so each hour of the week receives treatment equally often.
Because average delivery takes about 35 minutes, the team excludes the first 20 minutes of each window as burn-in. Metrics are aggregated per zone-hour, and the regression includes hour-of-week and zone fixed effects with cluster-robust errors. The result shows a 6 percent reduction in courier cost per order with a delivery time increase of under one minute, small enough to stay within the guardrail metric. A lagged-assignment check finds no meaningful carryover, so the team ships the algorithm with confidence that the estimate reflects true marketplace-wide impact.