Graphical models as categorical diagrams, Part 1: Conditioning in SEMs

Blog / Technical reports

Author

Evan Patterson

Published

2026-11-30

Abstract

Structural equation models (SEMs), a kind of probabilistic graphical model, are construed as diagrams in the sense of category theory. Conditioning is then expressed as an operation on diagrams, and conditional independence relations are derived by factorizing a diagram using initial functors.

The directed acyclic graphs (DAGs) known as Bayesian networks are widely used across the sciences to model probabilistic dependencies between the variables in a system. Bayesian nets are also the core abstraction behind a major approach to causal inference (Pearl 2009).

In my view, graphical models like Bayesian nets have been so popular because they are rare examples of statistical methods that explicitly separate the structural and analytical parts of a model. Before any probability distributions are assigned, the structure of the DAG concisely specifies a set of variables and conditional independence relations between them. Key assumptions of the model can be interrogated and criticized early in the modeling process, including by participants not steeped in the arcana of applied statistics.

Less satisfying is the mathematics of deriving conditional independence relations from a Bayesian network. The main definition, that of d-separation, is reproduced below from (Pearl 1988, sec. 3.3.1).

If X, Y, and Z are three disjoint subsets of nodes in a DAG D, then Z is said to d-separate X from Y, denoted <X|Z|Y>_D, if there is no path between a node in X and a node in Y along which the following two conditions hold: (1) every node with converging arrows is in Z or has a descendent in Z and (2) every other node is outside Z.

Another formulation, reproduced from (Pearl 2009, sec. 1.2.3), makes the definition’s structure more explicit:

A path p is said to be d-separated (or blocked) by a set of nodes Z if and only if (1) p contains a chain i→m→j or a fork i←m→j such that the middle node m is in Z, and (2) p contains an inverted fork (or collider) i→m←j such that the middle node m is not in Z and such that no descendent of m is in Z. A set Z is said to d-separate X from Y if and only if Z blocks every path from a node in X to a node in Y.

No matter how you write it, the definition of d-separation is a case analysis within a complicated sequence of quantifiers and negations. Taken as an algorithm, it is useful; as a mathematical definition, it looks rather ad hoc.

This series presents a mathematical account of conditional independence in directed graphical models that improves on d-separation in three ways. First, its main definition is a conceptual one that avoids intricate combinatorics and invokes long-standing mathematical concepts (from category theory1). Second, it is more general. The d-separation criterion fails on cyclic models, but our account works equally well for models with ineliminable equations between variables, as induced by cycles. Third, observation (conditioning) is natively represented in the graphical language and makes conditional independence appear as topological disconnection.

Among the several notions of directed graphical model, this post most directly treats not Bayesian networks but structural equation models (SEMs),2 also known as “structural causal models” or “functional causal models.”3 So we’ll begin by recalling how to transform a Bayesian network into an SEM.

1 From Bayesian nets to SEMs

A Bayesian network is, as standardly defined, simply a DAG. Its nodes are interpreted as random variables and its edges as direct probabilistic dependencies. Shown below is everyone’s favorite example of a Bayesian network, adapted from (Pearl 2009, fig. 1.2).

Though not specified by the DAG, we imagine the variable “Season” to be valued in a four-element set and the other variables to be boolean-valued.

In a structural equation model, the probabilistic dependencies of a Bayesian net are refined into functional dependencies, sometimes (but not always) viewed as mechanisms. Stochasticity is then reintroduced through a new set of random variables, interpreted as disturbances or errors and rarely observed. SEMs are traditionally drawn as graphs, just like Bayesian nets. We draw them in a more detailed style suggestive of our preferred mathematical formalization.

The SEM corresponding to the Bayesian net above is:

Figure 1: The sprinkler example as a structural equation model

There are two kinds of nodes, representing variables and operation applications. Each variable is assigned a type, written after the colon. At this level of specification, the types and operations are abstract, not yet interpreted by particular sets and functions. The new variables \varepsilon_i represent sources of randomness. Their types \mathcal{E}_i and intended distributions as random variables are irrelevant for the purpose of deriving conditional independence relations. What is important is that the variables \varepsilon_i will be interpreted as independent random variables.

