/
15_Total_Nets_2024-2026.Rmd
345 lines (293 loc) · 11.9 KB
/
15_Total_Nets_2024-2026.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
339
340
341
342
---
title: "Frontier plots for each country showing person-years of ITN access vs total nets required with World Bank populations 2020-2035"
author: "Hannah Koenker"
date: "`r format(Sys.time(), '%d %B, %Y')`"
output:
html_document:
toc: yes
toc_depth: 2
toc_float: yes
fig_width: 7
fig_height: 6
fig_caption: yes
df_print: kable
editor_options:
chunk_output_type: console
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE, message = FALSE)
library(haven)
library(tidyverse)
library(geofacet)
library(broom)
library(readxl)
library(janitor)
library(countrycode)
library(data.table)
library(stringr)
library(stringi)
library(ggrepel)
# ![](images/TH_logo.jpg){width=1.0"}
######################
# Set figure theme and colors
######################
theme_set(theme_classic())
```
These graphs show relative and total net need for the three-year period 2024-2026 (inclusive) for countries in sub-Saharan Africa where ITN retention times have been estimated. NOTE: Total populations are used to determine net need; they do NOT take into account subnational areas where populations are not targeted for ITN distribution due to low malaria risk or because the area is targeted for IRS. Thus for countries like Namibia, Botswana, Angola, Kenya, etc, the total net needs here are overestimates. However, the relative savings/increases between ITN strategy options would remain the same irrespective of population size.
Assumptions:
1. The total population of the country receives ITNs
1. ANC and EPI channels are active and reach 6% of the population annually in all scenarios (ANC/EPI nets are included in the totals below)
1. Target population ITN access is 80%.
1. Full Scale CD scenario assumes a very recent mass campaign in 2023. ITN access would be lower for countries/areas where the most recent campaign was in 2021 or 2022
```{r grid}
geofacet_fname <- "data/geofacet_ssa.csv"
ssa_grid <- fread(geofacet_fname) %>%
arrange(code)
```
```{r afpop}
## Extract Africa population data from UN WPP 2022 Demographic Indicators Medium File (https://population.un.org/wpp/Download/Standard/CSV/)
ls <- read_excel("data/MAP_retentiontime_DM_medianlifespan.xlsx", sheet="Sheet1") %>%
clean_names() %>%
filter(type=="MAP") %>%
drop_na(country) %>%
rename(lifespan=median_retention_years) %>%
separate(x95_percent_ci, into = c("lb", "ub"),
sep = "\\s*(–|-)\\s*", convert = TRUE) %>%
select(-site)
dm <- read_excel("../DM Maps/Median lifespan DM multisite.xlsx") %>%
clean_names() %>%
rename(lifespan=medianlifespan) %>%
separate(x95_percent_ci, into = c("lb", "ub"),
sep = "\\s*(–|-)\\s*", convert = TRUE) %>%
drop_na(lifespan) %>%
select(country, lifespan, lb, ub) %>%
mutate(type="DM")
lsdm <- ls %>%
bind_rows(dm) %>%
mutate(iso3=countrycode(country, origin="country.name", destination="iso3c")) %>%
mutate(iso3=case_when(type=="MAP" ~ as.character(iso3)))
levels <- lsdm$country[ls$type=='MAP'][rev(order(ls$lifespan[ls$type=='MAP']))]
lsdm$country_ord <- factor(lsdm$country, levels = levels)
# save a small version of retention times for joining into results tables:
rettimes <- lsdm %>%
filter(type=="MAP") %>%
mutate(name=case_when(country=="Burkina" ~ "Burkina Faso",
# country=="Cote d'Ivoire" ~ "Côte d'Ivoire",
country=="Congo (Republic of)" ~ "Rep. Congo",
TRUE~as.character(country))) %>%
dplyr::select(-type, -country, -lb, -ub, -both, -country_ord) %>%
mutate(name=stri_trans_general(name,"Latin-ASCII")) %>% # remove o-hat from Cote d'Ivoire
mutate(iso_a2 = countrycode(name, origin = "country.name", destination = "iso2c"))
a3levels <- rettimes$iso3 # make a list of the isoa2 countries included in retention times for later
a2levels <- rettimes$iso_a2 # make a list of the isoa2 countries included in retention times for later
afpop <- as.data.frame(read_csv("data/WPP2022_Demographic_Indicators_Medium.csv")) %>%
clean_names() %>%
select(iso2_code, iso3_code, location, t_population1july, time) %>%
mutate(t_population1july=t_population1july*1000) %>%
rename(pop=t_population1july,
year=time,
iso_a2=iso2_code,
country_code=iso3_code,
country_name=location) %>%
filter(year>2019 & year<2041) %>%
filter(iso_a2 %in% a2levels) %>%
pivot_wider(names_from=year, names_prefix="x", values_from=pop)
```
```{r}
table80rtlong <- read_csv("output/table80rtlong.csv")
```
```{r totalnetsdf}
# Figure for Total Nets Needed in a 3 year timeframe (2024-2026) for different scenarios
## WHY DOESN"T ROUTINE GET COUNTED IN SCEN 2 and 3??
tnets3 <- table80rtlong %>%
mutate(scenario_4=na_if(scenario_4,0.1)) %>%
left_join(afpop, by=c("iso3"= "country_code")) %>%
mutate(routine=.06,
tot0=x2024*routine+x2025*routine+x2026*routine+x2026/1.8,
tot2=x2024*(scenario_2/100)+x2025*(scenario_2/100)+x2026*(scenario_2/100)+x2024*routine+x2025*routine+x2026*routine,
tot3=x2024*routine+x2025*routine+x2026*routine+x2026/1.8+x2024*(scenario_3/100)+x2025*(scenario_3/100),
tot4=x2024*routine+x2025*routine+x2026*routine+x2026/scenario_4,
tot5=x2024*routine+x2025*routine+x2026*routine+x2024/scenario_5+x2026/scenario_5,
tot6=x2024*routine+x2025*routine+x2026*routine+x2024/1.8+x2026/1.8,
s0vs2=tot2/tot0,
s0vs3=tot3/tot0,
s0vs4=tot4/tot0,
s0vs5=tot5/tot0,
s0vs6=tot6/tot0)
totalnets <- tnets3 %>%
select(iso3, lifespan, tot0, tot2, tot3, tot4, tot5, tot6) %>%
pivot_longer(contains("tot"), names_to = "scenario", names_prefix = "tot", values_to = "totalnets")
scenpct <- tnets3 %>%
select(iso_a2, iso3, lifespan, contains("s0vs")) %>% # s2vs0, s2vs3, s2vs4, s2vs5
mutate(iso3=case_when(iso_a2=="ER" ~ "ERI",
TRUE ~ as.character(iso3))) %>%
mutate(s0vs0=1,
code=iso3) %>%
pivot_longer(contains("s0"), names_to="scenario", names_prefix = "s0vs", values_to = "pct") %>%
mutate(iso2=countrycode(code, origin="iso3c", destination="iso2c")) %>%
mutate(name=countrycode(code, origin="iso3c", destination="country.name"))
avgscenpct <- scenpct %>%
group_by(scenario) %>%
summarize(mean=mean(pct, na.rm = TRUE))
```
```{r map-3yr-totalnets, warning=FALSE}
scenpct %>%
# filter(name!="Eritrea") %>%
ggplot(aes(x = scenario, y = pct, fill = scenario)) +
geom_col() +
# geom_hline(yintercept = 0) +
# scale_y_continuous(name = "Percent",
# breaks = seq(-1, 1, 0.25),
# labels = seq(-1, 1, 0.25)) +
scale_x_discrete(labels = c("", "", "", "","")) +
scale_y_continuous(labels = scales::percent) +
facet_geo( ~ code, grid = ssa_grid, label = "code") +
labs(title = "Percentage difference in total nets needed over 2024-2026\nto maintain ≥80% ITN access, relative to Status Quo\n(3 year campaigns quantified using population/1.8, with ANC/EPI ITNs)",
x = "",
y = "Percent",
fill = "Scenario") +
scale_fill_brewer(
palette = "Dark2",
labels = c(
"Status Quo",
"Full Scale CD",
"Campaigns + CD",
"3-year Campaigns, \n(tailored)",
"2-year Campaigns, \n(tailored)",
"2-year Campaigns (pop/1.8)"
)
) +
theme_void() +
theme(
# legend.position="none",
# axis.text.x = element_text(angle=45, hjust=1)
# axis.text.x = element_blank(),
axis.line = element_blank(),
axis.line.x = element_blank(),
axis.line.x.bottom=element_line(color="white"),
axis.ticks.x = element_blank(),
# axis.ticks.y = element_blank(),
axis.text = element_text(size = 5),
# panel.grid.major.x = element_line(color = "darkgrey", size = 0),
strip.text.x = element_text(size = 6),
strip.background = element_rect(color = "white", linewidth = .5),
legend.key.size = unit(.25, 'cm'),
#change legend key size
# legend.key.height = unit(1, 'cm'), #change legend key height
# legend.key.width = unit(1, 'cm'), #change legend key width
legend.title = element_text(size = 10), #change legend title font size
legend.text = element_text(size = 8), #change legend text font size)
# axis.text.y = element_blank(),
# axis.ticks = element_blank(),
axis.title.x = element_blank(),
# axis.title.y = element_blank(),
# legend.position="none",
panel.background = element_blank(),
panel.border = element_blank(),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
plot.background = element_blank()
)
```
```{r testplot, eval=FALSE}
mill <- scales::unit_format(unit = "M", scale = 1e-6,accuracy = 0.1)
s2 <- tnets3 %>%
filter(iso3=="CMR") %>%
pull(scenario_2)
s3 <- tnets3 %>%
filter(iso3=="CMR") %>%
pull(scenario_3)
s4 <- tnets3 %>%
filter(iso3=="CMR") %>%
pull(scenario_4)
s5 <- tnets3 %>%
filter(iso3=="CMR") %>%
pull(scenario_5)
# scenario_6 qfactor not needed, it's just 1.8
tnets3 %>%
filter(iso3 == "CMR") %>%
select(contains("tot"),iso3, lifespan, country_name, contains("scenario")) %>%
pivot_longer(cols=contains("tot"), names_to = "scenario") %>%
ggplot(aes(
x = scenario,
y = value,
fill = as.factor(scenario))) +
geom_col() +
geom_text(aes(label=mill(value)), hjust=.5, vjust=-.5) +
scale_fill_brewer(
palette = "Dark2",
labels = c(
"Status Quo (pop/1.8)",
paste0("Full scale CD at pop x ",s2,"%"),
paste0("Campaigns + CD at pop x ",s3,"%"),
paste0("3-year campaigns at pop/",s4),
paste0("2-year campaigns at pop/",s5),
"2-year campaigns (pop/1.8)"
)) +
theme(axis.text.x = element_blank()) +
scale_y_continuous(labels = unit_format(unit = "M", scale = 1e-6)) +
labs(x = "",
y= "Total nets needed 2024-2026",
fill = "Scenario",
title = paste0("Cameroon",": "," years median retention time"))
```
Below are plots for each country, using the quantification factor that maintains 80% ITN access. One campaign is conducted in 2026 in the "Status Quo" and "Campaigns + CD" scenarios, while the Full Scale CD scenario assumes ITN access is relatively high due to a recent campaign in 2023.
```{r totalnets_function}
# function that plots total nets needed for GF 2024-2026 round to achieve 80% ITN access
totalfunctionloop <- function(iso3) {
mill <- scales::unit_format(unit = "M", scale = 1e-6,accuracy = 0.1)
# ptitle <- paste0("p",{{iso3}})
lifespan <- tnets3 %>%
filter(iso3 == {{iso3}}) %>%
pull(lifespan)
name <- tnets3 %>%
filter(iso3 == {{iso3}}) %>%
pull(country_name)
s2 <- tnets3 %>%
filter(iso3=={{iso3}}) %>%
pull(scenario_2)
s3 <- tnets3 %>%
filter(iso3=={{iso3}}) %>%
pull(scenario_3)
s4 <- tnets3 %>%
filter(iso3=={{iso3}}) %>%
pull(scenario_4)
s5 <- tnets3 %>%
filter(iso3=={{iso3}}) %>%
pull(scenario_5)
totplot <- tnets3 %>%
filter(iso3 == {{iso3}}) %>%
select(contains("tot"),iso3, lifespan, country_name, contains("scenario")) %>%
pivot_longer(cols=contains("tot"), names_to = "scenario") %>%
ggplot(aes(
x = scenario,
y = value,
fill = as.factor(scenario))) +
geom_col() +
geom_text(aes(label=mill(value)), hjust=.5, vjust=-.5) +
scale_fill_brewer(
palette = "Dark2",
labels = c(
"Status Quo (pop/1.8)",
paste0("Full scale CD at pop x ",s2,"%"),
paste0("Campaigns + CD at pop x ",s3,"%"),
paste0("3-year campaigns at pop/",s4),
paste0("2-year campaigns at pop/",s5),
"2-year campaigns (pop/1.8)"
)) +
theme(axis.text.x = element_blank()) +
scale_y_continuous(labels = scales::unit_format(unit = "M", scale = 1e-6)) +
labs(x = "",
y= "Total nets needed 2024-2026",
fill = "Scenario",
title = paste0(name,": ",lifespan," years median retention time"))
print(totplot)
plotname <- paste0("figs/tnets3/t3_",iso3,".pdf")
ggsave(plotname)
}
```
```{r totalloop, warning = FALSE, message=FALSE}
for(i in a3levels) {
totalfunctionloop(i)
}
```