Skip to Content
BayesiaLabKey ConceptsDirected Acyclic Graph (DAG)

Directed Acyclic Graphs

A Directed Acyclic Graph (DAG) consists of nodes and arcs, which the literature also calls vertices and edges. Nodes represent variables or events. Each arc points from one node to another, and no path that follows the arcs in their direction returns to its starting node. A DAG encodes conditional independence relationships among variables. For a DAG in general, an arc represents merely an association and does not imply a causal direction.

Loading SVG...
Click to Zoom
Directed Acyclic Graph.
Loading SVG...
Click to Zoom
Directed Cyclic Graph. For reference only. A DAG cannot contain a directed cycle.

Causal Directed Acyclic Graph (CDAG)

In a causal DAG, however, an arc does encode the causal direction asserted by a researcher or domain expert: an arc from node A\mathit{A} to node B\mathit{B} means we assume that A\mathit{A} can influence B\mathit{B}, that is, A\mathit{A} can have an effect on B\mathit{B}. The arc says nothing about whether this effect is strong or weak, positive or negative, deterministic or probabilistic. What it does state unambiguously is the direction. For example, “Fire causes Smoke” is encoded as Fire\mathit{Fire} →\rightarrow Smoke\mathit{Smoke}, which asserts that Fire\mathit{Fire} can cause Smoke\mathit{Smoke} and that Smoke\mathit{Smoke} cannot cause Fire\mathit{Fire}.

Structures in a CDAG

Any CDAG, regardless of size and complexity, can be decomposed into three basic structures. Each structure implies a specific pattern of associations expected in data collected from the underlying domain.

In the following three diagrams, A\mathit{A} and B\mathit{B} are the endpoints of a path and C\mathit{C} is the middle node. Marginally means without conditioning on C\mathit{C}. Conditionally on C\mathit{C} means we compare observations at the same value of C\mathit{C}. The symbol ⊥\bot means “is independent of.”

Chain

Loading SVG...
Click to Zoom

In this chain, A\mathit{A} can affect B\mathit{B} indirectly through C\mathit{C}.

  • A directed arc represents a potential direct causal effect. In this graph, A→C\mathit{A} \rightarrow \mathit{C} means we assume that A\mathit{A} can directly affect C\mathit{C}.
  • A missing arc represents a causal assumption. In this graph, we assume that A\mathit{A} has no direct effect on B\mathit{B}. Its effect on B\mathit{B} is mediated by C\mathit{C}.

Implication for Causality

A\mathit{A} has a potential causal effect on B\mathit{B} mediated by C\mathit{C}.

Implication for Association

Marginally (or unconditionally), A\mathit{A} and B\mathit{B} are dependent. This means that without knowing the exact value of C\mathit{C}, learning about A\mathit{A} informs us about B\mathit{B} and vice versa, i.e., the path between the nodes is unblocked, and information can flow in both directions.

Given C\mathit{C}, A\mathit{A} and B\mathit{B} are conditionally independent. In BayesiaLab, we represent an observation of C\mathit{C} by setting Hard Evidence on that node. In other words, by “hard”-conditioning on C\mathit{C}, we block the path from A\mathit{A} to B\mathit{B} and from B\mathit{B} to A\mathit{A}. Thus, A\mathit{A} and B\mathit{B} are conditionally independent, given C\mathit{C}:

A̸ ⁣⊥B, A⊥B∣C\mathit{A} \not\!\bot \mathit{B},\ \mathit{A} \bot \mathit{B} \mid \mathit{C}

Hard Evidence means that there is no uncertainty regarding the value of the observation or evidence. If uncertainty remains regarding the value of C\mathit{C}, the path will not be entirely blocked, and an association will remain between A\mathit{A} and B\mathit{B}.

Example: Can you predict a marathon runner’s ranking from their training?

Suppose we record how many days each runner trained before a marathon and compare those records with the race results. We would expect runners who trained more to finish faster and place higher. Runners who trained very little might finish near the back of the field or might not finish at all.