The content of the diagram is equivalently described by the system of equations

\begin{aligned} \mathrm{season} &= f_1(\varepsilon_1) \\ \mathrm{rain} &= f_2(\mathrm{season}, \varepsilon_2) \\ \mathrm{sprinkler} &= f_3(\mathrm{season}, \varepsilon_3) \\ \mathrm{wet} &= f_4(\mathrm{rain}, \mathrm{sprinkler}, \varepsilon_4) \\ \mathrm{slippery} &= f_5(\mathrm{wet}, \varepsilon_5) \end{aligned} \tag{1}

in the variables

\mathrm{season}: S,\, \mathrm{rain}: \mathbb{B},\, \mathrm{sprinkler}: \mathbb{B},\, \mathrm{wet}: \mathbb{B},\, \mathrm{slippery}: \mathbb{B},\, \varepsilon_1: \mathcal{E}_1,\, \dots,\, \varepsilon_5: \mathcal{E}_5.

The reader familiar with the literature on causal inference may recognize these equations as essentially identical to (Pearl 2009, Equation 1.44).4

The system of equations (1) is concretized by interpreting each type with a set and each operation with a function. Following (Pearl 2009, Equation 1.45), one possible interpretation is

\begin{aligned} \mathrm{season} &= \varepsilon_1 \\ \mathrm{rain} &= [(\mathrm{season} = \mathrm{Wi}) \vee (\mathrm{season} = \mathrm{Fa}) \vee u_2] \wedge \neg u_2' \\ \mathrm{sprinkler} &= [(\mathrm{season} = \mathrm{Su}) \vee (\mathrm{season} = \mathrm{Sp}) \vee u_3] \wedge \neg u_3' \\ \mathrm{wet} &= (\mathrm{rain} \vee \mathrm{sprinkler} \vee u_4) \wedge \neg u_4' \\ \mathrm{slippery} &= (\mathrm{wet} \vee u_5) \wedge \neg u_5' \end{aligned} \tag{2}

where the type assignments are

\begin{aligned} \mathbb{B} &\mapsto \{\top, \bot\} \\ S,\, \mathcal{E}_1 &\mapsto \{\mathrm{Sp}, \mathrm{Su}, \mathrm{Fa}, \mathrm{Wi}\} \\ \mathcal{E}_2, \dots, \mathcal{E}_5 &\mapsto \{\top, \bot\}^2 \end{aligned} \tag{3}

