H5: Organizational practices

Code
library(tidyverse)
library(targets)
library(tidybayes)
library(patchwork)
library(scales)
library(ggh4x)
library(glue)
library(gt)
library(gtExtras)

tar_config_set(
  store = here::here("_targets"),
  script = here::here("_targets.R")
)

preds_all <- tar_read(preds_conditional_treatment_only)

invisible(list2env(tar_read(graphic_functions), .GlobalEnv))
invisible(list2env(tar_read(table_functions), .GlobalEnv))

theme_set(theme_ngo())

H5a: Financial transparency

Hypothesis 5a: Financial transparency

Donors will show increased willingness to donate to NGOs that are financially transparent

Mechanism: Perception of efficacy

Estimand

\[ \begin{aligned} \theta =&\ \textbf{E}\bigl[ Y_i \mid \operatorname{do}\left( \text{Transparency} = \text{Yes} \right) \bigr] \end{aligned} \]

Code
h5a_mms <- preds_all %>% 
  group_by(feat_transp_short, .draw) %>% 
  summarize(avg = mean(.epred))

h5a_amces <- h5a_mms %>% 
  group_by(feat_transp_short) %>% 
  compare_levels(variable = avg, by = feat_transp_short, comparison = "control")
Code
p_h5a_mms <- h5a_mms %>% 
  ggplot(aes(x = avg, y = feat_transp_short, fill = feat_transp_short)) +
  stat_halfeye() +
  geom_vline(xintercept = 0.25, color = clrs$prism[8], linetype = "dashed", linewidth = 0.25) +
  scale_x_continuous(labels = label_percent()) +
  scale_y_discrete(labels = label_wrap(11)) +
  scale_fill_manual(values = clrs$prism[c(10, 3)], guide = "none") +
  labs(
    x = "Overall average predicted probability",
    y = NULL,
    fill = NULL,
    title = "Estimated marginal means"
  )

p_h5a_amces <- h5a_amces %>% 
  ungroup() %>% 
  separate_wider_delim(
    feat_transp_short,
    delim = " - ", 
    names = c("feat_transp_short", "reference_level")
  ) %>% 
  add_row(avg = 0, feat_transp_short = unique(.$reference_level)) %>%
  mutate(feat_transp_short = factor(feat_transp_short, levels = levels(h5a_mms$feat_transp_short))) %>% 
  ggplot(aes(x = avg, y = feat_transp_short, fill = feat_transp_short)) +
  stat_halfeye() +
  geom_vline(xintercept = 0, color = clrs$prism[8], linetype = "dashed", linewidth = 0.25) +
  scale_x_continuous(labels = label_pp) +
  scale_y_discrete(labels = label_wrap(11)) +
  scale_fill_manual(values = clrs$prism[c(10, 3)], guide = "none") +
  labs(
    x = "Percentage point change in probability of choice selection",
    y = NULL,
    fill = NULL,
    title = "Average marginal component effects (AMCEs)"
  )

p_h5a_mms | p_h5a_amces

Code
h5a_tbl_mm <- h5a_mms %>% 
  group_by(feat_transp_short) %>% 
  median_qi() %>% 
  mutate(nice = glue("{fmt_decimal(avg)}<br>{build_ci(.lower, .upper)}")) %>% 
  arrange(desc(feat_transp_short)) %>% 
  select(feat_transp_short, nice)

h5a_tbl_amces <- h5a_amces %>% 
  group_by(feat_transp_short) %>% 
  summarize(
    median_qi(avg),
    p_gt_0 = sum(avg > 0) / n()
  ) %>%
  mutate(p_neq_0 = ifelse(y >= 0, p_gt_0, 1 - p_gt_0)) %>% 
  mutate(nice = glue("{fmt_decimal(y)}<br>{build_ci(ymin, ymax)}")) %>% 
  mutate(feat_transp_short = str_replace(feat_transp_short, " - ", "−<br>")) %>% 
  mutate(across(starts_with("p_"), ~fmt_decimal(.))) %>% 
  arrange(desc(feat_transp_short)) %>% 
  select(contrast = feat_transp_short, amce_nice = nice, p_neq_0)

