Simplifying Probabilistic Expressions in Causal Inference
Full text
This is an electronic reprint of the original article. This reprint may differ from the original in pagination and typographic detail. Author(s): Title: Year: Version: Please cite the original version: All material supplied via JYX is protected by copyright and other intellectual property rights, and duplication or sale of all or part of any of the repository collections is not permitted, except that material may be duplicated by you for your research use or educational purposes in electronic or print form. You must obtain permission for any other use. Electronic or print copies may not be offered, whether for sale or otherwise to anyone who is not an authorised user. Simplifying Probabilistic Expressions in Causal Inference Tikka, Santtu; Karvanen, Juha Tikka, S., & Karvanen, J. (2017). Simplifying Probabilistic Expressions in Causal Inference. Journal of Machine Learning Research, 18, 1-30. http://jmlr.csail.mit.edu/papers/volume18/16-166/16-166.pdf 2017
Journal of Machine Learning Research 18 (2017) 1-30 Submitted 4/16; Revised 3/17; Published 4/17 Simplifying Probabilistic Expressions in Causal Inference Santtu Tikka [email protected] Juha Karvanen juha.t.karv[email protected] Department of Mathematics and Statistics P.O.Box 35 (MaD) FI-40014 University of Jyvaskyla, Finland Editor: Peter Spirtes Abstract Obtaining a non-parametric expression for an interventional distribution is one of the most fundamental tasks in causal inference. Such an expression can be obtained for an identifiable causal effect by an algorithm or by manual application of do-calculus. Often we are left with a complicated expression which can lead to biased or inefficient estimates when missing data or measurement errors are involved. We present an automatic simplification algorithm that seeks to eliminate symbolically unnecessary variables from these expressions by taking advantage of the structure of the underlying graphical model. Our method is applicable to all causal effect formulas and is readily available in the R package causaleffect. Keywords: simplification, probabilistic expression, causal inference, graphical model, graph theory 1. Introduction Symbolic derivations resulting in complicated expressions are often encountered in many fields working with mathematical notation. These expressions can be derived manually or they can be outputs from a computer algorithm. In both cases, the expressions may be correct but unnecessarily complex in a sense that some unrecognized identities or properties would lead to simpler expressions. We will consider simplification in the context of causal inference in graphical models (Pearl, 2009). Advances in causal inference have led to algorithmic solutions to problems such as identifiability of causal effects and conditional causal effects (Huang and Valtorta, 2006; Shpitser and Pearl, 2006a,b), z -identifiability (Bareinboim and Pearl, 2012), transportability and meta-transportability (Bareinboim and Pearl, 2013b,a) among others. The aforementioned algorithmic solutions operate symbolically on the joint distribution of the variables of interest and return expressions for the desired queries. These algorithms have been previously implemented in the R package causaleffect (Tikka and Karvanen, 2017). Another implementation of an identifiability algorithm can be found in the CIBN software by Jin Tian and Lexin Liu freely available from http://web.cs.iastate.edu/~jtian/Software/CIBN.htm . However, the algorithms themselves are imperfect in a sense that they often output an expression that is complicated and far from ideal. The question is whether there exists a simpler expression that is still a solution to the original problem. c 2017 Santtu Tikka and Juha Karvanen. License: CC-BY 4.0, see https://creativecommons.org/licenses/by/4.0/. Attribution requirements are provided at http://jmlr.org/papers/v18/16-166.html.
Tikka and Karvanen Simplification of expressions may provide significant benefits. First, a simpler expression can be understood and reported more easily. Second, evaluating a simpler expression will be less of a computational burden due to reduced dimensionality of the problem. Third, in situations where estimation of causal effects is of interest and missing data is a concern, eliminating variables with missing data from the expression has clear advantages. The same applies to variables with measurement error. We begin with presenting in Section 2 a general form of probabilistic expressions that are often encountered in causal inference. In this paper probabilistic expressions are formed by products of non-parametric conditional distributions of some variables and summations over the possible values of these variables. Simplification in this case is the process of eliminating terms from these expressions by carrying out summations. As our expressions correspond to causal effects, the expressions themselves take a specific form. Causal models are typically associated with a directed acyclic graph (DAG) which represents the functional relationships between the variables of interest. In situations where the joint distribution is faithful, meaning that no additional conditional independences are generated by the joint distribution (Spirtes et al., 2000), the conditional independence properties of the variables can be read from the graph itself through a concept known as d-separation (Geiger et al., 1990). We will use d-separation as our primary tool for operating on the probabilistic expressions. The reader is assumed to be familiar with a number of graph theoretic concepts that are explained for example in (Koller and Friedman, 2009) and used throughout the paper. Our simplification procedure is built on the definition of simplification sets, which is presented in Section 3. We continue by introducing a sound and complete simplification algorithm for probabilistic expressions defined in Section 2 for which these simplification sets exist. The algorithm takes as an input the expression to be simplified and the graph induced by the underlying causal model, and proceeds to construct a joint distribution of the variables contained in the expression by using the d-separation criteria. Higher level algorithms that use this simplification procedure are presented in Section 4. These include an algorithm for the simplification of a nested expression and an algorithm for the simplification of a quotient of two expressions. Section 5 contains examples on the application of these algorithms. We have also updated the causaleffect R-package to automatically apply these simplification procedures to causal effect expressions. As a motivating example we present an expression of a causal effect given by the ID algorithm of Shpitser and Pearl (2006a) that can be simplified. The complete derivation of this effect can be found in Appendix C. The causal effect of X on Z1, Z2, Z3 and Y is identifiable in the graph of Figure 1 and application of the ID algorithm gives P(Z1|Z2, X)P(Z3|Z2)PXP(Y|Z2, X, Z3, Z1)P(Z3|Z2, X)P(X|Z2)P(Z2) PX,Y P(Y|Z2, X, Z3, Z1)P(Z3|Z2, X)P(X|Z2)P(Z2)× X X,Z3,Y P(Y|Z2, X, Z3, Z1)P(Z3|Z2, X)P(X|Z2)P(Z2). It turns out that there exists a significantly simpler expression, P(Z1|Z2, X)P(Z2)X X P(Y|Z2, X, Z3, Z1)P(Z3|Z2, X)P(X|Z2),(1) 2
Simplifying Probabilistic Expressions Figure 1: A graph for the introductory example on simplification. for the same causal effect. This expression can be obtained without any knowledge of the underlying model by using standard probability manipulations. However, this requires that a favorable choice is made for the ordering of the nodes of the graph in the ID algorithm. In the case that we had chosen an ordering where Z1 precedes Z3 , the term for Z3 would instead be P ( Z3|Z2, Z1, X )and simplification would require knowledge about the underlying graph. We will take another look at this example later in Section 5 where we describe in detail how our procedure can be used to find expression (1). Our simplification procedure is different from the well-known exact inference method of minimizing the amount of numerical computations when evaluating expressions for conditional and marginal distributions by changing the order of summations and multiplications in the expression. Variants of this method are known by different names depending on the context, such as Bayesian variable elimination (Koller and Friedman, 2009) and the sum-product algorithm (Bishop, 2006) which is a generalization of belief propagation (Pearl, 1988; Lauritzen and Spiegelhalter, 1988). Efficient computational methods exist for causal effects as well, such as (Shpitser et al., 2011). The general principle is the same in all of the variants, and no symbolic simplification is performed. In our setting simplification can be defined explicitly but in general it is difficult to say what makes one expression simpler than another. Carette (2004) provides a formal definition for simplification in the context of Computer Algebra Systems (CAS) that operate on algebraic expressions. Modern CAS systems such as Mathematica (Wolfram Research Inc., 2015) and Maxima (Maxima, 2014) implement techniques for symbolic simplification. Bailey et al. (2014) and references therein discuss simplification techniques in CAS systems further. However to the best of our knowledge, the symbolic simplification procedures for probabilistic expressions described in this paper have neither been given previous attention nor implemented in any existing system. 2. Probabilistic Expressions Every expression that we consider is defined in terms of a set of variables W . As we are interested in probabilistic expressions, we also assume a joint probability distribution P for the variables of W . The most basic of expressions are called atomic expressions which will be the main focus of this paper. 3
Tikka and Karvanen Definition 1 (Atomic expression) Let W be a set of p discrete random variables and let Pbe any joint distribution of W. An atomic expression is a pair A=A[W] = hT,Si, where 1. T is a set of pairs {hV1,C1i,...,hVn,Cni} such that for each Vi and Ci it holds that Vi∈W,Ci⊆W,Vi6∈ Ciand Vi6=Vjfor i6=j. 2. S is a set {S1, . . . , Sm} ⊆ W such that for each i = 1 , . . . , m it holds that Si = Vj for some j∈ {1, . . . , n}. The value of an atomic expression Ais PA=X S n Y i=1 P(Vi|Ci). The probabilities P ( Vi|Ci )are referred to as the terms of the atomic expression. A term P ( Vi|Ci )is said to contain a variable V if Vi = V or V∈Ci . A term for a variable V refers to a term P ( V|· ). We also use the shorthand notation V [ A ] := {V1,...Vn} . As S is a set, we will only sum over a certain variable once. All variables are assumed to be univariate and discrete for clarity, but we may also consider multivariates and situations where some of the variables are continuous and the respective sums are interpreted as integrals instead. As an example we will construct an atomic expression describing the following formula X X P(Y|Z2, X, Z3, Z1)P(Z3|Z2, X)P(X|Z2)P(Z2), which is a part of the motivating example in the introduction. We let W = {X, Y, Z1, Z2, Z3} , which is the set of nodes of the graph of Figure 1. The sets T and S can now be defined as {hY, {Z2, X, Z3, Z1}i,hZ3,{Z2, X}i,hX, {Z2}i,hZ2,∅i} and {X}, respectively. Next we define a more general probabilistic expression. Definition 2 (Expression) Let W be a set of p variables and let P be the joint distribution of W. An expression is a triple B=B[W, n, m] = hB,A,Si, where 1. Sis a subset of W. 2. For m > 0,Ais a set of atomic expressions {hT1,S1i,...,hTm,Smi}. If m= 0 then A=∅. 4
Simplifying Probabilistic Expressions 3. For n > 0,Bis a set of expressions {B1[W1, n1, m1], . . . , Bn[Wn, nn, mn]} such that Wi⊆W,ni< n, mi< m for all i= 1, . . . , n. If n= 0 then B=∅. The value of an expression Bis PB=X S n Y i=1 PBi m Y j=1 PAj, where an empty product should be understood as being equal to 1. The recursive definition ensures the finiteness of the resulting expression by requiring that each sub-expression has fewer sub-expressions of their own than the expression above it. A single value might be shared by multiple expressions, as the terms of the product in the value of the expression are exchangeable. Expressions B1 [ W, n1, m1 ]and B2 [ W, n2, m2 ]are equivalent if their values PB1 and PB2 are equal for all P . Equivalence is defined similarly for atomic expressions. Every expression is formed by nested atomic expressions by definition. Because of this, we focus on the simplification of atomic expressions. As an example we construct an expression for the causal effect formula (1). We define W := {X, Y, Z1, Z2, Z3} and let the sets B and S be empty. We define the set A to consist of three atomic expressions A1, A2and A3defined as follows A1=h{hZ1,{Z2, X}i},∅i, A2=h{hZ2,∅}i},∅i, A2=h{hY, {Z2, X, Z3, Z1}i,hZ3,{Z2, X}i,hX, {Z2}i,hZ2,∅i},{X}i. In the context of probabilistic graphical models, we are provided additional information about the joint distribution of the variables of interest in the form of a DAG. As we are concerned on the simplification of the results of causal effect derivations in such models, the general form of the atomic expressions can be further narrowed down by using the structure of the graph and the ordering of vertices called a topological ordering. Definition 3 (Topological ordering) Topological ordering π of a DAG G = hW,Ei is an ordering of its vertices, such that if Xis an ancestor of Yin Gthen X < Y in π. The symbol Vπ j is used to denote the subset of vertices of G that are less than Vj in π . For sets we may define Vπ to contain those vertices of G that are less than every vertex of V in π . Consider a DAG G = hW,Ei and a topological ordering π of its vertices. We use the notation π ( · )to denote indexing over the vertex set W of G in the ordering given by π , that is Vπ(1) > Vπ(2) >· · · > Vπ(m) where m = |W| . For any atomic expression A [ V ] = hT,Si such that V⊆W we also define the induced ordering ω . This ordering is an ordering of the variables in V such that if X > Y in ω then X > Y also in π . From now on in this paper, any indexing over the variables of an atomic expression will refer to the induced ordering of the set Vwhen πis given, i.e V1> V2>· · · > Vnin ω. In other words, ωis obtained from πby leaving out variables that are not contained in A. 5
Tikka and Karvanen The ID algorithm performs the so-called C-component factorization. These components are subgraphs of the original graph where every node is connected by a path consisting entirely of bidirected edges. The resulting expressions of these factors serve as the basis for our simplification procedure. Definition 4 (Topological consistency) Let G0 be a DAG with a subgraph G = hW,Ei and let π be a topological ordering of the vertices of G . An atomic expression A [ W ] = hT,Si is topologically consistent (or π-consistent for short) if An(Vi)G⊆Ci⊆Vπ ifor all i= 1, . . . , n. Here An ( Vi ) G denotes the ancestors of Vi in G . To motivate this definition we note that the outputs of the algorithms of Shpitser and Pearl (2006a,b) can always be represented by using products and quotients of topologically consistent atomic expressions. An expression is topologically consistent when every atomic expression contained by it is topologically consistent with respect to a topological ordering of a subgraph. We provide a proof for this statement in Appendix A. This also shows that any manual derivation of a causal effect can always be represented by a topologically consistent expression. The assumption that An ( Vi ) G⊆Ci is not necessary for the simplification to be successful. This assumption is used to speed up the performance of our procedure in Section 3. 3. Simplification Simplification in our context is the procedure of eliminating variables from the set of variables that are to be summed over in expressions. In atomic expressions, a successful simplification in terms of a single variable should result in another expression that holds the same value, but with the respective term eliminated and the variable removed from the summation. As we are interested in causal effects, we consider only simplification of topologically consistent atomic expressions. Our approach to simplification is that the atomic expression has to represent a joint distribution of the variables present in the expression to make the procedure feasible. The question is whether the expression can be modified to represent a joint distribution. Before we can consider simplification, we have to define this property explicitly. Definition 5 (Simplification sets) Let G0 be a DAG and let G be a subgraph of G0 over a vertex set W with a topological ordering π . Let A [ W ] = hT,Si , where T = {hV1,C1,i,...,hVn,Cni} , be a π -consistent atomic expression and let Vj∈S . Suppose that Vπ(p)=Vjand that Vπ(q)=V1and let Mbe the set {U∈W|U6∈ V[A], Vπ(q)> U > Vπ(p)}. If there exists a set D⊂Vπ j and the sets EU⊆W for all U∈M such that the conditional distribution of the variables Vπ(p), . . . , Vπ(q)can be factorized as P(Vπ(p), . . . , Vπ(q)|D) = Y U∈M P(U|EU)Y Vi≥Vj P(Vi|Ci),(2) 6
Simplifying Probabilistic Expressions and (U⊥⊥ Vj|EU\ {Vj})G0for all U∈M.(3) then the sets Dand EU, U ∈Mare the simplification sets of Awith respect to Vj. This definition is tailored for the next result that can be used to determine the existence of a simpler expression when simplification sets exist. Afterwards we will show how this result can be applied in practice via an example. The definition characterizes π -consistent atomic expressions that represent joint distributions. It is apparent that simplifications sets are not always unique, which can lead to different but still simpler expressions. Henceforth the next result considers simplification in terms of a single variable. The proof is available in Appendix B. Theorem 6 (Simplification) Let G0 be a DAG and let G be a subgraph of G0 over a vertex set W with a topological ordering π . Let A [ W ] = hT,Si be a π -consistent atomic expression and let D and EU, U ∈M be its simplification sets with respect to a variable Vj∈S . Then there exist an expression A0 [ W\ {Vj} ] = hT0,S0i such that Vj6∈ S0 , PA = PA0 and no term in A0contains Vj. Note that even if M = ∅ in Definition 5, the existence of simplification sets still requires that QVi≥VjP ( Vi|Ci )= P ( Vj, . . . , V1|D ). In many cases there exists variables U∈M such that the expression does not contain a term for U . Condition (2) of Definition 5 guarantees that if these terms were contained in the expression it would represent a joint distribution. Our goal is thus to introduce these terms into the original expression temporarily, carry out the desired summation, and finally remove the added terms. This can only be achieved if the variables in the set M are conditionally independent of the variable currently being summed over, hence the assumption (U⊥⊥ Vj|EU\ {Vj})G0of condition (3) of Definition 5. We show how simplification sets can be used in practice to derive a simpler expression via an example. We consider the causal effect of {X, Z, W} on Y in the graph G of Figure 2. Figure 2: A graph Gfor the example on the use of simplification sets. The effect in question is identifiable and the ID algorithm readily gives atomic expression X X,W P(Y|X, W, Z)P(X|W)P(W). 7
Tikka and Karvanen We consider simplification sets with respect to Vj = W . The topological order is W < X < Z < Y . The atomic expression does not contain a term for Z so we have M = {Z} . By noting that ( Z⊥⊥ W|X ) G we are able to satisfy condition (3) of Definition 5. We can write P(Y, Z, X, W) = P(Z|X, W)P(Y|X, W, Z)P(X|W)P(W), as required by condition (2) of Definition 5 by setting EZ = {X, W} . Thus, the simplification sets D and EZ for the atomic expression with respect to W are ∅ and {X, W} , respectively. Finally, we obtain the simpler atomic expression by carrying out the summation over W: X X P(Y|X, Z)P(X). Neither Definition 5 nor Theorem 6 provide a method to obtain simplification sets or to determine whether they exist in general. To solve this problem we present a simplification algorithm for π -consistent atomic expressions that operates by constructing simplification sets iteratively for each variable in the summation set. Algorithm 1 always attempts to perform maximal simplification, meaning that as many variables of the set S are removed as possible. If the simplification in terms of the entire set S can not be completed, the intermediate result with as many variables simplified as possible is returned. If simplification in terms of specific variables or a subset is preferred, the set Sshould be defined accordingly. The function simplify takes three arguments: an atomic expression A [ W ]that is to be simplified, a graph G and a topological ordering π of its vertices. A is assumed to be π-consistent. On line 10 the function index.of returns the corresponding index i of the term containing Sj . Since A is π -consistent, we only have to iterate through the variables V1, . . . , Vj as the terms outside this range contain no relevant information about the simplification of Vj . The variables without a corresponding term in the atomic expression Aare retrieved on line 11 by the function get.missing . This function returns the set M of Definition 5 with respect to the current variable to be summed over. In order to show that the term of A represent some joint distribution, we proceed in the order dictated by the topological ordering of the vertices. The sets J and D keep track of the variables that have been successfully processed and of the conditioning set of the joint term that was constructed on the previous iteration. Similarly, the sets R and I keep track of the variables and conditioning sets of the corresponding variables that the atomic expression does not originally contain a term for. Iteration through relevant terms begins on line 13. Next, we take a closer look at the function join which is called next on line 14. Here P ( · )denotes the power set, 4 denotes the symmetric difference and An∗ ( · ) G denotes the ancestors with the argument included. The function join attempts to combine the joint term P ( J|D ), obtained from the previous iteration steps, with the term P ( V|C ) := P ( Vk|Ck ) of the current iteration step. d-separation statements of G are evaluated to determine whether this can be done. In practice this means finding a suitable subset Pi of G , where G∪An ( V ) G is the largest possible conditioning set of the new combined term. The set G is computed on line on line 4 of Algorithm 2. A valid subset Pi satisfies P ( J|D ) = P ( J|An∗ ( V ) G,Pi ) and P ( V|C ) = P ( V|An ( V ) G,Pi )which allow us to write the product P ( J|D ) P ( V|C )as P(J, V |An(V)G,Pi). 8
Simplifying Probabilistic Expressions The causal effect of Won Xis identifiable in this graph, and expression X Z,Y P(Y)P(Z|Y)P(X|W, Z, Y ) is obtained by direct application of the ID algorithm or by the truncated factorization formula for causal effects in Markovian models (Pearl, 2009). We let A be this atomic expression. The topological ordering π is X > W > Z > Y and M = {W} . The call to simplify(A, G, π)will first attempt simplification in terms of Z, by calling join(∅,∅, X, {W, Z, Y }, Z, {W}, G, π), which results in hX, {W, Z, Y },∅i. At the second call join({X},{W, Z, Y }, Z, Y, Z, {W}, G, π) we already run into trouble since we cannot find a conditioning set that would allow Z to be joined with {X} . However, since M is non-empty and W∈ {W, Z, Y } and W6∈ {Z} this means that the next call is insert({X},{W, Z, Y }, W, Z, G, π). Insertion fails in this case, as one can see from the fact that no conditioning set exists that would make Wconditionally independent of Z. Thus we recurse back to join and back to simplify and end up on line A1:15 which breaks out of the while-loop. Thus A cannot be simplified in terms of Z . Simplification is attempted next in terms of Y . The first two calls are in this case join(∅,∅, X, {W, Z, Y }, Y, {W}, G, π), join({X},{W, Z, Y }, Z, {Y}, Y, {W}, G, π), and in the second call we run into trouble again and have to attempt insertion insert({X},{W, Z, Y }, W, Y, G, π). This time we find that we can add a term for W which is P ( W|Z, Y )because ( W⊥⊥ Y|Z ) G . The other calls to join also succeed and we can write the value of Aas PZ,Y P(Y)P(Z|Y)P(W|Y, Z)P(X|W, Z, Y ) P(W|Z). and complete the summation in terms of Y . After the call to factorize we are left with the final expression X Z P(X|W, Z)P(Z). We continue by considering again graph G depicted in Figure 1. The topological ordering πis Y > Z1> Z3> X > Z2. Atomic expression A1given by X X,Y P(Y|Z2, X, Z3, Z1)P(Z3|Z2, X)P(X|Z2)P(Z2), 15
Tikka and Karvanen is a part of the expression to be simplified. We will first simplify A1 and take a closer look at how the function join operates. The call to simplify ( A1, G, π )will attempt simplification in terms of the set {X, Y } in the ordering that agrees with the topological ordering π , which is ( Y, X ). After initializing the required sets, we find the index of the term with Y as a variable on line 10. There is one missing variable, Z1 , so M = {Z1} as returned by get.missing on line A1:11. The first call to join results in hY, {Z2, X, Z3, Z1},∅i , because line A2:3 is triggered. Condition on line A1:15 is not satisfied since Jnew = {Y} 6⊆ ∅ = J . Thus we update the status of J and D on lines A1:18 and A1:19. Since Rnew = ∅ on line A1:20 we do not have to update the status of R,I and M on lines A1:21, A1:22 and A1:23. The innermost while-loop is now complete and we call factorize on line A1:27 which succeeds in removing the term P ( Y|Z2, X, Z3, Z1 ) by completing the sum. Now we update the status of the atomic expression on line A1:31 and remove Y from the set of variables to be summed over on line A1:32. The resulting value of the expression at this point is X X P(Z3|Z2, X)P(X|Z2)P(Z2). Next, the summation in terms of X is attempted. join is once again successful, because Z3 is the first variable to be joined and line A2:3 is triggered. Next we attempt to join the terms P(Z3|Z2, X)and P(X|Z2). Computation of the set Gon line A2:4 results in {Z3}π\An∗(X)G={X, Z2}\{X, Z2}=∅. The power set computed on line A2:5 contains only the empty set. For P1=∅we have A= (An(X)∗ G∪P1)4D= ({X, Z2}∪∅)4{X, Z2}=∅ on line 8, and B= (An(X)G∪P1)4C= ({Z2}∪∅)4{Z2}=∅ on line 9. The condition on line A2:10 evaluates to true and we return with h{Z3, X},{Z2},∅i . The innermost while-loop terminates allowing the summation over X to be performed. The function factorize provides us with the final expression P(Z3|Z2)P(Z2).(4) Next, we will consider the full example and see how q-simplify is applied. Using the ID algorithm we obtain the causal effect of X on Z1, Z2, Z3 and Y in graph G of Figure 1 and it is P(Z1|Z2, X)P(Z3|Z2)PXP(Y|Z2, X, Z3, Z1)P(Z3|Z2, X)P(X|Z2)P(Z2) PX,Y P(Y|Z2, X, Z3, Z1)P(Z3|Z2, X)P(X|Z2)P(Z2)× X X,Z3,Y P(Y|Z2, X, Z3, Z1)P(Z3|Z2, X)P(X|Z2)P(Z2). We will represent this as a quotient of expression using Definition 2. Let A1 be the atomic expression of the previous example and let A2also be an atomic expression given by X X P(Y|Z2, X, Z3, Z1)P(Z3|Z2, X)P(X|Z2)P(Z2), 16
Simplifying Probabilistic Expressions which is essentially the same as A1 , but with the variable Y removed from the summation set S. Similarly, we let A3be an atomic expression given by X X,Z3,Y P(Y|Z2, X, Z3, Z1)P(Z3|Z2, X)P(X|Z2)P(Z2). We also define the atomic expressions A4 with the value P ( Z3|Z2 )and A5 with the value P ( Z1|Z2, X ). Now, we define two expressions B1 and B2 for the quotient PB1/PB2 as follows: B1=h∅,{A2, A3, A4, A5},∅i, B2=h∅,{A1},∅i. We now call q-simplify ( B1, B2, G, π ). First, we must trace the calls to extract for both expressions on lines A6:2 and A6:3. For B1 and B2 this immediately results in a call to deconstruct on line A5:2. First, the function applies simplify to each atomic expression contained in the expressions on line A4:4. Let us first consider the simplification of A2 . As before with A1 , we have that join first succeeds in forming hY, {Z2, X, Z3, Z1},∅i, but this time Yis not in the summation set, so we continue. Next, the algorithm attempts to join P ( Y|Z2, X, Z3, Z1 )with P ( Z3|Z2, X ). The set Gis defined as {Y}π\An∗(Z3)G={Z3, Z1, X, Z2}\{Z3, Z2}={Z1, X} and its subsets are {Z1, X},{Z1},{X}and ∅. For the first subset P1=∅we have that A= (An∗(Z3)∪P1)4D={Z2, Z3}4{Z2, X, Z3, Z1}={X, Z1} and since ( Y6⊥⊥ X, Z1|Z3, Z2 ) G the condition on line A2:10 is not satisfied. We continue with P2={X}and obtain A= (An∗(Z3)∪P2)4D={X, Z2, Z3}4{Z2, X, Z3, Z1}={Z1} and since ( Y6⊥⊥ Z1|X, Z3, Z2 ) G the condition on line A2:10 is still not satisfied. Next, for P3={Z1}we have A= (An∗(Z3)∪P3)4D={Z2, Z3, Z1}4{Z2, X, Z3, Z1}={X} and since ( Y6⊥⊥ X|Z1, Z3, Z2 ) G the condition on line A2:10 is again, not satisfied. Finally, for P4={Z1, X}we have A= (An∗(Z3)∪P4)4D={Z2, X, Z3, Z1}4{Z2, X, Z3, Z1}={X} and B= (An(Z3)∪P4)4C={Z2, X, Z1}4{Z2, X}={Z1}. Both conditions on line A2:10 are now satisfied ny noting that ( Z3⊥⊥ Z1|X, Z2 ) G . Afterwards we obtain P(Y|Z2, X, Z3, Z1)P(Z3|Z2, X) = P(Y, Z3|Z1, Z2, X) and continue in an attempt to join the term P ( X|Z2 )with this result. The set G is now defined as {Y, Z3}π\An∗(X)G={Z1, X, Z2}\{X, Z2}={Z1} 17
Tikka and Karvanen and its subsets are {Z1}and ∅. Starting with P1=∅we have that A= (An∗(X)∪P1)4D={X, Z2}4{Z1, Z2, X}={Z1} and since ( Y, Z36⊥⊥ Z1|X, Z2 ) G the condition on line A2:10 is not satisfied. Continuing with P2={Z1}we have B= (An(X)∪P2)4C={Z2, Z1}4{Z2}={Z1}. Again, the condition on line A2:10 is not satisfied by noting that ( X6⊥⊥ Z1|Z2 ) G . We have exhausted the possible subsets, which means that we enter the loop on line A2:13 since the set M={Z1}is not empty of line A2:12. In this case insert is called to bring Z1 into the expression because Z1∈D = {Z1, Z2, X} and Z16∈ C={Z2}. The set Gis constructed on line A3:2 and it is Jπ\An∗(Z1)G={Y, Z3}π\ {X, Z1, Z2}=∅. For the only subset P1=∅we have B= (An(Z1)G∪P1) = {X, Z2} on line A3:6, and since ( Z16⊥⊥ X|Z2 ) G the condition on line A3:7 is not satisfied and we return with hJ,D,∅i unchanged on line 9 of Algorithm 3, which causes join to also return with the same output on line A3:18. The condition on line A1:15 is now satisfied and we cannot simplify A2. The atomic expression A3 can be simplified. First, Y is eliminated exactly as it was removed from A1 . Following the same principle we can see that whenever a variable in the summation set is the largest one in the topological order of the variables contained in the atomic expression, it will be removed successfully. From this we obtain that the value of A3 is in fact simply P ( Z2 ). Let us call the atomic expression with this value E , that is PE = P ( Z2 ). The atomic expression A1 can also be simplified, and its value is given by (4). Furthermore, since this value is made of two product terms, it is split into two atomic expressions respectively. Let these be called D1 and D2 such that PD1 = P ( Z3|Z2 )and PD2=P(Z2). Applying simplify to A4 and A5 simply returns the original expressions, since they do not contain any summations and the loop on line A1:3 is never entered. The set of atomic expressions is afterwards updated on line A4:6. Neither B1 nor B2 contain any sub-expressions or summations on line A4:9, so deconstruct ( B1, G, π )returns h∅,{A2, E, A4, A5},∅i and deconstruct ( B2, G, π )returns h∅,{D1, D2},∅i . The lack of summations on line A5:3 of causes extract to iterate through the atomic expression contained in B1 and B2 directly on line A5:6, since neither of them have any sub-expressions of their own. Only A2 contains a sum at this point. The iteration over the terms of A2 on line A5:10 finds that the only term that does not contain X is P ( Z2 )on line A5:11. Let us denote the atomic expression with the value P ( Z2 )as C1 and the atomic expression resulting from the extraction as C2which now has the value X X P(Y|Z2, X, Z3, Z1)P(Z3|Z2, X)P(X|Z2). 18
Simplifying Probabilistic Expressions This completes the extraction and results in an expression B0 1such that B0 1=h∅,{C1, C2, E, A4, A5},∅i. The expression B2remains unchanged. q -simplify is now able to proceed. Neither B0 1 nor B2 contain sub-expression so the loop on line A6:7 is not entered, and we are only subtracting their common atomic expressions in the loop on line A6:16. It is easy to see that A4 = D1 and C1 = D2 , so they are removed from both B0 1 and B2 . Finally, the expressions corresponding to the numerator and denominator are returned. To summarize, we began with the expression P(Z1|Z2, X)P(Z3|Z2)PXP(Y|Z2, X, Z3, Z1)P(Z3|Z2, X)P(X|Z2)P(Z2) PX,Y P(Y|Z2, X, Z3, Z1)P(Z3|Z2, X)P(X|Z2)P(Z2)× X X,Z3,Y P(Y|Z2, X, Z3, Z1)P(Z3|Z2, X)P(X|Z2)P(Z2). and successfully simplified it into P(Z1|Z2, X)P(Z2)X X P(Y|Z2, X, Z3, Z1)P(Z3|Z2, X)P(X|Z2). 6. Discussion We have presented a formal definition of topologically consistent atomic expressions and simplification sets and provided a sound and complete algorithm to find these sets for a given expression. We also discussed some general techniques that apply to a more general class of these expressions. Algorithm 7 and Algorithm 8, presented in Appendix A, have been previously implemented in the R package causaleffect (Tikka and Karvanen, 2017). We have updated the package to include all of the simplification procedures presented in this paper and they can be applied to all causal effect and conditional causal effect expressions derived from identification procedures. Our definition of topologically consistent atomic expressions is similar to g-functionals that can be used to characterize identifiability results under special conditions (Shpitser and Tchetgen Tchetgen, 2016). It is plausible that these procedures could also be extended into other causal inference results, such as formulas for z -identifiability, transportability and meta-transportability of causal effects. The extensions are non-trivial however, since transportability formulas contain terms with distributions from multiple domains and z -identifiable causal effects contain do-operators in the conditioning sets which would require the implementation of the rules of do-calculus into Algorithm 1. Do-calculus consists of three inference rules that can be used to manipulate probabilities involving the do-operator (Pearl, 2009). Currently, we operate only on expressions that do not involve the do-operator. In fact, in our procedure it is not required to know the original causal query that produced the result. Simpler expressions have many useful properties. They can help in understanding and communicating results and evaluating them saves computational resources. Estimation accuracy can also be improved in some cases when variables that are present in the original expression suffer from missing data or measurement error. One example where the benefits 19
Tikka and Karvanen Figure 4: A graph Gfor a situation where simplification fails of simplification are realized can be found in (Hyttinen et al., 2015), where expressions of causal effects are derived and repeatedly evaluated for a large number of causal models. Our approach to simplification stems from the nature of causal effect expressions. In our setting, a question still remains whether simplification sets completely characterize all situations where a variable can be eliminated from an atomic expression. One might also consider simplification in a general setting, where we do not assume topological consistency or any other constraints for the atomic expressions. In this case a ’black box’ definition for simplification could be considered, where we simply require that when the sum over a variable of interest is completed we are again left with another atomic expression without this variable in the summation set. This framework is theoretically interesting but we are not aware of any potential applications. The worst case time complexity of Algorithm 1 is difficult to gauge and is a topic for further research. One can observe that the performance of the algorithm is highly dependent on the size of the differences of the conditioning sets between adjacent terms. Both Algorithm 2 and Algorithm 3 iterate through the subsets of these differences and check d-separation criteria for each subset. Thus dynamic programming solutions could be implemented to further improve performance by collecting the results of these checks. Previously determined conditional independences would not need to be checked again and could be retrieved from memory instead. In some cases, simplification has some apparent connections to identifiability. Consider the graph G of Figure 4. In this graph the causal effect of X on Y is identifiable, and its expression is X Z P(Y|Z, X)P(Z). If we let Z be an unobserved variable instead, then G depicts the well-known bow-arc graph, where the same causal effect is unidentifiable. This corresponds to an unsuccessful attempt to remove Z from the expression of the causal effect. However, we cannot know beforehand whether an expression for a causal effect is going to be atomic or not, so we cannot use our algorithm to derive identifiability in general. A reviewer suggested a simplification algorithm where the ID algorithm would be applied to latent projections (Pearl and Verma, 1991) onto the variables to be marginalized. This algorithm would be able to solve many, but not all, simplification tasks. Importantly, in the example presented in Figure 1, we cannot make any variables latent, as we are interested in the causal effect of X on all of the other variables. A reviewer also suggested that simplified 20
Simplifying Probabilistic Expressions expressions could be categorized into those that are obtained through latent projections and those that are not. This categorization might give additional insight into the topic. Acknowledgments We thank the anonymous reviewers for their constructive feedback that greatly helped us to improve this paper. We also thank Lasse Leskelä for his comments. Appendix A. Topological Consistency of Causal Effect Formulas We prove the statement that every causal effect formula returned by the algorithms of Shpitser and Pearl (2006a,b) can be represented by using products and quotients of π -consistent atomic expressions such that πis a topological ordering of G. We use the notation G [ X ]to denote an induced subgraph, which is obtained from G by removing all vertices not in X and by keeping all edges between the vertices of X in G . Here GX,Z means the graph that is obtained from G by removing all incoming edges of X and all outgoing edges of Z . We say that G is an I-map of P if P admits the causal Markov factorization with respect to G=hV,Ei, which is P= n Y i=1 P(Vi|Pa∗(Vi)G) k Y j=1 P(Uj), where Pa∗(·)contains unobserved parents as well. Consider first lines 2, 3, 4 and 7 of Algorithm 7 where recursive calls occur and let πr be the topological ordering of the graph in the previous recursion step. Line 2 limits the identification procedure to the ancestors of Y so we can still obtain an expression that topologically consistent with respect to a topological ordering obtained from πr by removing non-ancestors. Lines 3 and 4 make no changes to the distribution P and the graph G . On line 7 the induced subgraph G [ S0 ]in the next call is a C-component, but the joint distribution in this case is a πr-consistent expression P(S0) = Y Vi∈S0 P(Vi|Vπr i∩S0, vπr i\s0), since every conditioning set is of the form Vπr i when we only consider variables instead of their values, so we obtain P(S0) = Y Vi∈S0 P(Vi|Vπr i), Furthermore, any expression returned from line 7 will now be πr -consistent. Thus all recursive calls retain topological consistency with respect to π. Consider now the non-recursive terminating calls on lines 1 and 6. Consider line 1 first. If line two was triggered previously, we can factorize P ( V )in such a way that each variable is conditioned by its ancestors, since the ancestors of ancestors of Y are by definition ancestors of Y . If line 7 was triggered previously we already know that the joint distribution was previously factorized in a πr -consistent fashion. If line 3 or 4 was triggered previously, we 21
Tikka and Karvanen know that they have not imposed any changes on P of G . Line 6 clearly produces a πr consistent end result. Lines 4, 6 and 7 can only produce either products of quotients. By noting that πr -consistency implies π -consistency, we have that the result of the algorithm can always be represented by using products and quotients of π-consistent atomic expressions. Algorithm 7 The causal effect of intervention do ( X = x )on Y (Shpitser and Pearl, 2006a). INPUT: Value assignments x and y , joint distribution P ( v )and a DAG G = hV,Ei . G is an I-map of P. OUTPUT: Expression for Px(y)in terms of P(v)or FAIL(F, F0). function ID(y,x, P, G) 1: if x=∅,then return Pv∈v\yP(v). 2: if V6=An(Y)G,then return ID(y,x∩An(Y)G, P(An(Y)G), G[An(Y)G)]. 3: Let W= (V\X)\An(Y)GX. if W6=∅,then return ID(y,x∪w, P, G). 4: if C(G[V\X]) = {G[S1], . . . , G[Sk]},then return Pv∈v\(y∪x)Qk i=1 ID(si,v\si, P, G). if C(G[V\X]) = {G[S]},then 5: if C(G) = {G},then throw FAIL(G, G[S]). 6: if G[S]∈C(G),then return Pv∈s\yQVi∈SP(vi|vπ i). 7: if (∃S0)S⊂S0such that G[S0]∈C(G),then return ID(y,x∩s0,QVi∈S0P(Vi|Vπ i∩S0, vπ i\s0), G[S0]). The claim is now apparent for Algorithm 8 since line 2 is eventually called for every conditional causal effect. Algorithm 8 The causal effect of intervention do ( X = x )on Y given Z (Shpitser and Pearl, 2006b). INPUT: Value assignments x , y and z , joint distribution P ( v )and a DAG G = hV,Ei . Gis an I-map of P. OUTPUT: Expression for Px(y|z)in terms of P(v)or FAIL(F, F0). function IDC(y,x,z, P, G) 1: if ∃Z∈Zsuch that (Y⊥⊥ Z|X,Z\ {Z})GX,Zthen return IDC(y,x∪ {z},z\ {z}, P, G). 2: else let P0=ID(y∪z,x, P, G). return P0/Py∈yP0 22
Simplifying Probabilistic Expressions Appendix B. Proof of Theorem 6 Proof By direct calculation we obtain PA=X Vj n Y i=1 P(Vi|Ci) =Y Vi<Vj P(Vi|Ci)X Vj Y Vi≥Vj P(Vi|Ci) =Y Vi<Vj P(Vi|Ci)X Vj P(Vπ(p), . . . , Vπ(q)|D) QU∈MP(U|EU) =Y Vi<Vj P(Vi|Ci)P(Vπ(p+1), . . . , Vπ(q)|D) QU∈MP(U|EU) =Y Vi<Vj P(Vi|Ci)Y Vi>Vj P(Vi|Di) := PA0, where the sets Di are obtained from the factorization of the joint term such that A0 is a π∗ -consistent where π∗ is obtained from π by removing Vj from the ordering. To justify the equalities, we first note that terms of variables Vi< Vj do not contain Vj and can be brought outside the sum. To obtain the third equality, we multiply by [ QU∈MP ( U|EU )] / [ QU∈MP ( U|EU )] and apply condition (2) of Definition 5 on the right-hand side as licensed by condition (3) of the definition. To obtain the fourth equality, we simply carry out the summation in terms of Vj . Conditions (2) and (3) of Definition 5 make it possible to refactorize the joint term into product terms so that the terms corresponding to variables U∈Mremain unchanged and can be divided out once more. Thus we obtain the last equality, and an expression that no longer contains Vjand has the same value as A. Appendix C. Derivation of the Causal Effect in the Introductory Example We present the derivation of the causal effect of X on Y, Z3, Z2, Z1 in the graph G of Figure 1 using Algorithm 7. We fix topological ordering of G as Z2< X < Z1< Z3< Y . The original call ID ( {Y, Z1, Z2, Z3},{X}, P ( V ) , G )fires line 4 and results in three new recursive calls. We have PX(Y, Z3, Z1, Z2) = PY,Z3,X,Z2(Z1)PY,Z1,X,Z2(Z3)PZ3,Z1,X (Y, Z2),(5) as the graph G [ V\{X} ]has three C-components formed by the sets {Z1} , {Z3} and {Y, Z2} , respectively. The first recursive call ID ( {Z1},{Y, Z3, X, Z2}, P ( V ) , G )fires line 2 because Z3 and Y are not ancestors of Z1 . The next call ID ( {Z1},{X, Z2}, P ( Z1, X, Z2 ) , G [ {Z1, X, Z2} ]) fires line 6 because C ( G [ {Z1} ]) contains only one C-component and it is not part of a larger 23
Tikka and Karvanen C-component in the graph of the current recursion stage. We have PY,Z3,X,Z2(Z1) = PX,Z2(Z1) = P(Z1|X, Z2).(6) To obtain PY,Z1,X,Z2 ( Z3 )we call ID ( {Z3},{Y, Z1, X, Z2}, P ( V ) , G )which also fires line 2 because X , Z1 and Y and not ancestors of Z3 . Calling ID ( {Z3},{Z2}, P ( Z3, Z2 ) , G [ {Z3, Z2} ]) fires line 6 C ( G [ {Z3} ]) contains only one C-component and it is not part of a larger C- component in the graph of the current recursion stage. We have PY,Z1,X,Z2(Z3) = PZ2(Z3) = P(Z3|Z2).(7) To obtain the last term we call ID ( {Y, Z2},{Z3, Z1, X}, P ( V ) , G ). The subgraph G [ V\ {Z3, Z1, X} ] = G [ {Y, Z2} ]has only one C-component, but it is part of a larger C-component formed by the set S0={Y, Z3, X, Z2}in the current graph G. Line 7 is fired resulting in ID({Y, Z2},{Z3, X}, P(Y|Z3, Z1, X, Z2)P(Z3|Z2, X)P(X|Z2)P(Z2), G[S0]).(8) This call fires line 2 since X is not an ancestor of Y in the graph G [ S0 ]. Letting T = S0\ {X}={Y, Z3, Z2}the next call is ID({Y, Z2},{Z3},X X P(Y|Z3, Z1, X, Z2)P(Z3|Z2, X)P(X|Z2)P(Z2), G[T]).(9) This time we trigger line 6 because G [ T\ {Z3} ]has only one C-component and there is no larger C-component of G[T]that would contain it. We obtain PZ3,Z1,X (Y, Z2) = PZ3,Z1,X (Y, Z2) =PZ3,X (Y, Z2) =PZ3(Y, Z2) =P∗(Y|Z3, Z2)P∗(Z2), (10) where P∗is the distribution of the current recursion stage, that is P∗(Y, Z3, Z2) = X X P(Y|Z3, Z1, X, Z2)P(Z3|Z2, X)P(X|Z2)P(Z2). In order to represent the conditional probability on the last line of (10), we write P∗(Y|Z3, Z2)P∗(Z2) = P∗(Y, Z3, Z2) P∗(Z3, Z2)P∗(Z2) =P∗(Y, Z3, Z2) PYP∗(Y, Z3, Z2)X Y,Z3 P∗(Y, Z3, Z2) =PXP(Y|Z2, X, Z3, Z1)P(Z3|Z2, X)P(X|Z2)P(Z2) PX,Y P(Y|Z2, X, Z3, Z1)P(Z3|Z2, X)P(X|Z2)P(Z2)× X X,Z3,Y P(Y|Z2, X, Z3, Z1)P(Z3|Z2, X)P(X|Z2)P(Z2). (11) 24