Lesson 2 of 5

Causal Diagrams with DAGs

Last lesson, Riverside Books mailed a coupon and randomizing it recovered its true $8 effect. But randomizing was a luxury. This month Riverside wants to know something it cannot randomize: does joining Riverside Plus, its paid membership, actually make a customer spend more? You cannot force random shoppers to join a membership, so the clean coin flip is off the table.

When you cannot randomize, you are forced to reason from assumptions instead. A causal diagram (a DAG) is those assumptions drawn as a picture, and its payoff is remarkable: once the picture is on paper, you can read straight off it which variables you must control for and which ones you must leave strictly alone.

By the end of this lesson you will be able to:

  • Draw a causal question as a DAG, where circles are variables and arrows are direct causes
  • Recognize the three shapes every diagram is built from, and give the control rule for each: a confounder, a mediator, and a collider
  • See, in real R, how controlling the wrong variable either hides a real effect or invents a fake one
  • Use the backdoor criterion to choose exactly the right set of variables to adjust for

Prerequisites: Lesson 1 (confounding, selection bias, and randomization), and you can fit lm() and read a coefficient. Every new term is defined as it appears. Toggle the three buttons below to see the whole lesson in one picture.

The idea

Causal Diagrams with DAGs

Start by writing Riverside's belief down. We think joining Plus (call it plus) raises monthly spend. That single belief is one arrow:

\[ \texttt{plus} \longrightarrow \texttt{spend} \]

That picture is a DAG, short for directed acyclic graph, and each word earns its place:

  • Graph because it is circles joined by lines. Each circle is a node, one variable we can measure (plus, spend, and soon others).
  • Directed because every line is an arrow with a direction. An arrow from A to B is a specific, strong claim: A is a direct cause of B. No arrow means you believe there is no direct causal link.
  • Acyclic because you can never follow the arrows in a loop back to where you started. A variable cannot end up causing itself; causes flow forward in time.

A DAG is nothing more than your causal assumptions, made explicit and drawn. That is its whole power: assumptions written this plainly can be argued about, criticized, and checked against what you know of the world, instead of hiding silently inside a regression. Building one is three honest steps.

Note
A DAG does not come from the data. It comes from you, from what you know about how Riverside's customers behave. The data cannot draw the arrows for you; it can only be interpreted once the arrows are drawn.