bind_cols(
  h5a_tbl_mm, 
  add_row(h5a_tbl_amces, contrast = "*(Reference)*")
) %>% 
  gt() %>% 
  sub_missing(columns = everything(), missing_text = "—") %>% 
  fmt_markdown(columns = c(nice, amce_nice, contrast)) %>%
  cols_align(align = "center", columns = everything()) %>% 
  cols_align(align = "left", columns = c(feat_transp_short, contrast)) %>% 
  cols_label(
    feat_transp_short = "Transparency", 
    nice = "Posterior EMM",
    contrast = "Contrast",
    amce_nice = "Posterior AMCE",
    p_neq_0 = "*p*~direction~",
    .fn = md
  ) %>% 
  tab_style(
    style = cell_text(v_align = "top"),
    locations = cells_body()
  ) %>% 
  tab_footnote(
    footnote = "Values are on the percentage-point scale; single value is posterior median; 95% credible interval in brackets.",
    locations = cells_column_labels(columns = c(nice, amce_nice))
  ) %>% 
  tab_footnote(
    footnote = md("The probability of direction (*p*~direction~) is the probability that the posterior AMCE is strictly positive or negative—it is the proportion of the posterior AMCE that is the sign of the median."),
    locations = cells_column_labels(columns = p_neq_0)
  ) %>% 
  gt_add_divider(columns = nice, style = "dashed", weight = px(1)) %>% 
  opt_footnote_marks(marks = "standard") %>% 
  opt_horizontal_padding(3) %>% 
  opts_theme()
Transparency Posterior EMM* Contrast Posterior AMCE* pdirection
Yes

0.307
[0.299, 0.314]

Yes−
No

0.103
[0.094, 0.112]

1.000
No

0.204
[0.198, 0.210]

(Reference)

* Values are on the percentage-point scale; single value is posterior median; 95% credible interval in brackets.
The probability of direction (pdirection) is the probability that the posterior AMCE is strictly positive or negative—it is the proportion of the posterior AMCE that is the sign of the median.

H5b: Relationship with host government and organizational practices

Transparency

Hypothesis 5b: Relationship with host government, organizational practices

Donors will show increased willingness to donate to NGOs that are criticized by the government/under government crackdown when they are also financially transparent

\[ \begin{aligned} \theta =&\ \textbf{E}\bigl[ Y_i \mid \operatorname{do}\left( \text{Transparency} = \text{Yes} \mid \text{Relationship = Under crackdown or Criticized} \right) \bigr] - \\ &\ \textbf{E}\bigl[ Y_i \mid \operatorname{do}\left( \text{Transparency} = \text{Yes} \mid \text{Relationship = Friendly} \right) \bigr] \end{aligned} \]

Code
h5b_mms <- preds_all %>% 
  group_by(feat_transp_short, feat_govt, .draw) %>% 
  summarize(avg = mean(.epred))

h5b_amces <- h5b_mms %>% 
  group_by(feat_govt) %>% 
  compare_levels(variable = avg, by = feat_transp_short, comparison = "control")
Code
p_h5b_mms <- h5b_mms %>% 
  ggplot(aes(x = avg, y = feat_transp_short, fill = feat_transp_short)) +
  stat_halfeye() +
  geom_vline(xintercept = 0.25, color = clrs$prism[8], linetype = "dashed", linewidth = 0.25) +
  scale_x_continuous(labels = label_percent()) +
  scale_y_discrete(labels = label_wrap(11)) +
  scale_fill_manual(values = clrs$prism[c(10, 3)], guide = "none") +
  facet_wrap(vars(feat_govt), ncol = 1) +
  labs(
    x = "Overall average predicted probability",
    y = NULL,
    fill = NULL,
    title = "Estimated marginal means"
  ) +
  theme(
    legend.position = "top",
    legend.justification = "left",
    legend.margin = margin(l = -7, t = 0)
  )

p_h5b_amces <- h5b_amces %>% 
  ungroup() %>% 
  separate_wider_delim(
    feat_transp_short,
    delim = " - ", 
    names = c("feat_transp_short", "reference_level")
  ) %>% 
  add_row(avg = 0, feat_transp_short = "No", feat_govt = "Friendly relationship with government") %>%
  add_row(avg = 0, feat_transp_short = "No", feat_govt = "Criticized by government") %>%
  add_row(avg = 0, feat_transp_short = "No", feat_govt = "Under government crackdown") %>%
  mutate(feat_transp_short = factor(feat_transp_short, levels = levels(h5b_mms$feat_transp_short))) %>% 
  mutate(feat_govt = factor(feat_govt, levels = levels(h5b_mms$feat_govt))) %>% 
  ggplot(aes(x = avg, y = feat_transp_short, fill = feat_transp_short)) +
  stat_halfeye() +
  geom_vline(xintercept = 0, color = clrs$prism[8], linetype = "dashed", linewidth = 0.25) +
  scale_x_continuous(labels = label_pp) +
  scale_y_discrete(labels = label_wrap(11)) +
  scale_fill_manual(values = clrs$prism[c(10, 3)], guide = "none") +
  facet_wrap(vars(feat_govt), ncol = 1) +
  labs(
    x = "Percentage point change in probability of choice selection",
    y = NULL,
    fill = NULL,
    title = "Difference in estimated marginal means"
  )

