Code
library(kirkegaard)
## Loading required package: tidyverse
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.1 ──
## ✓ ggplot2 3.3.5 ✓ purrr 0.3.4
## ✓ tibble 3.1.6 ✓ dplyr 1.0.8
## ✓ tidyr 1.2.0 ✓ stringr 1.4.0
## ✓ readr 2.1.2 ✓ forcats 0.5.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
## Loading required package: weights
## Loading required package: Hmisc
## Loading required package: lattice
## Loading required package: survival
## Loading required package: Formula
##
## Attaching package: 'Hmisc'
## The following objects are masked from 'package:dplyr':
##
## src, summarize
## The following objects are masked from 'package:base':
##
## format.pval, units
## Loading required package: assertthat
##
## Attaching package: 'assertthat'
## The following object is masked from 'package:tibble':
##
## has_name
## Loading required package: magrittr
##
## Attaching package: 'magrittr'
## The following object is masked from 'package:purrr':
##
## set_names
## The following object is masked from 'package:tidyr':
##
## extract
## Loading required package: psych
##
## Attaching package: 'psych'
## The following object is masked from 'package:Hmisc':
##
## describe
## The following objects are masked from 'package:ggplot2':
##
## %+%, alpha
## Loading required package: metafor
## Loading required package: Matrix
##
## Attaching package: 'Matrix'
## The following objects are masked from 'package:tidyr':
##
## expand, pack, unpack
##
## Loading the 'metafor' package (version 3.0-2). For an
## introduction to the package please type: help(metafor)
## Loading required package: rlang
##
## Attaching package: 'rlang'
## The following object is masked from 'package:magrittr':
##
## set_names
## The following object is masked from 'package:assertthat':
##
## has_name
## The following objects are masked from 'package:purrr':
##
## %@%, as_function, flatten, flatten_chr, flatten_dbl, flatten_int,
## flatten_lgl, flatten_raw, invoke, splice
##
## Attaching package: 'kirkegaard'
## The following objects are masked from 'package:rlang':
##
## is_error, is_logical
## The following object is masked from 'package:psych':
##
## rescale
## The following object is masked from 'package:assertthat':
##
## are_equal
## The following objects are masked from 'package:purrr':
##
## is_logical, is_numeric
## The following object is masked from 'package:base':
##
## +
d = read_tsv("Nation Vaccines prior to one year of age Totalb doses Group (range of doses) IMR
Andorra DTaP (3), Polio (3), Hib (3), HepB (3), Pneumo (3), MenC (2) 23 3.76
Australia DTaP (3), Polio (3), Hib (3), HepB (4), Pneumo (3), Rota (2) 24 4.75
Austria DTaP (3), Polio (3), Hib (3), HepB (3), Pneumo (3), Rota (2) 23 4.42
Belgium DTaP (3), Polio (3), Hib (3), HepB (3), Pneumo (2) 19 4.44
Canada DTaP (3), Polio (3), Hib (3), HepB (3), Pneumo (3), MenC (2), Flu 24 5.04
Cuba DTaP (3), Polio (3), Hib (3), HepB (4), MenBC (2), BCG 22 5.82
Czech Republic DTaP (3), Polio (3), Hib (3), HepB (3), BCG 19 3.79
Denmark DTaP (2), Polio (2), Hib (2), Pneumo (2) 12 4.34
Finland DTaP (2), Polio (2), Hib (2), Rota (3) 13 3.47
France DTaP (3), Polio (3), Hib (3), Pneumo (2), HepB (2) 19 3.33
Germany DTaP (3), Polio (3), Hib (3), Pneumo (3) 18 3 (18-20) 3.99
Greece DTaP (3), Polio (3), Hib (3), HepB (3), Pneumo (3), MenC (2) 23 5.16
Iceland DTaP (2), Polio (2), Hib (2), MenC (2) 12 3.23
Ireland DTaP (3), Polio (3), Hib (3), HepB (3), Pneumo (2), MenC (2), BCG 23 5.05
Israel DTaP (3), Polio (3), Hib (3), HepB (3) 18 4.22
Italy DTaP (3), Polio (3), Hib (3), HepB (3) 18 5.51
Japan DTaP (3), Polio (2), BCG 12 2.79
Liechtenstein DTaP (3), Polio (3), Hib (3), Pneumo (3) 18 4.25
Luxembourg DTaP (3), Polio (3), Hib (3), HepB (2), Pneumo (3), Rota (3) 22 4.56
Malta DTaP (3), Polio (3), Hib (3) 15 2 (15-17) 3.75
San Marino DTaP (3), Polio (3), Hib (3), HepB (3) 18 5.53
Monaco DTaP (3), Polio (3), Hib (3), HepB (3), Pneumo (3), HepA, BCG 23 5
Netherlands DTaP (4), Polio (4), Hib (4), Pneumo (4) 24 5 (24-26) 4.73
New Zealand DTaP (3), Polio (3), Hib (2), HepB (3) 17 4.92
Norway DTaP (2), Polio (2), Hib (2), Pneumo (2) 12 3.58
Portugal DTaP (3), Polio (3), Hib (3), HepB (3), MenC (2), BCG 21 4 (21-23) 4.78
Singapore DTaP (3), Polio (3), HepB (3), BCG, Flu 17 2.31
Slovenia DTaP (3), Polio (3), Hib (3) 15 4.25
South Korea DTaP (3), Polio (3), HepB (3) 15 4.26
Spain DTaP (3), Polio (3), Hib (3), HepB (3), MenC (2) 20 4.21
Sweden DTaP (2), Polio (2), Hib (2), Pneumo (2) 12 1 (12-14) 2.75
Switzerland DTaP (3), Polio (3), Hib (3), Pneumo (3) 18 4.18
United Kingdom DTaP (3), Polio (3), Hib (3), Pneumo (2), MenC (2) 19 4.85
United States DTaP (3), Polio (3), Hib (3), HepB (3), Pneumo (3), Rota (3), Flu (2) 26 6.22
") %>%
df_legalize_names()
## Rows: 34 Columns: 5
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: "\t"
## chr (3): Nation, Vaccines prior to one year of age, Group (range of doses)
## dbl (2): Totalb doses, IMR
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
#all countries
GG_scatter(d, "Totalb_doses", "IMR", case_names = "Nation", repel_names = T)
## `geom_smooth()` using formula 'y ~ x'

#large countries
d %>% filter(
!Nation %in% c("Andorra", "Liechtenstein", "Monaco", "San Marino")
) %>%
GG_scatter("Totalb_doses", "IMR", case_names = "Nation", repel_names = T) +
xlab("Total vaccine doses") +
ylab("Infant mortality rate")
## `geom_smooth()` using formula 'y ~ x'

GG_save("Pictures/vaccine_IMR.png")
## `geom_smooth()` using formula 'y ~ x'
# replication -------------------------------------------------------------
d2 = read_tsv("
nation Vaccine count Vaccine count all IMR
Austria 27 27 3.15
Belgium 27 29 2.83
Bulgaria 25 25 6.29
Croatia 24 26 4
Cyprus 23 25 3.54
Czech Republic 26 29 2.27
Denmark 18 22 3.13
Estonia 25 26 1.99
Finland 25 27 1.71
France 26 28 3.03
Germany 35 35 3.19
Greece 29 33 2.82
Hungary 19 20 4.05
Iceland 21 21 1.25
Ireland 30 30 2.7
Italy 25 27 2.6
Latvia 36 38 3.34
Liechtenstein 28 30
Lithuania 28 28 4.04
Luxembourg 26 28 2.87
Malta 23 25 4.97
Netherlands 21 31 2.51
Norway 23 25 2.07
Poland 24 25 3.28
Portugal 27 28 2.96
Romania 26 26 6.68
Slovakia 22 23 4.76
Slovenia 25 27 1.87
Spain 26 28 2.35
Sweden 24 27 2.04
") %>% df_legalize_names()
## Rows: 30 Columns: 4
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: "\t"
## chr (1): nation
## dbl (3): Vaccine count, Vaccine count all, IMR
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
#plot
d2 %>%
GG_scatter("Vaccine_count", "IMR", case_names = "nation", repel_names = T) +
xlab("Total vaccine doses") +
ylab("Infant mortality rate")
## `geom_smooth()` using formula 'y ~ x'

GG_save("Pictures/vaccine_IMR_replication.png")
## `geom_smooth()` using formula 'y ~ x'
#not enough variation?
describe2(d$Totalb_doses)
describe2(d2$Vaccine_count)
#cross-time correlations
d$ISO = pu_translate(d$Nation)
d2$ISO = pu_translate(d2$nation)
#join
d_merge = full_join(
d,
d2,
by = "ISO"
)
#IMR over time
GG_scatter(d_merge, "IMR.x", "IMR.y", case_names = "Nation", repel_names = T) +
xlab("Infant mortality rate, authors (CIA)") +
ylab("Infant mortality rate, Emil replication (UN)")
## `geom_smooth()` using formula 'y ~ x'

GG_save("IMR cross-time.png")
## `geom_smooth()` using formula 'y ~ x'
#without Malta
GG_scatter(d_merge %>% filter(Nation != "Malta"), "IMR.x", "IMR.y", case_names = "Nation", repel_names = T) +
xlab("Infant mortality rate, authors (CIA)") +
ylab("Infant mortality rate, Emil replication (UN)")
## `geom_smooth()` using formula 'y ~ x'

#vaccines over time
GG_scatter(d_merge, "Totalb_doses", "Vaccine_count", case_names = "Nation", repel_names = T) +
xlab("Vaccine dose count, authors") +
ylab("Vaccine dose count, Emil replication")
## `geom_smooth()` using formula 'y ~ x'

GG_save("vaccine cross-time.png")
## `geom_smooth()` using formula 'y ~ x'
#no DE NL
GG_scatter(d_merge %>% filter(!Nation %in% c("Germany", "Netherlands")), "Totalb_doses", "Vaccine_count", case_names = "Nation", repel_names = T) +
xlab("Vaccine dose count, authors") +
ylab("Vaccine dose count, Emil replication")
## `geom_smooth()` using formula 'y ~ x'
