Goals:

  • Show that \(Y(w) \perp\!\!\!\perp W\) can be extracted from a SWIG


DAG

Define and plot the DAG representing the structural causal model \[\begin{align*} W = & f_W(U_W) \\ Y = & f_Y(W,U_Y) \end{align*}\]

using the dagitty infrastructure

library(tidyverse)  # For ggplot2 and friends
library(dagitty)    # For dealing with DAG math
library(ggdag)      # For making DAGs with ggplot

## A/B test
## Randomized controlled trial
## Randomized experiment

# DAG
dag = dagitty('dag{
W [exposure,pos = "1,1"]
Y [outcome,pos = "2,1"]
W -> Y
}')

ggdag(dag) + theme_dag()

Check which (conditional) independences between observed variables are implied by the DAG:

impliedConditionalIndependencies(dag)

Not surprisingly none.



SWIG

Define and plot the SWIG implied by the structural causal model \[\begin{align*} W = & f_W(U_W) \\ Y = & f_Y(W,U_Y) \end{align*}\]

swig_exp = dagitty('dag{
W [exposure,pos = "1,1"]
Yw [outcome,pos = "2,1"]
w [pos = "1.2,1"]
w -> Yw
}')

ggdag(swig_exp) + theme_dag()

and observe that it implies the standard independence \(Y(w) \perp\!\!\!\perp W\) that is created be randomly allocating \(W\)

impliedConditionalIndependencies(swig_exp)
W _||_ Yw
W _||_ w
LS0tDQp0aXRsZTogIkNhdXNhbCBJbmZlcmVuY2U6IERBRyBhbmQgU1dJRyBmb3IgUkNUcyINCnN1YnRpdGxlOiAiQXBwbGljYXRpb24gbm90ZWJvb2siDQphdXRob3I6ICJNaWNoYWVsIEtuYXVzIg0KZGF0ZTogImByIGZvcm1hdChTeXMudGltZSgpLCAnJW0vJXknKWAiDQpvdXRwdXQ6IA0KICBodG1sX25vdGVib29rOg0KICAgIHRvYzogdHJ1ZQ0KICAgIHRvY19mbG9hdDogdHJ1ZQ0KICAgIGNvZGVfZm9sZGluZzogc2hvdw0KLS0tDQoNCg0KR29hbHM6DQoNCi0gU2hvdyB0aGF0ICRZKHcpIFxwZXJwXCFcIVwhXHBlcnAgVyQgY2FuIGJlIGV4dHJhY3RlZCBmcm9tIGEgU1dJRw0KDQo8YnI+DQoNCiMg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