p_h5b_mms | p_h5b_amces

Code
h5b_tbl_mm <- h5b_mms %>% 
  group_by(feat_govt, feat_transp_short) %>% 
  median_qi() %>% 
  mutate(nice = glue("{fmt_decimal(avg)}<br>{build_ci(.lower, .upper)}")) %>% 
  arrange(desc(feat_govt), desc(feat_transp_short)) %>% 
  select(feat_transp_short, feat_govt, nice)

h5b_tbl_amces <- h5b_amces %>% 
  group_by(feat_govt, feat_transp_short) %>% 
  summarize(
    median_qi(avg),
    p_gt_0 = sum(avg > 0) / n()
  ) %>%
  ungroup() %>% 
  mutate(p_neq_0 = ifelse(y >= 0, p_gt_0, 1 - p_gt_0)) %>% 
  mutate(nice = glue("{fmt_decimal(y)}<br>{build_ci(ymin, ymax)}")) %>% 
  mutate(feat_transp_short = str_replace(feat_transp_short, " - ", "−<br>")) %>% 
  mutate(across(starts_with("p_"), ~fmt_decimal(.))) %>% 
  arrange(desc(feat_govt)) %>% 
  select(contrast = feat_transp_short, diff_nice = nice, p_neq_0)

bind_cols(
  h5b_tbl_mm, 
  h5b_tbl_amces %>% 
    add_row(contrast = NA, .after = 1) %>% 
    add_row(contrast = NA, .after = 3) %>% 
    add_row(contrast = NA, .after = 5)
) %>% 
  mutate(feat_govt = fct_relabel(feat_govt, ~paste("Relationship with government:", .x))) %>% 
  group_by(feat_govt) %>% 
  gt() %>% 
  sub_missing(columns = everything(), missing_text = "—") %>% 
  fmt_markdown(columns = c(nice, diff_nice, contrast)) %>%
  cols_align(align = "center", columns = everything()) %>% 
  cols_align(align = "left", columns = c(feat_transp_short, contrast)) %>% 
  cols_label(
    feat_transp_short = "Transparency", 
    nice = "Posterior EMM",
    contrast = "Contrast",
    diff_nice = "Posterior ∆",
    p_neq_0 = "*p*~direction~",
    .fn = md
  ) %>% 
  tab_style(
    style = cell_text(v_align = "top"),
    locations = cells_body()
  ) %>% 
  tab_style(
    style = cell_fill(color = "grey90"),
    locations = cells_row_groups()
  ) %>% 
  tab_footnote(
    footnote = "Values are on the percentage-point scale; single value is posterior median; 95% credible interval in brackets.",
    locations = cells_column_labels(columns = c(nice, diff_nice))
  ) %>% 
  tab_footnote(
    footnote = md("The probability of direction (*p*~direction~) is the probability that the posterior difference in marginal means is strictly positive or negative—it is the proportion of the posterior difference in marginal means that is the sign of the median."),
    locations = cells_column_labels(columns = p_neq_0)
  ) %>% 
  gt_add_divider(columns = nice, style = "dashed", weight = px(1)) %>% 
  opt_footnote_marks(marks = "standard") %>% 
  opt_horizontal_padding(3) %>% 
  opts_theme()
Transparency Posterior EMM* Contrast Posterior ∆* pdirection
Relationship with government: Under government crackdown
Yes

0.254
[0.245, 0.264]

Yes−
No

0.091
[0.083, 0.098]

1.000
No

0.163
[0.156, 0.171]

Relationship with government: Criticized by government
Yes

0.294
[0.284, 0.304]

Yes−
No

0.101
[0.092, 0.110]

1.000
No

0.193
[0.185, 0.201]

Relationship with government: Friendly relationship with government
Yes

0.372
[0.361, 0.383]

Yes−
No

0.118
[0.108, 0.128]

1.000
No

0.254
[0.245, 0.264]

* Values are on the percentage-point scale; single value is posterior median; 95% credible interval in brackets.
The probability of direction (pdirection) is the probability that the posterior difference in marginal means is strictly positive or negative—it is the proportion of the posterior difference in marginal means that is the sign of the median.

Accountability

Hypothesis 5b2: Relationship with host government, organizational practices

Donors will show increased willingness to donate to NGOs that are criticized by the government/under government crackdown when they are accountable and hold regular third party audits

\[ \begin{aligned} \theta =&\ \textbf{E}\bigl[ Y_i \mid \operatorname{do}\left( \text{Accountability} = \text{Yes} \mid \text{Relationship = Under crackdown or Criticized} \right) \bigr] - \\ &\ \textbf{E}\bigl[ Y_i \mid \operatorname{do}\left( \text{Accountability} = \text{Yes} \mid \text{Relationship = Friendly} \right) \bigr] \end{aligned} \]

