library(tidyverse)
library(scales)
library(patchwork)
library(pander)
library(kableExtra)
library(countrycode)
library(sf)
library(here)
source(here("lib", "graphics.R"))
source(here("lib", "pandoc.R"))
my_seed <- 1234
set.seed(my_seed)df_donor <- readRDS(here("data", "derived_data", "df_donor.rds"))
df_donor_us <- readRDS(here("data", "derived_data", "df_donor_usaid.rds"))
df_country_aid <- readRDS(here("data", "derived_data", "df_country_aid.rds"))
df_country_aid_laws <- filter(df_country_aid, laws)
df_autocracies <- readRDS(here("data", "derived_data", "df_autocracies.rds"))num_countries <- df_country_aid_laws %>% distinct(gwcode) %>% nrow()
num_years <- df_country_aid_laws %>% distinct(year) %>% nrow()
year_first <- df_country_aid_laws %>% distinct(year) %>% min()
year_last <- df_country_aid_laws %>% distinct(year) %>% max()Our data includes information about 142 countries across 25 years (from 1990–2014)
(From our AJPS submission): The values here are slightly different from what we had at ISA and MPSA (and our ISQ submission) because we’re now using V-Dem 8.0 and AidData 3.1.
And now the values are even different-er, since we’re using V-Dem 10.0 and have really clean data now.
vars_to_summarize <- read_csv(here("data", "manual_data", "coefs.csv")) %>%
mutate(summary_order = 1:n())
vars_summarized <- df_country_aid_laws %>%
select(one_of(vars_to_summarize$term)) %>%
mutate(total_oda = total_oda / 1000000) %>%
mutate(gdpcap_log = exp(gdpcap_log)) %>%
pivot_longer(names_to = "term", values_to = "value", everything()) %>%
filter(!is.na(value)) %>%
group_by(term) %>%
summarize(N = n(),
Mean = mean(value),
Median = median(value),
`Std. Dev.` = sd(value),
Min = min(value),
Max = max(value)) %>%
ungroup() %>%
left_join(vars_to_summarize, by = "term") %>%
arrange(summary_order) %>%
mutate(across(c(Mean, `Std. Dev.`, Median, Min, Max),
~case_when(
format == "percent" ~ percent_format(accuracy = 0.1)(.),
format == "dollar" ~ dollar_format(accuracy = 1)(.),
format == "number" ~ comma_format(accuracy = 0.1)(.)))) %>%
mutate(N = comma(N)) %>%
select(category, subcategory, Variable = term_clean_table, Source = source,
Mean, `Std. Dev.`, Median, Min, Max, N)
vars_summarized %>%
select(-category, ` ` = subcategory) %>%
kbl() %>%
kable_styling() %>%
pack_rows(index = table(fct_inorder(vars_summarized$category))) %>%
collapse_rows(columns = 1, valign = "top")| Variable | Source | Mean | Std. Dev. | Median | Min | Max | N | |
|---|---|---|---|---|---|---|---|---|
| Outcome | ||||||||
| Total aid (constant 2011 USD, millions) | OECD and AidData | $1,261 | $2,918 | $445 | $0 | $63,233 | 3,435 | |
| Proportion of contentious aid | OECD and AidData | 6.8% | 10.4% | 2.9% | 0.0% | 100.0% | 3,435 | |
| Proportion of aid to domestic NGOs | USAID | 4.2% | 13.9% | 0.2% | 0.0% | 100.0% | 3,435 | |
| Proportion of aid to foreign NGOs | USAID | 13.1% | 20.1% | 0.9% | 0.0% | 100.0% | 3,435 | |
| Treatment | ||||||||
| Total legal barriers | @christensen2013 and @Chaudhry:2016 | 1.6 | 1.9 | 1.0 | 0.0 | 9.5 | 3,435 | |
| Barriers to advocacy | @christensen2013 and @Chaudhry:2016 | 0.3 | 0.5 | 0.0 | 0.0 | 2.0 | 3,435 | |
| Barriers to entry | @christensen2013 and @Chaudhry:2016 | 0.8 | 0.9 | 1.0 | 0.0 | 3.0 | 3,435 | |
| Barriers to funding | @christensen2013 and @Chaudhry:2016 | 0.4 | 0.9 | 0.0 | 0.0 | 4.5 | 3,435 | |
| Core civil society index | @christensen2013 and @Chaudhry:2016 | 0.6 | 0.3 | 0.7 | 0.0 | 1.0 | 3,435 | |
| Confounders | ||||||||
| Human rights and politics | Electoral democracy index (polyarchy) | V-Dem | 0.4 | 0.2 | 0.4 | 0.0 | 0.9 | 3,435 |
| Political corruption index | V-Dem | 0.6 | 0.3 | 0.7 | 0.0 | 1.0 | 3,435 | |
| Rule of law index | V-Dem | 0.5 | 0.3 | 0.4 | 0.0 | 1.0 | 3,435 | |
| Civil liberties index | V-Dem | 0.6 | 0.2 | 0.7 | 0.0 | 1.0 | 3,435 | |
| Physical violence index | V-Dem | 0.6 | 0.3 | 0.6 | 0.0 | 1.0 | 3,435 | |
| Private civil liberties index | V-Dem | 0.6 | 0.3 | 0.7 | 0.0 | 1.0 | 3,435 | |
| Economics and development | GDP per capita (constant 2011 USD) | UN | $6,418 | $10,464 | $2,758 | $92 | $82,410 | 3,435 |
| Trade as % of GDP | UN | 78.4% | 46.1% | 69.6% | 1.9% | 441.6% | 3,435 | |
| Educational equality | V-Dem | 0.1 | 1.3 | -0.1 | -3.2 | 3.6 | 3,435 | |
| Health equality | V-Dem | 0.1 | 1.4 | -0.1 | -3.3 | 3.5 | 3,435 | |
| Infant mortality rate (deaths per 1,000 birhts) | V-Dem and Gapminder | 44.7 | 34.3 | 35.3 | 2.2 | 171.0 | 3,435 | |
| Unexpected shocks | Internal conflict in last 5 years | UCDP/PRIO | 0.3 | 0.5 | 0.0 | 0.0 | 1.0 | 3,435 |
| Natural disasters | EM-DAT | 2.1 | 3.5 | 1.0 | 0.0 | 43.0 | 3,435 | |
total_oecd_aid <- df_country_aid_laws %>%
summarise(total = dollar(sum(total_oda))) %>%
pull(total)OECD members donated $4,333,135,732,679 between 1990 and 2013.
plot_aid <- df_country_aid_laws %>%
filter(year <= 2013) %>%
group_by(year) %>%
summarise(total = sum(total_oda)) %>%
mutate(fake_facet_title = "ODA commitments (all OECD)")
fig_oecd_aid <- ggplot(plot_aid, aes(x = year, y = (total / 1000000000))) +
geom_line(size = 0.5) +
labs(x = NULL, y = "Billions of USD") +
scale_y_continuous(labels = dollar) +
coord_cartesian(xlim = c(1990, 2015)) +
theme_donors() +
facet_wrap(vars(fake_facet_title))
fig_oecd_aid
df_donor %>%
filter(year >= 1990) %>%
group_by(purpose_contentiousness) %>%
summarise(Total = sum(oda)) %>%
ungroup() %>%
mutate(Percent = Total / sum(Total)) %>%
mutate(Total = dollar(Total),
Percent = percent_format(accuracy = 0.1)(Percent)) %>%
rename(`Contentiousness` = purpose_contentiousness) %>%
kbl() %>%
kable_styling()| Contentiousness | Total | Percent |
|---|---|---|
| High | $267,373,936,986 | 6.2% |
| Low | $4,071,293,867,271 | 93.8% |
plot_aid_contentiousness <- df_donor %>%
filter(year >= 1990) %>%
group_by(year, purpose_contentiousness) %>%
summarise(total = sum(oda)) %>%
mutate(perc = total / sum(total)) %>%
filter(purpose_contentiousness == "High") %>%
mutate(fake_facet_title = "Contentious aid (all OECD)")
fig_oecd_contention <- ggplot(plot_aid_contentiousness, aes(x = year, y = perc)) +
geom_line(size = 0.5) +
scale_y_continuous(labels = percent_format(accuracy = 1)) +
labs(x = NULL, y = "Percent") +
coord_cartesian(xlim = c(1990, 2015)) +
theme_donors() +
facet_wrap(vars(fake_facet_title))
fig_oecd_contention
total_us_aid <- df_country_aid_laws %>%
summarise(total = dollar(sum(oda_us))) %>%
pull(total)
total_us_aid_post_2000 <- df_country_aid_laws %>%
filter(year > 1999) %>%
summarise(total = dollar(sum(oda_us))) %>%
pull(total)The US donated $389,773,308,222 between 1990 and 2014 and $266,150,720,203 between 2000 and 2014.
plot_aid_us <- df_country_aid_laws %>%
filter(year >= 1990) %>%
group_by(year) %>%
summarise(total = sum(oda_us)) %>%
mutate(fake_facet_title = "ODA commitments (USAID only)")
fig_us_aid <- ggplot(plot_aid_us, aes(x = year, y = (total / 1000000000))) +
geom_line(size = 0.5) +
expand_limits(y = 0) +
labs(x = NULL, y = "Billions of USD") +
scale_y_continuous(labels = dollar) +
coord_cartesian(xlim = c(1990, 2015)) +
theme_donors() +
facet_wrap(vars(fake_facet_title))
fig_us_aid
Total amounts over time:
usaid_total <- df_country_aid_laws %>%
summarise(total = sum(oda_us)) %>% pull(total)
channels_nice <- tribble(
~channel, ~channel_clean,
"oda_us_ngo_dom", "Domestic NGOs",
"oda_us_ngo_int", "International NGOs",
"oda_us_ngo_us", "US-based NGOs"
)
df_country_aid_laws %>%
pivot_longer(names_to = "channel", values_to = "total_oda_us",
c(oda_us_ngo_dom, oda_us_ngo_int, oda_us_ngo_us)) %>%
group_by(channel) %>%
summarise(total = sum(total_oda_us)) %>%
ungroup() %>%
left_join(channels_nice, by = "channel") %>%
mutate(perc = total / usaid_total) %>%
mutate(total = dollar(total), perc = percent(perc)) %>%
select(Channel = channel_clean, Total = total, Percent = perc) %>%
kbl() %>%
kable_styling()| Channel | Total | Percent |
|---|---|---|
| Domestic NGOs | $7,057,013,854 | 1.8% |
| International NGOs | $14,412,538,155 | 3.7% |
| US-based NGOs | $31,189,618,294 | 8.0% |
The US clearly favors US-based NGOs or international NGOs over domestic NGOs.
usaid_total_yearly <- df_country_aid_laws %>%
group_by(year) %>%
summarise(annual_total = sum(oda_us)) %>%
mutate(fake_facet_title = "USAID ODA channeled through NGOs")
plot_usaid_channel <- df_country_aid_laws %>%
filter(year >= 1990) %>%
pivot_longer(names_to = "channel", values_to = "total_oda_us",
c(oda_us_ngo_dom, oda_us_ngo_int, oda_us_ngo_us)) %>%
group_by(year, channel) %>%
summarise(total = sum(total_oda_us)) %>%
left_join(usaid_total_yearly, by = "year") %>%
mutate(perc = total / annual_total) %>%
left_join(channels_nice, by = "channel")
fig_usaid_channel <- ggplot(plot_usaid_channel,
aes(x = year, y = perc, colour = channel_clean)) +
geom_line(size = 0.5) +
scale_y_continuous(labels = percent_format(accuracy = 1)) +
scale_colour_manual(values = channel_colors) +
labs(x = NULL, y = "Percent") +
guides(colour = guide_legend(title = NULL, reverse = TRUE, nrow = 2)) +
coord_cartesian(xlim = c(1990, 2015)) +
theme_donors() +
facet_wrap(vars(fake_facet_title))
fig_usaid_channel
USAID data categorizes all aid as government-channeled before 2000 because of some quirk in the data.
plot_usaid_channels_all <- df_donor_us %>%
group_by(year, channel_subcategory_name) %>%
summarise(total = sum(oda_us_2011)) %>%
mutate(perc = total / sum(total)) %>%
mutate(channel = ifelse(str_detect(channel_subcategory_name, "NGO"), "NGO", "Other"))
ggplot(plot_usaid_channels_all,
aes(x = year, y = perc, colour = channel_subcategory_name)) +
geom_line(size = 0.5) +
scale_y_continuous(labels = percent_format(accuracy = 1)) +
labs(x = NULL, y = "Percent of US aid given through different channels") +
guides(colour = guide_legend(title = NULL, ncol = 2)) +
theme_donors()
So we just look at aid after 2000.
fig_usaid_channel_trimmed <- fig_usaid_channel +
coord_cartesian(xlim = c(2000, 2015))
fig_usaid_channel_trimmed
fig_dvs <- (fig_oecd_aid + fig_oecd_contention) /
(fig_us_aid + fig_usaid_channel_trimmed) &
theme_donors(base_size = 10) +
theme(legend.text = element_text(size = rel(0.6)),
axis.title.y = element_text(margin = margin(r = 3)),
legend.box.margin = margin(t = -0.5, unit = "lines"))
fig_dvs
ggsave(here("analysis", "output", "fig-dvs.pdf"), fig_dvs,
width = 6.5, height = 4.75, device = cairo_pdf)
ggsave(here("analysis", "output", "fig-dvs.png"), fig_dvs,
width = 6.5, height = 4.75, dpi = 300, type = "cairo")dcjw_indexes <- read_csv(here("data", "manual_data", "dcjw_index.csv")) %>%
mutate(Laws = str_replace_all(Laws, "\n", "\n\n"))
caption <- "Description of indexes of NGO barriers {#tbl:ngo-barriers-index}"
dcjw_index_table <- pandoc.table.return(dcjw_indexes, keep.line.breaks = TRUE,
style = "grid", justify = "lll", caption = caption)
cat(dcjw_index_table)| Index | Maximum value | Laws |
|---|---|---|
| Barriers to entry | 3 |
|
| Barriers to funding | 5 |
|
| Barriers to advocacy | 2 |
|
| Total barriers | 10 | — |
cat(dcjw_index_table, file = here("analysis", "output", "tbl-ngo-barriers-index.md"))# barriers_total = advocacy + entry + funding
dcjw_questions <- read_csv(here("data", "manual_data", "dcjw_questions.csv")) %>%
filter(!ignore_in_index) %>%
select(barrier_group = barrier_display, barrier = question_clean,
barrier_display = question_display) %>%
mutate(barrier_group = paste0("Barriers to ", str_to_lower(barrier_group)))
df_barriers <- df_country_aid_laws %>%
group_by(gwcode, year) %>%
summarize(across(one_of(dcjw_questions$barrier), ~. > 0)) %>%
group_by(year) %>%
summarize(across(-gwcode, ~sum(.))) %>%
ungroup() %>%
pivot_longer(names_to = "barrier", values_to = "value", -year) %>%
left_join(dcjw_questions, by = "barrier") %>%
mutate(barrier_display = str_replace(barrier_display, "XXX", "\n")) %>%
arrange(desc(value)) %>%
mutate(barrier_display = fct_inorder(barrier_display, ordered = TRUE))
dcjw_entry_plot <- ggplot(filter(df_barriers,
barrier_group == "Barriers to entry"),
aes(x = year, y = value,
color = barrier_display,
linetype = barrier_display)) +
geom_line(size = 0.5) +
expand_limits(y = c(0, 90)) +
scale_y_continuous(sec.axis = sec_axis(~ . / num_countries,
labels = percent_format(accuracy = 1)),
expand = c(0, 0)) +
scale_colour_manual(values = c("black", "grey80", "grey50"), name = NULL) +
scale_linetype_manual(values = c("solid", "solid", "21"), name = NULL) +
coord_cartesian(xlim = c(1990, 2015), ylim = c(0, 90)) +
guides(color = guide_legend(nrow = 2)) +
labs(x = NULL, y = "Number of countries") +
theme_donors(10) +
theme(legend.justification = "left") +
facet_wrap(vars(barrier_group))
dcjw_funding_plot <- ggplot(filter(df_barriers,
barrier_group == "Barriers to funding"),
aes(x = year, y = value,
color = barrier_display,
linetype = barrier_display)) +
geom_line(size = 0.5) +
scale_y_continuous(sec.axis = sec_axis(~ . / num_countries,
labels = percent_format(accuracy = 1)),
expand = c(0, 0)) +
scale_colour_manual(values = c("black", "grey80", "grey50", "black", "grey80"), name = NULL) +
scale_linetype_manual(values = c("solid", "solid", "solid", "21", "21"), name = NULL) +
coord_cartesian(xlim = c(1990, 2015), ylim = c(0, 40)) +
guides(color = guide_legend(nrow = 3),
linetype = guide_legend(nrow = 3)) +
labs(x = NULL, y = "Number of countries") +
theme_donors(10) +
theme(legend.justification = "left") +
facet_wrap(vars(barrier_group))
dcjw_advocacy_plot <- ggplot(filter(df_barriers,
barrier_group == "Barriers to advocacy"),
aes(x = year, y = value,
color = barrier_display)) +
geom_line(size = 0.5) +
scale_y_continuous(sec.axis = sec_axis(~ . / num_countries,
labels = percent_format(accuracy = 1)),
expand = c(0, 0)) +
scale_colour_manual(values = c("black", "grey80"), name = NULL) +
coord_cartesian(xlim = c(1990, 2015), ylim = c(0, 60)) +
guides(color = guide_legend(nrow = 1)) +
labs(x = NULL, y = "Number of countries") +
theme_donors(10) +
theme(legend.justification = "left") +
facet_wrap(vars(barrier_group))
df_ccsi_plot <- df_country_aid %>%
left_join(df_autocracies, by = "gwcode") %>%
group_by(year, autocracy) %>%
nest() %>%
mutate(cis = data %>% map(~ mean_cl_normal(.$v2xcs_ccsi))) %>%
unnest(cis) %>%
ungroup() %>%
mutate(fake_facet_title = "Core civil society index",
autocracy = factor(autocracy,
labels = c("Democracies (Regimes of the World > 4)",
"Non-democracies (Regimes of the World ≤ 4)"),
ordered = TRUE))
fig_ccsi <- ggplot(df_ccsi_plot, aes(x = year, y = y)) +
geom_ribbon(aes(ymin = ymin, ymax = ymax, fill = autocracy), alpha = 0.2) +
geom_line(aes(color = autocracy), size = 0.5) +
annotate(geom = "text", x = 2015, y = 0.1, hjust = "right", size = pts(7),
label = "Higher values = more open civil society") +
scale_colour_manual(values = c("black", "grey75"), name = NULL) +
scale_fill_manual(values = c("black", "grey75"), name = NULL) +
scale_linetype_manual(values = c("solid", "solid", "21")) +
coord_cartesian(xlim = c(1990, 2015), ylim = c(0, 1)) +
guides(color = guide_legend(nrow = 2)) +
labs(y = "Average", x = NULL) +
theme_donors(10) +
theme(legend.justification = "left") +
facet_wrap(vars(fake_facet_title))
barriers_summary <-
((dcjw_entry_plot + dcjw_funding_plot) /
(dcjw_advocacy_plot + fig_ccsi)) &
theme(legend.text = element_text(size = rel(0.6)),
axis.title.y = element_text(margin = margin(r = 3)),
legend.box.margin = margin(t = -0.5, unit = "lines"))
barriers_summary
ggsave(here("analysis", "output", "fig-barriers-summary.pdf"), barriers_summary,
width = 6.5, height = 6, device = cairo_pdf)
ggsave(here("analysis", "output", "fig-barriers-summary.png"), barriers_summary,
width = 6.5, height = 6, dpi = 300, type = "cairo")Laws requiring NGO registration aren’t necessarily a sign of oppression—even the US requires that nonprofits that earn above a certain threshold register as 501(c)(3) organizations. Though the figure below shows that compulsory regulation have increased over time, actual restriction has occurred too. Burdensome registration is not just another standard layer of bureaucracy.
df_regulation <- df_country_aid_laws %>%
left_join(select(df_autocracies, gwcode, autocracy), by = "gwcode") %>%
group_by(year, autocracy) %>%
summarise(`Registration required` = sum(ngo_register) / n(),
`Registration burdensome` = sum(ngo_register_burden) / n()) %>%
ungroup() %>%
pivot_longer(names_to = "type_of_law", values_to = "value", -c(year, autocracy)) %>%
mutate(autocracy =
factor(autocracy, levels = c(TRUE, FALSE),
labels = c("Non-democracies", "Democracies")))
fig_regulation_burden <- ggplot(df_regulation,
aes(x = year, y = value, color = type_of_law)) +
geom_line(size = 0.5) +
scale_y_continuous(labels = percent_format(accuracy = 1)) +
scale_x_continuous(expand = c(0, 0)) +
coord_cartesian(ylim = c(0, 0.7), xlim = c(1990, 2014)) +
guides(colour = guide_legend(title = NULL)) +
labs(x = NULL, y = "Proportion of countries\nwith regulation") +
theme_donors(10) +
facet_wrap(vars(autocracy))
fig_regulation_burden
ggsave(here("analysis", "output", "fig-regulation-burden.pdf"), fig_dvs,
width = 6, height = 2.5, device = cairo_pdf)
ggsave(here("analysis", "output", "fig-regulation-burden.png"), fig_dvs,
width = 6, height = 2.5, dpi = 300, type = "cairo")aid_donor_type_time <- df_donor %>%
group_by(year, donor_type_collapsed) %>%
summarise(total_aid = sum(oda, na.rm = TRUE))
ggplot(aid_donor_type_time, aes(x = year, y = total_aid / 1000000000,
colour = donor_type_collapsed)) +
geom_line(size = 0.5) +
labs(x = NULL, y = "Billions of USD",
caption = "Source: OECD and AidData. 2011 dollars.") +
guides(colour = guide_legend(title = NULL)) +
scale_y_continuous(labels = dollar) +
theme_donors()
aid_contention_time <- df_donor %>%
group_by(year, purpose_contentiousness) %>%
summarise(total_aid = sum(oda, na.rm = TRUE))
ggplot(aid_contention_time, aes(x = year, y = total_aid / 1000000000,
colour = purpose_contentiousness)) +
geom_line(size = 0.5) +
labs(x = NULL, y = "Billions of USD",
caption = "Source: OECD and AidData. 2011 dollars.") +
guides(colour = guide_legend(title = NULL)) +
scale_y_continuous(labels = dollar) +
theme_donors()
inv_logit <- function(f, a) {
a <- (1 - 2 * a)
(a * (1 + exp(f)) + (exp(f) - 1)) / (2 * a * (1 + exp(f)))
}
dvs_clean_names <- tribble(
~barrier, ~barrier_clean,
"barriers_total", "All barriers",
"advocacy", "Barriers to advocacy",
"entry", "Barriers to entry",
"funding", "Barriers to funding"
)
ivs_clean_names <- tribble(
~variable, ~variable_clean, ~hypothesis,
"total_oda_lead1", "Total ODA", "H1",
"prop_contentious_lead1", "Contentious aid", "H2",
"prop_ngo_dom_lead1", "Aid to domestic NGOs", "H3",
"prop_ngo_foreign_lead1", "Aid to foreign NGOs", "H3"
)df_plot_barriers_oda <- df_country_aid_laws %>%
select(year, gwcode, country, total_oda_lead1,
one_of(dvs_clean_names$barrier)) %>%
pivot_longer(names_to = "barrier", values_to = "value",
one_of(dvs_clean_names$barrier)) %>%
left_join(dvs_clean_names, by = "barrier") %>%
mutate(barrier_clean = fct_inorder(barrier_clean, ordered = TRUE))
ggplot(df_plot_barriers_oda,
aes(x = value, y = total_oda_lead1, color = barrier_clean)) +
geom_point(alpha = 0.5) +
stat_smooth(method = "lm") +
stat_smooth(data = filter(df_plot_barriers_oda,
total_oda_lead1 > 10000000000),
method = "lm", linetype = "21") +
scale_y_continuous(labels = dollar) +
guides(color = FALSE) +
labs(x = "Number of legal barriers", y = "Total ODA in next year",
title = "Total ODA in next year",
subtitle = "Dotted lines show trends when omitting observations\nwith less than $10,000,000,000 in ODA") +
theme_donors(10) +
theme(strip.text.x = element_text(margin = margin(t = 1, b = 1))) +
facet_wrap(vars(barrier_clean), scales = "free_x", nrow = 2)
df_plot_barriers_contention <- df_country_aid_laws %>%
select(year, gwcode, country, prop_contentious_lead1,
one_of(dvs_clean_names$barrier)) %>%
pivot_longer(names_to = "barrier", values_to = "value",
one_of(dvs_clean_names$barrier)) %>%
left_join(dvs_clean_names, by = "barrier") %>%
mutate(barrier_clean = fct_inorder(barrier_clean, ordered = TRUE))
ggplot(df_plot_barriers_contention,
aes(x = value, y = prop_contentious_lead1, color = barrier_clean)) +
geom_point(alpha = 0.5) +
stat_smooth(method = "lm") +
stat_smooth(data = filter(df_plot_barriers_contention,
prop_contentious_lead1 > 0.05),
method = "lm", linetype = "21") +
scale_y_continuous(labels = percent) +
guides(color = FALSE) +
labs(x = "Number of legal barriers",
y = "Proportion of contentious aid in next year",
title = "Proportion of contentious aid in next year",
subtitle = "Dotted lines show trends when omitting observations\nwith less than 5% contentious aid") +
theme_donors(10) +
theme(strip.text.x = element_text(margin = margin(t = 1, b = 1))) +
facet_wrap(vars(barrier_clean), scales = "free_x", nrow = 2)
df_plot_barriers_ngos <- df_country_aid_laws %>%
select(year, gwcode, country,
prop_ngo_dom_lead1, prop_ngo_foreign_lead1,
one_of(dvs_clean_names$barrier)) %>%
pivot_longer(names_to = "barrier", values_to = "value",
one_of(dvs_clean_names$barrier)) %>%
pivot_longer(names_to = "ngo_type", values_to = "prop_ngo",
c(prop_ngo_dom_lead1, prop_ngo_foreign_lead1)) %>%
left_join(dvs_clean_names, by = "barrier") %>%
left_join(ivs_clean_names, by = c("ngo_type" = "variable")) %>%
mutate(barrier_clean = fct_inorder(barrier_clean, ordered = TRUE))
ggplot(df_plot_barriers_ngos,
aes(x = value, y = prop_ngo, color = barrier_clean)) +
geom_point(alpha = 0.5) +
stat_smooth(method = "lm") +
stat_smooth(data = filter(df_plot_barriers_ngos,
prop_ngo > 0.05),
method = "lm", linetype = "21") +
scale_y_continuous(labels = percent) +
guides(color = FALSE) +
labs(x = "Number of legal barriers",
y = "Proportion of aid to NGOs in next year",
title = "Proportion of aid channeled to types of NGOs in next year",
subtitle = "Dotted lines show trends when omitting observations\nwith less than 5% aid to NGOs") +
coord_cartesian(ylim = c(0, 1)) +
theme_donors(10) +
theme(strip.text.x = element_text(margin = margin(t = 1, b = 1))) +
facet_wrap(vars(variable_clean, barrier_clean), scales = "free_x", ncol = 4)
df_plot_ccsi_ngos <- df_country_aid_laws %>%
select(year, gwcode, country,
one_of(ivs_clean_names$variable), v2xcs_ccsi) %>%
pivot_longer(names_to = "variable", values_to = "value",
c(one_of(ivs_clean_names$variable))) %>%
left_join(ivs_clean_names, by = "variable") %>%
mutate(hypothesis_clean = paste0(hypothesis, ": ", variable_clean)) %>%
arrange(hypothesis_clean) %>%
mutate(hypothesis_clean = fct_inorder(hypothesis_clean, ordered = TRUE))
ggplot(df_plot_ccsi_ngos,
aes(x = v2xcs_ccsi, y = value, color = hypothesis)) +
geom_point(alpha = 0.25) +
scale_color_viridis_d(option = "plasma", end = 0.9) +
guides(color = FALSE) +
labs(x = "Civil society index",
y = "Variable value in next year",
title = "Core civil society index") +
theme_donors() +
facet_wrap(vars(hypothesis_clean), scales = "free_y")
civicus <- read_csv(here("data", "raw_data", "Civicus", "civicus_monitor_2017.csv"),
na = "Null") %>%
mutate(Population = as.double(Population), # Integers can't handle world population
Rating = factor(Rating, levels = c("Open", "Narrowed", "Obstructed",
"Repressed", "Closed"),
ordered = TRUE),
iso3 = countrycode(Country, "country.name", "iso3c",
custom_match = c("Kosovo" = "XKK",
"Micronesia" = "FSM")))
# Use the Robinson map projection
projection <- "ESRI:54030"
world_map <- read_sf(here("data", "raw_data", "ne_110m_admin_0_countries",
"ne_110m_admin_0_countries.shp")) %>%
filter(ISO_A3 != "ATA")civicus %>% count(Rating) %>% pandoc.table()| Rating | n |
|---|---|
| Open | 26 |
| Narrowed | 64 |
| Obstructed | 50 |
| Repressed | 35 |
| Closed | 20 |
map_with_civicus <- world_map %>%
# Fix some Natural Earth ISO weirdness
mutate(ISO_A3 = ifelse(ISO_A3 == "-99", as.character(ISO_A3_EH), as.character(ISO_A3))) %>%
mutate(ISO_A3 = case_when(
.$ISO_A3 == "GRL" ~ "DNK",
.$NAME == "Norway" ~ "NOR",
.$NAME == "Kosovo" ~ "XKK",
TRUE ~ ISO_A3
)) %>%
left_join(select(civicus, iso3, Rating), by = c("ISO_A3" = "iso3"))
plot_civicus_map <- ggplot() +
geom_sf(data = map_with_civicus, aes(fill = Rating), size = 0.15, color = "black") +
coord_sf(crs = st_crs(projection)) +
scale_fill_manual(values = c("grey90", "grey70", "grey45",
"grey20", "black"),
na.translate = FALSE, name = "Civic space") +
theme_donors_map() +
theme(legend.key.size = unit(0.7, "lines"))
plot_civicus_map
ggsave(here("analysis", "output", "fig-civicus-map.pdf"), plot_civicus_map,
width = 5.5, height = 3, device = cairo_pdf)
ggsave(here("analysis", "output", "fig-civicus-map.png"), plot_civicus_map,
width = 5.5, height = 3, dpi = 300, type = "cairo")matrix_from_vector <- function(x, ncol) {
n_balanced <- ceiling(length(x) / ncol) * ncol
matrix(c(x, rep(NA, n_balanced - length(x))), ncol = ncol)
}
all_countries <- df_country_aid_laws %>%
distinct(country) %>%
arrange(country) %>%
pull(country)
caption <- paste0("All countries included in models (N = ",
length(all_countries),
") {#tbl:countries}")
ncol_countries <- 4
tbl_countries <- all_countries %>%
matrix_from_vector(ncol = ncol_countries) %>%
pandoc.table.return(justify = paste0(rep("l", ncol_countries), collapse = ""),
caption = caption, missing = "")
cat(tbl_countries)| Afghanistan | Ecuador | Liberia | Saudi Arabia |
| Albania | Egypt | Libya | Senegal |
| Algeria | El Salvador | Lithuania | Serbia |
| Angola | Equatorial Guinea | Madagascar | Sierra Leone |
| Argentina | Eritrea | Malawi | Singapore |
| Armenia | Estonia | Malaysia | Slovakia |
| Azerbaijan | Eswatini | Mali | Slovenia |
| Bahrain | Ethiopia | Mauritania | Solomon Islands |
| Bangladesh | Fiji | Mauritius | Somalia |
| Belarus | Gabon | Mexico | South Africa |
| Benin | Gambia | Moldova | South Korea |
| Bhutan | Georgia | Mongolia | South Sudan |
| Bolivia | Ghana | Montenegro | Sri Lanka |
| Bosnia & Herzegovina | Guatemala | Morocco | Sudan |
| Botswana | Guinea | Mozambique | Syria |
| Brazil | Guinea-Bissau | Myanmar (Burma) | Tajikistan |
| Bulgaria | Guyana | Namibia | Tanzania |
| Burkina Faso | Haiti | Nepal | Thailand |
| Burundi | Honduras | Nicaragua | Timor-Leste |
| Cambodia | Hungary | Niger | Togo |
| Cameroon | India | Nigeria | Trinidad & Tobago |
| Central African Republic | Indonesia | North Korea | Tunisia |
| Chile | Iran | North Macedonia | Turkey |
| China | Iraq | Oman | Turkmenistan |
| Colombia | Israel | Pakistan | Uganda |
| Comoros | Jamaica | Panama | Ukraine |
| Congo - Brazzaville | Jordan | Papua New Guinea | United Arab Emirates |
| Congo - Kinshasa | Kazakhstan | Paraguay | Uruguay |
| Costa Rica | Kenya | Peru | Uzbekistan |
| Côte d’Ivoire | Kosovo | Philippines | Venezuela |
| Croatia | Kuwait | Poland | Vietnam |
| Cuba | Kyrgyzstan | Portugal | Yemen |
| Cyprus | Laos | Qatar | Zambia |
| Czechia | Latvia | Romania | Zimbabwe |
| Djibouti | Lebanon | Russia | |
| Dominican Republic | Lesotho | Rwanda |
cat(tbl_countries, file = here("analysis", "output", "tbl-countries.md"))