Overview
This guide explains the methodology and usage of CUPED (Controlled experiments Using Pre-Experiment Data) for covariate adjustment in LaunchDarkly Experimentation results.Covariate adjustment refers to the use of variables unaffected by treatment, known as covariates, for:- Variance reduction: reduces the variance of experiment lift estimates, which increases measurement precision and experiment velocity.
- Bias removal: removes the conditional bias of experiment lift estimates, which increases measurement accuracy. In mainstream statistics, covariate adjustment is typically performed using Fisher’s (1932) analysis of covariance (ANCOVA) model. In the context of online experimentation, Deng et al. (2013) introduced CUPED (short for Controlled Experiments Using Pre-Experiment Data), which can be thought of as a special case of ANCOVA with the pre-period version of the modeled outcome as a single covariate. In this guide, we use the terms covariate adjustment, analysis of covariance (ANCOVA), and CUPED interchangeably.
Context
In a randomized experiment, there are three types of variables defined for each experiment unit, such as “user,” in a user-randomized experiment:- Treatment: a variable indicating treatment for the unit. For example: 1 if the unit is assigned to the “treatment” variation, and 0 if assigned to the “control” variation.
- Outcomes: post-treatment variables that we want to measure experiment performance on, such as experiment revenue.
- Covariates: pre-treatment variables that we use to improve our measurement of the outcomes, typically for segmentation and variance reduction, such as pre-experiment revenue. Outcomes are post-treatment variables. These are variables potentially affected by the treatment, or measured after the treatment is assigned. An example is revenue measured after the user enters the experiment. Covariates must be pre-treatment variables, which are variables measured before the treatment is assigned, or variables unaffected by treatment. Examples include revenue measured before a user enters the experiment, which is measured before treatment, and gender, which is unaffected by the treatment.
Method
The goal of covariate adjustment is to improve the measurement of an experiment outcome, such as experiment revenue, through the use of prognostic covariates. Prognostic covariates are covariates predictive of the outcome. Pre-experiment revenue is an example of a prognostic covariate, which is typically predictive of experiment revenue. The ANCOVA model, and CUPED in particular, does this by leveraging the correlation, which is the strength of linear relationship, between an outcome and a set of covariates, with the goal of improving measurement precision and accuracy.Variance Reduction
We illustrate this with a simple example of an outcome , such as experiment revenue, and a covariate , such as pre-experiment revenue. In this example, there is a strong linear relationship between them for both treatment and control variations, shown in the scatter plot on the left below:
Left: A scatter plot of outcome versus covariate with sample mean prediction lines. Right: A density plot of errors relative to control mean, showing large variance.

