arXiv:2611.25877stat.MENov 2026

Manuscript Offprint

arXiv:2611.25877

On the trajectories of the ID algorithm

Ivano Lodato, Simran Hiranandani, Aditya Varna Iyer

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

The ID algorithm decides whether an interventional distribution can be computed from observational data and, when it can, returns a formula in which products, ratios and summations of conditional probabilities are nested inside one another. We study these formulas by following the trajectories of the calls of the algorithm, each of which ends with a tail (an alternation of lines 7 and 2) and an exit, and we derive two main results. First, line 4 and the exit lines fix the single outer summation of the output, while the tail forms everything inside it, both the inner summations and the ratios. Second, a ratio keeps a summation in its denominator only when a repetition of the tail is entangled, and a test of ancestry in the original graph decides, before any formula is computed, whether a topological order can be chosen so as to avoid it. We also derive a bound on the nesting depth of the output, and show a simple “dimensional” count that every output has to satisfy. Together, these results constrain the form of an ID output and guide its implementation and simplification.

1 Introduction

The effect of an action, a decision or a policy is most reliably measured by an experiment, but experiments are often costly, unethical or infeasible, and one is then led to ask whether the same effect can be inferred from data that have merely been observed. The question acquires a precise form when the causal assumptions are encoded in a diagram GG, whose directed edges represent direct causal influence and whose bidirected edges represent latent common causes. The quantity of interest is the effect of an intervention, that is, the distribution P(Y∣X^)P(\mathbf{Y}\mid\hat{\mathbf{X}}) that a set of outcomes Y\mathbf{Y} would have if the variables X\mathbf{X} were set by an external action rather than observed, and this effect is identifiable if it can be computed from the observational distribution P(V)P(\mathbf{V}) and GG alone (Pearl, 1995). The do-calculus (Pearl, 1995) is complete for this task (Shpitser and Pearl, 2006a; Huang and Valtorta, 2006), but it does not prescribe the order in which its rules should be applied, and the decisive step towards an algorithm was the observation of Tian and Pearl (2002); Tian and Pearl (2003) that P(V)P(\mathbf{V}) factorises over the c-components of GG, the maximal sets of vertices connected by bidirected paths. The ID algorithm of Shpitser and Pearl (2006a); Shpitser and Pearl (2008) turns this factorisation into a recursive procedure of seven lines, which decides identifiability in polynomial time (Section 2) and, when the effect is identifiable, returns a formula for it. The correctness of this procedure is well established, whereas much less is known about the formula that it returns, whose structure has so far been examined only in order to simplify it, and this formula is the subject of the present paper.

The formula that ID returns is built from (possibly nested) products, ratios and summations of conditional distributions P(V∣C)P(V\mid C), which we call terms. A familiar instance is the front-door graph

X$$Z$$Y

for which ID returns

P(Y∣X^)=∑Z(P(Z∣X) ∑XP(X) P(Y∣X,Z)),P(Y\mid\hat{X})=\sum_{Z}\Bigl(P(Z\mid X)\ \sum_{X}P(X)\,P(Y\mid X,Z)\Bigr),

a formula whose two summations have different origins. The outer one, over ZZ, is written by line 4 of the algorithm and marginalises the variables that are neither intervened on nor queried. The inner one, over XX, arises at a later stage of the execution, where line 7, having isolated the c-component {X,Y}\{X,Y\} of YY, rebuilds a distribution on it, and the line 2 that follows marginalises XX, which is not an ancestor of YY within that component. We call such an alternation of lines 7 and 2 a tail, and each pair of lines a repetition of it. In larger graphs the tail has several repetitions, each of which, after the first, takes conditionals of a distribution that already carries a summation, and this is how ratios of sums come to appear inside further sums. Here and throughout, every variable is written with a capital letter. The letter XX thus occurs in (1) in two roles, as the intervened variable in P(Z∣X)P(Z\mid X), where it stands for the value set by the intervention, and as a summation variable inside the brackets.

Any implementation of the ID algorithm, such as the R package causaleffect (Tikka and Karvanen, 2017b) or the Python library of the same name (Pedemonte et al., 2021), has to store such formulas and, as far as possible, to simplify them. The ID algorithm writes a summation wherever a marginalisation is called for and a ratio wherever a conditional of a summed distribution is called for, whether or not the summation can be carried out or the ratio cancelled. Storing such formulas requires a class of expressions, and the available choices differ. For instance, Tikka and Karvanen (2017a) nest products and summations of terms into expressions and treat a quotient of two expressions separately, as a last operation, whereas Pedemonte et al. (2021) use a recursive probability object, which may be summed over a set of variables and may carry a divisor of the same kind. Simplifying those expressions means carrying out summations (Tikka and Karvanen, 2017a; Lodato et al., 2026), cancelling factors within a single ratio, or cancelling factors between different ratios. These simplifications are applied to the finished formula or, at best, step by step while it is assembled, and in either case without regard to the way in which the algorithm produces it.

Here we study the formula at its source, by following the trajectories of the algorithm, that is, the sequences of lines through which it arrives at the formula, and we determine where the summations and the ratios of an output are created, which terms they involve and how deeply they can be nested. The trajectories, and the sets of vertices on which each of their lines acts, are obtained from the graph and the query by graph operations alone, so that this information is available before any formula is written; it constrains the expressions that an implementation has to represent and indicates where each kind of simplification can act. Section 2 determines the trajectories that are possible and where the summations of the output are created. Section 3 studies the ratios, which arise when the rebuild-and-marginalise step of the tail is repeated, and decides on the graph when they can be avoided. Section 4 shows what simplification can do with the ratios that remain, and Section 5 bounds the nesting depth of the output. All the proofs are collected in Appendix A.