ML Systems Lab Open interactive version →
Intermediate 32 min read RCTrandomised controlled trialA/B testITT

RCT Design

Randomisation, SUTVA, Intent-to-Treat, treatment effect heterogeneity

The DAG module showed you how to find the right adjustment set when you're stuck with data you didn't get to design — draw the graph, block backdoor paths, leave colliders and mediators alone. Recall from Potential Outcomes: there's a design that skips needing an adjustment set at all. Randomization balances every confounder between arms — the ones in your DAG and the ones you never thought to draw — because it doesn't rely on you specifying anything correctly. This module is about building that design well, because "we randomized" is necessary and nowhere near sufficient.

An e-commerce company tests a new checkout flow: half of users see it, half see the old one. After two weeks, conversion is 4.8% in the new flow versus 4.3% in the old — significant at p = 0.02. Do they ship it?

If assignment was truly random — a coin flip, not a business rule dressed up as one — treatment and control are identical in expectation on every dimension: age, income, device, time of day, past behavior, and confounders nobody measured. Pause here: if a fair coin decided each user's arm, what's the chance the groups differ systematically on some variable you didn't think to record? Vanishingly small, and it shrinks as the sample grows — a guarantee no DAG-derived adjustment set can offer, since a DAG only protects against confounders you thought to draw. With randomization, the only systematic difference between arms is the treatment itself.

Getting there takes real decisions before anything is flipped. Unit of randomization: user-level gives one consistent experience with no within-user contamination; session-level gains power but the same user can land in both arms; page-level gains the most power at the highest contamination risk. Sometimes none of those units are isolated enough — when SUTVA forces it (a feature that propagates through a social graph, a marketplace, a city-level rollout), you randomize whole clusters (friend groups, cities) instead of individuals. That buys interference protection at a real, computable power cost: the design effect DEFF≈1+(m−1)×ICC tells you how much, where m is the average cluster size and ICC (intraclass correlation) is how similar outcomes are within the same cluster versus across clusters — at ICC=0.1 and m=100, DEFF≈10.9, meaning you need roughly 11× the individual-level sample size to hold power constant. Stratifying by known covariates (device, geography) before randomizing balances small samples chance alone might leave lopsided; block randomization within each stratum keeps counts even. Sample size isn't a number to guess afterward — run a power analysis first. Power is the probability of detecting a true effect if one exists, at a significance level α — a false-positive tolerance fixed by the experimenter, not something the data hands you. At 80% power and α = 0.05, compute the minimum sample size to detect the smallest lift that matters — the minimum detectable effect (MDE). That minimum scales roughly as 1/MDE²: halving the detectable effect roughly quadruples the users needed — why hunting a 0.1-point lift takes months and a 5-point lift takes days.

Correct randomization still doesn't protect against interference. If users share carts with friends, a treated user describing the new checkout to an untreated one changes that person's behavior even though they're assigned to control. The coin flip was fair, but propagation through the social graph means "control" is no longer the clean baseline promised — the same SUTVA violation that broke naive estimates in Potential Outcomes, breaking a properly randomized one too.

Randomization guarantees balance on assignment, not on what people do with it. Assign half of users to the new checkout and some never load it — a stale cache, an ad blocker, a bounce before render. Reversed: some assigned to the old checkout hit a cached copy of the new one and see it anyway — non-compliance can run either direction. Either way you're compared by the group you were assigned to, not the page you actually saw — that's the Intent-to-Treat estimate (ITT), and it's what you actually observe, since compliance can't be forced. ITT understates the effect on people who used the new checkout, diluted by the assigned-but-unexposed. The clean case is one-sided: nobody in control ever crosses into the new flow, only some of treatment fails to load it (monotonicity — no defiers: nobody does the opposite of their assignment). Concretely: if 80% of treatment actually loaded the new flow and ITT comes out to $6.40 per user, the effect among compliers — the Complier Average Causal Effect (CACE) — is ITT divided by that compliance rate: CACE = $6.40 / 0.80 = $8.00. The $8.00 is what tells you the redesign itself works; the $6.40 is what tells you what shipping it to everyone, non-compliers included, will actually move. If control also has crossover, the same idea generalizes to the Wald estimator: divide by the *difference* in take-up between arms instead of the raw 0.80.

None of this is what "statistically significant" certifies. p = 0.02 says the gap is unlikely under no effect — nothing more. That reading only holds if randomization was valid, the primary metric was pre-specified, the run lasted as planned, and the result is worth acting on. That last condition gets harder the more metrics you check: with 15 secondary metrics tested at α = 0.05, chance alone predicts roughly 15 × 0.05 = 0.75 false positives, so finding two or three "significant" secondaries isn't surprising on its own — a Bonferroni correction (dividing α by the number of tests) is the standard fix, and whether the metric driving your headline result was pre-registered as primary, versus fished out after the fact, changes how much weight its p-value deserves. A p = 0.001 result on a 0.01% lift costing $500K to build isn't a success story — significance means reliably nonzero, not worth building.

Key points

Takeaway

Randomization eliminates confounding by construction, but SUTVA violations, non-compliance, the wrong unit of randomization, and underpowered designs can each silently invalidate the estimate even when the coin flip was executed correctly.

Recap

Check your understanding

Q1. In your A/B test for a new email feature, 20% of users assigned to treatment never opened the email. You report ITT. Select the two true statements about ITT and how to estimate the effect on actual users.

Q2. You run a marketplace experiment: treated cities see new pricing tool; control cities do not. No effect on GMV after two weeks. Colleague says 'underpowered'; another says 'SUTVA violation.' How do you diagnose?

Q3. Your A/B test shows statistically significant positive effect on 7-day retention (p=0.02) but you also ran 15 secondary metrics and found significance on 3. How do you interpret this?

Q4. Why does cluster-level randomisation reduce statistical power, and when is it unavoidable?

Try it interactively

ML Systems Lab is a free interview-prep platform for ML engineers — work through the full interactive module, quizzes, and drills.

Open ML Systems Lab →