Left: A scatter plot of outcome versus covariate with regression prediction lines. Right: A density plot of errors relative to the control regression prediction, showing smaller variance.
Bias Removal
In addition to reducing the variance of lift estimates, CUPED applies an adjustment to the sample means and to produce the following covariate-adjusted means:Where and denote the covariate means for, respectively, the treatment and control variations, and denote the covariate mean over all experiment variations. Although the unadjusted means and are unbiased estimators of the variation averages over many realizations of the experiment, for a specific experiment there could be some conditional bias. Conditional bias may occur due to the random imbalances between the treatment and control variation covariate means and . As long as the linear regression model is correct, the adjustments and control for these imbalances and remove the conditional bias.Implementation
In this section we discuss the scope and model for the CUPED implementation in the LaunchDarkly Experimentation product.CUPED availability
CUPED is available for experiments when the following criteria have been met:- Average metrics: CUPED can be applied to metrics using the “average” analysis method, including conversion metrics and continuous numeric metrics. CUPED is not applied to metrics using a percentile analysis method.
- Metrics with historical data: CUPED can only be applied to a metric that has received events within the seven days prior to the start of the experiment. This is because CUPED requires historical metric data to compare current metric data to.
- Unfiltered metrics: CUPED cannot be applied to metrics with event filters.
- Experiments that have been running for at least 90 minutes: CUPED is not available for experiments receiving events for less than an hour and a half, due to the longer time it takes to compute the covariate-adjusted means and their standard errors (SEs) in the data pipeline. Results before the first hour and a half are not covariate-adjusted, even if the above CUPED criteria have been met.
Model
The covariate adjustment model implemented is characterized by the following two features:- Feature 1—Most General Model: LaunchDarkly uses the most general ANCOVA model, which allows for unequal covariate slopes and unequal error variances by experiment group. Using the convention of Yang and Tsiatis (2001), we refer to this model as the ANCOVA 3 model. To learn more, read Covariate adjustment.
- Feature 2—Single Pre-period Covariate: LaunchDarkly restricts the model to use only one covariate. We used the pre-period version of the modeled outcome, which is the covariate proposed by Deng et al. (2013) for the CUPED model and by Soriano (2019) for the PrePost model. Besides giving us the most general model, another advantage of Feature 1 is that we can implement the ANCOVA model by fitting separate linear regression models by variation. This means we fit one for each experiment variation, which simplifies implementation. One advantage of Feature 2 is that we can fit the linear regression models using simple analytical formulas without needing to use specialized statistical software for linear regression. Combining Features 1 and 2 yields a very simple SQL implementation that you can apply to big data with computational efficiency. Some may express concern about our using only one covariate in the model when we could potentially include more. In practice, using only the single pre-period covariate is advantageous from both the data collection and model fit points of view:
- Data collection: it simplifies the data collection process because we do not need to gather more covariates. Instead, we only need to collect data for the current outcome in the pre-period to obtain the pre-period covariate.
- Model fit: in practice, the pre-period covariate used is typically the covariate with the largest correlation with the experiment-period outcome. When such a highly correlated covariate is included in the model, including additional covariates typically does not improve the overall fit. In other words, the R-squared of the linear regression model would not increase by much. The pre-period covariate is measured over a seven-day lookback window before the start of the experiment. Precedent for using only seven days is established by the implementation of the PrePost model for covariate adjustment for YouTube experiments, mentioned in Soriano (2019), which is the basis for our implementation. There is also a tradeoff between using shorter versus longer windows in terms of relevance versus sufficiency. Shorter windows may have more relevance due to the recency of the information measured, but may not have captured all the information to optimize the outcome-covariate correlation. Longer windows capture more information, but risk including irrelevant information from older events, which may decrease the outcome-covariate correlation.
CUPED on the Results tab
Each LaunchDarkly experiment indicates whether CUPED is enabled or disabled on its Results tab above the “Exposures” graph.
An experiment's CUPED status.
- CUPED Disabled: CUPED is disabled for your experiment because all of its metrics are percentile metrics.
- CUPED Enabled: If CUPED is enabled, the experiment can be in one of three states:
- CUPED is enabled, but no metrics are covariate-adjusted yet. This can be because the experiment has been receiving results for less than 90 minutes, or because there is no pre-experiment data in the seven days before the experiment started.
- Only some of the metrics are covariate-adjusted.
- All of the metrics are covariate-adjusted.
Advanced topics
For those interested, we will cover some advanced topics in the following sections.Covariate adjustment
For a two-variation experiment, you can formulate the ANCOVA 3 model implemented at LaunchDarkly as a single model. For example:where if unit is in the treatment variation and if unit is in the control variation. The original ANCOVA model introduced by Fisher (1932) makes the following assumptions:- Assumption 1—Equal Slopes: equal covariate slope for all experiment variations, that is, in the example above.
- Assumption 2—Equal Variances: equal error variance for all experiment variations, that is, in the example above.[Yang and Tsiatis (2001)](https://www.jstor.org/stable/
- referred to this original model as the ANCOVA 1 model. If we remove Assumption 1 to allow for unequal covariate slopes, that is, allowing for , then we have what [Yang and Tsiatis (2001)](https://www.jstor.org/stable/
- calls the ANCOVA 2 model, also known as Lin’s (2013) model or the ANHECOVA (ANalysis of HEterogeneous COVAriance) model of Ye et al. (2021).
- Single model: a single generalized least squares (GLS) model, which allows for error variances that vary by experiment group. This can be fitted using, for example, the
nlme::glsfunction in R. - Separate models: an equivalent, but simpler, way to implement ANCOVA 3 is to fit one separate regression model for each experiment variation. Fitting separate models has the advantage of fitting very simple regression models when there is only one covariate. This makes for a simple SQL implementation without leveraging additional software, which improves computational efficiency, especially on big data. We give an example of a simple SQL implementation of the ANCOVA 3 model in the section SQL Implementation.