Code
h5b2_mms <- preds_all %>% 
  group_by(feat_acc_short, feat_govt, .draw) %>% 
  summarize(avg = mean(.epred))

h5b2_amces <- h5b2_mms %>% 
  group_by(feat_govt) %>% 
  compare_levels(variable = avg, by = feat_acc_short, comparison = "control")
Code
p_h5b2_mms <- h5b2_mms %>% 
  ggplot(aes(x = avg, y = feat_acc_short, fill = feat_acc_short)) +
  stat_halfeye() +
  geom_vline(xintercept = 0.25, color = clrs$prism[8], linetype = "dashed", linewidth = 0.25) +
  scale_x_continuous(labels = label_percent()) +
  scale_y_discrete(labels = label_wrap(11)) +
  scale_fill_manual(values = clrs$prism[c(9, 4)], guide = "none") +
  facet_wrap(vars(feat_govt), ncol = 1) +
  labs(
    x = "Overall average predicted probability",
    y = NULL,
    fill = NULL,
    title = "Estimated marginal means"
  ) +
  theme(
    legend.position = "top",
    legend.justification = "left",
    legend.margin = margin(l = -7, t = 0)
  )

p_h5b2_amces <- h5b2_amces %>% 
  ungroup() %>% 
  separate_wider_delim(
    feat_acc_short,
    delim = " - ", 
    names = c("feat_acc_short", "reference_level")
  ) %>% 
  add_row(avg = 0, feat_acc_short = "No", feat_govt = "Friendly relationship with government") %>%
  add_row(avg = 0, feat_acc_short = "No", feat_govt = "Criticized by government") %>%
  add_row(avg = 0, feat_acc_short = "No", feat_govt = "Under government crackdown") %>%
  mutate(feat_acc_short = factor(feat_acc_short, levels = levels(h5b2_mms$feat_acc_short))) %>% 
  mutate(feat_govt = factor(feat_govt, levels = levels(h5b2_mms$feat_govt))) %>% 
  ggplot(aes(x = avg, y = feat_acc_short, fill = feat_acc_short)) +
  stat_halfeye() +
  geom_vline(xintercept = 0, color = clrs$prism[8], linetype = "dashed", linewidth = 0.25) +
  scale_x_continuous(labels = label_pp) +
  scale_y_discrete(labels = label_wrap(11)) +
  scale_fill_manual(values = clrs$prism[c(9, 4)], guide = "none") +
  facet_wrap(vars(feat_govt), ncol = 1) +
  labs(
    x = "Percentage point change in probability of choice selection",
    y = NULL,
    fill = NULL,
    title = "Difference in estimated marginal means"
  )

p_h5b2_mms | p_h5b2_amces

Code
h5b2_tbl_mm <- h5b2_mms %>% 
  group_by(feat_govt, feat_acc_short) %>% 
  median_qi() %>% 
  mutate(nice = glue("{fmt_decimal(avg)}<br>{build_ci(.lower, .upper)}")) %>% 
  arrange(desc(feat_govt), desc(feat_acc_short)) %>% 
  select(feat_acc_short, feat_govt, nice)

h5b2_tbl_amces <- h5b2_amces %>% 
  group_by(feat_govt, feat_acc_short) %>% 
  summarize(
    median_qi(avg),
    p_gt_0 = sum(avg > 0) / n()
  ) %>%
  ungroup() %>% 
  mutate(p_neq_0 = ifelse(y >= 0, p_gt_0, 1 - p_gt_0)) %>% 
  mutate(nice = glue("{fmt_decimal(y)}<br>{build_ci(ymin, ymax)}")) %>% 
  mutate(feat_acc_short = str_replace(feat_acc_short, " - ", "−<br>")) %>% 
  mutate(across(starts_with("p_"), ~fmt_decimal(.))) %>% 
  arrange(desc(feat_govt)) %>% 
  select(contrast = feat_acc_short, diff_nice = nice, p_neq_0)

