set.seed(6320)
n_sv <- 300
sv_data <- tibble(
x = runif(n_sv, -1, 1),
y0 = 2 + 0.8 * x + rnorm(n_sv, 0, 0.4),
y1 = 2 + 0.8 * x + 2.5 + rnorm(n_sv, 0, 0.4),
treated = ifelse(x >= 0, 1, 0),
y_obs = ifelse(x >= 0, y1, y0)
)
# Left panel: Potential outcomes (both visible, with scatter)
p_left <- ggplot(sv_data) +
geom_point(aes(x = x, y = y0), color = accent_coral, alpha = 0.3, size = 1.5) +
geom_point(aes(x = x, y = y1), color = secondary_teal, alpha = 0.3, size = 1.5) +
geom_smooth(aes(x = x, y = y0), method = "lm", se = FALSE,
color = accent_coral, linewidth = 1.5) +
geom_smooth(aes(x = x, y = y1), method = "lm", se = FALSE,
color = secondary_teal, linewidth = 1.5) +
geom_vline(xintercept = 0, linetype = "dashed", color = slate_gray, linewidth = 1) +
annotate("text", x = -0.7, y = 1, label = "Y\u2070 (untreated)",
color = accent_coral, fontface = "bold", size = 4.5) +
annotate("text", x = 0.7, y = 5.5, label = "Y\u00b9 (treated)",
color = secondary_teal, fontface = "bold", size = 4.5) +
annotate("text", x = 0, y = 6.8, label = "Cutoff",
color = slate_gray, size = 3.5) +
labs(title = "Potential Outcomes",
subtitle = "Both are smooth everywhere",
x = "Running Variable", y = "Potential Outcomes") +
theme_health_econ() +
coord_cartesian(ylim = c(0, 7))
# Right panel: Realized outcomes (only observed arm, with LATE annotation)
p_right <- ggplot(sv_data, aes(x = x, y = y_obs, color = factor(treated))) +
geom_point(alpha = 0.4, size = 1.5) +
geom_smooth(method = "lm", se = FALSE, linewidth = 1.5) +
geom_vline(xintercept = 0, linetype = "dashed", color = slate_gray, linewidth = 1) +
scale_color_manual(values = c("0" = accent_coral, "1" = secondary_teal),
guide = "none") +
annotate("segment", x = 0, xend = 0, y = 2, yend = 4.5,
arrow = arrow(ends = "both", length = unit(0.1, "inches")),
color = primary_blue, linewidth = 2) +
annotate("label", x = 0.18, y = 3.25, label = "LATE",
color = "white", fill = primary_blue, fontface = "bold",
size = 5, label.size = 0) +
annotate("text", x = 0, y = 6.8, label = "Cutoff",
color = slate_gray, size = 3.5) +
labs(title = "Actual Outcomes",
subtitle = "Treatment switches which outcome we observe",
x = "Running Variable", y = "Observed Outcome") +
theme_health_econ() +
coord_cartesian(ylim = c(0, 7))
p_left + p_right