Marathon Training→Finishing Time→Ranking\mathit{Marathon\ Training} \rightarrow \mathit{Finishing\ Time} \rightarrow \mathit{Ranking}

Now look at the runners who finished. Once we know each runner’s finishing time, we can put them in order. Knowing how many days they trained tells us nothing further about their ranking. Observing Finishing Time\mathit{Finishing\ Time} blocks the flow of information from Marathon Training\mathit{Marathon\ Training} to Ranking\mathit{Ranking}.

Common Cause

Loading SVG...
Click to Zoom

The second configuration has C\mathit{C} as the common parent of A\mathit{A} and B\mathit{B}.

Implication for Causality

C\mathit{C} is the common cause of both A\mathit{A} and B\mathit{B}.

Implication for Association

A common cause and a chain imply the same pattern of conditional independence. Thus, A\mathit{A} and B\mathit{B} are marginally dependent but conditionally independent given C\mathit{C} (by setting Hard Evidence on C\mathit{C}):

A̸ ⁣⊥B, A⊥B∣C\mathit{A} \not\!\bot \mathit{B},\ \mathit{A} \bot \mathit{B} \mid \mathit{C}

Example: Can you predict hair length from height?

Imagine we measure Body Height\mathit{Body\ Height} and Hair Length\mathit{Hair\ Length} in a sample of adults from around the world. Suppose we find that the taller a person is, the shorter their hair tends to be. Why should someone’s height tell us anything about their hair?

Now consider Sex\mathit{Sex}. In our sample, men are taller on average and typically wear their hair shorter. Women are shorter on average and typically wear their hair longer. These two differences can produce the association we see when we pool the observations.

Body Height←Sex→Hair Length\mathit{Body\ Height} \leftarrow \mathit{Sex} \rightarrow \mathit{Hair\ Length}

What happens if we compare men with men and women with women? In this model, knowing a person’s height then tells us nothing further about their hair length. In other words, Body Height\mathit{Body\ Height} and Hair Length\mathit{Hair\ Length} are conditionally independent given Sex\mathit{Sex}.

Common Effect

Loading SVG...
Click to Zoom

The final structure has a common child C\mathit{C}, with A\mathit{A} and B\mathit{B} being its parents. This structure is called a “V-Structure.” In this configuration, the common child C\mathit{C} is also known as a “collider.”

Implication for Causality

A\mathit{A} and B\mathit{B} are the direct causes of C\mathit{C}.

Implication for Association1

Marginally (or unconditionally), A\mathit{A} and B\mathit{B} are independent, i.e., there is no information flow between A\mathit{A} and B\mathit{B}. When we observe the common effect C\mathit{C}, its two causes A\mathit{A} and B\mathit{B} become dependent. If we condition on the collider C\mathit{C}, information can flow between A\mathit{A} and B\mathit{B}, i.e., conditioning on C\mathit{C} opens the information flow between A\mathit{A} and B\mathit{B}:

A⊥B, A̸ ⁣⊥B∣C\mathit{A} \bot \mathit{B},\ \mathit{A} \not\!\bot \mathit{B} \mid \mathit{C}

Even introducing a minor change in the distribution of C\mathit{C}, e.g., from no observation (“color unknown”) to a very vague observation (“it could be anything, but it is probably not purple”), opens the information flow.

For purposes of formal reasoning, this type of connection is of special significance. Conditioning on C\mathit{C} facilitates inter-causal reasoning, often referred to as the ability to “explain away” the other cause, given that the common effect is observed (see Inter-Causal Reasoning in Chapter 4).

Example: Did it rain last night?

You look out the window in the morning and see that the lawn is wet. That makes you think it may have rained overnight. Then you check the sprinkler log and discover that the sprinkler ran. How does that change the probability that it rained?

