forked from KellyLuo233/mental_illness.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathanxiety_report.Rmd
340 lines (307 loc) · 11.1 KB
/
anxiety_report.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
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
---
title: "Anxiety"
output:
html_document:
code_folding: hide
toc: true
toc_float:
toc_collapsed: true
theme: journal
---
```{r, message=FALSE}
library(tidyverse)
library(viridis)
library(plotly)
knitr::opts_chunk$set(
echo = TRUE,
warning = FALSE,
fig.width = 8,
fig.height = 6,
out.width = "90%"
)
options(
ggplot2.continuous.colour = "viridis",
ggplot2.continuous.fill = "viridis"
)
scale_colour_discrete = scale_colour_viridis_d
scale_fill_discrete = scale_fill_viridis_d
theme_set(
theme_minimal() +
theme(
legend.position = "bottom",
plot.title = element_text(hjust = 0.5)
)
)
```
```{r, message=FALSE}
anx_dep =
read_csv("data/nhis_data01.csv") %>%
janitor::clean_names() %>%
filter(year>=2015) %>%
select(year, worrx, worfreq, worfeelevl, deprx, depfreq, depfeelevl, age, sex, marst, poverty) %>%
mutate(
sex = recode_factor(sex,
"1" = "Male",
"2" = "Female"),
marst = recode_factor(marst,
"10" = "Married", "11" = "Married", "12" = "Married", "13" = "Married",
"20" = "Widowed",
"30" = "Divorced",
"40" = "Separated",
"50" = "Never married"),
poverty = recode_factor(poverty,
"11" = "Less than 1.0", "12" = "Less than 1.0",
"13" = "Less than 1.0", "14" = "Less than 1.0",
"21" = "1.0-2.0", "22" = "1.0-2.0",
"23" = "1.0-2.0", "24" = "1.0-2.0",
"25" = "1.0-2.0",
"31" = "2.0 and above","32" = "2.0 and above",
"33" = "2.0 and above","34" = "2.0 and above",
"35" = "2.0 and above","36" = "2.0 and above",
"37" = "2.0 and above","38" = "2.0 and above"),
worrx = recode_factor(worrx,
'1' = "no",
'2' = "yes"),
worfreq = recode_factor(worfreq,
'1' = "Daily",
'2' = "Weekly",
'3' = "Monthly",
'4' = "A few times a year",
'5' = "Never"),
worfeelevl = recode_factor(worfeelevl,
'1' = "A lot",
'3' = "Somewhere between a little and a lot",
'2' = "A little"),
deprx = recode_factor(deprx, '1' = "no", '2' = "yes"),
depfreq = recode_factor(depfreq, '1' = "Daily", '2' = "Weekly",
'3' = "Monthly", '4' = "A few times a year",
'5' = "Never"),
depfeelevl = recode_factor(depfeelevl, '1' = "A lot",
'3' = "Somewhere between a little and a lot",
'2' = "A little"),
age = ifelse(age>=85, NA, age)
)
```
## Medication Proportion
According to the plot, from 2015 to 2021, the percentage of people who report taking medication for worry, stress or anxiety is constantly increasing from 9.13% in 2015 to 13.57% in 2021. We can observe a rapid increase from 2017 to 2019 and, contrary to our expectations, a relatively slow increase from 2019 to 2020. The effect of COVID-19 on anxiety percentage is not evident in this plot.
```{r, message=FALSE}
anx_dep %>%
drop_na(worrx) %>%
group_by(year, worrx) %>%
summarize(wor_num = n()) %>%
pivot_wider(
names_from = worrx,
values_from = wor_num
) %>%
mutate(
wor_percentage = yes/(no + yes)*100,
text_label = str_c(yes, " out of ", no + yes)
) %>%
ungroup() %>%
plot_ly(
y = ~wor_percentage,
x = ~year,
color = ~year,
type = "bar",
colors = "viridis",
text = ~text_label
) %>%
layout(
title = "Percentage of people reported taken medication for anxiety",
xaxis = list (title = ""),
yaxis = list (title = "Percentage"),
showlegend = FALSE
) %>%
hide_colorbar()
```
### Sex Difference
Stratify the reported percentage of people taking medication for worried, nervous, or anxious feelings by biological sex, we can observe a much higher percentage among females than males. There is also a faster increase in the percentage among females from 14.41% in 2018 to 16.52% in 2019. Among males, the percentage is relatively stable from 2018 to 2020, while there is an increase from 2020 to 2021. Considering the fact that COVID-19 is prevalent in the United States starting in 2020, the effect of COVID-19 on anxiety percentage is not evident for either sex.
```{r, message=FALSE}
anx_dep %>%
drop_na(sex, worrx) %>%
group_by(sex, year, worrx) %>%
summarize(wor_num = n()) %>%
pivot_wider(
names_from = worrx,
values_from = wor_num
) %>%
mutate(
wor_percentage = yes/(no + yes)*100,
text_label = str_c(yes, " out of ", no + yes)
) %>%
ungroup() %>%
plot_ly(
y = ~wor_percentage,
x = ~year,
color = ~sex,
type = "bar",
colors = "viridis",
text = ~text_label
) %>%
add_trace(
x = ~year,
y = ~wor_percentage,
color = ~sex,
type='scatter',
mode='lines+markers'
) %>%
layout(
title = "Percentage of people reported taken medication for anxiety, by biological sex",
xaxis = list (title = ""),
yaxis = list (title = "Percentage"),
legend = list(orientation = 'h')
)
```
### Family Income
Stratify the percentage of people reported taken medication for worried, nervous, or anxious feelings by the ratio of household income to the poverty line, we can clearly see that the lower the household income, the higher their percentage. The percentage among the lowest income stratum decreased rapidly from 17.30% in 2017 to 15.84% in 2018, which is the opposite of what happened in the other two strata. Although the percentage of the lowest income stratum decreased rapidly from 2017 to 2018, they still had the highest percentage of the three strata, and this decrease was followed by a rapid increase from 15.84% in 2018 to 18.58% in 2019. From 2020 to 2021, the percentage decreases for the other two strata, while for the highest-income stratum, the percentage steadily increases. Although household income appears to have an effect on anxiety, the effect of COVID-19 on anxiety is not evident for all three strata.
```{r, message=FALSE}
anx_dep %>%
drop_na(poverty, worrx) %>%
group_by(poverty, year, worrx) %>%
summarize(wor_num = n()) %>%
pivot_wider(
names_from = worrx,
values_from = wor_num
) %>%
mutate(
wor_percentage = yes/(no + yes)*100,
text_label = str_c(yes, " out of ", no + yes)
) %>%
ungroup() %>%
plot_ly(
y = ~wor_percentage,
x = ~year,
color = ~poverty,
type = "scatter",
mode = "lines+markers",
colors = "viridis",
text = ~text_label
) %>%
layout(
title = "Percentage of people reported taken medication for anxiety, by household income",
xaxis = list (title = ""),
yaxis = list (title = "Percentage"),
legend = list(orientation = 'h')
)
```
### Martial Status
Stratify the percentage of people reported taken medication for worried, nervous, or anxious feelings by current martial status, we can observe a rapid increase from 14.31% in 2019 to 17.49% in 2020 in those separated. Considering the timing, this could be an effect of COVID-19.For other strata, the effect of COVID-19 is not obvious.
```{r, message=FALSE}
anx_dep %>%
drop_na(marst, worrx) %>%
group_by(marst, year, worrx) %>%
summarize(wor_num = n()) %>%
pivot_wider(
names_from = worrx,
values_from = wor_num
) %>%
mutate(
wor_percentage = yes/(no + yes)*100,
text_label = str_c(yes, " out of ", no + yes)
) %>%
ungroup() %>%
plot_ly(
y = ~wor_percentage,
x = ~year,
color = ~marst,
type = "scatter",
mode='lines+markers',
colors = "viridis",
text = ~text_label
) %>%
layout(
title = "Percentage of people reported taken medication for anxiety, by martial status",
xaxis = list (title = ""),
yaxis = list (title = "Percentage"),
legend = list(orientation = 'h')
)
```
## Age Distribution
As we can see from the plot, the age distribution of people taking medication for worried, nervous, or anxious feelings did not change much from 2015 to 2021. The effect of COVID-19 was not evident in this plot.
```{r}
age_plot =
anx_dep %>%
drop_na(age, worrx) %>%
ggplot(
aes(x=age, group=worrx, fill=worrx)
) +
geom_density(alpha=0.4) +
facet_wrap(~year) +
labs(
title = "Age distribution of whether reported taken medication for anxiety",
fill = "Whether taken medicine for anxiety"
)
ggplotly(age_plot) %>%
layout(legend = list(orientation = "h"))
```
## Frequency
From this bar plot about how often people feel worried, nervous, or anxious, we can observe that the frequency is steadily increasing from 2015 to 2021. There is also a rapid increase from 2019 to 2020, which could be COVID-19 related.
```{r, message=FALSE}
anx_dep %>%
drop_na(worfreq) %>%
group_by(year, worfreq) %>%
summarize(count = n()) %>%
group_by(year) %>%
summarize(
percentage=100 * count/sum(count),
sum_count = sum(count),
worfreq = worfreq,
count=count
) %>%
mutate(
text_label = str_c(count, " out of ", sum_count)
) %>%
plot_ly(
y = ~percentage,
x = ~year,
color = ~worfreq,
type = "bar",
colors = "viridis",
text = ~text_label
) %>%
layout(
title = "Frequency of anxiety",
xaxis = list (title = ""),
yaxis = list (title = "Percentage"),
barmode = 'stack',
legend = list(orientation = 'h')
)
```
## Stages of Anxiety
From this bar plot about the level of worried, nervous, or anxious feelings people felt last time, we can observe a relatively large increase from 2018 to 2019 in the percentage of people who felt worried, stressed, or anxious a lot or between a little and a lot. However, the distribution did not change much from 2019 to 2020, which indicates that the impact of COVID-19 on level of anxiety may not be significant.
```{r, message=FALSE}
anx_dep %>%
drop_na(worfeelevl) %>%
group_by(year, worfeelevl) %>%
summarize(count = n()) %>%
group_by(year) %>%
summarize(
percentage=100 * count/sum(count),
sum_count = sum(count),
worfeelevl = worfeelevl,
count=count
) %>%
mutate(
text_label = str_c(count, " out of ", sum_count)
) %>%
plot_ly(
y = ~percentage,
x = ~year,
color = ~worfeelevl,
type = "bar",
colors = "viridis",
text = ~text_label
) %>%
layout(
title = "Level of anxiety",
xaxis = list (title = ""),
yaxis = list (title = "Percentage"),
barmode = 'stack',
legend = list(orientation = 'h')
)
```
## Conclusion
- Contrary to our expectation, the association between COVID-19 and anxiety may not be significant from the plots.
- There is no major change in the trend of anxiety from 2019 to 2020.
- The increase in anxiety actually occurred prior to the COVID-19 period.
- Other factors such as biological sex and household income seem to have an greater impact on anxiety.