Section 11.11

Causal inference

Definition

Causal inference is the reasoning that turns data into a claim about the effect of an intervention: how an outcome would change if a condition were set one way rather than another, for the same units (the things studied, such as devices). It defines the effect through counterfactual outcomes, those the units would have shown under the condition they did not receive, and states the design and assumptions under which the observed data determine that effect. Without such an argument, a difference in data is only an association.

The idea

A request handled by a new software version took 12 milliseconds (ms). The causal question is how long the same request would have taken under the old version. That second number is a counterfactual: it would have been observed only if the request had been handled differently, and it never was. Running the request again under the old version gives a related number, not the same one, because the moment, the temperature and the radio noise have changed. This is called the fundamental problem of causal inference: for each unit, at most one of the outcomes being compared is ever observed.

Causal inference supplies the missing outcome with a stand-in and argues that the stand-in is fair. Three stand-ins are common.

How it works

  1. Define the question: the units, the population of units the answer is about, the two conditions as exact versions (which build, which settings), and the outcome with its unit of measurement.

  2. Define the causal estimand §11.2, the quantity the study aims to estimate. The most common is the average treatment effect (ATE): the average, over the population of units, of each unit’s outcome under the treatment (the changed condition) minus its outcome under the baseline (the reference condition).

  3. Choose a design that supplies the stand-ins: a randomized experiment; a paired design §11.7, in which each unit receives both conditions in random order; a blocked design; or an observational comparison of units that happened to receive different conditions, with adjustment.

  4. State the assumptions that connect the observed data to the estimand (listed under Stated precisely) and argue for each one.

  5. Estimate the effect, with an uncertainty computed from the variation between the units that were assigned.

  6. Ask what would break the conclusion. A sensitivity analysis §11.46 states how strong an unmeasured influence would have to be to change the answer.

The reasoning can be written in two notations. Potential outcomes, used in the rest of this entry, list each unit’s outcome under each condition. A causal diagram is a directed acyclic graph §14.17 in which an arrow from one factor to another means that the first directly affects the second. The diagram shows which factors must be held fixed or adjusted for: those that open a second route between condition and outcome through a common cause (see the confounding §11.10 entry).

Worked example

Take a hypothetical population of two units whose outcomes under both conditions are known, which never happens in practice.

Unit Baseline (ms) Treatment (ms) Effect (ms)
A 10 12 2
B 20 26 6

The individual effects are 12−10=212 - 10 = 2 ms and 26−20=626 - 20 = 6 ms. The average treatment effect is (2+6)/2=4(2 + 6)/2 = 4 ms.

One unit per condition, chosen by a fair coin. Treating A and leaving B at baseline shows 12 ms and 20 ms, a difference of 12−20=−812 - 20 = -8 ms. Treating B shows 26 ms and 10 ms, a difference of 26−10=1626 - 10 = 16 ms. Each assignment has probability one half, so the expected estimate is (−8+16)/2=8/2=4(-8 + 16)/2 = 8/2 = 4 ms, the true average. The design is unbiased, yet every single run of it is off by 12 ms.

A deliberate choice. An engineer who applies the new version to the unit that looks slow, B, always observes the difference 26−10=1626 - 10 = 16 ms, four times the true average. Unit B was slower to begin with, by 20−10=1020 - 10 = 10 ms. That baseline gap is the confounding bias: 16=6+1016 = 6 + 10, the effect on B plus the gap.

Each unit under both conditions. Measuring each unit under both conditions gives 12−10=212 - 10 = 2 ms for A and 26−20=626 - 20 = 6 ms for B, an average of 4 ms, exactly, every time. This within-unit stand-in is the best available when its two assumptions hold: the unit does not change between the two measurements, and the first measurement does not affect the second.

Stated precisely

Number the units i=1,…,ni = 1, \dots, n. Let Yi(1)Y_i(1) and Yi(0)Y_i(0) be the potential outcomes of unit ii: the outcomes it would show under the treatment and under the baseline. Let ZiZ_i be 1 if unit ii received the treatment and 0 otherwise. The unit’s effect is τi=Yi(1)−Yi(0)\tau_i = Y_i(1) - Y_i(0), with τ\tau the Greek letter tau, and the average treatment effect over the nn units is ATE=1n∑i=1nτi,\mathrm{ATE} = \frac{1}{n} \sum_{i=1}^{n} \tau_i, where ∑i=1n\sum_{i=1}^{n} means the sum over all nn units. Only one of Yi(1)Y_i(1) and Yi(0)Y_i(0) is ever observed. The connection to data rests on named assumptions:

Under consistency, no interference and complete randomization (a fixed number n1n_1 of treated units, 0<n1<n0 < n_1 < n, with every choice of those units equally likely), the mean observed outcome of the treated units minus that of the baseline units has an expected value, over the random assignment, equal to the ATE. Under consistency, no interference, exchangeability within levels of WW and positivity, the average of Y(1)−Y(0)Y(1) - Y(0) over a population equals ∑wP(W=w)(E[Y∣Z=1,W=w]−E[Y∣Z=0,W=w]),\sum_{w} P(W = w) \, (E[Y \mid Z = 1, W = w] - E[Y \mid Z = 0, W = w]), where P(W=w)P(W = w) is the share of the population with W=wW = w, and E[Y∣Z=z,W=w]E[Y \mid Z = z, W = w] is the mean observed outcome of the units with condition zz and level ww. This adjustment formula compares the conditions inside each level of WW and weights each level by its share.

Limits and common mistakes

Random assignment between units identifies average effects, not the effect on any single unit. In the example, the randomized comparison recovers 4 ms on average but never shows that unit A’s effect is 2 ms.

The within-unit stand-in depends on stability and on the absence of carryover, the influence of the first measurement on the second. Neither can be fully checked from the two measurements; randomizing the order and repeating the pair is the usual protection.

Correlation §15.44, time order and a plausible mechanism do not establish a cause.

An effect identified for the units, inputs and conditions studied need not hold for others; that question is external validity §11.44.

Outcomes that go missing for reasons tied to the condition or to the outcome, such as runs that crashed under the new version and were dropped, break the argument unless a rule stated in advance handles them.

Knowing that a change causes an effect does not say how. A claim about the mechanism needs its own evidence, such as measurements of the intermediate steps.

Questions answered

What comparison approximates the counterfactual for the same unit?

The closest approximation is the same unit measured under the other condition at a nearby time, with the order of the two conditions chosen at random and nothing carried over from the first measurement to the second. The counterfactual is the outcome the unit would have shown under the condition it did not receive. This within-unit comparison, a paired design, estimates the unit’s own effect if the unit stays stable between the two measurements. When a unit can receive only one condition, for example because the first measurement changes it permanently, random assignment across comparable units is the next stand-in. It does not recover any one unit’s counterfactual, but it recovers the average effect over the units, because chance cannot favor either condition. A comparison of units that happened to receive different conditions needs the explicit assumption that no unmeasured factor affects both the condition and the outcome. An uncontrolled before-and-after comparison is not a fair stand-in, because everything else that changed in between is mixed into the difference.

Related entries: Paired design (§11.7), Randomization (§11.8), Confounding (§11.10), External validity (§11.44), Estimand and estimator (§11.2).