library(tidyverse)
library(targets)
library(tidybayes)
library(glue)
library(brms)
library(scales)
library(kableExtra)
library(modelsummary)
library(here)

# Generated via random.org
set.seed(9936)

# Load data and models
withr::with_dir(here::here(), {
  source(tar_read(plot_funs))
  
  # Load big list of models
  model_df <- tar_read(model_df) %>% 
    filter(str_detect(model, "baseline") | str_detect(model, "v2csreprss")) %>% 
    filter(!str_detect(model, "_train"))
  
  # Load actual model objects
  tar_load(c(m_pts_baseline, m_pts_v2csreprss, 
             m_lhr_baseline, m_lhr_v2csreprss))
  
  # Load regression tables
  tar_load(c(models_tbl_e2a, models_tbl_e2b))
  
  # Load lookup list for coefficients in regression tables
  tar_load(coef_list)
})
models <- model_df %>% 
  mutate(actual_model = model %>% map(~eval(rlang::sym(.)))) %>% 
  mutate(across(c(outcome_var, explan_var, family), ~fct_inorder(., ordered = TRUE)))

coefs_clean <- tribble(
  ~coef, ~coef_clean,
  "b_v2csreprss", "Civil society repression",
  "b_v2csreprss_lag1", "Civil society repression (t - 1)",
  "b_v2csreprss_within", "Civil society repression (within)",
  "b_v2csreprss_lag1_within", "Civil society repression (within; t - 1)"
) %>% 
  mutate(across(everything(), ~fct_inorder(., ordered = TRUE))) %>% 
  mutate(lagging = str_detect(coef, "lag1"))

E2a: Civil society environment and political terror

Results table

# Build nicer column names
models_for_table_e2a <- models %>% 
  filter(outcome_var == "Political terror") %>% 
  mutate(outcome_var = recode(outcome_var, "Political terror" = "PTS"),
         explan_var = recode(explan_var, "Civil society repression" = "CS repression")) %>% 
  mutate(model_name = glue("{outcome_var} (t + 1)<br>({explan_var})"))

# Make a named vector of original model names and nice names
model_names_tbl_e2a <- models_for_table_e2a %>% 
  pull(model_name) %>% 
  set_names(models_for_table_e2a$model)

# Rename the columns
names(models_tbl_e2a) <- recode(names(models_tbl_e2a), !!!model_names_tbl_e2a)

modelsummary(models_tbl_e2a,
             statistic = "[{conf.low}, {conf.high}]",
             coef_map = coef_list,
             gof_omit = "ELPD",
             escape = FALSE,
             notes = list("Posterior means; 95% credible intervals in brackets"))
PTS (t + 1)
(Baseline)
PTS (t + 1)
(CS repression)
Civil society repression −0.382
[−0.666, −0.122]
Civil society repression (t - 1) 0.081
[−0.189, 0.346]
PTS = 2 2.399 2.265
[2.112, 2.688] [1.969, 2.571]
PTS = 3 4.423 4.297
[4.057, 4.798] [3.921, 4.690]
PTS = 4 6.518 6.340
[6.035, 6.978] [5.864, 6.826]
PTS = 5 8.861 8.619
[8.272, 9.502] [7.998, 9.240]
Polyarchy index −2.220 −1.273
[−2.889, −1.609] [−2.287, −0.303]
Log GDP per capita −0.397 −0.424
[−0.539, −0.269] [−0.560, −0.284]
Trade as % of GDP −0.368 −0.412
[−0.668, −0.068] [−0.740, −0.101]
Armed conflict 1.010 1.054
[0.720, 1.326] [0.758, 1.363]
Num.Obs. 3736 3612
R2 0.805 0.806
R2 Marg. 0.711 0.714
LOOIC 5456.1 5252.0
LOOIC s.e. 98.5 97.3
WAIC 5455.6 5251.4
Posterior means; 95% credible intervals in brackets

Coefficients

coef_plots <- models %>% 
  filter(model == "m_pts_v2csreprss") %>% 
  mutate(coef_draws = map(
    actual_model, 
    ~gather_draws(model = ., `b_v2csreprss.*`, regex = TRUE))) %>% 
  select(-actual_model) %>% 
  unnest(coef_draws) %>% 
  left_join(coefs_clean, by = c(".variable" = "coef"))

coef_plots %>% 
  ggplot(aes(y = fct_rev(coef_clean), x = .value)) +
  stat_halfeye(aes(alpha = lagging), .width = c(0.8, 0.95)) +
  geom_vline(xintercept = 0) +
  guides(fill = "none", alpha = "none") +
  scale_alpha_manual(values = c(1, 0.4)) +
  labs(x = "Coefficient", y = NULL) +
  theme_ngo()

Marginal effects

mfx <- models %>% 
  filter(model == "m_pts_v2csreprss") %>% 
  mutate(plot_vars = "v2csreprss") %>% 
  mutate(fx = map2(actual_model, plot_vars, 
                   ~conditional_effects(.x, effects = .y,
                                        categorical = TRUE)[[1]])) %>% 
  select(-actual_model) %>% 
  unnest(fx)