bind_cols(
  h5b2_tbl_mm, 
  h5b2_tbl_amces %>% 
    add_row(contrast = NA, .after = 1) %>% 
    add_row(contrast = NA, .after = 3) %>% 
    add_row(contrast = NA, .after = 5)
) %>% 
  mutate(feat_govt = fct_relabel(feat_govt, ~paste("Relationship with government:", .x))) %>% 
  group_by(feat_govt) %>% 
  gt() %>% 
  sub_missing(columns = everything(), missing_text = "—") %>% 
  fmt_markdown(columns = c(nice, diff_nice, contrast)) %>%
  cols_align(align = "center", columns = everything()) %>% 
  cols_align(align = "left", columns = c(feat_acc_short, contrast)) %>% 
  cols_label(
    feat_acc_short = "Accountability", 
    nice = "Posterior EMM",
    contrast = "Contrast",
    diff_nice = "Posterior ∆",
    p_neq_0 = "*p*~direction~",
    .fn = md
  ) %>% 
  tab_style(
    style = cell_text(v_align = "top"),
    locations = cells_body()
  ) %>% 
  tab_style(
    style = cell_fill(color = "grey90"),
    locations = cells_row_groups()
  ) %>% 
  tab_footnote(
    footnote = "Values are on the percentage-point scale; single value is posterior median; 95% credible interval in brackets.",
    locations = cells_column_labels(columns = c(nice, diff_nice))
  ) %>% 
  tab_footnote(
    footnote = md("The probability of direction (*p*~direction~) is the probability that the posterior difference in marginal means is strictly positive or negative—it is the proportion of the posterior difference in marginal means that is the sign of the median."),
    locations = cells_column_labels(columns = p_neq_0)
  ) %>% 
  gt_add_divider(columns = nice, style = "dashed", weight = px(1)) %>% 
  opt_footnote_marks(marks = "standard") %>% 
  opt_horizontal_padding(3) %>% 
  opts_theme()
Accountability Posterior EMM* Contrast Posterior ∆* pdirection
Relationship with government: Under government crackdown
Yes

0.253
[0.244, 0.263]

Yes−
No

0.089
[0.081, 0.097]

1.000
No

0.164
[0.157, 0.172]

Relationship with government: Criticized by government
Yes

0.293
[0.283, 0.303]

Yes−
No

0.099
[0.090, 0.108]

1.000
No

0.194
[0.186, 0.202]

Relationship with government: Friendly relationship with government
Yes

0.371
[0.360, 0.381]

Yes−
No

0.115
[0.106, 0.125]

1.000
No

0.256
[0.246, 0.265]

* Values are on the percentage-point scale; single value is posterior median; 95% credible interval in brackets.
The probability of direction (pdirection) is the probability that the posterior difference in marginal means is strictly positive or negative—it is the proportion of the posterior difference in marginal means that is the sign of the median.

H5c: Relationship with host government, organizational practices, and funding sources

Hypothesis 5c: Relationship with host government, organizational practices, and funding sources

Donors will show increased willingness to donate to NGOs that are criticized by the government/under government crackdown when they are also financially transparent and are funded primarily by numerous small private donors

Estimand

TODO

Code
h5c_mms <- preds_all %>% 
  group_by(feat_transp_short, feat_govt, feat_funding_short, .draw) %>% 
  summarize(avg = mean(.epred))

h5c_amces <- h5c_mms %>% 
  group_by(feat_govt, feat_funding_short) %>% 
  compare_levels(variable = avg, by = feat_transp_short, comparison = "control")
Code
p_h5c_mms <- h5c_mms %>%
  ggplot(aes(x = avg, y = feat_transp_short, fill = feat_transp_short)) +
  stat_halfeye() +
  geom_vline(xintercept = 0.25, color = clrs$prism[8], linetype = "dashed", linewidth = 0.25) +
  scale_x_continuous(labels = label_percent()) +
  scale_y_discrete(labels = label_wrap(11)) +
  scale_fill_manual(values = clrs$prism[c(10, 3)], guide = "none") +
  facet_nested_wrap(
    vars(feat_govt, feat_funding_short),
    ncol = 3,
    strip = strip_nested(
      text_x = list(element_text(
        family = "Libre Franklin",
        face = "bold"
      ), NULL),
      background_x = list(element_rect(fill = "grey96"), NULL),
      by_layer_x = TRUE
    )
  ) +
  labs(
    x = "Overall average predicted probability",
    y = NULL,
    fill = NULL,
    title = "Estimated marginal means"
  ) +
  theme(
    legend.position = "top",
    legend.justification = "left",
    legend.margin = margin(l = -7, t = 0)
  )
p_h5c_mms

Code

baselines <- expand_grid(
  avg = 0,
  feat_transp_short = "No",
  feat_govt = levels(h5c_mms$feat_govt),
  feat_funding_short = levels(h5c_mms$feat_funding_short)
)

p_h5c_amces <- h5c_amces %>% 
  ungroup() %>% 
  separate_wider_delim(
    feat_transp_short,
    delim = " - ", 
    names = c("feat_transp_short", "reference_level")
  ) %>% 
  bind_rows(baselines) %>% 
  mutate(feat_transp_short = factor(feat_transp_short, levels = levels(h5c_mms$feat_transp_short))) %>% 
  mutate(feat_govt = factor(feat_govt, levels = levels(h5c_mms$feat_govt))) %>% 
  ggplot(aes(x = avg, y = feat_transp_short, fill = feat_transp_short)) +
  stat_halfeye() +
  geom_vline(xintercept = 0, color = clrs$prism[8], linetype = "dashed", linewidth = 0.25) +
  scale_x_continuous(labels = label_pp) +
  scale_y_discrete(labels = label_wrap(11)) +
  scale_fill_manual(values = clrs$prism[c(10, 3)], guide = "none") +
  facet_nested_wrap(
    vars(feat_govt, feat_funding_short),
    ncol = 3,
    strip = strip_nested(
      text_x = list(element_text(
        family = "Libre Franklin",
        face = "bold"
      ), NULL),
      background_x = list(element_rect(fill = "grey96"), NULL),
      by_layer_x = TRUE
    )
  ) +
  labs(
    x = "Percentage point change in probability of choice selection",
    y = NULL,
    fill = NULL,
    title = "Difference in estimated marginal means"
  )

p_h5c_amces

H5d: Relationship with host government, organizational practices, and issue area

Hypothesis 5d: Relationship with host government, organizational practices, and issue area

Donors will show increased willingness to donate to NGOs that are criticized by the government/under government crackdown when they are also financially transparent and work in less contentious areas (emergency response and refugee relief)

Estimand

TODO

Code
h5d_mms <- preds_all %>% 
  group_by(feat_transp_short, feat_govt, feat_issue, .draw) %>% 
  summarize(avg = mean(.epred))

h5d_amces <- h5d_mms %>% 
  group_by(feat_govt, feat_issue) %>% 
  compare_levels(variable = avg, by = feat_transp_short, comparison = "control")
Code
p_h5d_mms <- h5d_mms %>%
  ggplot(aes(x = avg, y = feat_transp_short, fill = feat_transp_short)) +
  stat_halfeye() +
  geom_vline(xintercept = 0.25, color = clrs$prism[8], linetype = "dashed", linewidth = 0.25) +
  scale_x_continuous(labels = label_percent()) +
  scale_y_discrete(labels = label_wrap(11)) +
  scale_fill_manual(values = clrs$prism[c(10, 3)], guide = "none") +
  facet_nested_wrap(
    vars(feat_govt, feat_issue),
    ncol = 4,
    strip = strip_nested(
      text_x = list(element_text(
        family = "Libre Franklin",
        face = "bold"
      ), NULL),
      background_x = list(element_rect(fill = "grey96"), NULL),
      by_layer_x = TRUE
    )
  ) +
  labs(
    x = "Overall average predicted probability",
    y = NULL,
    fill = NULL,
    title = "Estimated marginal means"
  ) +
  theme(
    legend.position = "top",
    legend.justification = "left",
    legend.margin = margin(l = -7, t = 0)
  )
p_h5d_mms

Code

baselines <- expand_grid(
  avg = 0,
  feat_transp_short = "No",
  feat_govt = levels(h5d_mms$feat_govt),
  feat_issue = levels(h5d_mms$feat_issue)
)

p_h5d_amces <- h5d_amces %>% 
  ungroup() %>% 
  separate_wider_delim(
    feat_transp_short,
    delim = " - ", 
    names = c("feat_transp_short", "reference_level")
  ) %>% 
  bind_rows(baselines) %>% 
  mutate(feat_transp_short = factor(feat_transp_short, levels = levels(h5d_mms$feat_transp_short))) %>% 
  mutate(feat_govt = factor(feat_govt, levels = levels(h5d_mms$feat_govt))) %>% 
  ggplot(aes(x = avg, y = feat_transp_short, fill = feat_transp_short)) +
  stat_halfeye() +
  geom_vline(xintercept = 0, color = clrs$prism[8], linetype = "dashed", linewidth = 0.25) +
  scale_x_continuous(labels = label_pp) +
  scale_y_discrete(labels = label_wrap(11)) +
  scale_fill_manual(values = clrs$prism[c(10, 3)], guide = "none") +
  facet_nested_wrap(
    vars(feat_govt, feat_issue),
    ncol = 4,
    strip = strip_nested(
      text_x = list(element_text(
        family = "Libre Franklin",
        face = "bold"
      ), NULL),
      background_x = list(element_rect(fill = "grey96"), NULL),
      by_layer_x = TRUE
    )
  ) +
  labs(
    x = "Percentage point change in probability of choice selection",
    y = NULL,
    fill = NULL,
    title = "Difference in estimated marginal means"
  )

p_h5d_amces

H5e: Relationship with host government, organizational practices, issue area, and funding sources

