3.2 — DAGs
ECON 480 • Econometrics • Fall 2022
Dr. Ryan Safner
Associate Professor of Economics
safner@hood.edu
ryansafner/metricsF22
metricsF22.classes.ryansafner.com
Statistics profession is obstinant that we cannot say anything about causality
But you have to! It’s how the human brain works!
We can’t conceive of (spurious) correlation without some causation
Should we ONLY base policies on the evidence from Randomized Controlled Trials
| ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄|
— Ellie Murray (@EpiEllie) July 13, 2018
IF U DONT SMOKE,
U ALREADY
BELIEVE IN
CAUSAL INFERENCE
WITHOUT
RANDOMIZED TRIALS
|__________|
(__/) ||
(•ㅅ•) ||
/ づ#HistorianSignBunny #Epidemiology
Source: British Medical Journal
"Correlation implies casuation," the dean whispered as he handed me my PhD.
— David Robinson (@drob) June 22, 2017
"But then why-"
"Because if they knew, they wouldn't need us."
We will seek to understand what causality is and how we can approach finding it
We will also explore the different common research designs meant to identify causal relationships
These skills, more than supply & demand, constrained optimization models, ISLM, etc, are the tools and comparative advantage of a modern research economist
BREAKING NEWS:
— The Nobel Prize (@NobelPrize) October 11, 2021
The 2021 Sveriges Riksbank Prize in Economic Sciences in Memory of Alfred Nobel has been awarded with one half to David Card and the other half jointly to Joshua D. Angrist and Guido W. Imbens.#NobelPrize pic.twitter.com/nkMjWai4Gn
]
Simultaneous “credibility revolution” in econometrics (c.1990s—2000s)
Use clever research designs to approximate natural experiments
Note: major disagreements between Pearl & Angrist/Imbens, etc.!
Causality isn't achieved; it's approached.
— John B. Holbein (@JohnHolbein1) April 7, 2018
The sine qua non of causal claims are counterfactuals: what would \(Y\) have been if \(X\) had been different?
It is impossible to make a counterfactual claim from data alone!
Need a (theoretical) causal model of the data-generating process!
Again, RCTs are invoked as the gold standard for their ability to make counterfactual claims:
Treatment/intervention \((X)\) is randomly assigned to individuals
If person i who recieved treatment had not recieved the treatment, we can predict what his outcome would have been
If person j who did not recieve treatment had recieved treatment, we can predict what her outcome would have been
RCTs are but the best-known method of a large, growing science of causal inference
We need a causal model to describe the data-generating process (DGP)
Requires us to make some assumptions
A visual model of the data-generating process, encodes our understanding of the causal relationships
Requires some common sense/economic intuition
Remember, all models are wrong, we just need them to be useful!
Suppose we have data on three variables
IP
: how much a firm spends on IP lawsuitstech
: whether a firm is in tech industryprofit
: firm profitsThey are all correlated with each other, but what’s are the causal relationships?
We need our own causal model (from theory, intuition, etc) to sort
Consider all the variables likely to be important to the data-generating process (including variables we can’t observe!)
For simplicity, combine some similar ones together or prune those that aren’t very important
Consider which variables are likely to affect others, and draw arrows connecting them
Test some testable implications of the model (to see if we have a correct one!)
Drawing an arrow requires a direction - making a statement about causality!
Omitting an arrow makes an equally important statement too!
If two variables are correlated, but neither causes the other, likely they are both caused by another (perhaps unobserved) variable - add it!
There should be no cycles or loops (if so, there’s probably another missing variable, such as time)
In social science and complex systems, 1000s of variables could plausibly be in DAG!
So simplify:
Background, Year of birth, Location, Compulsory schooling, all cause education
Background, year of birth, location, job connections probably cause wages
Background, Year of birth, Location, Compulsory schooling, all cause education
Background, year of birth, location, job connections probably cause wages
Job connections in fact is probably caused by education!
Location and background probably both caused by unobserved factor (u1
)
This is messy, but we have a causal model!
Makes our assumptions explicit, and many of them are testable
DAG suggests certain relationships that will not exist:
laws
and conx
go through educ
educ
, then cor(laws,conx)
should be zero!Dagitty.net is a great tool to make these and give you testable implications
Click Model -> New Model
Name your “exposure” variable \((X\) of interest) and “outcome” variable \((Y)\)
Click and drag to move nodes around
Add a new variable by double-clicking
Add an arrow by double-clicking one variable and then double-clicking on the target (do again to remove arrow)
Minimal sufficient adjustment sets containing background, location, year for estimating the total effect of educ on wage: background, location, year
Tells you some testable implications of your model
These are (conditional) independencies:
\[X \perp Y \, | \, Z\]
“X is independent of Y, given Z”
Tells you some testable implications of your model
Example: look at the last one listed:
job_connections
\(\perp\) year
\(\vert\) educ
“Job connections are independent of year, controlling for education”
educ
, there should be no correlation between job_connections
and year
— can test this with data!background
, location
, and year
, we can identify the causal effect of educ
\(\rightarrow\) wage
.R
ggdag
Y ~ X + Z
means “Y
is caused by X
and Z
”R
IIdagitty.net
!dagitty()
from the dagitty
package, and paste the code in quotes# install.packages("dagitty")
library(dagitty)
dagitty('dag {
bb="0,0,1,1"
background [pos="0.413,0.335"]
compulsory_schooling_laws [pos="0.544,0.076"]
educ [exposure,pos="0.185,0.121"]
job_connections [pos="0.302,0.510"]
location [pos="0.571,0.431"]
u1 [pos="0.539,0.206"]
wage [outcome,pos="0.552,0.761"]
year [pos="0.197,0.697"]
background -> educ
background -> wage
compulsory_schooling_laws -> educ
educ -> job_connections
educ -> wage
job_connections -> wage
location -> educ
location -> wage
u1 -> background
u1 -> location
year -> educ
year -> wage
}') %>%
ggdag()+
theme_dag()
R
text = FALSE, use_labels = "name
inside ggdag()
, makes it easier to readdagitty('dag {
bb="0,0,1,1"
background [pos="0.413,0.335"]
compulsory_schooling_laws [pos="0.544,0.076"]
educ [exposure,pos="0.185,0.121"]
job_connections [pos="0.302,0.510"]
location [pos="0.571,0.431"]
u1 [pos="0.539,0.206"]
wage [outcome,pos="0.552,0.761"]
year [pos="0.197,0.697"]
background -> educ
background -> wage
compulsory_schooling_laws -> educ
educ -> job_connections
educ -> wage
job_connections -> wage
location -> educ
location -> wage
u1 -> background
u1 -> location
year -> educ
year -> wage
}') %>%
ggdag(., text = FALSE, use_labels = "name")+
theme_dag()
ggdag
: Additional ToolsX
(exposure
) and Y
(outcome
), you can use ggdag_paths()
to have it show all possible paths between \(X\) and \(Y\)!ggdag
: Additional ToolsX
(exposure
) and Y
(outcome
), you can use ggdag_adjustment_set()
to have it show you what you need to control for in order to identify \(X \rightarrow Y\)!ggdag
: Additional ToolsimpliedConditionalIndependencies()
from the dagitty
package to have it show the testable implications from dagitty.netbckg _||_ conx | educ
bckg _||_ laws
bckg _||_ loc | u1
bckg _||_ year
conx _||_ laws | educ
conx _||_ loc | educ
conx _||_ u1 | bckg, loc
conx _||_ u1 | educ
conx _||_ year | educ
educ _||_ u1 | bckg, loc
laws _||_ loc
laws _||_ u1
laws _||_ wage | bckg, educ, loc, year
laws _||_ year
loc _||_ year
u1 _||_ wage | bckg, loc
u1 _||_ year
How does dagitty.net and ggdag
know how to identify effects, or what to control for, or what implications are testable?
Comes from fancy math called “do-calculus”
Typical notation:
\(X\) is independent variable of interest
\(Y\) is dependent or “response” variable
Other variables use other letters
You can of course use words instead of letters!
Arrows indicate causal effect (& direction)
Two types of causal effect:
Arrows indicate causal effect (& direction)
Two types of causal effect:
Direct effects: \(X \rightarrow Y\)
Indirect effects: \(X \rightarrow M \rightarrow Y\)
Arrows indicate causal effect (& direction)
Two types of causal effect:
Direct effects: \(X \rightarrow Y\)
Indirect effects: \(X \rightarrow M \rightarrow Y\)
\(Z\) is a “confounder”: it causes both \(X\) and \(Y\)
\(cor(X,Y)\) is made up of two parts:
Failing to control for \(Z\) will bias our estimate of the causal effect of \(X \rightarrow Y\)!
\[Y_i=\beta_0+\beta_1 X_i\]
By leaving out \(Z_i\), this regression is biased
\(\hat{\beta}_1\) picks up both:
Ideally, if we ran a randomized control trial and randomly assigned different values of \(X\) to different individuals, this would delete the arrow between \(Z\) and \(X\)
This would only leave the front-door, \(X \rightarrow Y\)
But we can rarely run an ideal RCT
Instead of an RCT, if we can just “adjust for” or “control for” \(Z\), we can block the back-door path \(X \leftarrow Z \rightarrow Y\)
This would only leave the front-door path open, \(X \rightarrow Y\)
“As good as” an RCT!
Using our terminology from last class, we have an outcome \((Y)\), and some treatment
But there are unobserved factors \((u)\)
\[Y_i = \beta_0 + \beta_1 Treatment + u_i\]
Using our terminology from last class, we have an outcome \((Y)\), and some treatment
But there are unobserved factors \((u)\)
\[Y_i = \beta_0 + \beta_1 Treatment + u_i\]
\[cor(treatment,u)=0\]
Using our terminology from last class, we have an outcome \((Y)\), and some treatment
But there are unobserved factors \((u)\)
\[Y_i = \beta_0 + \beta_1 Treatment + u_i\]
Controlling for a single variable along a long causal path is sufficient to block that path!
Causal path: \(X \rightarrow Y\)
Backdoor path: \(X \leftarrow A \rightarrow B \rightarrow C \rightarrow Y\)
It is sufficient to block this backdoor by controlling either \(A\) or \(B\) or \(C\)!
Controlling for a single variable along a long causal path is sufficient to block that path!
Causal path: \(X \rightarrow Y\)
Backdoor path: \(X \leftarrow A \rightarrow B \rightarrow C \rightarrow Y\)
It is sufficient to block this backdoor by controlling either \(A\) or \(B\) or \(C\)!
To identify the causal effect of \(X \rightarrow Y\):
“Back-door criterion”: control for the minimal amount of variables sufficient to ensure that no open back-door exists between \(X\) and \(Y\)
Example: in this DAG, control for \(Z\)
Example:
Example:
\(X \rightarrow Y\) (front-door)
\(X \leftarrow A \rightarrow B \rightarrow Y\) (back-door)
Need only control for \(A\) or \(B\) to block the back-door path
\(C\) and \(Z\) have no effect on \(X\), and therefore we don’t need to control for them!
Example:
Example:
Are you less likely to get the flu if you are hit by a bus?
\(Flu\): getting the flu
\(Bus\): being hit by a bus
\(Hos\): being in the hospital
Both \(Flu\) and \(Bus\) send you to \(Hos\) (arrows)
Conditional on being in \(Hos\), negative correlation between \(Flu\) and \(Bus\) (spurious!)
Example
\(X \rightarrow M \rightarrow Y\) (front-door)
\(X \leftarrow A \rightarrow Y\) (back-door)
\(X \leftarrow B \rightarrow Y\) (back-door)
Should we control for \(M\)?
If we did, this would block the front-door!
Example
\(X \rightarrow M \rightarrow Y\) (front-door)
\(X \leftarrow A \rightarrow Y\) (back-door)
\(X \leftarrow B \rightarrow Y\) (back-door)
If we control for \(M\), would block the front-door!
If we can estimate \(X \rightarrow M\) and \(M \rightarrow Y\) (note, no back-doors to either of these!), we can estimate \(X \rightarrow Y\)
This is the front door method
Tobacco industry claimed that \(cor(smoking, cancer)\) could be spurious due to a confounding gene
that affects both!
gene
is unobservableSuppose smoking causes tar
buildup in lungs, which cause cancer
We should not control for tar
, it’s on the front-door path
Thus, to achieve causal identification, control for the minimal amount of variables such that: