CUPED and Regression-Adjusted Variance Reduction
Summary
CUPED (Controlled-experiment Using Pre-Experiment Data; Deng, Xu, Kohavi & Walker, WSDM 2013) imports the Monte Carlo control variate trick into A/B testing. Replace each arm’s mean by , where is a covariate measured before assignment. Because randomization guarantees , the adjusted difference remains unbiased for the treatment effect, and with the optimal its variance is . The best covariate is almost always the same metric in the pre-period. On Bing, CUPED cut variance by about 50%, equivalent to doubling traffic or halving run time. The one hard rule: never use a covariate that the treatment could have affected.
Overview
Online experiments chase effects of a fraction of a percent, and the required sample size grows as (see ^ex-power and Power Analysis and Sample Size). Deng et al. list why simply adding traffic is not enough: effects are tiny, results are needed quickly (especially for harmful treatments), many features have low triggering rates, and traffic must be shared among many concurrent experiments. The alternative to increasing is decreasing .
The analysis framework is the two-sample -test, with statistic where and, by independence of the arms, . So reducing the variance of the difference reduces to reducing the variance of each mean, which is exactly the problem studied in Monte Carlo simulation. The goal is an adjusted estimator that is (i) still unbiased for the mean shift and (ii) lower variance, without the parametric commitments of a linear model (ANCOVA assumes and homoscedastic errors) and without the machinery of semiparametric efficiency theory (Tsiatis 2006), to which the result is nonetheless equivalent.
Main Content
Stratification
Split the sampling region into strata with probabilities and form . The variance decomposition (Deng et al. Sec. 3.1.1) is
so stratification removes the between-strata variance. Online, users cannot be sampled stratum by stratum because they arrive over time, but strata can be formed after the fact from pre-experiment variables (browser, country, heavy/light user), giving the post-stratified delta . Because the stratifying variable is pre-experiment it is independent of the treatment effect, which keeps unbiased.
Control variates
Control variate estimator ^def-control-variate
Given i.i.d. pairs with known, define for any constant
is unbiased for and
Optimal coefficient and variance reduction (Deng et al. Eqs. 4-5) ^thm-cuped-variance
The variance of is minimised at
the OLS slope of on , giving
With several covariates becomes from the regression of on . More generally, among adjustments the optimal is the regression function .
The CUPED observation
In simulation, the hard part of a control variate is knowing . In an experiment we do not need it:
CUPED delta is unbiased (Deng et al. Sec. 3.2.2, Eq. 7) ^thm-cuped-unbiased
If is constructed only from information that precedes treatment, randomization implies . Then
is unbiased for (the unknown terms cancel), and with ,
The same must be used in both arms; the simplest estimate is from the pooled treatment-plus-control sample.
Read the formula as: the in-experiment difference, corrected by the chance pre-experiment imbalance between the arms. If the treatment group happened to draw heavier users, and the raw delta is pulled down accordingly.
Stratification is a special case. With a categorical , using the indicators as control variates (whose means are the weights ) reproduces exactly; the fitted coefficients are (Appendix A). Control variates therefore generalise stratification to continuous covariates and avoid having to estimate .
Practical guidance (Secs. 4-5)
- Which covariate? Across a large class of metrics, the same metric measured in the pre-experiment period gives the largest reduction. In a 3-week A/A test on queries-per-user: entry-day alone gave 9-10%; pre-period queries-per-user gave more than 45%; both together added only 2-3%.
- How long a pre-period? Two forces compete. Correlation rises with a longer pre-period (better signal-to-noise for cumulative metrics). Coverage, the share of experiment users seen in the pre-period, rises with pre-period length but falls as the experiment runs longer (late arrivals are new or cookie-churned users). Reduction peaked at about two weeks of experiment; 1-2 weeks of pre-period is the recommendation, giving roughly 50% reduction over a wide range of durations.
- Missing pre-period data. Add a binary covariate “appeared in the pre-period” and set the missing to any constant. This is equivalent to stratifying on presence and then adjusting within the matched stratum.
- Beyond the pre-period. The requirement is only that the treatment cannot affect . Information fixed at a user’s first appearance (e.g. entry day-of-week) or anything established before triggering qualifies, which is useful for low-trigger-rate features.
- Non-user metrics. For page-level metrics such as CTR = clicks / page views with user-level randomization, combine CUPED with the delta method: linearise both ratios and compute from the user-level covariance of (clicks, views, pre-clicks, pre-views) (Appendix B). Compare Standard Errors and Clustering.
- Where it fails. Revenue-per-user gained less than 5% because pre- and in-experiment revenue are weakly correlated. CUPED works best for metrics with stable heavy/light-user heterogeneity.
Post-treatment covariates bias the estimate (Sec. 5.3) ^warn-post-treatment
In an experiment known to increase queries-per-user, the in-experiment metric Distinct-Queries-per-user is an almost perfect correlate and shrinks the interval dramatically. But the treatment also raised DQ, so and the “corrected” delta came out significantly negative: a narrow interval around the wrong sign. This is the experimental version of conditioning on a mediator or collider; see Logic of Regression Adjustment.
Relation to regression adjustment
CUPED with one covariate is numerically the ANCOVA estimate from regressing on treatment and centred , but its justification is design-based: unbiasedness comes from randomization, not from the linear model being correct. The semiparametric literature (Yang & Tsiatis 2001; Tsiatis et al. 2008) shows ANCOVA-type estimators are asymptotically at least as efficient as the unadjusted test even under misspecification. Later work replaces the linear with a machine-learned prediction (Larsen et al. Sec. 2.1), following the optimal- remark above. This is the opposite use of regression to the one in Logic of Regression Adjustment: there, covariates remove confounding; here there is no confounding to remove, and covariates only soak up outcome variance.
Examples
Slowdown experiment (Sec. 5.1). Bing delayed responses by 250 ms. After two weeks on a small slice the CTR effect was borderline ( just under 0.05); a much larger rerun confirmed it at . Re-analysing the original run with CUPED and two-week pre-period CTR as the covariate made the effect significant from day 1, and CUPED on half the users was still more sensitive than the raw -test on all of them. Three later experiments showed reductions of 45%, 52% and 49% with one week of pre-period data.
Code sketch.
import numpy as np
def cuped(y, x_pre, treat):
"""y: in-experiment metric, x_pre: same metric pre-assignment, treat: 0/1."""
theta = np.cov(y, x_pre)[0, 1] / np.var(x_pre, ddof=1) # pooled, both arms
y_adj = y - theta * (x_pre - x_pre.mean())
d = y_adj[treat == 1].mean() - y_adj[treat == 0].mean()
se = np.sqrt(y_adj[treat == 1].var(ddof=1) / (treat == 1).sum()
+ y_adj[treat == 0].var(ddof=1) / (treat == 0).sum())
return d, se # var ratio vs raw is about 1 - corr(y, x_pre)**2With the variance falls by , so an experiment planned for four weeks reaches the same power in about two.
Connections
- Online Experimentation - Overview — the sensitivity problem CUPED addresses.
- Power Analysis and Sample Size — replace by in any sample-size formula.
- Logic of Regression Adjustment — same algebra, different purpose (precision rather than identification); both forbid post-treatment controls.
- Time-Based Regression Estimator for Geo Experiments — the geo analogue: pre-period control-geo sales predict the counterfactual and absorb variance.
- Geo-Experiment Design and Power Analysis — pre-period matching and stratification of geos is the design-stage counterpart of post-stratification.
- Confidence Sequences — variance-reduced, regression-adjusted estimates can be monitored sequentially; Howard et al.’s ATE sequence accepts arbitrary predictions of the potential outcomes for the same reason.
- The Experimental Ideal — randomization is what makes .