select(country, year, gdp_percap) %>%
distinct() %>%
mutate(gdp_percap = as.numeric(as.character(gdp_percap)))
tp_legal <- tp_long %>%
left_join(gdppc_clean, by = c("tp_name" = "country", "year")) %>%
mutate(tp_legal = gdp_percap * tp_weight) %>%
group_by(case, comp_idx) %>%
summarise(total_tp_legal = sum(tp_legal, na.rm = TRUE), .groups = "drop")
main_legal <- main_long2 %>%
left_join(gdppc_clean, by = c("main_name" = "country", "year")) %>%
mutate(main_legal = gdp_percap) %>%
group_by(case, comp_idx) %>%
summarise(total_main_legal = sum(main_legal, na.rm = TRUE), .groups = "drop")
main_legal_ratio <- main_long2 %>%
left_join(gdppc_clean, by = c("main_name" = "country", "year")) %>%
mutate(main_legal = gdp_percap * main_weight) %>%
group_by(case, comp_idx, main_idx) %>%
summarise(total_legal = sum(main_legal, na.rm = TRUE), .groups = "drop") %>%
pivot_wider(names_from = main_idx, values_from = total_legal, names_prefix = "legal_") %>%
mutate(ratio_main_legal = legal_resp / legal_comp)
master_legal <- full_join(tp_legal, main_legal, by = c("case", "comp_idx")) %>%
mutate(
legal_index = total_tp_legal/total_main_legal
) %>%
left_join(main_legal_ratio, by = c("case", "comp_idx"))
master_legal$ratio_main_legal[is.nan(master_legal$ratio_main_legal)] <- 0
master_legal$ratio_main_legal[is.infinite(master_legal$ratio_main_legal)] <- max(master_legal$ratio_main_legal[is.finite(master_legal$ratio_main_legal)], na.rm = TRUE)
write_csv(master_legal, "Data/Legal Capacity.csv")
### Code Regime Type ###
vdem_clean <- vdem_clean %>%
select(country, year, libdem) %>%
distinct()
tp_libdem <- tp_long %>%
left_join(vdem_clean, by = c("tp_name" = "country", "year")) %>%
mutate(tp_libdem = libdem * tp_weight) %>%
group_by(case, comp_idx) %>%
summarise(total_tp_libdem = sum(tp_libdem, na.rm = TRUE), .groups = "drop")
main_libdem <- main_long2 %>%
left_join(vdem_clean, by = c("main_name" = "country", "year")) %>%
mutate(main_libdem = libdem * main_weight) %>%
group_by(case, comp_idx) %>%
summarise(total_main_libdem = sum(main_libdem, na.rm = TRUE), .groups = "drop")
main_libdem_ratio <- main_long2 %>%
left_join(vdem_clean, by = c("main_name" = "country", "year")) %>%
mutate(main_libdem = libdem) %>%
group_by(case, comp_idx, main_idx) %>%
summarise(total_libdem = sum(main_libdem, na.rm = TRUE), .groups = "drop") %>%
pivot_wider(names_from = main_idx, values_from = total_libdem, names_prefix = "libdem_") %>%
mutate(ratio_main_libdem = libdem_resp / libdem_comp)
master_libdem <- full_join(tp_libdem, main_libdem, by = c("case", "comp_idx")) %>%
mutate(libdem_index = total_tp_libdem/total_main_libdem) %>%
left_join(main_libdem_ratio, by = c("case", "comp_idx"))
master_libdem$ratio_main_libdem[is.nan(master_libdem$ratio_main_libdem)] <- 0
master_libdem$ratio_main_libdem[is.infinite(master_libdem$ratio_main_libdem)] <- max(master_libdem$ratio_main_libdem[is.finite(master_libdem$ratio_main_libdem)], na.rm = TRUE)
write_csv(master_libdem, "Data/Libdem Score.csv")
### Code Case Outcome ###
case_outcome <- master %>%
mutate(
settle = ifelse(!is.na(mas_date) | !is.na(mas_day), 1, 0),
early_settle = ifelse((!is.na(mas_date) | !is.na(mas_day)) & (is.na(panel_date) | !is.na(panel_day)), 1, 0),
no_settle = ifelse(is.na(mas_date) & is.na(mas_day), 1, 0)
) %>%
select(case, comp_idx, settle, no_settle)
write_csv(case_outcome, "Data/Case Outcome.csv")
### Code Case Complexity ###
complexity <- master %>%
unnest_wider(agreement, names_sep = "")
complexity_raw <- master %>%
select(case, comp_idx, agreement) %>%
setNames(c("case", "comp_idx", "agreement", "")) %>%
separate('agreement', into = paste0("agreement", 1:6), sep = ", ", fill = "right")
complexity_expand <- complexity_raw %>%
pivot_longer(cols = paste0("agreement", 1:6), names_to = "agreement_idx", values_to = "agreement_name") %>%
filter(!is.na(agreement_name) | (is.na(agreement_name) & agreement_idx == "agreement1"))
case_complexity <- complexity_expand %>%
group_by(case, comp_idx) %>%
summarise(complexity = sum(!is.na(agreement_name))) %>%
left_join(master, by = c("case", "comp_idx")) %>%
select(case, comp_idx, complexity)
write_csv(case_complexity, "Data/Case Complexity.csv")
### Code Article XXII ###
case_article_xxii <- master %>%
left_join(article_source) %>%
select(case, comp_idx, xxii_cited)
write_csv(case_article_xxii, "Data/Case Article XXII Cited.csv")
### Code Systemic Issues ###
case_systemic_issue <- master %>%
left_join(article_source) %>%
select(case, comp_idx, systemic_cited)
write_csv(case_systemic_issue, "Data/Case Systemic Issue Cited.csv")
### Code Disputed Policy ###
categorical_policy <- master %>%
select(case, comp_idx, policy)
categorical_policy <- categorical_policy %>%
mutate(policy_group = case_when(
# Group 1: Discrimination
grepl("discriminat|preferential|gsp|origin", policy, ignore.case = TRUE) ~ 1,
# Group 2: Export, Import, Technical, Safeguards Barriers
grepl("export|import|ban|restriction|quota|licensing|customs valuation|customs|technical|safeguard|transit|quantitative",
policy, ignore.case = TRUE) ~ 2,
# Group 3: Subsidies, Anti-dumping
grepl("subsid|anti-dumping|dumping|countervailing|zeroing|sunset review|national",
policy, ignore.case = TRUE) ~ 3,
# Group 4: Intellectual Property
grepl("intellectual property|trips|patent|copyright|geographical indication",
policy, ignore.case = TRUE) ~ 4,
# Group 5: Goods, Services, Investments
grepl("goods|services|investment|tariff|market access|content requirement|visa|tax|taxation",
policy, ignore.case = TRUE) ~ 5,
TRUE ~ 0
))
dummy_policy <- categorical_policy %>%
mutate(
policy_discrimination = if_else(policy_group == 1, 1, 0),
policy_barriers = if_else(policy_group == 2, 1, 0),
policy_subsidies = if_else(policy_group == 3, 1, 0),
policy_ip = if_else(policy_group == 4, 1, 0),
policy_gs = if_else(policy_group == 5, 1, 0)
)
case_policy <- dummy_policy
write_csv(case_policy, "Data/Case Policy.csv")
### Combine Dataset ###
final_master <- left_join(master, case_outcome, by = c("case", "comp_idx")) %>%
left_join(tp_count) %>%
left_join(tp_dummy) %>%
left_join(master_mta_count) %>%
left_join(master_mta_depth) %>%
left_join(master_trade) %>%
left_join(master_legal) %>%
left_join(master_libdem) %>%
left_join(case_complexity) %>%
left_join(case_article_xxii) %>%
left_join(case_systemic_issue) %>%
left_join(case_policy) %>%
select(case, comp_idx, settle, tp_count, tp_dummy,
tp_total_mtac, mtac_all_ratio, mtac_tp_mp_ratio,
tp_total_mtad, mtad_all_ratio, mtad_tp_mp_ratio,
total_tp_volume, trade_volume_all_ratio, trade_volume_tp_mp_ratio,
total_tp_legal, legal_index,
total_tp_libdem, libdem_index,
complexity, xxii_cited, systemic_cited,
policy_group, policy_discrimination, policy_barriers, policy_subsidies, policy_ip, policy_gs) %>%
drop_na() %>%
filter(tp_dummy == 1) %>%
write_csv("Data/Final Dataset Unscaled.csv") %>%
mutate(across(4:27, ~ scale(.)[,1])) %>%
mutate(across(3:27, ~ as.numeric(.))) %>%
write_csv("Data/Final Dataset.csv") %>%
select(-tp_dummy)
final_master_unscaled <- read_csv("Data/Final Dataset Unscaled.csv") %>%
select(-tp_dummy)
final_master_unscaled_df <- as.data.frame(final_master_unscaled) %>%
select(-case, -comp_idx) %>%
rename(
"Early Settlement" = settle,
"Third Party Count" = tp_count,
"TP Raw MTA Count Total" = tp_total_mtac,
"TP to AP MTA Count Ratio" = mtac_all_ratio,
"TP to MP MTA Count Ratio" = mtac_tp_mp_ratio,
"TP Raw MTA Depth Total" = tp_total_mtad,
"TP to AP MTA Depth Ratio" = mtad_all_ratio,
"TP to MP MTA Depth Ratio" = mtad_tp_mp_ratio,
"TP Raw Trade Volume Total*" = total_tp_volume,
"TP to AP Trade Volume Ratio" = trade_volume_all_ratio,
"TP to MP Trade Volume Ratio" = trade_volume_tp_mp_ratio,
"Average TP Legal Capacity**" = total_tp_legal,
"TP to MP Legal Capacity Ratio" = legal_index,
"Average TP LibDem Score" = total_tp_libdem,
"TP to MP LibDem Score Ratio" = libdem_index,
"Case Complexity" = complexity,
"Article XXII Cited" = xxii_cited,
"Systemic Issue Cited" = systemic_cited,
"Policy Group" = policy_group,
"Discriminative Policy" = policy_discrimination,
"Trade Barrier Policy" = policy_barriers,
"Subsidies Policy" = policy_subsidies,
"Intellectual Property Policy" = policy_ip,
"Goods Services Policy" = policy_gs
)
stargazer(final_master_unscaled_df, type= "latex", title = "Summary Statistics", summary = TRUE, median = TRUE, iqr = TRUE, digits = 3, out = "Output/Summary Statistics.tex", column.sep.width = "5pt", notes = "TP=Third Parties; AP=All Parties; MP=Main Parties; LibDem=Liberal Democracy. *Trade in millions of 2014 US dollars. **GDP Per Capita in 2024 US dollars.")
final_master_df <- as.data.frame(final_master) %>%
select(-case, -comp_idx) %>%
rename(
"Early Settlement" = settle,
"Third Party Count" = tp_count,
"TP Raw MTA Count Total" = tp_total_mtac,
"TP to AP MTA Count Ratio" = mtac_all_ratio,
"TP to MP MTA Count Ratio" = mtac_tp_mp_ratio,
"TP Raw MTA Depth Total" = tp_total_mtad,
"TP to AP MTA Depth Ratio" = mtad_all_ratio,
"TP to MP MTA Depth Ratio" = mtad_tp_mp_ratio,
"TP Raw Trade Volume Total" = total_tp_volume,
"TP to AP Trade Volume Ratio" = trade_volume_all_ratio,
"TP to MP Trade Volume Ratio" = trade_volume_tp_mp_ratio,
"Average TP Legal Capacity" = total_tp_legal,
"TP to MP Legal Capacity Ratio" = legal_index,
"Average TP LibDem Score" = total_tp_libdem,
"TP to MP LibDem Score Ratio" = libdem_index,
"Case Complexity" = complexity,
"Article XXII Cited" = xxii_cited,
"Systemic Issue Cited" = systemic_cited,
"Policy Group" = policy_group,
"Discriminative Policy" = policy_discrimination,
"Trade Barrier Policy" = policy_barriers,
"Subsidies Policy" = policy_subsidies,
"Intellectual Property Policy" = policy_ip,
"Goods Services Policy" = policy_gs
)
stargazer(final_master_df, type= "latex", title = "Standardized Summary Statistics", summary = TRUE, median = TRUE, iqr = TRUE, digits = 3, out = "Output/Standardized Summary Statistics.tex", column.sep.width = "5pt", notes = "TP=Third Parties; AP=All Parties; MP=Main Parties; LibDem=Liberal Democracy")
### Check Variable Correlations ###
cor_data <- final_master %>%
select(where(is.numeric)) %>%
select(-comp_idx)
# Run together - From here #
cor_matrix <- cor(cor_data, use = "complete.obs")
colnames(cor_matrix) <- c("Early Settlement", "TP Count",
"TP Raw MTA Count Total", "TP-AP MTA Count Ratio", "TP-MP MTA Count Ratio",
"TP Raw MTA Depth Total", "TP-AP MTA Depth Ratio", "TP-MP MTA Depth Ratio",
"TP Raw Trade Volume Total", "TP-AP Trade Volume Ratio", "TP-MP Trade Volume Ratio",
"Ave TP Legal Capacity", "TP-MP Legal Capacity Ratio", "Ave TP Liberal Democracy Score", "TP-MP Liberal Democracy Score Ratio",
"Case Complexity", "Article XXII Cited", "Systemic Issue Cited",
"Policy Group", "Discriminative Policy", "Trade Barrier Policy", "Subsidies Policy", "Intellectual Property Policy", "Goods Services Policy")
rownames(cor_matrix) <- colnames(cor_matrix)
png("Output/Correlation Matrix.png", width = 8000, height = 6000, res = 100)
par(family = "serif")
corrplot(cor_matrix, method = "color", type = "upper",
tl.cex = 5.5, number.cex = 5, cl.cex = 5.5,
tl.col = "black", tl.srt = 45,
addCoef.col = "black",
addgrid.col = "black"
)
# Run together - To here #
cor_matrix_df <- as.data.frame(cor_matrix)
write_csv(cor_matrix_df, "Data/Correlation Matrix.csv")
### MTA Count Models (1-3) ###
model_tp_mtac <- glm(settle ~ tp_count + tp_total_mtac + legal_index + libdem_index + complexity + xxii_cited + systemic_cited + policy_group, data = final_master, family = "binomial"(link = "probit"))
model_mtac_all_ratio <- glm(settle ~ tp_count + mtac_all_ratio + legal_index + libdem_index + complexity + xxii_cited + systemic_cited + policy_group, data = final_master, family = "binomial"(link = "probit"))
model_mtac_tp_mp_ratio <- glm(settle ~ tp_count + mtac_tp_mp_ratio + legal_index + libdem_index + complexity + xxii_cited + systemic_cited + policy_group, data = final_master, family = "binomial"(link = "probit"))
### MTA Depth Models (4-6) ###
model_tp_mtad <- glm(settle ~ tp_count + tp_total_mtad + legal_index + libdem_index + complexity + xxii_cited + systemic_cited + policy_group, data = final_master, family = "binomial"(link = "probit"))
model_mtad_all_ratio <- glm(settle ~ tp_count + mtad_all_ratio + legal_index + libdem_index + complexity + xxii_cited + systemic_cited + policy_group, data = final_master, family = "binomial"(link = "probit"))
model_mtad_tp_mp_ratio <- glm(settle ~ tp_count + mtad_tp_mp_ratio + legal_index + libdem_index + complexity + xxii_cited + systemic_cited + policy_group, data = final_master, family = "binomial"(link = "probit"))
### Trade Volume Models (7-9) ###
model_tp_trade <- glm(settle ~ tp_count + total_tp_volume + legal_index + libdem_index + complexity + xxii_cited + systemic_cited + policy_group, data = final_master, family = "binomial"(link = "probit"))
model_trade_all_ratio <- glm(settle ~ tp_count + trade_volume_all_ratio + legal_index + libdem_index + complexity + xxii_cited + systemic_cited + policy_group, data = final_master, family = "binomial"(link = "probit"))
model_trade_tp_mp_ratio <- glm(settle ~ tp_count + trade_volume_tp_mp_ratio + legal_index + libdem_index + complexity + xxii_cited + systemic_cited + policy_group, data = final_master, family = "binomial"(link = "probit"))
### Collect all models ###
models <- list(
model_tp_mtac, model_mtac_all_ratio, model_mtac_tp_mp_ratio,
model_tp_mtad, model_mtad_all_ratio, model_mtad_tp_mp_ratio,
model_tp_trade, model_trade_all_ratio, model_trade_tp_mp_ratio
)
texreg(l = models,
file = "Output/Regression Results.tex",
stars = c(0.001, 0.01, 0.05),
caption.above = TRUE,
caption = "Regression Results",
label = "Regression Results",
booktabs = TRUE,
scalebox = 0.8,
custom.model.names = c(
"(1)",
"(2)",
"(3)",
"(4)",
"(5)",
"(6)",
"(7)",
"(8)",
"(9)"
),
custom.header = list("MTA Count" = 1:3, "MTA Depth" = 4:6, "Trade Volume" = 7:9),
custom.coef.map = list(
"(Intercept)" = "Constant",
"tp_count" = "Third Party Count",
"tp_total_mtac" = "Third Party Raw Total",
"mtac_all_ratio" = "TP to All Party Ratio",
"mtac_tp_mp_ratio" = "TP to Main Party Ratio",
"tp_total_mtad" = "Third Party Raw Total",
"mtad_all_ratio" = "TP to All Party Ratio",
"mtad_tp_mp_ratio" = "TP to Main Party Ratio",
"total_tp_volume" = "Third Party Raw Total",
"trade_volume_all_ratio" = "TP to All Party Ratio",
"trade_volume_tp_mp_ratio" = "TP to Main Party Ratio",
"legal_index" = "TP to MP Legal Capacity Ratio",
"libdem_index" = "TP to MP LibDem Score Ratio",
"complexity" = "Case Complexity",
"xxii_cited" = "Article XXII Cited",
"systemic_cited" = "Systemic Issue Cited",
"policy_group" = "Policy Group"
),
custom.note = "%stars. TP=Third Parties; MP=Main Parties; LibDem=Liberal Democracy.",
digits = 3
)
### Average Marginal Effects and Marginal Effects at the Mean ###
ame_results <- lapply(models, avg_slopes)
modelsummary(ame_results)
### Rename Models ###
model_names <- c(
"Model (1)",
"Model (2)",
"Model (3)",
"Model (4)",
"Model (5)",
"Model (6)",
"Model (7)",
"Model (8)",
"Model (9)"
)
for (i in seq_along(ame_results)) {
ame_results[[i]]$model_name <- model_names[i]
}
### Create Dataset ###
ame_mtac_df <- bind_rows(ame_results) %>%
slice(1:24)
ame_mtad_df <- bind_rows(ame_results) %>%
slice(25:48)
ame_trade_df <- bind_rows(ame_results) %>%
slice(49:72)
### Visualize MTA count ###
figure_3 <- ggplot(ame_mtac_df %>% filter(term == "tp_total_mtac" | term == "mtac_all_ratio" | term == "mtac_tp_mp_ratio") %>%
mutate(term = recode(term,
"tp_total_mtac" = "Third Party Raw Total",
"mtac_all_ratio" = " Third Party to All Party Ratio",
"mtac_tp_mp_ratio" = "  Third Party to Main Party Ratio"
)),
aes(x = estimate, y = term, color = model_name)) +
geom_vline(xintercept = 0, color = "red", linetype = "dashed") +
geom_point(position = position_dodge(width = 0.7)) +
geom_errorbar(aes(xmin = conf.low, xmax = conf.high), width = 0.2, position = position_dodge(width = 0.7)) +
labs(
x = "Marginal Effects (Change in Settlement Probability)",
y = "MTA Count Variables",
color = "Model"
) +
theme_bw(base_family = "serif") +
theme(
plot.title = element_text(size = 16),
axis.title = element_text(size = 14),
axis.text = element_text(size = 12),
legend.title = element_text(size = 13),
legend.text = element_text(size = 11),
axis.title.x = element_text(margin = margin(t = 20)),
axis.title.y = element_text(margin = margin(r = 10))
)
ggsave("Output/Marginal Effects Across MTA Count Models.png", plot = figure_3, width = 10, height = 4, units = "in")
### Visualize MTA Depth ###
figure_4 <- ggplot(ame_mtad_df %>% filter(term == "tp_total_mtad" | term == "mtad_all_ratio" | term == "mtad_tp_mp_ratio") %>%
mutate(term = recode(term,
"tp_total_mtad" = "Third Party Raw Total",
"mtad_all_ratio" = " Third Party to All Party Ratio",
"mtad_tp_mp_ratio" = "  Third Party to Main Party Ratio"
)),
aes(x = estimate, y = term, color = model_name)) +
geom_vline(xintercept = 0, color = "red", linetype = "dashed") +
geom_point(position = position_dodge(width = 0.7)) +
geom_errorbar(aes(xmin = conf.low, xmax = conf.high), width = 0.2, position = position_dodge(width = 0.7)) +
labs(
x = "Marginal Effect (Change in Settlement Probability)",
y = "MTA Depth Variables",
color = "Model"
) +
theme_bw(base_family = "serif") +
theme(
plot.title = element_text(size = 16),
axis.title = element_text(size = 14),
axis.text = element_text(size = 12),
legend.title = element_text(size = 13),
legend.text = element_text(size = 11),
axis.title.x = element_text(margin = margin(t = 20)),
axis.title.y = element_text(margin = margin(r = 10))
)
ggsave("Output/Marginal Effects Across MTA Depth Models.png", plot = figure_4, width = 10, height = 4, units = "in")
### Visualize Trade Volume ###
figure_5 <- ggplot(ame_trade_df %>% filter(term == "total_tp_volume" | term == "trade_volume_all_ratio" | term == "trade_volume_tp_mp_ratio") %>%
mutate(term = recode(term,
"total_tp_volume" = "Third Party Raw Total",
"trade_volume_all_ratio" = " Third Party to All Party Ratio",
"trade_volume_tp_mp_ratio" = "  Third Party to Main Party Ratio"
)), aes(x = estimate, y = term, color = model_name)) +
geom_vline(xintercept = 0, color = "red", linetype = "dashed") +
geom_point(position = position_dodge(width = 0.7)) +
geom_errorbar(aes(xmin = conf.low, xmax = conf.high), width = 0.2, position = position_dodge(width = 0.7)) +
labs(
x = "Marginal Effect (Change in Settlement Probability)",
y = "Trade Volume Variables",
color = "Model"
) +
theme_bw(base_family = "serif") +
theme(
plot.title = element_text(size = 16),
axis.title = element_text(size = 14),
axis.text = element_text(size = 12),
legend.title = element_text(size = 13),
legend.text = element_text(size = 11),
axis.title.x = element_text(margin = margin(t = 20)),
axis.title.y = element_text(margin = margin(r = 10))
)
ggsave("Output/Marginal Effects Across Trade Volume Models.png", plot = figure_5, width = 10, height = 4, units = "in")
### Evaluate Predicted Probability ###
model_list <- list(
model_tp_mtac,
model_mtac_all_ratio,
model_mtac_tp_mp_ratio,
model_tp_mtad,
model_mtad_all_ratio,
model_mtad_tp_mp_ratio,
model_tp_trade,
model_trade_all_ratio,
model_trade_tp_mp_ratio
)
model_names <- paste0("model_", 1:9)
vars_to_vary <- c("tp_total_mtac", "mtac_all_ratio", "mtac_tp_mp_ratio",
"tp_total_mtad", "mtad_all_ratio", "mtad_tp_mp_ratio",
"total_tp_volume", "trade_volume_all_ratio", "trade_tp_mp_ratio",
"complexity", "xxii_cited", "systemic_cited", "legal_index", "libdem_index")
prediction_results <- list()
for (i in seq_along(model_list)) {
model <- model_list[[i]]
model_name <- model_names[[i]]
for (var in vars_to_vary) {
if (!(var %in% names(coef(model)))) next
newdata_grid <- data.frame(var_values = seq(-2, 2, by = 0.25)) %>%
rename(!!var := var_values)
vars_in_model <- names(coef(model))
control_vars <- setdiff(vars_in_model, c("(Intercept)", var))
for (cv in control_vars) {
newdata_grid[[cv]] <- 0
}
pred <- predictions(model, newdata = newdata_grid)
pred_out <- pred %>%
mutate(model = model_name, variable = var) %>%
rename(var_value = !!sym(var))
prediction_results[[paste(model_name, var, sep = "_")]] <- pred_out
}
}
pred_prob <- bind_rows(prediction_results)
predicted_probabilities <- pred_prob %>%
mutate(percentile = case_when(
var_value == -0.75 ~ "25th",
var_value == 0     ~ "50th (Mean)",
var_value == 0.75  ~ "75th"
)) %>%
select(c("model","variable", "percentile", "estimate", "p.value", "conf.low", "conf.high")) %>%
filter(!is.na(percentile))
write_csv(predicted_probabilities, "Data/Predicted Probabilities.csv")
### Plot Predicted Probability for Select Models ###
figure_6 <- plot_predictions(model_tp_mtac, condition = "tp_total_mtac", draw = TRUE) +
labs(
x = "Third Party Raw MTA Count Total",
y = "Probability of Early Settlement",
) +
theme_bw(base_family = "serif") +
theme(
plot.title = element_text(size = 16),
axis.title = element_text(size = 14),
axis.text = element_text(size = 12),
legend.title = element_text(size = 13),
legend.text = element_text(size = 11),
axis.title.x = element_text(margin = margin(t = 10)),
axis.title.y = element_text(margin = margin(r = 10))
)
ggsave("Output/Predicted Probability of MTA Count.png", plot = figure_6, width = 6, height = 5, units = "in")
figure_7 <- plot_predictions(model_tp_mtad, condition = "tp_total_mtad") +
labs(
x = "Third Party Raw MTA Depth Total",
y = "Probability of Early Settlement",
) +
theme_bw(base_family = "serif") +
theme(
plot.title = element_text(size = 16),
axis.title = element_text(size = 14),
axis.text = element_text(size = 12),
legend.title = element_text(size = 13),
legend.text = element_text(size = 11),
axis.title.x = element_text(margin = margin(t = 10)),
axis.title.y = element_text(margin = margin(r = 10))
)
ggsave("Output/Predicted Probability of MTA Depth.png", plot = figure_7, width = 6, height = 5, units = "in")
figure_8 <- plot_predictions(model_tp_trade, condition = "total_tp_volume") +
labs(
x = "Third Party Raw Trade Volume Total",
y = "Probability of Early Settlement",
) +
theme_bw(base_family = "serif") +
theme(
plot.title = element_text(size = 16),
axis.title = element_text(size = 14),
axis.text = element_text(size = 12),
legend.title = element_text(size = 13),
legend.text = element_text(size = 11),
axis.title.x = element_text(margin = margin(t = 10)),
axis.title.y = element_text(margin = margin(r = 10))
)
ggsave("Output/Predicted Probability of Trade Volume.png", plot = figure_8, width = 6, height = 5, units = "in")
cor_matrix <- cor(cor_data, use = "complete.obs")
colnames(cor_matrix) <- c("Early Settlement", "TP Count",
"TP Raw MTA Count Total", "TP-AP MTA Count Ratio", "TP-MP MTA Count Ratio",
"TP Raw MTA Depth Total", "TP-AP MTA Depth Ratio", "TP-MP MTA Depth Ratio",
"TP Raw Trade Volume Total", "TP-AP Trade Volume Ratio", "TP-MP Trade Volume Ratio",
"Ave TP Legal Capacity", "TP-MP Legal Capacity Ratio", "Ave TP Liberal Democracy Score", "TP-MP Liberal Democracy Score Ratio",
"Case Complexity", "Article XXII Cited", "Systemic Issue Cited",
"Policy Group", "Discriminative Policy", "Trade Barrier Policy", "Subsidies Policy", "Intellectual Property Policy", "Goods Services Policy")
rownames(cor_matrix) <- colnames(cor_matrix)
png("Output/Correlation Matrix.png", width = 8000, height = 6000, res = 100)
par(family = "serif")
corrplot(cor_matrix, method = "color", type = "upper",
tl.cex = 5.5, number.cex = 5, cl.cex = 5.5,
tl.col = "black", tl.srt = 45,
addCoef.col = "black",
addgrid.col = "black"
)