Hypothesis 5e: Relationship with host government, organizational practices, issue area, and funding sources

Donors will show increased willingness to donate to NGOs that are criticized by the government/under government crackdown when they are also financially transparent and work in less contentious areas (emergency response and refugee relief) and are funded by numerous small donors

TODO

Code
h5e_mms <- preds_all %>% 
  group_by(feat_transp_short, feat_govt, feat_funding_short, feat_issue, .draw) %>% 
  summarize(avg = mean(.epred))

h5e_amces <- h5e_mms %>% 
  group_by(feat_govt, feat_funding_short, feat_issue) %>% 
  compare_levels(variable = avg, by = feat_transp_short, comparison = "control")
Code
p_h5e_mms <- h5e_mms %>%
  ggplot(aes(x = avg, y = feat_transp_short, fill = feat_transp_short)) +
  stat_halfeye() +
  geom_vline(xintercept = 0.25, color = clrs$prism[8], linetype = "dashed", linewidth = 0.25) +
  scale_x_continuous(labels = label_percent()) +
  scale_y_discrete(labels = label_wrap(11)) +
  scale_fill_manual(values = clrs$prism[c(10, 3)], guide = "none") +
  facet_nested_wrap(
    vars(feat_govt, feat_funding_short, feat_issue),
    ncol = 12,
    strip = strip_nested(
      text_x = list(element_text(
        family = "Libre Franklin",
        face = "bold"
      ), NULL),
      background_x = list(element_rect(fill = "grey96"), NULL),
      by_layer_x = TRUE
    )
  ) +
  labs(
    x = "Overall average predicted probability",
    y = NULL,
    fill = NULL,
    title = "Estimated marginal means"
  ) +
  theme(
    legend.position = "top",
    legend.justification = "left",
    legend.margin = margin(l = -7, t = 0)
  )
p_h5e_mms

Code

baselines <- expand_grid(
  avg = 0,
  feat_transp_short = "No",
  feat_govt = levels(h5e_mms$feat_govt),
  feat_funding_short = levels(h5e_mms$feat_funding_short),
  feat_issue = levels(h5e_mms$feat_issue)
)

p_h5e_amces <- h5e_amces %>% 
  ungroup() %>% 
  separate_wider_delim(
    feat_transp_short,
    delim = " - ", 
    names = c("feat_transp_short", "reference_level")
  ) %>% 
  bind_rows(baselines) %>% 
  mutate(feat_transp_short = factor(feat_transp_short, levels = levels(h5e_mms$feat_transp_short))) %>% 
  mutate(feat_govt = factor(feat_govt, levels = levels(h5e_mms$feat_govt))) %>% 
  ggplot(aes(x = avg, y = feat_transp_short, fill = feat_transp_short)) +
  stat_halfeye() +
  geom_vline(xintercept = 0, color = clrs$prism[8], linetype = "dashed", linewidth = 0.25) +
  scale_x_continuous(labels = label_pp) +
  scale_y_discrete(labels = label_wrap(11)) +
  scale_fill_manual(values = clrs$prism[c(10, 3)], guide = "none") +
  facet_nested_wrap(
    vars(feat_govt, feat_funding_short, feat_issue),
    ncol = 12,
    strip = strip_nested(
      text_x = list(element_text(
        family = "Libre Franklin",
        face = "bold"
      ), NULL),
      background_x = list(element_rect(fill = "grey96"), NULL),
      by_layer_x = TRUE
    )
  ) +
  labs(
    x = "Percentage point change in probability of choice selection",
    y = NULL,
    fill = NULL,
    title = "Difference in estimated marginal means"
  )

p_h5e_amces

H5f: Accountability

Hypothesis 5f: Accountability

Donors should be no more or less likely to donate to NGOs that are accountable and hold regular third party audits

Mechanism: Donors don’t necessarily seek assurance through third-party programs/audits and charity watchdogs, but rather through word of mouth, personal scrutiny and local networks

Estimand

\[ \begin{aligned} \theta =&\ \textbf{E}\bigl[ Y_i \mid \operatorname{do}\left( \text{Accountability} = \text{Yes} \right) \bigr] \end{aligned} \]

Code
h5f_mms <- preds_all %>% 
  group_by(feat_acc_short, .draw) %>% 
  summarize(avg = mean(.epred))

h5f_amces <- h5f_mms %>% 
  group_by(feat_acc_short) %>% 
  compare_levels(variable = avg, by = feat_acc_short, comparison = "control")
