ECON 4309 · Quantitative Methods for Social Sciences · Reading companion

Causal Diagrams, in about 15 minutes

A plain-language guide to three short chapters of The Effect by Nick Huntington-Klein: Ch. 6 (Causal Diagrams), Ch. 7 (Drawing Causal Diagrams), and Ch. 8 (Causal Paths and Closing Back Doors). Read this first, play with the two simulators, and then use the reading guide at the end to decide which parts of the chapters to read closely.

Pairs with Lecture 4: Measurement and DAGsBook: Ch. 6, 7, 8~15 min

1. The big idea in 60 seconds

Chapter 6 has a puzzle. You'd expect more police to mean less crime. But in the chapter's data on North Carolina counties, places with more police per person also have more crime. Do police cause crime?

Probably not. The chapter's explanation is that last year's crime is part of the story. High-crime places get assigned more police, and high-crime places tend to stay high-crime. So police and crime move together even if police lower crime. The raw correlation mixes the effect you want with an alternative explanation.

A causal diagram is a picture of how you think the data were generated: boxes for variables, arrows for "this causes that." Once it's drawn, you can list every path that links your treatment to your outcome, sort them into the ones that answer your question and the ones that don't, and figure out what to control for to shut the bad ones.

The book's working definition of a cause is worth memorizing: X causes Y if, when you step in and change X, the distribution of Y changes. The chapter's example: people wear shorts more on days they eat ice cream, but putting someone in shorts won't make them buy ice cream. Both are driven by something else (hot weather). Correlation without causation.

The three chapters build one recipe:

  1. Draw the diagram (Ch. 6 and 7). Include everything important, leave out the rest, and own those choices as assumptions.
  2. List every path from treatment to outcome and mark each as Good or Bad (Ch. 8).
  3. Close every Bad path by controlling for something on it, without closing a Good path and without controlling for a collider (Ch. 8).

2. Words you need

We'll use Lecture 4's running example throughout: what is the effect of an extra year of education on earnings? In the lecture's diagram, a person's background, location, and year of birth affect both education and earnings, and education affects earnings partly through job connections.

Causal diagram (DAG)A picture of the data generating process. Directed: arrows have one direction. Acyclic: following the arrows never brings you back where you started.Education → Earnings, plus everything else that matters for either one.
Node and arrowEach node is one variable (with all its possible values). An arrow means "causes." It says nothing about size or sign.Background → Education: background changes how much school you get, in some direction.
Unobserved variableSomething that matters but you can't measure. When two things are related and neither causes the other, the book draws an unknown common cause, U1.U1 links Background and Location in the lecture diagram.
PathAny route from one variable to another along the arrows, ignoring which way they point. Each path is a reason the two variables could move together.Education ← Year of birth → Earnings is one path.
Front door / back doorFront door: every arrow points away from the treatment. Back door: at least one arrow points back toward it. Usually front doors are the Good paths and back doors the Bad paths.Education → Job connections → Earnings is a front door.
Controlling (adjusting)Removing the variation in a variable, so it can't drive the relationship. Regression controls, matching, or picking a sample where it doesn't vary all do this.Comparing people with the same background.
Open / closedA path is open if everything on it is free to vary, so it carries association. Controlling for a variable on the path closes it.Controlling for Year of birth closes Education ← Year → Earnings.
ColliderA variable where both arrows on a path point into it (→ C ←). A path with a collider is closed by default. Controlling for the collider opens it.The lecture's example: being hired at a tech company is caused by both programming and social skills.
d-separatedThe lecture's term for "every path between two variables is closed." If X and Y are d-separated, any relationship you then see between them must come from somewhere else.Control for Background, Location, and Year, and the back doors are shut.

3. Drawing a diagram (Ch. 7)

Chapter 7 walks through a study the author worked on: does taking an online course make community-college students more likely to drop out? The lecture follows the same steps for education and earnings:

  1. List variables. Start with treatment and outcome. Then ask: what causes the treatment? What causes the outcome? What causes those? (For online classes: preferences, available time, work hours, internet access, past academics, demographics, and so on.)
  2. Draw arrows. For each pair, ask whether one causes the other. If two things are related but neither causes the other, add a common cause like U1.
  3. Simplify. The book's first draft is a hairball, so it trims it with four tests (each comes with a "probably," so think before you cut):
    • Unimportance: tiny effects can go (the chapter's example: quiet cafés nearby might nudge a few students toward online classes, but not many).
    • Redundancy: variables with exactly the same arrows in and out can be merged (Race and Gender become "Demographics"; the lecture groups socioeconomic status and demographics into "Background").
    • Mediators: a variable that only passes an effect along (A → B → C, nothing else touching B) can be replaced by A → C, unless the mechanism is what you're studying.
    • Irrelevance: a variable that sits on no path between treatment and outcome can go.
  4. No cycles. If it looks like A causes B and B causes A, add time. The book's example is a fistfight: my punch now causes your punch next period, which causes my punch the period after. The lecture's version: Wealtht−1 → Powert → Wealtht.
What's missing is an assumption tooEvery variable you leave off says "this doesn't matter much." Every arrow you leave out says "these two don't directly cause each other." The book calls the ones your answer depends on identifying assumptions. Writing them down is scary because people can disagree with them. That is the point: your critics can see exactly what you assumed. Someone who refuses to draw a diagram is still making those assumptions, just without saying so.

4. Simulator: open and close the paths

This is the lecture's education-and-earnings diagram, with two additions so you can see every kind of variable: Schooling laws (from the lecture's variable list) and Owns a home, which we added as a collider. Owning a home is plausibly caused by both education and earnings. Click a box to control for it. The list below the diagram updates to show which paths are open.