Rain→Wet Lawn←Sprinkler Ran\mathit{Rain} \rightarrow \mathit{Wet\ Lawn} \leftarrow \mathit{Sprinkler\ Ran}

Suppose the sprinkler runs on a timer, independently of the weather. Before you saw the lawn, learning that the sprinkler ran would have told you nothing about rain. Once you know the lawn is wet, the same information matters. Either rain or the sprinkler could have soaked the grass. Learning that the sprinkler ran makes rain less probable than it seemed when all you knew was that the lawn was wet.

This type of reasoning is often referred to as explaining away. In Chapter 4, we explore it more formally under the heading Inter-Causal Reasoning.

Application to Complex CDAGs

As we assemble more nodes and arcs into a larger graph, we can represent our assumptions about an entire domain. And, from this systematic encoding of individual causal assumptions, we can extract more understanding than what we entered through our assumptions. A DAG therefore encodes more than its arcs state explicitly: for any pair of nodes, the graph alone determines whether they are marginally or conditionally dependent or independent.

Loading SVG...
J\mathit{J} and K\mathit{K} are marginally dependent.D\mathit{D} and E\mathit{E} are marginally independent.

CDAG Example: University Admissions

In preparation for their university application, students take an initial math test that produces a score helping them understand their math proficiency. Knowing their Initial Math Score\mathit{Initial\ Math\ Score}, students can elect to participate in Math Tutoring\mathit{Math\ Tutoring} sessions. We assume that the Initial Math Score\mathit{Initial\ Math\ Score} influences the decision to sign up for Math Tutoring\mathit{Math\ Tutoring}. Later, the students take a final math test, which is presumably influenced by their initial proficiency and any Math Tutoring\mathit{Math\ Tutoring} they may have taken. The Final Math Score\mathit{Final\ Math\ Score} is then taken into account for the University Admission\mathit{University\ Admission} decision. In other words, the Final Math Score\mathit{Final\ Math\ Score} influences University Admission\mathit{University\ Admission}.

The following graph shows this example encoded as a CDAG.

Loading SVG...
Click to Zoom

In this context, one interesting research question might be the effect of Math Tutoring\mathit{Math\ Tutoring} on the probability of University Admission\mathit{University\ Admission}. Later, we will obtain a data set that includes observations for all the variables in this domain. However, it is not the data that determines whether it is possible to estimate the effect of Math Tutoring\mathit{Math\ Tutoring} on University Admission\mathit{University\ Admission} or any other effect in this domain. Instead, we will need to perform Causal Identification in the next step.

The four panels below highlight examples of all three structures in the admissions CDAG. The first two show chains, the third shows a common cause, and the fourth shows a common effect.

Loading SVG...
Click to Zoom
Chain
Via Math Tutoring\mathit{Math\ Tutoring}
Loading SVG...
Click to Zoom
Chain
Via Final Math Score\mathit{Final\ Math\ Score}
Loading SVG...
Click to Zoom
Common Cause
Initial Math Score\mathit{Initial\ Math\ Score}
Loading SVG...
Click to Zoom
Common Effect
Final Math Score\mathit{Final\ Math\ Score}

A node’s role depends on the path we trace. Final Math Score\mathit{Final\ Math\ Score} is a common effect of Initial Math Score\mathit{Initial\ Math\ Score} and Math Tutoring\mathit{Math\ Tutoring}. On the path from Math Tutoring\mathit{Math\ Tutoring} to University Admission\mathit{University\ Admission}, that same node is the mediator in the chain.

Next Step: Causal Identification

Footnotes

  1. Observing a consequence of a common effect can also open the path through it. In the admissions example, Final Math Score\mathit{Final\ Math\ Score} is a common effect of Initial Math Score\mathit{Initial\ Math\ Score} and Math Tutoring\mathit{Math\ Tutoring}. Observing University Admission\mathit{University\ Admission}, which is influenced by Final Math Score\mathit{Final\ Math\ Score}, can open that path as well. ↩