-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path03_covid_i_stress.2.Rmd
308 lines (210 loc) · 12.5 KB
/
03_covid_i_stress.2.Rmd
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
---
title: "Technical Appendix: Welfare State and Risk Perceptions, Part III"
author: "Nate Breznau"
date: "5/18/2020"
output:
html_document: default
pdf_document: default
---
This is an HTML output of an analysis of public concern about the Covid-19 pandemic and various socioeconomic factors at the country-level. The statistical analysis is performed in R Studio and this is an R Markdown file that it produces.
You will find all of the data files plus the original R code on the Open Science Framework: https://osf.io/muhdz/
```{r setup, warning=F, message=F}
rm(list = ls(all = TRUE))
# this is a function to remove missing data
completeFun <- function(data, desiredCols) {
completeVec <- complete.cases(data[, desiredCols])
return(data[completeVec, ])
}
# need pacman package installed to run this
# install.packages("pacman")
pacman::p_load("dplyr","countrycode","car","ggplot2","jtools","sjPlot","sjmisc","sjlabelled","tidyverse","psych","lavaan","kable","kableExtra","ggrepel","stringi","margins", "ragg")
```
The files
cis_clean.Rmd
covid_i_stress.Rmd
produce the cis2.Rdata file for analysis here.
Figure 1 and the correlation tables are produced in 01_covid_i_stress.Rmd.
```{r round2load, warning=F, message=F, echo=T}
load(file = here::here("data/cis2.Rdata"))
```
### Figure 1. Outbreak Severity by Country and Day
```{r fi1_import}
knitr::include_graphics(here::here("results/Fig1.png"))
```
### Table 1. Descriptive Correlations and Model Indices
Taken from 01_covid_i_stress.Rmd https://osf.io/cbep2/
![Table_1](C:/GitHub/WS_Covid/results/Tbl1.png)
### Fig A. Covid-19 Two Types of Concern, by Country
```{r figA, echo=T}
ggplot(data=finaldf_C, aes(x=concern_society , y=concern_self)) +
geom_point() +
geom_text_repel(aes(label = iso)) +
geom_smooth(method=lm, se=FALSE) +
labs(x= "Coronavirus Concerns, Societal", y = "Coronavirus Concerns, Societal")
```
### Fig B. Days Since Peak and Self Concern by Country
```{r figB, warning = F, message=F, echo=T}
mid <- 0
ggplot(data=finaldf_C, aes(x=days_since_peak, y=concern_self, color = conf_delta)) +
geom_point() +
geom_smooth(method=lm, se=FALSE, color = "gray50", linetype = "dashed") +
geom_text_repel(aes(label = iso), size = 2.5) +
scale_color_gradient2(midpoint=mid, low="blue", mid="gray55", high="red", space="Lab") +
labs(x= "Days Since Outbreak Curve Inflection", y = "Coronavirus Concerns, Personal", color = "Weekly New Cases\n(rate of change)") +
theme(panel.background = element_rect(fill = "white", colour = "grey50"),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
legend.title = element_text(size = 9))
```
### Fig C. Days Since Peak and Society Concern by Country
```{r figC, warning = F, message=F, echo=T}
mid <- 0
ggplot(data=finaldf_C, aes(x=days_since_peak, y=concern_society, color = conf_delta)) +
geom_point() +
geom_smooth(method=lm, se=FALSE, color = "gray50", linetype = "dashed") +
geom_text_repel(aes(label = iso), size = 2.5) +
scale_color_gradient2(midpoint=mid, low="blue", mid="gray55", high="red", space="Lab") +
labs(x= "Days Since Outbreak Curve Inflection", y = "Coronavirus Concerns, Societal", color = "Weekly New Cases\n(rate of change)") +
theme(panel.background = element_rect(fill = "white", colour = "grey50"),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
legend.title = element_text(size = 9))
```
### Fig 2. Welfare State Strength and Covid Concern Society by Country
```{r fig2, warning = F, message=F, echo=T}
agg_png(file = here::here("results/Fig2.png"), width = 1000, height = 700, res = 144)
mid <- 34
ggplot(data=finaldf_C, aes(x=socpolicy, y=concern_self, color=days_since_peak)) +
geom_point() +
geom_smooth(method=lm, se=FALSE, color = "gray50", linetype = "dashed") +
geom_text_repel(aes(label = iso), size = 3.5) +
scale_color_gradient2(midpoint=mid, low="red", mid="gray55", high="blue", space="Lab") +
labs(x= "Welfare State Strength, spending and coverage", y = "Coronavirus Concerns, Personal", color = "Days Since\nCurve Inflection") +
theme(panel.background = element_rect(fill = "white", colour = "grey50"),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
legend.title = element_text(size = 14),
axis.title = element_text(size = 14),
legend.text = element_text(size = 14))
dev.off()
knitr::include_graphics(here::here("results/Fig2.png"))
```
### Fig 3. Welfare State Strength and Covid Concern Society by Country
```{r fig3, warning = F, message=F, echo=T}
mid <- 34
ggplot(data=finaldf_C, aes(x=socpolicy, y=concern_society, color=days_since_peak)) +
geom_point() +
geom_smooth(method=lm, se=FALSE, color = "gray50", linetype = "dashed") +
geom_text_repel(aes(label = iso), size = 2.5) +
scale_color_gradient2(midpoint=mid, low="red", mid="gray55", high="blue", space="Lab") +
labs(x= "Welfare State Strength, spending and coverage", y = "Coronavirus Concerns, Societal", color = "Days Since\nCurve Inflection") +
theme(panel.background = element_rect(fill = "white", colour = "grey50"),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
legend.title = element_text(size = 9))
```
#### Fig D. Government Intervention and Personal Concerns
```{r figD, warning = F, message=F, echo=T}
mid <- 0.7
ggplot(data=finaldf_C, aes(x=intervention, y=concern_self, color=socpolicy)) +
geom_point() +
geom_smooth(method=lm, se=FALSE, color = "gray50", linetype = "dashed") +
geom_text_repel(aes(label = iso), size = 2.5) +
scale_color_gradient2(midpoint=mid, low="blue", mid="gray55", high="red", space="Lab") +
labs(x= "Government Intervention, days before 1st death", y = "Personal Coronavirus Concerns", color = "Welfare State\nStrength") +
theme(panel.background = element_rect(fill = "white", colour = "grey50"),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
legend.title = element_text(size = 9))
```
#### Fig E. Government Intervention and Societal Concerns
```{r figE, warning = F, message=F, echo=T}
mid <- 0.7
ggplot(data=finaldf_C, aes(x=intervention, y=concern_society, color=socpolicy)) +
geom_point() +
geom_smooth(method=lm, se=FALSE, color = "gray50", linetype = "dashed") +
geom_text_repel(aes(label = iso), size = 2.5) +
scale_color_gradient2(midpoint=mid, low="blue", mid="gray55", high="red", space="Lab") +
labs(x= "Government Intervention, days before 1st death", y = "Personal Coronavirus Concerns", color = "Welfare State\nStrength") +
theme(panel.background = element_rect(fill = "white", colour = "grey50"),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
legend.title = element_text(size = 9))
```
## Regressions
### Table 2. Regression Models, Personal Concerns
```{r T2reg, warning = F, message=F}
m1 <- lm(concern_self ~ days_since_peak + conf_delta, data = finaldf_C)
m2 <- lm(concern_self ~ days_since_peak + conf_delta + gdp, data = finaldf_C)
m3 <- lm(concern_self ~ days_since_peak + conf_delta + socpolicy, data = finaldf_C)
m4 <- lm(concern_self ~ days_since_peak + conf_delta + intervention*gdp, data = finaldf_C)
m5 <- lm(concern_self ~ days_since_peak + conf_delta + intervention*socpolicy, data = finaldf_C)
tab_model(m1, m2, m3, m4, m5, p.style = "stars", p.threshold = c(0.10, 0.05, 0.01), show.ci = F, rm.terms = c("(Intercept)"), dv.labels = c("M1", "M2","M3","M4", "M5"), pred.labels = c("Days Since Curve Inflection", "New Cases", "GDP", "Welfare State Strength", "Government Intervention", "Intervention*GDP", "Intervention*Welfare State"), file = here::here("data/Tbl2.html"))
```
#### Model X. reviewer requested model with intervention alone
```{r reviwermodel}
m3x <- lm(concern_self ~ days_since_peak + conf_delta + intervention, data = finaldf_C)
tab_model(m3x)
```
Standardized effect for M3
```{r M3Z, warning = F, message=F}
tab_model(m3, p.style = "stars", p.threshold = c(0.10, 0.05, 0.01), show.ci = F, rm.terms = c("(Intercept)"), show.std = T, dv.labels = c("M3"), pred.labels = c("Case Increase, past week", "Days Since Curve Inflection", "Welfare State, scale", "Government Intervention", "Intervention*Welfare State"))
```
### Table 3. Regression Models, Societal Concerns
```{r T3reg, warning = F, message=F}
m11 <- lm(concern_society ~ days_since_peak + conf_delta, data = finaldf_C)
m12 <- lm(concern_society ~ days_since_peak + conf_delta + gdp + socpolicy, data = finaldf_C)
m13 <- lm(concern_society ~ days_since_peak + conf_delta + socpolicy, data = finaldf_C)
m14 <- lm(concern_society ~ days_since_peak + conf_delta + intervention*gdp, data = finaldf_C)
m15 <- lm(concern_society ~ days_since_peak + conf_delta + intervention*socpolicy, data = finaldf_C)
tab_model(m11, m12, m13, m14, m15, p.style = "stars", p.threshold = c(0.10, 0.05, 0.01), show.ci = F, rm.terms = c("(Intercept)"), dv.labels = c("M1", "M2","M3","M4", "M5"), pred.labels = c("Days Since Curve Inflection", "New Cases", "GDP", "Welfare State Strength", "Government Intervention", "Intervention*GDP", "Intervention*Welfare State"))
```
### Fig 4. Margins Plot for Table 2 and 3
```{r Fig4marg, warning = F, message = F}
m5plot <- plot_model(m5, type = "pred", terms = c("socpolicy", "intervention [10,-30]"))
agg_png(file = here::here("results/Fig4.png"), width = 1000, height = 700, res = 144)
m5plot + labs(title = "", x = "Welfare State Strength", y = "Coronavirus Concerns, Personal") +
scale_color_manual(name="Government\nIntervention",
labels=c("WEAK \n30-days late","STRONG \n5-days advance"),
values=c("red","blue")) +
theme(panel.background = element_blank(),
axis.line = element_line(color = "black"),
legend.spacing.x = unit(0.5, 'cm'),
legend.text = element_text(margin = margin(t = 5), size = 12),
legend.title = element_text(size = 14),
axis.title = element_text(size = 14))
dev.off()
knitr::include_graphics(here::here("results/Fig4.png"))
```
### Fig 5. Margins Plot for Table 3
```{r Fig5marg, warning = F}
m15plot <- plot_model(m15, type = "pred", terms = c("socpolicy", "intervention [10,-30]"))
m15plot + labs(title = "", x = "Welfare State Strength", y = "Coronavirus Concerns, Societal") +
scale_color_manual(name="Government\nIntervention",
labels=c("WEAK \n30-days late","STRONG \n5-days advance"),
values=c("red","blue")) +
theme(panel.background = element_blank(),
axis.line = element_line(color = "black"),
legend.spacing.x = unit(0.5, 'cm'),
legend.text = element_text(margin = margin(t = 5), size = 12),
legend.title = element_text(size = 14),
axis.title = element_text(size = 14))
```
### Table 2a. Table 2 With Outlier Countries.
```{r T1areg, warning = F, message=F}
m1a <- lm(concern_self ~ days_since_peak + conf_delta, data = finaldf_Ca)
m2a <- lm(concern_self ~ days_since_peak + conf_delta + gdp, data = finaldf_Ca)
m3a <- lm(concern_self ~ days_since_peak + conf_delta + socpolicy, data = finaldf_Ca)
m4a <- lm(concern_self ~ days_since_peak + conf_delta + intervention*gdp, data = finaldf_C)
m5a <- lm(concern_self ~ days_since_peak + conf_delta + intervention*socpolicy, data = finaldf_Ca)
tab_model(m1a, m2a, m3a, m4a, m5a, p.style = "stars", p.threshold = c(0.10, 0.05, 0.01), show.ci = F, rm.terms = c("(Intercept)"), dv.labels = c("M1", "M2","M3","M4", "M5"), pred.labels = c("Days Since Curve Inflection", "New Cases", "GDP", "Welfare State Strength", "Government Intervention", "Intervention*GDP", "Intervention*Welfare State"), file = here::here("results/Tbl2a.html"))
```
### Table 3a. Table 3 With Outlier Countries.
```{r T2areg, warning = F, message=F}
m11a <- lm(concern_society ~ days_since_peak + conf_delta, data = finaldf_Ca)
m12a <- lm(concern_society ~ days_since_peak + conf_delta + gdp + socpolicy, data = finaldf_Ca)
m13a <- lm(concern_society ~ days_since_peak + conf_delta + socpolicy, data = finaldf_Ca)
m14a <- lm(concern_society ~ days_since_peak + conf_delta + intervention*gdp, data = finaldf_Ca)
m15a <- lm(concern_society ~ days_since_peak + conf_delta + intervention*socpolicy, data = finaldf_Ca)
tab_model(m11a, m12a, m13a, m14a, m15a, p.style = "stars", p.threshold = c(0.10, 0.05, 0.01), show.ci = F, rm.terms = c("(Intercept)"), dv.labels = c("M1", "M2","M3","M4", "M5"), pred.labels = c("Days Since Curve Inflection", "New Cases", "GDP", "Welfare State Strength", "Government Intervention", "Intervention*GDP", "Intervention*Welfare State"))
```