Code
p_h5f_mms <- h5f_mms %>% 
  ggplot(aes(x = avg, y = feat_acc_short, fill = feat_acc_short)) +
  stat_halfeye() +
  geom_vline(xintercept = 0.25, color = clrs$prism[8], linetype = "dashed", linewidth = 0.25) +
  scale_x_continuous(labels = label_percent()) +
  scale_y_discrete(labels = label_wrap(11)) +
  scale_fill_manual(values = clrs$prism[c(9, 4)], guide = "none") +
  labs(
    x = "Overall average predicted probability",
    y = NULL,
    fill = NULL,
    title = "Estimated marginal means"
  )

p_h5f_amces <- h5f_amces %>% 
  ungroup() %>% 
  separate_wider_delim(
    feat_acc_short,
    delim = " - ", 
    names = c("feat_acc_short", "reference_level")
  ) %>% 
  add_row(avg = 0, feat_acc_short = unique(.$reference_level)) %>%
  mutate(feat_acc_short = factor(feat_acc_short, levels = levels(h5f_mms$feat_acc_short))) %>% 
  ggplot(aes(x = avg, y = feat_acc_short, fill = feat_acc_short)) +
  stat_halfeye() +
  geom_vline(xintercept = 0, color = clrs$prism[8], linetype = "dashed", linewidth = 0.25) +
  scale_x_continuous(labels = label_pp) +
  scale_y_discrete(labels = label_wrap(11)) +
  scale_fill_manual(values = clrs$prism[c(9, 4)], guide = "none") +
  labs(
    x = "Percentage point change in probability of choice selection",
    y = NULL,
    fill = NULL,
    title = "Average marginal component effects (AMCEs)"
  )

p_h5f_mms | p_h5f_amces

Code
h5f_tbl_mm <- h5f_mms %>% 
  group_by(feat_acc_short) %>% 
  median_qi() %>% 
  mutate(nice = glue("{fmt_decimal(avg)}<br>{build_ci(.lower, .upper)}")) %>% 
  arrange(desc(feat_acc_short)) %>% 
  select(feat_acc_short, nice)

h5f_tbl_amces <- h5f_amces %>% 
  group_by(feat_acc_short) %>% 
  summarize(
    median_qi(avg),
    p_gt_0 = sum(avg > 0) / n()
  ) %>%
  mutate(p_neq_0 = ifelse(y >= 0, p_gt_0, 1 - p_gt_0)) %>% 
  mutate(nice = glue("{fmt_decimal(y)}<br>{build_ci(ymin, ymax)}")) %>% 
  mutate(feat_acc_short = str_replace(feat_acc_short, " - ", "−<br>")) %>% 
  mutate(across(starts_with("p_"), ~fmt_decimal(.))) %>% 
  arrange(desc(feat_acc_short)) %>% 
  select(contrast = feat_acc_short, amce_nice = nice, p_neq_0)

bind_cols(
  h5f_tbl_mm, 
  add_row(h5f_tbl_amces, contrast = "*(Reference)*")
) %>% 
  gt() %>% 
  sub_missing(columns = everything(), missing_text = "—") %>% 
  fmt_markdown(columns = c(nice, amce_nice, contrast)) %>%
  cols_align(align = "center", columns = everything()) %>% 
  cols_align(align = "left", columns = c(feat_acc_short, contrast)) %>% 
  cols_label(
    feat_acc_short = "Accountability", 
    nice = "Posterior EMM",
    contrast = "Contrast",
    amce_nice = "Posterior AMCE",
    p_neq_0 = "*p*~direction~",
    .fn = md
  ) %>% 
  tab_style(
    style = cell_text(v_align = "top"),
    locations = cells_body()
  ) %>% 
  tab_footnote(
    footnote = "Values are on the percentage-point scale; single value is posterior median; 95% credible interval in brackets.",
    locations = cells_column_labels(columns = c(nice, amce_nice))
  ) %>% 
  tab_footnote(
    footnote = md("The probability of direction (*p*~direction~) is the probability that the posterior AMCE is strictly positive or negative—it is the proportion of the posterior AMCE that is the sign of the median."),
    locations = cells_column_labels(columns = p_neq_0)
  ) %>% 
  gt_add_divider(columns = nice, style = "dashed", weight = px(1)) %>% 
  opt_footnote_marks(marks = "standard") %>% 
  opt_horizontal_padding(3) %>% 
  opts_theme()
Accountability Posterior EMM* Contrast Posterior AMCE* pdirection
Yes

0.306
[0.299, 0.313]

Yes−
No

0.101
[0.092, 0.110]

1.000
No

0.205
[0.198, 0.211]

(Reference)

* Values are on the percentage-point scale; single value is posterior median; 95% credible interval in brackets.
The probability of direction (pdirection) is the probability that the posterior AMCE is strictly positive or negative—it is the proportion of the posterior AMCE that is the sign of the median.