What is the effect of education on earnings?

Click a variable to control for it (it turns dark). Click it again to un-control it. U1 is unobserved, so you can't control for it. Hover over a path in the list to highlight it.

Treatment / outcomeControlledUnobserved
Controlling for
nothing
Bad paths still open
—
Good paths still open
—
The rule, in one sentenceIf you control for at least one variable on every Bad path, control for nothing on a Good path, and leave colliders alone, then whatever relationship is left between treatment and outcome is the causal effect you asked about (assuming your diagram is right).

The book practices this on its own example: does drinking wine make you live longer? Its diagram has two front doors (Wine → Lifespan, and Wine → Drugs → Lifespan) and four back doors that run through Income and Health, which share an unobserved cause U1. Controlling for Income closes three of the back doors. Adding Health closes the fourth. Note that you never had to control for U1, which is lucky, because you can't.

How to find every path (the book's walking method)Start at the treatment. Follow any arrow, in or out. Keep walking from node to node. If you reach the outcome, write the path down. If you'd revisit a node, that's a loop, not a path. Back up and try the next arrow until you've tried them all. It's tedious at first. After a few diagrams you'll spot paths by eye, and software can do it for you (section 10).

5. Confounders, mediators, colliders

The lecture sorts the associations in a diagram into three types. The middle variable plays a different role in each, and the right move is different:

ZXY Confounder (common cause)
X ← Z → Y. Z opens a back door.
Control for it.
Lecture: candidate quality drives both campaign money and win margin.
ZXY Mediator
X → Z → Y. Z is part of the effect.
Usually don't control for it.
Lecture: job connections, between education and earnings.
ZXY Collider
X → Z ← Y. The path is already closed.
Don't control for it.
Lecture: getting hired at a tech company.

Why does controlling for a collider create a link? The book uses a sandwich. Suppose your boss sometimes buys lunch for the office, but always announces it after you've ordered. Buying a sandwich and being given one are unrelated. But if you know someone ate a sandwich, the two become linked: if they didn't buy one, they must have been given one. Knowing the collider makes its causes predict each other.

The lecture's version: survey workers at a tech company and you'll find that people with better programming skills have worse social skills. That's not because coding ruins your social life. The company hires people who are strong in at least one of the two, so among the hired, a person weak in one is probably strong in the other. Similarly, height seems unrelated to basketball skill among NBA players. The book adds a warning: choosing a sample is controlling. Study only college students and you have controlled for college attendance, whether you meant to or not.

6. Simulator: see the bias in data

The diagram tells you which paths are open. This simulator shows what an open path does to your numbers. All the data here are simulated, made up so we know the true answer. They are not from the book or the lecture.

Confounding: campaign money and win margin

—
—
—
—
—
—

7. Why controlling works

Every open path is a story for why treatment and outcome move together. The Ch. 6 police example has two Bad stories (last year's crime, and local "law and order" politics, each of which affects both police and crime) and Good ones (police reduce crime directly, and by making crime less likely to pay off). To get at the Good stories, you need to get rid of the variation that comes from the Bad ones.

A path carries association only if every variable on it is free to vary. The book's example: in a sample where nobody uses drugs, Wine → Drugs → Lifespan can't explain anything, because Drugs never changes. Controlling for a variable does the same thing statistically. The lecture describes it in two equivalent ways and lists the tools for doing it:

Colliders are the exception. A collider doesn't cause anything on its path, so it can't supply an alternative story. It is the thing being caused, which is why its path starts out closed. Controlling for it makes its causes related to each other, and that opens the path.

8. What has to be true (and how to check it)

Assumption 1: The diagram is close enough to being right

Everything above holds if the diagram is correct, and no diagram is perfect. The Ch. 6 police diagram leaves out the poverty rate, and the book admits that probably belongs on it. The goal is a diagram that's useful: everything important, as little else as possible. Too many variables and nothing can be identified. Too few and you miss a back door.

How to check it: the book's Ch. 7 advice is to treat each assumption as "probably true" or "probably false" rather than proven, and to ask what evidence would convince a skeptical reader. Its example: in a study of door-knocking and votes, if a reader asks "doesn't campaign money pay for door-knocking?", look at prior studies, or check whether money and door-knocking are correlated in your data. And show your diagram to someone who knows the setting.

Assumption 2: You can measure what you need to control for

A back door through something unobserved (like U1) can only be closed if another variable on the same path is measured. If every variable on a Bad path is unobserved, controlling can't save you, and you need a different research design. Most of the rest of the course is about those designs.

Check: placebo tests (testable implications)

Your diagram makes claims you can test. Pick two variables that the diagram says should be unrelated once you control for certain things, and check whether they actually are. The lecture writes this as X ⊥ Y | Z: "X is independent of Y, given Z."

The book's example: the wine diagram implies that Income and Drug use are related only through Wine. So after controlling for Wine, they should be unrelated. That seems unlikely, and if the data show a relationship, the diagram is missing something. Failing a placebo test doesn't end the project, since every diagram leaves something out. A small leftover relationship is a minor worry. A big one means back to the drawing board.

9. What you actually estimate

Which paths count as Good depends on your research question, not on the diagram.

Total effect"Does wine change lifespan, by any route?" Both front doors are Good, so you leave Drugs alone. In the lecture example, leave Job connections alone.
Direct effect"Does wine change lifespan other than through drug use?" Now Wine → Drugs → Lifespan is a path you don't want, so you'd control for Drugs. Only Treatment → Outcome is Good.

The book is explicit that either question can be valid. Just decide which one you're asking before you pick your controls. Controlling for a mediator by accident (the lecture calls it overcontrolling) quietly changes your question from "total" to "direct."

10. Doing it in R (with AI help)

In this class, AI writes most of the code. Your job is the design and the checking. The dagitty and ggdag packages (or the website dagitty.net) will find paths and adjustment sets for you, but only for the diagram you give them.

StepTypical RWhat you check
1. Write the diagramdag <- dagify(Earnings ~ Education + JobConnections + Background + Location + Year, JobConnections ~ Education, Education ~ Background + Location + Year + SchoolLaws, Background ~ U1, Location ~ U1, exposure = "Education", outcome = "Earnings", latent = "U1")Is every arrow one you believe? Is every missing arrow an assumption you can defend? Are unobserved variables marked latent?
2. Plot itggdag(dag), isAcyclic(dag)Does the picture match your story? Any cycles? (If so, add time.)
3. List the pathspaths(dag, "Education", "Earnings") or ggdag_paths(dag)Same paths you found by hand? Which are front doors, and which are open?
4. Find what to control foradjustmentSets(dag, effect = "total") or ggdag_adjustment_set(dag)No mediators or colliders in the set. Do you actually have those variables in your data?
5. Check your control setpaths(dag, Z = c("Background", "Location", "Year"))Every back door closed, every front door still open.
6. Test the diagramimpliedConditionalIndependencies(dag), then localTests(dag, data = df)Placebo tests. Small violations are normal; big ones mean the diagram is missing something.
7. Estimatelm(earnings ~ education + background + location + year, data = df)The controls in the regression should be the adjustment set, not "everything I have."
The software only knows your diagramadjustmentSets() gives the right answer for the diagram you typed in. If you left out an important variable or arrow, it will confidently give you the wrong answer. AI is the same: ask it "what should I control for?" without a diagram and it may suggest "everything you have," which can include mediators and colliders.
Common mistakes

11. How to read the chapters

Together the three chapters run about 16,000 words, but they're among the most readable in the book, and Ch. 8 is the foundation for everything after it. Here's where to spend your time:

SectionWhat it covers
6.1 CausalityThe "intervene and the distribution changes" definition, causal vs. weasel words, ice cream and shorts.Read
6.2 Causal DiagramsNodes, arrows, unobserved variables, U1. The coin-flip-for-cake example builds up step by step.Read
6.3 On an Omission MissionThe police-and-crime diagram, and why everything left off is an assumption.Read closely
6.4 Research QuestionsDirect vs. indirect effects in the police diagram.Skim
6.5 ModeratorsHow interactions fit (awkwardly) into diagrams.Optional
7.1–7.2 Thinking Through the DGPBuilding the online-classes diagram variable by variable. Follow the logic; don't memorize the list.Skim
7.3 SimplifyThe four simplification tests.Read
7.4–7.5 Cycles; AssumptionsBreaking cycles with time; convincing a skeptical reader.Skim
8.1–8.3 Paths; Good and BadWhat a path is, how to find them all, front and back doors. Work the wine example yourself before reading the answer.Read closely
8.4 Open and Closed PathsControlling closes paths. The core rule for identification.Read closely
8.5 CollidersWhy colliders close paths and controlling for them reopens them. Read the sandwich footnote.Read closely
8.6 Testing Your DiagramPlacebo tests from the diagram's own implications.Read
8.7 Path GlossaryOne-line definitions. Good for review before the quiz.Skim