Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Causal inference

Introduction

The tools introduced in the Bayesian Modelling chapter give us a powerful framework for reasoning under uncertainty: given observations, we can update our beliefs about latent variables and model parameters, make predictions, and take decisions that minimize expected loss. Yet there is a class of questions that standard probabilistic inference cannot answer, no matter how much data we collect.

Consider a dealer quoting a bond instrument. The dealer observes that, historically, tighter spreads correlate with higher hit rates. Should she tighten her spread? The correlation is real, but it does not tell us what will happen if she intervenes and changes her spread — because the historical spread was itself set by a policy that depended on bond characteristics, client type, and market conditions. The clients who received tight spreads were not a random sample: they may have been clients with better credit ratings, larger notional requests, or bonds in high demand. A purely statistical model trained on this data will confound the effect of the spread with the effect of all these background variables.

This is the domain of causal inference: the study of what happens when we do something, rather than merely observe it. The distinction is fundamental. A probabilistic model can answer observational questions of the form “given that I see spread δ\delta, what is the probability of a hit?” but not interventional questions of the form “if I set spread δ\delta, what would the probability of a hit be?” The difference between these two quantities is the confounding effect of the variables that determined the historical spread.

Causal inference, formalized by Judea Pearl Pearl et al., 2016, provides a principled framework to answer interventional and counterfactual questions using a combination of graphical models and a symbolic calculus. The framework rests on three key components: (1) a causal graph (a directed acyclic graph, or DAG) that encodes qualitative assumptions about which variables causally influence which others; (2) the do-operator, which formally distinguishes interventions from observations; and (3) identification theorems (notably the back-door criterion) that tell us when, and how, interventional quantities can be estimated from observational data.

This chapter introduces these ideas in a self-contained way. Readers familiar with Bayesian Networks from the Bayesian Modelling chapter will recognize the graphical language; the new content is the causal semantics layered on top. The chapter is organized as follows. We begin with Pearl’s ladder of causation, which hierarchically orders the types of questions that probabilistic and causal models can answer. We then develop the formalism of structural causal models and the do-operator, including the back-door criterion and the adjustment formula. We close with counterfactual reasoning, which occupies the highest rung of the ladder and enables reasoning about hypothetical scenarios.

The ideas developed here are applied directly in the Modelling RfQs in Dealer to Client Markets chapter, where the RfQ pricing problem is formulated as a causal intervention and the back-door criterion is used to identify a valid conditioning set for the hit probability model.

The three ladders of causation

Pearl’s central organizing principle is the ladder of causation Pearl et al., 2016, a three-rung hierarchy that classifies queries by the type of information they require:

RungActivityQuery formExample
1Seeing (Association)P(YX=x)P(Y \mid X = x)What is the hit rate when spread is δ\delta?
2Doing (Intervention)P(Ydo(X=x))P(Y \mid \text{do}(X = x))What hit rate would result if we set spread to δ\delta?
3Imagining (Counterfactual)P(YxX=x)P(Y_x \mid X = x')Would this RfQ have been a hit if we had quoted δ\delta instead of δ\delta'?

Rung 1 — Association. Standard probability and statistics live on this rung. Given a dataset, we can estimate conditional probabilities P(YX=x)P(Y \mid X = x) by grouping observations and fitting a model. The key limitation is that this quantity reflects the distribution of the population that happened to have X=xX = x, not the distribution that would result from forcing XX to equal xx. In the bond market, the population of RfQs where the dealer quoted a tight spread is not representative of all RfQs: it was selected by the dealer’s pricing policy, which in turn depended on bond and client characteristics.

Rung 2 — Intervention. The second rung asks what would happen if we surgically set X=xX = x for every unit in the population, overriding whatever value XX would naturally have taken. This is written P(Ydo(X=x))P(Y \mid \text{do}(X = x)). In a randomized controlled experiment, we directly observe this quantity by randomly assigning XX regardless of background variables. Without randomization, answering second-rung queries requires a causal model — a representation of the data-generating mechanism that lets us reason about hypothetical interventions.

Rung 3 — Counterfactuals. The third rung goes further: it asks what would have happened to a specific individual unit had a different value been assigned to XX, given that we know what actually happened to that unit. This is written P(YxX=x)P(Y_x \mid X = x'), the probability that YY would take a given value if XX had been xx, for a unit that actually had X=xX = x'. Counterfactuals are fundamental to attribution and responsibility: “would this client have hit if we had quoted 5 bps tighter?” They require the full machinery of structural causal models.

A crucial insight is that Rung 2 queries cannot in general be answered from Rung 1 data without additional assumptions, and Rung 3 queries cannot in general be answered from Rung 1 or 2 data alone. The ladder is strict: each rung requires strictly more information than the one below it.

Interventions and the Do-calculus

Structural Causal Models and DAGs

The formal language of causal inference is the Structural Causal Model (SCM). An SCM consists of:

  1. A set of endogenous (modelled) variables V={V1,,Vn}V = \{V_1, \ldots, V_n\}.

  2. A set of exogenous (background) variables U={U1,,Un}U = \{U_1, \ldots, U_n\}, assumed mutually independent.

  3. A set of structural equations Vi=fi(Pa(Vi),Ui)V_i = f_i(\text{Pa}(V_i), U_i) for each ii, where Pa(Vi)\text{Pa}(V_i) are the parents of ViV_i: the variables that directly causally determine ViV_i.

Each SCM induces a directed acyclic graph (DAG) G\mathcal{G}, where each variable ViV_i is a node and a directed edge VjViV_j \to V_i exists whenever VjPa(Vi)V_j \in \text{Pa}(V_i). The acyclicity condition rules out causal loops; the graph encodes the qualitative causal structure of the model.

The probabilistic Bayesian Network framework introduced in Bayesian Modelling uses the same DAG language and the same conditional independence reading via d-separation. The critical addition in the SCM framework is causal semantics: arrows represent mechanisms, not mere conditional dependences. This distinction only becomes visible when we intervene.

Example. Consider three variables: bond volatility σ\sigma, the dealer’s spread δ\delta, and the RfQ outcome (hit/miss) HH. In the observational distribution, σ\sigma and δ\delta are correlated because the dealer uses σ\sigma to set δ\delta: high-volatility bonds attract wider spreads. If we simply condition on δ\delta in a regression of HH on δ\delta, we confound the true effect of δ\delta on HH with the selection effect induced by σ\sigma. The DAG σδ\sigma \to \delta, σH\sigma \to H, δH\delta \to H makes this confounding explicit: σ\sigma is a common cause of both δ\delta and HH, opening a spurious back-door path δσH\delta \leftarrow \sigma \to H.

The Do-Operator

An intervention do(X=x)\text{do}(X = x) on an SCM is implemented by replacing the structural equation for XX with a constant: XxX \leftarrow x, removing all arrows into XX in the DAG. All other structural equations remain unchanged. The resulting modified SCM defines the interventional distribution P(Vdo(X=x))P(V \mid \text{do}(X = x)).

This mutilation of the graph is the formal counterpart of a randomized experiment: by setting XX externally, we sever the causal link from XX’s natural parents to XX, eliminating confounding through those parents. The do-operator thus replaces an observational quantity with a causal one.

In the bond RfQ example, P(Hdo(δ))P(H \mid \text{do}(\delta)) is the probability of a hit if the dealer were to set spread δ\delta by a policy that ignores σ\sigma, client features, and all other variables that would normally influence δ\delta. This is the interventional quantity of interest for optimal pricing.

Identifying Causal Effects: the Back-Door Criterion

The central identification problem is: when can we compute P(Ydo(X))P(Y \mid \text{do}(X)) from purely observational data, and how? The adjustment formula gives the answer when a valid conditioning set ZZ can be found:

P(Ydo(X=x))=zP(YX=x,Z=z)P(Z=z)P(Y \mid \text{do}(X = x)) = \sum_z P(Y \mid X = x, Z = z) \, P(Z = z)

where the sum (or integral) is over all values of the conditioning set ZZ. The left-hand side is a causal quantity; the right-hand side involves only standard conditional probabilities, which can be estimated from data. The key is finding a ZZ that makes this identity valid.

Definition (Back-door criterion). A set of variables ZZ satisfies the back-door criterion relative to an ordered pair (X,Y)(X, Y) in DAG G\mathcal{G} if:

  1. No variable in ZZ is a descendant of XX.

  2. ZZ blocks every path between XX and YY that contains an arrow into XX (a back-door path).

A back-door path is any path from XX to YY that begins with an arrow pointing into XX: such paths represent confounding by common causes of XX and YY. Condition 2 requires all such paths to be blocked by ZZ, where “blocked” is defined by the d-separation rules from Bayesian Modelling: a path is blocked by ZZ if it contains a chain AMBA \to M \to B or a fork AMBA \leftarrow M \to B with MZM \in Z, or a collider ACBA \to C \leftarrow B with CZC \notin Z (and no descendant of CC in ZZ).

When ZZ satisfies the back-door criterion, the adjustment formula holds and we can estimate the causal effect from observational data by:

  1. Conditioning on ZZ when fitting the outcome model P(YX,Z)P(Y \mid X, Z).

  2. Marginalizing over the distribution of ZZ in the population.

In practice, we prefer the smallest valid ZZ to minimize variance. Among valid sets, the analyst should prefer variables that are more easily measured and least collinear with XX.

Example (RfQ pricing, continued). In the causal DAG for the RfQ process (see Modelling RfQs in Dealer to Client Markets), the back-door paths from dealer spread δ\delta to hit probability HH run through bond features BFBF, client features CFCF, RfQ features RFRF, and volatility σ\sigma — all of which influence both δ\delta (through the dealer’s pricing policy) and HH (through client reservation price and competitor spreads). The minimal valid conditioning set is Ztmin={σ,RF,BF,CF}\mathcal{Z}_t^{\min} = \{\sigma, RF, BF, CF\}, giving:

P(Hdo(δ),RfQ)=P(Hδ,RfQ,σ,RF,BF,CF)P(H \mid \text{do}(\delta), \text{RfQ}) = P(H \mid \delta, \text{RfQ}, \sigma, RF, BF, CF)

The do-operator on the left is replaced by a standard conditional probability on the right, which can be estimated by any supervised learning method trained on the correct feature set.

Do-Calculus

Pearl’s do-calculus is a complete set of three symbolic inference rules for transforming expressions involving the do-operator into estimable observational quantities. Each rule applies under specific d-separation conditions in modified versions of the graph G\mathcal{G}:

Rule 1 (Insertion/deletion of observations):

P(ydo(x),z,w)=P(ydo(x),w)if (Y ⁣ ⁣ ⁣ZX,W)GXP(y \mid \text{do}(x), z, w) = P(y \mid \text{do}(x), w) \quad \text{if } (Y \perp\!\!\!\perp Z \mid X, W)_{\mathcal{G}_{\overline{X}}}

Rule 2 (Action/observation exchange):

P(ydo(x),do(z),w)=P(ydo(x),z,w)if (Y ⁣ ⁣ ⁣ZX,W)GXZP(y \mid \text{do}(x), \text{do}(z), w) = P(y \mid \text{do}(x), z, w) \quad \text{if } (Y \perp\!\!\!\perp Z \mid X, W)_{\mathcal{G}_{\overline{X}\,\underline{Z}}}

Rule 3 (Insertion/deletion of actions):

P(ydo(x),do(z),w)=P(ydo(x),w)if (Y ⁣ ⁣ ⁣ZX,W)GXZ(W)P(y \mid \text{do}(x), \text{do}(z), w) = P(y \mid \text{do}(x), w) \quad \text{if } (Y \perp\!\!\!\perp Z \mid X, W)_{\mathcal{G}_{\overline{X}\,\overline{Z(W)}}}

where Z(W)Z(W) denotes the set of ZZ-nodes that are not ancestors of any WW-node in GX\mathcal{G}_{\overline{X}}. These rules are complete: any causal quantity that is expressible in observational data can be derived by a finite sequence of these rules applied to the observational distribution. The back-door adjustment formula is a direct consequence of Rule 2.

Counterfactuals

Counterfactuals occupy the top rung of the ladder of causation. A counterfactual statement has the form: “Given that unit uu was observed to have X=xX = x' and Y=yY = y', what would YY have been if XX had been xx instead?” This is written Yx(u)Y_x(u) for a specific unit uu, or P(Yx=yX=x,Y=y)P(Y_x = y \mid X = x', Y = y') in the population version.

To evaluate counterfactuals, the SCM framework uses a three-step abduction-action-prediction procedure:

  1. Abduction: Use the observed evidence on unit uu to infer the exogenous variables UU that are consistent with what was observed. This updates the prior P(U)P(U) to the posterior P(Uevidence)P(U \mid \text{evidence}).

  2. Action: Modify the structural equations by performing the hypothetical intervention: replace the equation for XX with XxX \leftarrow x.

  3. Prediction: Use the modified SCM with the updated exogenous variables to compute the counterfactual outcome Yx(u)Y_x(u).

Counterfactuals are logically stronger than interventional quantities because they condition on individual-level data. An interventional query P(Ydo(X=x))P(Y \mid \text{do}(X=x)) asks “what would happen to a randomly drawn unit if we set X=xX=x?”, whereas a counterfactual P(YxX=x,Y=y)P(Y_x \mid X=x', Y=y') asks “what would have happened to this specific unit?” — one for which we already know both the treatment xx' and the outcome yy'. The posterior over UU obtained in the abduction step is what allows this individual-level reasoning.

Example. A dealer quotes δ=10\delta' = 10 bps on an RfQ and misses. The counterfactual question is: “Would the client have hit if the dealer had quoted δ=7\delta = 7 bps?” The abduction step infers the client’s reservation spread δres\delta_{\text{res}} from the observed miss: since the client did not hit at δ=10\delta' = 10, either δres<10\delta_{\text{res}} < 10 bps or a competitor quoted more aggressively. This posterior on δres\delta_{\text{res}} is sharper than the unconditional prior. The action step sets δ=7\delta = 7 in the structural equation for RSRS. The prediction step computes the probability that δ=7δres\delta = 7 \leq \delta_{\text{res}} and δδdealer\delta \leq \delta_{\text{dealer}} given the updated posterior on δres\delta_{\text{res}}.

This type of reasoning is central to post-trade attribution and revenue potential analysis in RfQ markets. In practice, counterfactuals are often approximated by simpler interventional quantities; the full counterfactual calculation requires a fully specified SCM including the exogenous noise structure.

Exercises

  1. d-separation. Consider the DAG with nodes {A,B,C,D,E}\{A, B, C, D, E\} and edges ABA \to B, ACA \to C, BDB \to D, CDC \to D, DED \to E. (a) Is AA d-separated from EE given {D}\{D\}? (b) Is BB d-separated from CC given {A}\{A\}? (c) Is BB d-separated from CC given \emptyset? Justify each answer by identifying whether every path between the two nodes is blocked.

  2. Back-door criterion. In a causal DAG representing the RfQ hit probability, the main variables are: spread quoted by dealer δ\delta, hit indicator HH, market volatility σ\sigma, reference price flag RFRF, and a confounder CFCF that affects both dealer pricing and client behaviour. The edges are σδ\sigma \to \delta, σH\sigma \to H, δH\delta \to H, RFHRF \to H, CFδCF \to \delta, CFHCF \to H. (a) Identify all back-door paths from δ\delta to HH (paths that enter δ\delta through a non-descendant). (b) Show that the adjustment set {σ,RF,CF}\{\sigma, RF, CF\} satisfies the back-door criterion. (c) Write the back-door adjustment formula for P(Hdo(δ))P(H \mid \text{do}(\delta)).

  3. Interventional distribution via Rule 2. In a simple chain DAG ZXYZ \to X \to Y with an additional direct edge ZYZ \to Y, and suppose there are no hidden confounders. (a) Write the observational factorisation P(X,Y,Z)P(X, Y, Z). (b) Using Rule 2 of the do-calculus (action/observation exchange), show that P(Ydo(X=x))=zP(YX=x,Z=z)P(Z=z)P(Y \mid \text{do}(X=x)) = \sum_z P(Y \mid X=x, Z=z) P(Z=z). (c) Verify that this is precisely the back-door adjustment with adjustment set {Z}\{Z\}.

  4. Counterfactual reasoning. A dealer quotes δ=8\delta' = 8 bps and the client misses (H=0H = 0). The SCM for the hit event is H=1[δδres]H = \mathbf{1}[\delta \leq \delta_{\text{res}}], where the client’s reservation spread is drawn as δres=U20\delta_{\text{res}} = U \cdot 20 with UUniform[0,1]U \sim \text{Uniform}[0, 1] (the exogenous noise). (a) Compute P(H=0δ=8)P(H = 0 \mid \delta' = 8). (b) Apply the abduction step: compute the posterior P(UH=0,δ=8)P(U \mid H=0, \delta'=8). (c) Apply action and prediction: compute the counterfactual probability P(Hδ=5=1H=0,δ=8)P(H_{\delta=5} = 1 \mid H=0, \delta'=8). (d) Compare this to the interventional quantity P(H=1do(δ=5))P(H=1 \mid \text{do}(\delta=5)) and explain the difference.

References
  1. Pearl, J., Glymour, M., & Jewell, N. P. (2016). Causal Inference in Statistics: A Primer. Wiley.