library(dagitty) #Library to create and analyze causal graphs
library(ggplot2) #Plotting
suppressWarnings(suppressMessages(library(ggdag))) #library to plot causal graphs

Time Series Causal Inference

Example Applications

Time Series Statistical Properties

Dependence and Limit Theorems

Inference For Time Series

Point Interventions

Difference in Means Estimator

Repeated experiments

repexdag<-dagify(Y3~X3+Y2+X2+Y1+X1,Y2~X2+Y1+X1,Y1~X1) #create graph 
#Set position of nodes so they lie on a straight line
  coords<-list(x=c(X1 = 0, Y1 = 0, X2=1, Y2=1, X3=2, Y3=2),
               y=c(X1 = 1, Y1 = 0, X2=1, Y2=0, X3=1, Y3=0))
  coords_df<-coords2df(coords)
  coordinates(repexdag)<-coords2list(coords_df)
ggdag(repexdag, edge_type = "arc")+theme_dag_blank()+labs(title="X randomized in every time period") #Plot causal graph

Generalized IRFs

Sequential Conditional Random Assignment

seqdag<-dagify(Y4~X4+Y3+X3+Y2+X2+Y1+X1,Y3~X3+Y2+X2+Y1+X1,Y2~X2+Y1+X1,Y1~X1,
                 X4~Y3+X3+Y2+X2+Y1+X1,X3~Y2+X2+Y1+X1, X2~Y1+X1) #create graph 
#Set position of nodes so they lie on a straight line
  coords<-list(x=c(X1 = 0, Y1 = 0, X2=1, Y2=1, X3=2, Y3=2, X4=3, Y4=3),
               y=c(X1 = 1, Y1 = 0, X2=1, Y2=0, X3=1, Y3=0, X4=1, Y4=0))
  coords_df<-coords2df(coords)
  coordinates(seqdag)<-coords2list(coords_df)
ggdag(seqdag, edge_type = "arc")+theme_dag_blank()+labs(title="X may depend on all past variables") #Plot causal graph