mfx %>% 
  ggplot(aes(x = effect1__, y = estimate__, color = effect2__, fill = effect2__)) +
  geom_ribbon(aes(ymin = lower__, ymax = upper__), alpha = 0.4, color = NA) +
  geom_line(size = 1) +
  labs(x = "Civil society repression\n(higher values = less repression)",
       y = "Predicted probability of category",
       color = "Political terror scale", fill = "Political terror scale") +
  theme_ngo()

 

E2b: Civil society environment and latent physical integrity rights

# Build nicer column names
models_for_table_e2b <- models %>% 
  filter(outcome_var == "Latent human rights") %>% 
  mutate(explan_var = recode(explan_var, "Civil society repression" = "CS repression")) %>% 
  mutate(model_name = glue("{outcome_var} (t + 1)<br>({explan_var})"))

# Make a named vector of original model names and nice names
model_names_tbl_e2b <- models_for_table_e2b %>% 
  pull(model_name) %>% 
  set_names(models_for_table_e2b$model)

# Rename the columns
names(models_tbl_e2b) <- recode(names(models_tbl_e2b), !!!model_names_tbl_e2b)

modelsummary(models_tbl_e2b,
             statistic = "[{conf.low}, {conf.high}]",
             coef_map = coef_list,
             gof_omit = "ELPD",
             escape = FALSE,
             notes = list("Posterior means; 95% credible intervals in brackets"))
Latent human rights (t + 1)
(Baseline)
Latent human rights (t + 1)
(CS repression)
Civil society repression 0.053
[0.024, 0.083]
Civil society repression (t - 1) −0.037
[−0.067, −0.007]
Latent human rights (t) 0.965 0.963
[0.954, 0.975] [0.952, 0.974]
Polyarchy index 0.090 0.017
[0.053, 0.130] [−0.053, 0.085]
Log GDP per capita 0.006 0.009
[0.000, 0.014] [0.002, 0.017]
Trade as % of GDP 0.022 0.022
[0.003, 0.041] [0.002, 0.042]
Armed conflict −0.007 −0.003
[−0.031, 0.019] [−0.027, 0.023]
Intercept −0.076 −0.074
[−0.135, −0.019] [−0.134, −0.012]
Num.Obs. 3769 3629
R2 0.968 0.968
R2 Marg. 0.968 0.968
LOOIC 118.9 61.6
LOOIC s.e. 352.5 350.5
WAIC 118.3 60.3
RMSE 0.79 0.79
Posterior means; 95% credible intervals in brackets

Coefficients

coef_plots <- models %>% 
  filter(model == "m_lhr_v2csreprss") %>% 
  mutate(coef_draws = map(
    actual_model, 
    ~gather_draws(model = ., `b_v2csreprss.*`, regex = TRUE))) %>% 
  select(-actual_model) %>% 
  unnest(coef_draws) %>% 
  left_join(coefs_clean, by = c(".variable" = "coef"))

coef_plots %>% 
  ggplot(aes(y = fct_rev(coef_clean), x = .value)) +
  stat_halfeye(aes(alpha = lagging), .width = c(0.8, 0.95)) +
  geom_vline(xintercept = 0) +
  guides(fill = "none", alpha = "none") +
  scale_alpha_manual(values = c(1, 0.4)) +
  labs(x = "Coefficient", y = NULL) +
  theme_ngo()

Marginal effects

mfx <- models %>% 
  filter(model == "m_lhr_v2csreprss") %>% 
  mutate(fx = map2(actual_model, "v2csreprss",
                   ~conditional_effects(.x, effects = .y)[[1]])) %>% 
  select(-actual_model) %>% 
  unnest(fx)

mfx %>% 
  ggplot(aes(x = effect1__, y = estimate__)) +
  geom_ribbon(aes(ymin = lower__, ymax = upper__), alpha = 0.4, 
              fill = "#FF4136", color = NA) +
  geom_line(size = 1, color = "#FF4136") +
  labs(x = "Civil society repression\n(higher values = less repression)",
       y = "Predicted latent human rights\n(higher values = less violence)") +
  theme_ngo()

LS0tCnRpdGxlOiAiRX4yfjogQ2l2aWwgc29jaWV0eSBlbnZpcm9ubWVudCBwcmVkaWN0cyBkZXRlcmlvcmF0aW5nIGh1bWFuIHJpZ2h0cyIKYXV0aG9yOiAiU3VwYXJuYSBDaGF1ZGhyeSBhbmQgQW5kcmV3IEhlaXNzIgpkYXRlOiAiTGFzdCBydW46IGByIGZvcm1hdChTeXMudGltZSgpLCAnJUYnKWAiCm91dHB1dDogCiAgaHRtbF9kb2N1bWVudDoKICAgIGNvZGVfZm9sZGluZzogaGlkZQplZGl0b3Jfb3B0aW9uczogCiAgY2h1bmtfb3V0cHV0X3R5cGU6IGNvbnNvbGUKLS0tCgpgYGB7ciBzZXR1cCwgaW5jbHVkZT1GQUxTRX0KbGlicmFyeShrbml0cikKbGlicmFyeShrYWJsZUV4dHJhKQprbml0X3ByaW50LmR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