# Panel 1: Prediction
p_predict <- ggplot() +
# Features
annotate("rect", xmin = 0.5, xmax = 3.5, ymin = 2, ymax = 8,
fill = light_gray, color = slate_gray, linewidth = 0.5) +
annotate("text", x = 2, y = 8.5, label = "Features (X)",
fontface = "bold", size = 5, color = primary_blue) +
annotate("text", x = 2, y = 7, label = "Age, BMI,\nBlood Pressure,\nLab Results",
size = 3.5, color = slate_gray) +
# Arrow
annotate("segment", x = 3.5, xend = 5.5, y = 5, yend = 5,
arrow = arrow(length = unit(0.3, "inches")),
linewidth = 1.5, color = primary_blue) +
annotate("text", x = 4.5, y = 5.8, label = "Model\n(pattern matching)",
size = 3, color = slate_gray, fontface = "italic") +
# Outcome
annotate("rect", xmin = 5.5, xmax = 8.5, ymin = 3, ymax = 7,
fill = scales::alpha(primary_blue, 0.15), color = primary_blue, linewidth = 0.5) +
annotate("text", x = 7, y = 7.5, label = "Predicted Y",
fontface = "bold", size = 5, color = primary_blue) +
annotate("text", x = 7, y = 5, label = "\"This patient\nhas heart\ndisease\"",
size = 3.5, color = primary_blue) +
# Title
annotate("text", x = 4.5, y = 9.5, label = "PREDICTION",
fontface = "bold", size = 6, color = primary_blue) +
xlim(0, 9) + ylim(1, 10) +
theme_void()
# Panel 2: Causation
p_cause <- ggplot() +
# Treatment
annotate("rect", xmin = 0.5, xmax = 3, ymin = 4, ymax = 6.5,
fill = scales::alpha(secondary_teal, 0.15), color = secondary_teal, linewidth = 0.5) +
annotate("text", x = 1.75, y = 7, label = "Treatment (D)",
fontface = "bold", size = 5, color = secondary_teal) +
annotate("text", x = 1.75, y = 5.25, label = "Ventilator\nYes/No",
size = 3.5, color = secondary_teal) +
# Confounders
annotate("rect", xmin = 3, xmax = 6, ymin = 7.5, ymax = 9.5,
fill = scales::alpha(accent_coral, 0.15), color = accent_coral,
linewidth = 0.5, linetype = "dashed") +
annotate("text", x = 4.5, y = 8.5, label = "Confounders (U)\nSeverity, Age, ...",
size = 3.2, color = accent_coral) +
# Arrows from confounders
annotate("segment", x = 3.5, xend = 2.5, y = 7.5, yend = 6.5,
arrow = arrow(length = unit(0.2, "inches")),
linewidth = 1, color = accent_coral, linetype = "dashed") +
annotate("segment", x = 5.5, xend = 6.5, y = 7.5, yend = 6.5,
arrow = arrow(length = unit(0.2, "inches")),
linewidth = 1, color = accent_coral, linetype = "dashed") +
# Arrow from treatment to outcome
annotate("segment", x = 3, xend = 5.5, y = 5.25, yend = 5.25,
arrow = arrow(length = unit(0.3, "inches")),
linewidth = 1.5, color = secondary_teal) +
annotate("text", x = 4.25, y = 4.5, label = "Causal effect\n(what we want)",
size = 3, color = secondary_teal, fontface = "italic") +
# Outcome
annotate("rect", xmin = 5.5, xmax = 8, ymin = 4, ymax = 6.5,
fill = scales::alpha(secondary_teal, 0.15), color = secondary_teal, linewidth = 0.5) +
annotate("text", x = 6.75, y = 7, label = "Outcome (Y)",
fontface = "bold", size = 5, color = secondary_teal) +
annotate("text", x = 6.75, y = 5.25, label = "Survival\nYes/No",
size = 3.5, color = secondary_teal) +
# Title
annotate("text", x = 4.5, y = 10.2, label = "CAUSATION",
fontface = "bold", size = 6, color = secondary_teal) +
xlim(0, 9) + ylim(3, 10.5) +
theme_void()
p_predict + p_cause