and the function assignments are implied by (2), e.g., f_1 is interpreted as the identity function. We have also introduced the abbreviation (u_i, u_i') \coloneqq \varepsilon_i for i = 2,\dots,5. As Pearl puts it, “u_i and u_i' stand for triggering and inhibiting abnormalities, respectively.”

2 SEMs as categorical diagrams

Comparing the graphical and equational displays of the SEM, the category theorist might notice that the solution set of Equation 2 is the limit of a certain category-theoretic diagram suggested by Figure 1. Indeed, a limit in the category of sets and functions has the general form of a product of sets filtered by functional constraints. This observation is a first hint that it may be fruitful to study SEMs from the perspective of diagrams and limits.

With that motivation, we will explain in detail how to formalize SEMs as category-theoretic diagrams. This account builds on my recent proposal of a categorical and operational semantics for e-graphs (Patterson 2026). Although e-graphs and SEMs have, on the face of it, nothing to do with each other, it turns out that the two concepts can be described by essentially the same mathematics. We’ll aim to keep this post self-contained, but the reader looking for more mathematical background is referred to the cited paper and references therein.

First, some terminology. Recall that a diagram in a category \mathsf{C} consists of a small category \mathsf{J}, the shape of the diagram, along with a functor D: \mathsf{J} \to \mathsf{C}. A category is cartesian if it has finite products, and a functor (between categories with finite products) is cartesian if it preserves finite products. Less standardly, we say that a diagram D: \mathsf{J} \to \mathsf{C} in a cartesian category \mathsf{C} is cartesian if its shape \mathsf{J} is cartesian and so is D itself as a functor.

Generalizing how a free diagram is generated by a labeled graph, a free cartesian diagram is generated by a labeled multigraph. For us, a multigraph5 is a combinatorial object comprising a set of vertices and a set of multiedges, where each multiedge is assigned a list of vertices as its source and a single vertex as its target. So, a multigraph is like a (directed) graph, except that an edge is allowed to have zero, one, or multiple inputs. A cartesian diagram is free if its shape is a cartesian category freely generated by a multigraph. A free cartesian diagram in a cartesian category \mathsf{C} is equivalently specified by a multigraph labeled by \mathsf{C}, i.e., a multigraph homomorphism into the underlying multigraph of \mathsf{C}.

Recasting our running example of an SEM (Figure 1) as a free cartesian diagram should make this avalanche of jargon more transparent. First, take the target category \mathsf{C} to be generated6 by objects \mathbb{B}, S, \mathcal{E}_1, \dots, \mathcal{E}_5 and by morphisms

\begin{aligned} f_1 &: \mathcal{E}_1 \to S \\ f_2 &: S \times \mathcal{E}_2 \to \mathbb{B} \\ f_3 &: S \times \mathcal{E}_3 \to \mathbb{B} \\ f_4 &: \mathbb{B} \times \mathbb{B} \times \mathcal{E}_4 \to \mathbb{B} \\ f_5 &: \mathbb{B} \times \mathcal{E}_5 \to \mathbb{B}. \end{aligned}

Next, take the shape \mathsf{J} to be the cartesian category freely generated by the multigraph

with vertices \varepsilon_1, \dots, \varepsilon_5 and “\mathrm{season}”, “\mathrm{rain}”, \dots and five multiedges, left unnamed. Finally, the diagram {D: \mathsf{J} \to \mathsf{C}} is the evident functor. The formal meaning of Figure 1 is this free cartesian diagram.

2.1 Set-theoretic interpretations

The cartesian diagram D: \mathsf{J} \to \mathsf{C}, depicted by Figure 1, encodes the system of equations (1). What about the system of equations (2) with f_1, \dots, f_5 replaced by specific functions?

Such an interpretation amounts to a cartesian functor F: \mathsf{C} \to \mathsf{Set} into the category of sets and functions. In this example, F is defined on generating objects by Equation 3 and on generating morphisms by sending f_1 to the identity function, sending f_2 to the function

(x_1, u_2, u_2')\ \mapsto\ [(x_1 = \mathrm{Wi}) \vee (x_1 = \mathrm{Fa}) \vee u_2] \wedge \neg u_2',

and so on. Post-composing the original diagram in \mathsf{C} with F yields another cartesian diagram, F \circ D: \mathsf{J} \to \mathsf{Set}, now valued in sets. This diagram corresponds to Equation 2 in the same way that D does to Equation 1.

Which diagram, D or F \circ D, is “the” structural equation model? The literature on causal models strikes me as ambivalent on this point, but when formal definitions are made, they tend to fall back on familiar set-theoretic and analytic mathematics.7 Our perspective is that the two descriptions, synthetic and analytic,8 are equally valid: an interpreted model F \circ D is required to generate or compare against data, but the abstracted model D already contains the model’s key commitments and suffices to reason about conditional independencies.

2.2 Limits

When a category theorist talks about diagrams, it is usually as a prelude to talking about limits (or colimits). Indeed, we will now compute the limits of the two diagrams defining the example SEM.

Let’s begin with the set-valued diagram, since limits always exist in \mathsf{Set}. Applying the general formula9 for a limit of sets, the limit of the diagram F \circ D: \mathsf{J} \to \mathsf{Set} is (isomorphic to) the subset of the cartesian product

F(S) \times \{\top,\bot\} \times \cdots \times \{\top,\bot\} \times F(\mathcal{E}_1) \times \{\top,\bot\}^2 \times \cdots \times \{\top, \bot\}^2

that consists of the elements

(\mathrm{season},\, \mathrm{rain},\, \dots,\, \mathrm{slippery},\, \varepsilon_1,\, \varepsilon_2,\, \dots,\, \varepsilon_5)

satisfying the system of equations (2), where again (u_i, u_i') \coloneqq \varepsilon_i for i = 2,\dots,5. The limit captures the idea of the solution set of—or, more abstractly, the universal solution to—the system of equations presented by a diagram. In this case, the equations in question are the eponymous “structural equations” of an SEM.10

The limit of the diagram F \circ D is alternatively just the cartesian product

\lim (F \circ D) \cong \{ (\varepsilon_1, \dots, \varepsilon_5): \varepsilon_1 \in \{\mathrm{Sp}, \mathrm{Su}, \mathrm{Fa}, \mathrm{Wi}\},\, \varepsilon_2, \dots, \varepsilon_5 \in \{\top,\bot\}^2 \}.

The intuitive reason is that the error variables consistently and uniquely determine all of the other variables. Similarly, although the cartesian category \mathsf{C} does not have all limits, the limit of the diagram D: \mathsf{J} \to \mathsf{C} exists and is the product

\lim D \cong \mathcal{E}_1 \times \cdots \times \mathcal{E}_5.

In other words, the limit of D is the same as the limit of the discrete diagram on the objects \mathcal{E}_1, \dots, \mathcal{E}_5. Later we will see how to formalize this kind of reasoning about diagrams and limits using morphisms of diagrams.

3 Conditioning in SEMs

Labeled multigraphs and cartesian diagrams are more complicated than DAGs, and the uninitiated in category theory could be forgiven for wondering whether the extra formalism is worth it. A first advantage of this formalism over DAGs is its ability to express conditioning within the graphical language, instead of exclusively through the analytic theory of probability. As we will explain, conditioning on a variable is represented by adding a new, nullary multiedge into the corresponding vertex. A DAG cannot support this interpretation because the presence of multiple edges into a node already has a meaning11 (namely, that the node has multiple parents).

Suppose that, in our running example, we condition on \mathrm{wet} = c, that is, we observe that the variable “\mathrm{wet}” is equal to some constant c. To record this new information, we augment the diagram in Figure 1 with a nullary multiedge into the corresponding vertex:

Figure 2: The sprinkler example of an SEM, after having observed the value of the variable “\mathrm{wet}”

The system of equations represented by the augmented SEM is

\begin{aligned} \mathrm{season} &= f_1(\varepsilon_1) \\ \mathrm{rain} &= f_2(\mathrm{season}, \varepsilon_2) \\ \mathrm{sprinkler} &= f_3(\mathrm{season}, \varepsilon_3) \\ \mathrm{wet} &= f_4(\mathrm{rain}, \mathrm{sprinkler}, \varepsilon_4) \\ \mathrm{wet} &= c \\ \mathrm{slippery} &= f_5(\mathrm{wet}, \varepsilon_5) \end{aligned} \tag{4}

where we follow the standard practice of conflating a nullary operation with a constant.

Formally, given a cartesian diagram D: \mathsf{J} \to \mathsf{C}, conditioning on a set of variables x_1 : X_1, \dots, x_k: X_k is accomplished as follows. To the target \mathsf{C}, freely adjoin nullary morphisms c_1 : 1 \to X_1, \dots, c_k: 1 \to X_k, yielding a cartesian category \mathsf{C}'. Then post-compose D with the accompanying inclusion \mathsf{C} \hookrightarrow \mathsf{C}' to obtain a diagram \mathsf{J} \to \mathsf{C}'. Finally, to this cartesian diagram in \mathsf{C}', freely adjoin12 morphisms 1 \to x_1, \dots, 1 \to x_k over c_1, \dots, c_k, yielding a cartesian diagram D': \mathsf{J}' \to \mathsf{C}'.

4 Conditional independence by diagrammatic reasoning

In the new system of equations (4), corresponding to the SEM conditioned on \mathrm{wet} = c, naive equational reasoning lets us replace the occurrence of the variable “\mathrm{wet}” in the final equation with the constant c. This seemingly trivial substitution has an important consequence: the system (4) factorizes as two independent systems of equations

\left\{ \begin{aligned} \mathrm{season} &= f_1(\varepsilon_1) \\ \mathrm{rain} &= f_2(\mathrm{season}, \varepsilon_2) \\ \mathrm{sprinkler} &= f_3(\mathrm{season}, \varepsilon_3) \\ \mathrm{wet} &= f_4(\mathrm{rain}, \mathrm{sprinkler}, \varepsilon_4) \\ \mathrm{wet} &= c \end{aligned} \right. \qquad\quad\text{and}\quad\qquad \Big\{ \mathrm{slippery} = f_5(c, \varepsilon_5) \tag{5}

in the variables “\mathrm{season}”, \dots, “\mathrm{wet}”, \varepsilon_1, \dots, \varepsilon_4 and the variables “\mathrm{slippery}” and \varepsilon_5, respectively.

When the variables are upgraded to random variables, the factorization implies conditional independences among them. Suppose \varepsilon_1, \dots, \varepsilon_5 are made into random variables that are independent but otherwise arbitrarily distributed, and the remaining variables inherit a joint distribution from Equation 1. Then the factorization of Equation 4 displayed in Equation 5 implies that, conditional on “\mathrm{wet}”, the variable “\mathrm{slippery}” is independent of the other named variables. Or, in standard notation:

\mathrm{Season},\, \mathrm{Rain},\, \mathrm{Sprinkler} \mathrel{\mathrlap{\perp}\mkern 2mu\perp} \mathrm{Slippery} \mid \mathrm{Wet}.

In the remainder of this post, we will explain how to translate this intuitive, if slightly informal, way of manipulating equations into a formal calculus for manipulating cartesian diagrams.

Just as the system of equations (4) corresponds to the cartesian diagram in Figure 2, the systems of equations (5), taken together, correspond to the cartesian diagram:

Figure 3: The sprinkler example, after conditioning on “\mathrm{wet}” and factorizing

This diagram has two connected components; formally, it is a coproduct in a category of cartesian diagrams.

The next step is to translate the equational reasoning implicit in going from Equation 4 to Equation 5 into diagrammatic reasoning that justifies going from Figure 2 to Figure 3. This diagrammatic reasoning will be based on morphisms between diagrams.

4.1 Morphisms of diagrams

The literature is replete with more and less famous ways of representing structural equation models and other statistical models by diagrams.13 What justifies this particular way of representing SEMs by diagrams is its natural notion of morphism, which leads to rules for drawing inferences like the one above.

We recall another swathe of terminology. A morphism from a diagram {D_0: \mathsf{J} \to \mathsf{C}} to another diagram {D: \mathsf{K} \to \mathsf{C}} in the same category is a functor R: \mathsf{J} \to \mathsf{K} between their shapes making the evident triangle commute, i.e., D \circ R = D_0. In other words, the category of diagrams in a category \mathsf{C} is the slice category \mathsf{Cat}/\mathsf{C}. Similarly, a morphism of cartesian diagrams in a common cartesian category is a morphism of diagrams whose underlying functor is cartesian; that is, the category of cartesian diagrams in a cartesian category \mathsf{C} is the slice \mathsf{Cart}/\mathsf{C}.

Suppose that R: (\mathsf{J}, D_0) \to (\mathsf{K}, D) is a morphism of diagrams in a category \mathsf{C} and that both diagrams, D and D_0 = D \circ R, have a limit in \mathsf{C}. By the universal property of the latter, there is a canonical morphism

\textstyle \lim_{\mathsf{K}} D \to \lim_{\mathsf{J}} (D \circ R) \tag{6}

between the two limits. In general, this morphism is not invertible; that is, restricting a diagram along an arbitrary functor does not necessarily preserve its limit.

There is a special class of functors for which the limit is always unchanged. These are called the initial functors. To be precise, a functor R: \mathsf{J} \to \mathsf{K} is initial if, for every diagram D: \mathsf{K} \to \mathsf{C} in any category \mathsf{C}, the canonical morphism in Equation 6 is an isomorphism (each limit existing if the other does). It turns out that it suffices to take \mathsf{C} = \mathsf{Set} in this criterion: a functor R: \mathsf{J} \to \mathsf{K} is initial if and only if, for every diagram D: \mathsf{K} \to \mathsf{Set}, the canonical function in Equation 6 is a bijection. For a review of the essential facts about initial functors, including other characterizations, see the nLab or (Patterson 2026, Appendix A).

Extending this jargon, a morphism of diagrams is initial if its underlying functor is initial. The initial morphisms of diagrams are those guaranteed to preserve the system of equations represented by the diagrams, no matter how they are later interpreted set-theoretically.

4.2 Three motifs of conditional independence

Readers familiar with Bayesian networks will have encountered the three famous motifs: chains, forks, and colliders. They are key sources of intuition, and they appear explicitly in the definition of d-separation (Pearl 2009, Definition 1.2.3). For each of these motifs, we show how the expected relations of conditional independence arise from an initial morphism of cartesian diagrams. The motifs are, when possible, taken as fragments of our running example (Figure 1).

4.2.1 Chain

Consider a chain, such as the cartesian diagram:

In a DAG, a chain is simply a (directed) path, perhaps assumed to have length 2. In a free cartesian diagram, paths and chains can be construed more broadly. Without being too precise, we think of this example as a chain (\mathrm{rain}, \mathrm{sprinkler}) \to \mathrm{wet} \to \mathrm{slippery}.

Now, condition on the intermediate variable of the chain, as shown on the left below. Then the morphism of cartesian diagrams below, drawn from right to left,14 sends both variables “\mathrm{wet}” and “\mathrm{wet}'” on the right to the variable “\mathrm{wet}” on the left and sends both copies of c on the right to c on the left.

Under any set-theoretic interpretation, the limits of the left- and right-hand sides are sets given by fragments of the systems of equations (4) and (5), respectively, in the four named variables and \varepsilon_4, \varepsilon_5. We’ve already observed informally that these equations are equivalent; the precise statement is that the two sets are put into canonical bijection by the morphism of diagrams. Thus, this morphism is initial.

As we reasoned earlier, under any assignment of random variables that is consistent with the left-hand side, and makes “\mathrm{Rain}”, “\mathrm{Sprinkler}”, and \varepsilon_4 independent of \varepsilon_5, the factorization on the right-hand side witnesses the conditional independence:

\mathrm{Rain},\, \mathrm{Sprinkler} \mathrel{\mathrlap{\perp}\mkern 2mu\perp}\mathrm{Slippery} \mid \mathrm{Wet}.

4.2.2 Fork

Next, a fork:

Condition on the middle of the fork, as shown on the left below. Then the morphism of cartesian diagrams, again drawn from right to left,

is initial. Under any assignment of random variables consistent with the left-hand side and making {\varepsilon_1, \varepsilon_2, \varepsilon_3} independent, the factorization on the right-hand side witnesses the conditional independence:

\mathrm{Rain} \mathrel{\mathrlap{\perp}\mkern 2mu\perp}\mathrm{Sprinkler} \mid \mathrm{Season}.

4.2.3 Collider

Finally, the most subtle motif, a collider:

Without conditioning in this collider, the morphism of cartesian diagrams, again drawn from right to left,

is initial, as the limit of both diagrams is the product \mathcal{E}_2 \times \mathcal{E}_3 \times \mathcal{E}_4. The factorization on the right-hand side witnesses the (unconditional) independence:

\mathrm{Rain} \mathrel{\mathrlap{\perp}\mkern 2mu\perp}\mathrm{Sprinkler}.

If, on the other hand, we condition on the middle of the collider, then there is still a morphism of cartesian diagrams

but it is not initial, since the limit of the right-hand side remains the product \mathcal{E}_2 \times \mathcal{E}_3 \times \mathcal{E}_4 but the limit of the left-hand side, if it exists, is not a product. Indeed, the independence relation no longer holds after conditioning, except in degenerate cases:

\mathrm{Rain} \not\mathrel{\mathrlap{\perp}\mkern 2mu\perp}\mathrm{Sprinkler} \mid \mathrm{Wet}.

We caution that while the chosen examples of a chain and a fork both embed into the full example in Figure 1, and the corresponding initial morphisms extend to it, the same is not true of this example of a collider. The signatures of f_i, for i=2,3, have implicitly changed from S \times \mathcal{E}_i \to \mathbb{B} to \mathcal{E}_i \to \mathbb{B}, so the diagrams are not even in the same category. To extend this calculation to the full example, we would need to hold the season constant too. We would then find that

\mathrm{Rain} \mathrel{\mathrlap{\perp}\mkern 2mu\perp}\mathrm{Sprinkler} \mid \mathrm{Season} \qquad\text{but}\qquad \mathrm{Rain} \not\mathrel{\mathrlap{\perp}\mkern 2mu\perp}\mathrm{Sprinkler} \mid \mathrm{Season},\, \mathrm{Wet}.

5 Outlook

We’ve shown how to express a structural equation model (SEM), whether abstract or set-theoretical, as a cartesian diagram. We then expressed conditioning in an SEM within the language of cartesian diagrams. Finally, we illustrated through the motifs of chains, forks, and colliders how to derive conditional independences by factorizing a cartesian diagram using a special class of morphisms of cartesian diagrams, the initial morphisms. Suggestive though these calculations are, we stopped short of formalizing a procedure to deduce conditional independences. Our most pressing task is to establish a soundness and completeness theorem relating such factorizations to conditional independence, a counterpart to the well-known theorem relating d-separation and conditional independence. This will be the topic of the next post in this series.

From among the notions of directed graphical model, we singled out SEMs because they share with category-theoretic limits a functional nature. We were thus able to apply very classical concepts in category theory, all well understood by the early 1970s. However, models like Bayesian nets, which take stochastic rather than functional maps as primitive, remain of interest. In the future we may investigate how to extend the methods of this post to irreducibly stochastic models.

References

Bollen, Kenneth A. 1989. Structural Equations with Latent Variables. Wiley. https://doi.org/10.1002/9781118619179.
Bongers, Stephan, Patrick Forré, Jonas Peters, and Joris M. Mooij. 2021. “Foundations of Structural Causal Models with Cycles and Latent Variables.” The Annals of Statistics 49 (5): 2885–915. https://doi.org/10.1214/21-AOS2064.
Fritz, Tobias, and Andreas Klingler. 2023. “The d-Separation Criterion in Categorical Probability.” Journal of Machine Learning Research 24 (46): 1–49. https://jmlr.org/papers/v24/22-0916.html.
Leinster, Tom. 2014. Basic Category Theory. Cambridge University Press. https://doi.org/10.1017/CBO9781107360068.
Patterson, Evan. 2020. “The Algebra and Machine Representation of Statistical Models.” PhD thesis, Stanford University. https://arxiv.org/abs/2006.08945.
———. 2026. “How to Prove Equations Using Diagrams: A Categorical and Operational Semantics for e-Graphs.” https://arxiv.org/abs/2611.05924.
Patterson, Evan, Andrew Baas, Timothy Hosgood, and James Fairbanks. 2023. “A Diagrammatic View of Differential Equations in Physics.” Mathematics in Engineering 5 (2): 1–59. https://doi.org/10.3934/mine.2023036.
Pearl, Judea. 1988. Probabilistic Reasoning in Intelligent Systems: Networks of Plausible Inference. Morgan Kaufmann. https://doi.org/10.1016/C2009-0-27609-4.
———. 2009. Causality: Models, Reasoning, and Inference. 2nd ed. Cambridge University Press. https://doi.org/10.1017/CBO9780511803161.
Wright, Sewall. 1934. “The Method of Path Coefficients.” The Annals of Mathematical Statistics 5 (3): 161–215. https://doi.org/10.1214/aoms/1177732676.

Footnotes

  1. There are now more than a few works that study probabilistic graphical models using ideas from category theory, especially Markov categories. Most relevant to this post is Fritz and Klingler (2023)’s paper on “the d-separation criterion in categorical probability.” Two important differences from this post are that Fritz–Klingler use Markov categories, while we use cartesian categories to treat functional models, and that Fritz–Klingler define d-separation combinatorially for string diagrams in free Markov categories, whereas our key concept, initial functors, is invariant to presentation.↩︎

  2. We use the term “structural equation model” in its generalized, nonparametric sense, not assuming the classical linear-Gaussian form that occupies the bulk of texts like Bollen (1989).↩︎

  3. In this post, we avoid the terms “structural causal model” and “functional causal model” (Pearl 2009, sec. 1.4) because we are not yet assuming the model to have any causal or mechanistic interpretation. Causal concepts like intervention and counterfactuals are topics for the future.↩︎

  4. Besides cosmetic changes to the notation, the only difference compared to (Pearl 2009, Equation 1.44) is that Pearl takes f_1 to be the identity and thus equates the variables “season” and \varepsilon_1. We have included f_1 to emphasize that the translation from Bayesian networks to SEMs is purely mechanical. In any case, this choice does not affect the conditional independencies implied by the SEM.↩︎

  5. We do not use “(directed) multigraph” in the graph theorist’s sense, which for us is simply a “graph.” Rather, “multigraph” is used in analogy with a multicategory.↩︎

  6. So, in this example, \mathsf{C} is itself a cartesian category freely generated by a multigraph. However, nothing depends on it being free. In general, we regard the target category as an algebraic theory.↩︎

  7. See, for example, the definition of “structural causal model” in (Bongers et al. 2021, Definition 2.1).↩︎

  8. In my PhD thesis (Patterson 2020)—which has a different formalism but a similar spirit—I call the synthetic notion a “statistical theory” and reserve “statistical model” for the more familiar analytic notion.↩︎

  9. The formula for a limit in \mathsf{Set} is standard (e.g., Leinster 2014, Example 5.1.22). However, while it conveys the right intuition, it does not, strictly speaking, yield the stated result. We are actually applying (Patterson 2026, Proposition B.9) to reduce the limit of a free cartesian diagram to its generating data, indexed by a multigraph.↩︎

  10. As a point of comparison, Bongers et al. (2021) define the structural equations induced by a structural causal model and the solutions of the structural equations (Definitions 2.2–2.3) similarly but exclusively using analytic mathematics, so that in general every variable is a function of every other. (They also separate endogenous and exogenous variables in the definition, a distinction to which we shall return later.)↩︎

  11. That a bare graph cannot unambiguously express both multiary operations and equational constraints was noted by the author and collaborators in their study of “Tonti diagrams” in computational physics (Patterson et al. 2023). While the application is rather different, the problem is the same.↩︎

  12. The operations of “freely adjoining” new morphisms to a cartesian category, or to a cartesian diagram in a fixed category, can themselves be formalized as pushouts in suitable categories. We will not dwell on this point, as pushouts are a standard technique in category theory not central to our story, but see Patterson (2026) for further discussion.↩︎

  13. Besides DAGs, particularly relevant are the path diagrams for depicting systems of simultaneous equations (Bollen 1989), which go back to the earliest work on structural equations (Wright 1934). Unlike both DAGs and category-theoretic diagrams, path diagrams seem to be regarded as visual aids to understanding equations rather than as mathematical objects in their own right.↩︎

  14. When considering limits, there are formal reasons to take the category of cartesian diagrams to be (\mathsf{Cart}/\mathsf{C})^\mathrm{op} rather than \mathsf{Cart}/\mathsf{C} (cf. Patterson et al. 2023, sec. 4), which would also have the advantage of making the morphism here go from left to right. On balance, though, we think it least confusing to preserve the native orientation of a functor.↩︎

Comments