-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathintraday_change_scraps.R
139 lines (126 loc) · 6.79 KB
/
intraday_change_scraps.R
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#make a set of plots
pred_blk_lat_asi_gg <- ggplot(intraday_preds %>% filter(pm_cat %in% c("Predominantly Black",
"Predominantly Latinx", "Predominantly Asian")),
aes(y = race_eth, x = pred, xmin = lower, xmax = upper,
fill = fct_rev(fct_year))) +
facet_grid(race_eth ~ pm_cat, scales = "free_y") +
geom_bar(stat = "identity", position = "dodge") +
geom_vline(xintercept = 0) +
geom_errorbarh(position = position_dodge(width = 1), height = .5) +
scale_fill_brewer(palette = "Set2") +
scale_x_continuous(limits = c(-.5, .5), labels = scales::percent) +
theme_bw() +
theme(legend.position = "bottom",
strip.text.y = element_blank()) +
guides(fill = guide_legend(reverse = TRUE)) +
labs(x = "\nPredicted Intraday Change", y = "", fill = "",
subtitle = "Model: Ordinary Least Squares, No Metro FE")
#make a set of plots
pred_blk_lat_asi_fe_gg <- ggplot(intraday_preds_fe %>%
filter(pm_cat %in% c("Predominantly Black", "Predominantly Latinx",
"Predominantly Asian", "Predominantly White")),
aes(y = race_eth, x = pred, xmin = lower, xmax = upper,
fill = fct_rev(fct_year))) +
facet_grid(race_eth ~ pm_cat, scales = "free_y") +
geom_bar(stat = "identity", position = "dodge") +
geom_vline(xintercept = 0) +
geom_errorbarh(position = position_dodge(width = 1), height = .5) +
scale_fill_brewer(palette = "Set2") +
scale_x_continuous(limits = c(-.5, .5), labels = scales::percent) +
theme_bw() +
theme(legend.position = "bottom",
strip.text.y = element_blank()) +
guides(fill = guide_legend(reverse = TRUE)) +
labs(x = "\nPredicted Intraday Change", y = "", fill = "",
subtitle = "Model: Ordinary Least Squares, Metro FE")
pred_wht_mxd_gg <- ggplot(intraday_preds %>% filter(pm_cat %in% c("Predominantly White", "White-Mixed")),
aes(y = race_eth, x = pred, xmin = lower, xmax = upper, fill = fct_rev(fct_year))) +
facet_grid(race_eth ~ pm_cat, scales = "free_y") +
geom_bar(stat = "identity", position = "dodge") +
geom_vline(xintercept = 0) +
geom_errorbarh(position = position_dodge(width = 1), height = .5) +
scale_fill_brewer(palette = "Set2") +
scale_x_continuous(limits = c(-.5, .5), labels = scales::percent) +
theme_bw() +
theme(legend.position = "bottom",
strip.text.y = element_blank()) +
guides(fill = guide_legend(reverse = TRUE)) +
labs(x = "\nPredicted Intraday Change", y = "", fill = "",
subtitle = "Model: Ordinary Least Squares, No Metro FE")
pred_wht_mxd_fe_gg <- ggplot(intraday_preds_fe %>% filter(pm_cat %in% c("Predominantly White", "White-Mixed")),
aes(y = race_eth, x = pred, xmin = lower, xmax = upper, fill = fct_rev(fct_year))) +
facet_grid(race_eth ~ pm_cat, scales = "free_y") +
geom_bar(stat = "identity", position = "dodge") +
geom_vline(xintercept = 0) +
geom_errorbarh(position = position_dodge(width = 1), height = .5) +
scale_fill_brewer(palette = "Set2") +
scale_x_continuous(limits = c(-.5, .5), labels = scales::percent) +
theme_bw() +
theme(legend.position = "bottom",
strip.text.y = element_blank()) +
guides(fill = guide_legend(reverse = TRUE)) +
labs(x = "\nPredicted Intraday Change", y = "", fill = "",
subtitle = "Model: Ordinary Least Squares, Metro FE")
pred_wht_mxd_wls_gg <- ggplot(intraday_preds_fe %>% filter(pm_cat %in% c("Predominantly White", "White-Mixed")),
aes(y = race_eth, x = pred, xmin = lower, xmax = upper, fill = fct_rev(fct_year))) +
facet_grid(race_eth ~ pm_cat, scales = "free_y") +
geom_bar(stat = "identity", position = "dodge") +
geom_vline(xintercept = 0) +
geom_errorbarh(position = position_dodge(width = 1), height = .5) +
scale_fill_brewer(palette = "Set2") +
scale_x_continuous(limits = c(-.5, .5), labels = scales::percent) +
theme_bw() +
theme(legend.position = "bottom",
strip.text.y = element_blank()) +
guides(fill = guide_legend(reverse = TRUE)) +
labs(x = "\nPredicted Intraday Change", y = "", fill = "",
subtitle = "Model: Weighted Least Squares, includes Metro FE")
pred_mlt_gg <- ggplot(intraday_preds %>% filter(pm_cat %in% c("Multiethnic", "Non-White-Mixed")),
aes(y = race_eth, x = pred, xmin = lower, xmax = upper, fill = fct_rev(fct_year))) +
facet_grid(race_eth ~ pm_cat, scales = "free_y") +
geom_bar(stat = "identity", position = "dodge") +
geom_vline(xintercept = 0) +
geom_errorbarh(position = position_dodge(width = 1), height = .5) +
scale_fill_brewer(palette = "Set2") +
scale_x_continuous(limits = c(-.5, .5), labels = scales::percent) +
theme_bw() +
theme(legend.position = "bottom",
strip.text.y = element_blank()) +
guides(fill = guide_legend(reverse = TRUE)) +
labs(x = "\nPredicted Intraday Change", y = "", fill = "",
subtitle = "Model: Ordinary Least Squares, No Metro FE")
pred_mlt_fe_gg <- ggplot(intraday_preds_fe %>% filter(pm_cat %in% c("Multiethnic", "Non-White-Mixed")),
aes(y = race_eth, x = pred, xmin = lower, xmax = upper, fill = fct_rev(fct_year))) +
facet_grid(race_eth ~ pm_cat, scales = "free_y") +
geom_bar(stat = "identity", position = "dodge") +
geom_vline(xintercept = 0) +
geom_errorbarh(position = position_dodge(width = 1), height = .5) +
scale_fill_brewer(palette = "Set2") +
scale_x_continuous(limits = c(-.5, .5), labels = scales::percent) +
theme_bw() +
theme(legend.position = "bottom",
strip.text.y = element_blank()) +
guides(fill = guide_legend(reverse = TRUE)) +
labs(x = "\nPredicted Intraday Change", y = "", fill = "",
subtitle = "Model: Ordinary Least Squares, Metro FE")
pred_mlt_wls_gg <- ggplot(intraday_preds_wls %>% filter(pm_cat %in% c("Multiethnic", "Non-White-Mixed")),
aes(y = race_eth, x = pred, xmin = lower, xmax = upper, fill = fct_rev(fct_year))) +
facet_grid(race_eth ~ pm_cat, scales = "free_y") +
geom_bar(stat = "identity", position = "dodge") +
geom_vline(xintercept = 0) +
geom_errorbarh(position = position_dodge(width = 1), height = .5) +
scale_fill_brewer(palette = "Set2") +
scale_x_continuous(limits = c(-.5, .5), labels = scales::percent) +
theme_bw() +
theme(legend.position = "bottom",
strip.text.y = element_blank()) +
guides(fill = guide_legend(reverse = TRUE)) +
labs(x = "\nPredicted Intraday Change", y = "", fill = "",
subtitle = "Model: Weighted Least Squares, includes Metro FE")
#print them to screen
pred_blk_lat_asi_gg
pred_wht_mxd_gg
pred_mlt_gg
pred_blk_lat_asi_fe_gg
pred_wht_mxd_fe_gg
pred_mlt_fe_gg