-
-
Save bmorphism/2656f5b6cee1243f0013dd1e325add06 to your computer and use it in GitHub Desktop.
Bayes ball
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using CausalInference | |
V = [:U, :T, :P, :O] | |
g = digraph([1=>3, 2=>3, 3=>4, 2=>4, 1=>4]) | |
# Can estimate total effect T=>O without observing U? | |
u = 2 | |
v = 4 | |
∅ = Set{Int}() | |
observed = 2:4 | |
collect(list_covariate_adjustment(g, u, v, ∅, observed)) | |
# No adjustment needed. | |
# What happens if we condition on P? | |
u = 2 | |
C = [3] | |
V2 = [:U, :U, :T, :T, :P, :P, :O, :O] # bayesball_graph has each vertex twice | |
g2 = CausalInference.bayesball_graph(g, u, C) | |
using GraphMakie, GLMakie, NetworkLayout | |
fig = Figure(resolution=(500, 500)) | |
ax1 = Axis(fig[1,1]) | |
hidespines!(ax1) | |
hidedecorations!(ax1) | |
graphplot!(ax1, g; layout=Stress(), arrow_shift = :end, ilabels=V, arrow_size=25, ilabels_fontsize = 30) | |
fig | |
ax2 = Axis(fig[1,2]) | |
hidespines!(ax2) | |
hidedecorations!(ax2) | |
graphplot!(ax2, g2; ilabels=V2, arrow_size=25, ilabels_fontsize = 30) | |
fig | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment