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.
Note: This is the printable version. The interactive version, with the simulators, is on the course website.
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:
- Draw the diagram (Ch. 6 and 7). Include everything important, leave out the rest, and own those choices as assumptions.
- List every path from treatment to outcome and mark each as Good or Bad (Ch. 8).
- 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.
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:
- 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.)
- 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.
- 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.
- 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.
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.
- Try 1: Click Background. Three paths close. Which Bad paths are still open? Close them all with the fewest clicks. (The lecture's answer: Background, Location, and Year of birth.)
- Try 2: Now also click Job connections. The back doors stay closed, but you've just shut one of your Good paths. That's overcontrolling: you'd only measure the part of education's effect that doesn't run through job connections.
- Try 3: Un-click Job connections and click Owns a home. A path that was closed by default opens, because you controlled for a collider. Then click Schooling laws: nothing changes, because it isn't on any path to earnings.
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.
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:
X ← Z → Y. Z opens a back door.
Control for it.
Lecture: candidate quality drives both campaign money and win margin.
X → Z → Y. Z is part of the effect.
Usually don't control for it.
Lecture: job connections, between education and earnings.
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
- Try 1: In Confounder, drag the strength to 0. The naive slope and the adjusted slope both sit near the true 1.0. Now drag it to 2. The naive slope climbs toward 1.8, while the adjusted slope stays near 1.0.
- Try 2: Switch the view to Quality removed. This is the lecture's recipe: take out the part of money explained by quality, take out the part of win margin explained by quality, and look at what's left. The slope of that cloud is the adjusted estimate.
- Try 3: Switch to Collider and set hiring to 100%. Programming and social skills are unrelated. Now lower it to 20%. Among the people hired, a clear negative relationship appears. Nobody's skills changed. Only who you're looking at changed.
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:
- Hold it constant: compare candidates as if they had the same quality.
- Remove what it predicts: strip out the part of money and the part of win margin that quality explains, then relate what's left (Simulator 2's "Quality removed" view).
- Ways to do it: add it to a regression (
margin ~ money + quality), matching, stratifying, or inverse probability weighting. You'll meet these later in the course.
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.
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.
| Step | Typical R | What you check |
|---|---|---|
| 1. Write the diagram | dag <- 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 it | ggdag(dag), isAcyclic(dag) | Does the picture match your story? Any cycles? (If so, add time.) |
| 3. List the paths | paths(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 for | adjustmentSets(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 set | paths(dag, Z = c("Background", "Location", "Year")) | Every back door closed, every front door still open. |
| 6. Test the diagram | impliedConditionalIndependencies(dag), then localTests(dag, data = df) | Placebo tests. Small violations are normal; big ones mean the diagram is missing something. |
| 7. Estimate | lm(earnings ~ education + background + location + year, data = df) | The controls in the regression should be the adjustment set, not "everything I have." |
adjustmentSets() 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.- Kitchen-sink regressions. Throwing in every available control can close Good paths (mediators) and open Bad ones (colliders).
- Thinking "collider" is a type of variable. The book stresses that it depends on the path: the same variable can be a collider on one path and not on another.
- Forgetting that sample selection is controlling. Studying only employees, only college students, or only NBA players can open a collider path.
- Treating an arrow as "positive." An arrow means "causes," with no sign and no size.
- Leaving out unobserved variables because you can't measure them. They still belong on the diagram, and they decide whether a back door can be closed.
- Drawing a cycle (A → B → A). Break it with time periods.
- Reading "linked to" as "causes." The book lists these "weasel words": linked to, predicts, is followed by, people who X are more likely to Y.
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:
| Section | What it covers | |
|---|---|---|
| 6.1 Causality | The "intervene and the distribution changes" definition, causal vs. weasel words, ice cream and shorts. | Read |
| 6.2 Causal Diagrams | Nodes, arrows, unobserved variables, U1. The coin-flip-for-cake example builds up step by step. | Read |
| 6.3 On an Omission Mission | The police-and-crime diagram, and why everything left off is an assumption. | Read closely |
| 6.4 Research Questions | Direct vs. indirect effects in the police diagram. | Skim |
| 6.5 Moderators | How interactions fit (awkwardly) into diagrams. | Optional |
| 7.1–7.2 Thinking Through the DGP | Building the online-classes diagram variable by variable. Follow the logic; don't memorize the list. | Skim |
| 7.3 Simplify | The four simplification tests. | Read |
| 7.4–7.5 Cycles; Assumptions | Breaking cycles with time; convincing a skeptical reader. | Skim |
| 8.1–8.3 Paths; Good and Bad | What 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 Paths | Controlling closes paths. The core rule for identification. | Read closely |
| 8.5 Colliders | Why colliders close paths and controlling for them reopens them. Read the sandwich footnote. | Read closely |
| 8.6 Testing Your Diagram | Placebo tests from the diagram's own implications. | Read |
| 8.7 Path Glossary | One-line definitions. Good for review before the quiz. | Skim |