Causality

Causal Models

Control: Review

d-separation in general graphs

Backdoor Criterion

Backdoor criterion, intuition (Code)

library(dagitty) #Library to create and analyze causal graphs
library(ggdag) #library to plot causal graphs
#Check if W satisfies criterion
isAdjustmentSet(graphname,"W",exposure="X",outcome="Y")
#Find variables that satisfy criterion, if they exist
adjustmentSets(graphname,exposure="X",outcome="Y") 

Backdoor criterion, intuition

#Check if W satisfies criterion
isAdjustmentSet(graphname,"W",exposure="X",outcome="Y")
#Find variables that satisfy criterion, if they exist
adjustmentSets(graphname,exposure="X",outcome="Y") 

Example: finding adjustment sets (Code)

complicatedgraph<-dagify(Y~A+C,B~X+Y,A~X,X~C,D~B) #create graph
#Set position of nodes 
coords<-list(x=c(X = 0, A = 1, B = 1, C=1, Y=2, D=2),
     y=c(X = 0, A = 0.1, B=0, C=-0.1, Y = 0, D=0.1)) 
coords_df<-coords2df(coords)
coordinates(complicatedgraph)<-coords2list(coords_df)

#Plot causal graph  
ggdag(complicatedgraph)+theme_dag_blank()
  +labs(title="Complicated Graph") 

Example: finding adjustment sets

Measuring effect of X on Y

adjustmentSets(complicatedgraph,exposure="X",outcome="Y")
##  { C }

Imperfect control (Code)

confoundgraph<-dagify(Y~X+W,X~W) #create graph
#Set position of nodes 
coords<-list(x=c(X = 0, W = 1, Y = 2),
          y=c(X = 0, W = -0.1, Y = 0)) 
coords_df<-coords2df(coords)
coordinates(confoundgraph)<-coords2list(coords_df)
#Plot causal graph
ggdag(confoundgraph)+theme_dag_blank() 

Imperfect control

Imperfect Control, ctd

Endogeneity

An alternative: Instrumental variables (IV)

Goal of IV estimation

Causal graph of IV model (Code)

ivgraph<-dagify(Y~X+W,X~W, X~Z) #create graph
#Set position of nodes 
coords<-list(x=c(X = 0, W = 1, Y = 2, Z=-1),
          y=c(X = 0, W = 0.1, Y = 0, Z=0)) 
coords_df<-coords2df(coords)
coordinates(ivgraph)<-coords2list(coords_df)
#Plot causal graph
ggdag(ivgraph)+theme_dag_blank()
  +labs(title="Instrumental Variables") 

Causal graph of IV model

Finding an instrument

Estimation in IV Model

One more assumption

Finding \(\beta_1\) using IV

Finding \(\beta_1\)

Solving the system

\[E[Y-\beta_0-\beta_1X]=0\] \[E[Z(Y-\beta_0-\beta_1X)]=0\]

IV Estimator

\[\hat{\beta}_1^{IV}=\frac{\frac{1}{n}\sum_{i=1}^{n}(Z_i-\bar{Z})(Y_i-\bar{Y})}{\frac{1}{n}\sum_{i=1}^{n}(Z_i-\bar{Z})(X_i-\bar{X})}\] \[\hat{\beta}_0^{IV}=\frac{1}{n}\sum_{i=1}^{n}Y_i-\hat{\beta}_1^{IV}\frac{1}{n}\sum_{i=1}^{n}X_i\]

Relevance Condition

Exclusion restriction

Reduced Form and First Stage

IV interpretation

  1. First stage \(\pi\) small, but total effect \(\rho\) of instrument on outcome big
    • Then effect must have come from very large effect of \(X\)
    • \(X\) didn’t move much even though outcome did
  2. First stage \(\pi\) big but total effect \(\rho\) of instrument on outcome small
    • \(X\) must have small effect
    • \(X\) moved a lot with the experiment but outcome \(Y\) mostly stayed the same

Example: Effect of longer prison sentences on recidivism

Endogeneity problem

IV solution

IV Results

Conclusions

Next 2 classes