Data science & ML

A/B Testing and Causal Inference

The effect of assignment is distinguished from the effect of voluntary use before defining randomisation units, primary metrics and harm guardrails. Minimum detectable effects, power, early stopping and CUPED assumptions shape the experiment plan. A checkout-interface example illustrates cross-exposure and allocation imbalance. When randomisation is unavailable, observational approaches are considered with their additional identification assumptions made explicit.

On this page

What question does an A/B test answer?

An A/B test estimates the average effect of assignment to a variant in a defined population. Comparing voluntary users with non-users answers a different question because choosing to use the feature can introduce selection bias. Intention-to-treat analysis preserves the assignment distinction. The primary metric and harm guardrails also shape interpretation: higher conversion accompanied by more returns or payment errors does not establish that the design is better overall.

Randomization unit and interference

Randomizing by user, session, company or store produces different dependence structures. The same user entering both groups can violate intended assignment. Interference occurs when one participant's treatment affects others, as in social networks or marketplaces. Cluster randomization also requires cluster-aware uncertainty estimation. Choose units from product behavior rather than convenience. A/A tests and sample-ratio-mismatch checks can reveal instrumentation or assignment problems before interpreting effects.

From experiment design to a product decisionHypothesis + metricRandomizationRun + quality checksEffect + intervalDecision + follow-up
Figure 1. Hypotheses and metrics are set before randomisation; the decision uses effect estimates, uncertainty and harm guardrails.

Primary metrics and guardrails

Prespecifying one primary decision metric reduces multiple-testing risk. Guardrails such as error rate, failed payments, latency and complaints detect unacceptable harms. They are not alternative metrics to cherry-pick after the fact. Metric definitions depend on aggregation: conversion per user and conversion per page view have different units and estimands. Version the SQL or analytics logic before launch. Redefining metrics after seeing results undermines confidence.

Minimum detectable effect and power

Experiment duration depends on baseline conversion, the smallest meaningful effect, error thresholds, power and traffic. Detecting tiny effects reliably requires larger samples. A two-day experiment may be severely underpowered. Repeated events and clustered users reduce effective sample size relative to raw event counts. There is also no value in running a very long test solely to detect changes too small to matter. Power estimates rely on data-quality and design assumptions.

Peeking and early stopping

Checking p-values every hour and stopping the first time p drops below .05 can invalidate the error properties of a conventional fixed-sample test. Sequential methods and prespecified interim analyses offer alternatives, but their stopping rules must be part of the design. Stopping only when results look good creates selection bias. Operational interruptions for traffic or system failure should be logged separately. Experiment platforms and statistical design need a shared protocol.

Distinctions that matter in designCorrelation: associationRCT: intervention effectDiD: parallel-trend assumptionA/A: instrumentation check
Figure 2. Correlation, randomised experiments, parallel-trend assumptions and A/A checks provide different kinds of evidence.

CUPED and pre-experiment variance reduction

CUPED uses pre-experiment covariates correlated with the outcome to reduce estimator variance. Applied correctly, it can improve precision without changing the treatment assignment. The covariate must not be affected by treatment; post-treatment information can introduce bias. Specify covariates and estimation rules in the analysis plan. Gains may differ across user subgroups. CUPED does not repair broken randomization or poor instrumentation; it improves an otherwise valid experiment.

Causal methods when randomization is unavailable

Sometimes a product is rolled out everywhere or randomization is impossible. Difference-in-differences, regression discontinuity and matching approaches may then be candidates. Each relies on substantive assumptions. In DiD, the treatment and control groups need plausible parallel counterfactual trends without intervention. Comparing pre-treatment trends supports—but cannot prove—this condition. A predictive model performing well observationally does not establish causal effects. Report designs alongside their assumptions and sensitivity analyses.

Turning experiment evidence into a product decision

A decision report should include absolute and relative effects, confidence intervals, sample size, duration and guardrail outcomes. A statistically detectable gain may be economically trivial. Aggregate benefits can hide subgroup harms, though unrestricted subgroup exploration increases false discovery. Rollout decisions combine technical quality, operational cost and possible long-term effects. Plan follow-up to see whether gains persist after launch. An experiment is strong evidence for a decision, not the whole decision itself.

A checkout experiment where one user sees both variants

Illustrative scenario; not a measured project result.

Suppose an e-commerce checkout button changes. Conversion looks higher on day one, but users exposed to both variants across devices or imbalanced mobile assignments can confound the interpretation. User-level randomization, duration, minimum detectable effect and guardrail metrics need prespecification. This is a fictional experimental scenario, not actual conversion data.

From conversion uplift to a product decision

A redesigned checkout button can show higher conversion on its first day. The interpretation changes if users see both variants across devices or allocation is imbalanced. An experiment needs to describe the effect size, uncertainty and possible harm, not just name a winner. Comparisons without randomisation carry an additional burden because their causal interpretation depends on stronger assumptions.

Frequently asked questions

Should we randomize users or sessions?

It depends on the product; examine cross-exposure and dependence.

Does a small p-value mandate rollout?

No. Consider absolute effect, cost, guardrails and uncertainty.

Can we estimate causal effects without an A/B test?

Some observational designs are possible but require stronger assumptions and sensitivity analysis.

References and further reading

  1. Microsoft — Experimentation Platform research
  2. Causal Inference: The Mixtape
  3. statsmodels — Statistical models