include(joinpath(dirname(Base.active_project()), "scripts", "book_bootstrap.jl"))
@auto_using DAGMakie CairoMakie Graphs
# Nodes: 1=W, 2=C, 3=C* (≡ C^rec), 4=R_C [, 5=Z]
g_mcar = SimpleDiGraph(4)
add_edge!(g_mcar, 1, 2); add_edge!(g_mcar, 2, 3); add_edge!(g_mcar, 4, 3)
g_mar = SimpleDiGraph(4)
add_edge!(g_mar, 1, 2); add_edge!(g_mar, 2, 3); add_edge!(g_mar, 4, 3); add_edge!(g_mar, 1, 4)
g_conf = SimpleDiGraph(5)
add_edge!(g_conf, 1, 2); add_edge!(g_conf, 2, 3); add_edge!(g_conf, 4, 3)
add_edge!(g_conf, 5, 2); add_edge!(g_conf, 5, 4)
g_mnar = SimpleDiGraph(4)
add_edge!(g_mnar, 1, 2); add_edge!(g_mnar, 2, 3); add_edge!(g_mnar, 4, 3); add_edge!(g_mnar, 2, 4)
# Planar grid: W→C on top, R_C→C* on bottom. For MNAR, place R_C under C
# so C→R_C is vertical rather than a diagonal across the square. Z sits to the left.
layout4 = Point2f[
Point2f(0.0, 1.0), Point2f(1.6, 1.0), Point2f(1.6, 0.0), Point2f(0.0, 0.0),
]
layout4_mnar = Point2f[
Point2f(0.0, 1.0), Point2f(1.6, 1.0), Point2f(2.8, 1.0), Point2f(1.6, 0.0),
]
layout5 = Point2f[
Point2f(1.2, 1.0), Point2f(2.8, 1.0), Point2f(2.8, 0.0), Point2f(1.2, 0.0),
Point2f(0.0, 0.5),
]
const _miss_lab4 = ["W", "C", "C*", "R_C"]
const _miss_lab5 = ["W", "C", "C*", "R_C", "Z"]
# Observed / latent-complete / recorded / response / confounder
const _col_obs = RGBf(0.30, 0.55, 0.70)
const _col_lat = RGBf(0.85, 0.65, 0.05)
const _col_R = RGBf(0.55, 0.55, 0.55)