-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfigure15.r
More file actions
85 lines (81 loc) · 3.21 KB
/
figure15.r
File metadata and controls
85 lines (81 loc) · 3.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# Source simulation data
source("sim_viz_preamble.r")
source("ggsavepdf.r")
# system("module load imagemagick/7.1.1-39")
# =============================================================================
# 15. Plot: Treatment Effect Coverage (Subgroup 1)
# =============================================================================
factor = 2.5
p1 <- summarised %>%
filter(a_interaction == "Aggregation bias") %>%
ggplot(aes(
x = as.factor(round(tau, 2)),
y = 100 * cov_subgroup1,
color = method, shape = method, group = method
)) +
geom_abline(intercept = 95, slope = 0, linetype = "dashed") +
geom_line() +
geom_point(size = 4) +
scale_shape_manual(values = 0:11) +
scale_y_continuous(breaks = c(seq(30, 90, 10)), labels = ~ paste0(.x, "%")) +
labs(
x = expression("Treatment heterogeneity" ~ (tau)),
y = "",
title = "Noncollapsibility with confounding \n (aggregation bias)"
) +
# scale_y_continuous(breaks = seq(90, 100, 2), labels = ~ paste0(.x, "%")) +
facet_grid(k ~ scenario, switch = "y",
labeller = labeller(k = ~ paste0("k = ", .x))) +
defined_theme +
defined_shade() +
theme(
text = element_text(size = 11 * factor),
axis.text.x = element_text(size = 9 * factor),
axis.text.y = element_text(size = 9 * factor),
axis.title.x = element_text(size = 10 * factor),
axis.title.y = element_text(size = 10 * factor),
strip.text.x = element_text(size = 10 * factor),
strip.text.y = element_text(size = 10 * factor),
legend.position = "bottom",
legend.justification = "bottom",
plot.title = element_text(size = 12 * factor),
plot.subtitle = element_text(size = 10 * factor),
plot.caption = element_text(size = 8 * factor)
)
p2 <- summarised %>%
filter(a_interaction != "Aggregation bias") %>%
ggplot(aes(
x = as.factor(round(tau, 2)),
y = 100 * cov_subgroup1,
color = method, shape = method, group = method
)) +
geom_abline(intercept = 95, slope = 0, linetype = "dashed") +
geom_line() +
geom_point(size = 4) +
scale_shape_manual(values = 0:11)+
scale_y_continuous(breaks = seq(92, 98, 2), labels = ~ paste0(.x, "%")) +
labs(
x = expression("Treatment heterogeneity" ~ (tau)),
y = "",
title = "Noncollapsibility without confounding \n (no aggregation bias)"
) +
facet_grid(k ~ scenario, switch = "y",
labeller = labeller(k = ~ paste0("k = ", .x))) +
defined_theme +
defined_shade() +
theme(
text = element_text(size = 11 * factor),
axis.text.x = element_text(size = 9 * factor),
axis.text.y = element_text(size = 9 * factor),
axis.title.x = element_text(size = 10 * factor),
axis.title.y = element_text(size = 10 * factor),
strip.text.x = element_text(size = 10 * factor),
strip.text.y = element_text(size = 10 * factor),
legend.position = "bottom",
legend.justification = "center",
plot.title = element_text(size = 12 * factor),
plot.subtitle = element_text(size = 10 * factor),
plot.caption = element_text(size = 8 * factor)
)
p <- wrap_elements(p2) / wrap_elements(p1)
ggsavepdf("img/viz_coverage_beta1.png", plot = p, width = 22, height = 22)