Representing the geopolitical context of the cold war period and after it ended through a network is an riveting way of approaching this historical interval in a mathematical way, therefore, if we understand the actors of international relations (States) as nodes of a network
library("network")
library("ggnetwork")
library("sna")
library("dplyr")
library("knitr")
library("tibble")
library("ggrepel")
setwd("C:/Users/jebet/OneDrive/Escritorio/UEXT/ULB/Social network analysis/Directory")
all_data <- read.table("alliance_v4.1_by_dyad.csv", sep=",", header=TRUE, na.strings="", stringsAsFactors = FALSE)
View(all_data)
We made many functions in order to create easier subsets an to be able to use the measures.
subseting <- function(start_d, end_d){
sub <- subset(all_data,
asymmetric == 0 & defense == 1 &
(dyad_st_year <= end_d | (is.na(dyad_st_year) & left_censor == 1)) &
(dyad_end_year >= start_d | (is.na(dyad_end_year) & right_censor == 1)))
country_codes <- sort(unique(c(sub$ccode1, sub$ccode2)))
N <- length(country_codes)
sub$snd <- match(sub$ccode1, country_codes)
sub$rec <- match(sub$ccode2, country_codes)
sub$val <- 1
sub_edges <- sub[, c("snd", "rec", "val")]
country_names_all <- data.frame(ccode = c(sub$ccode1, sub$ccode2),
state = c(as.character(sub$state_name1),
as.character(sub$state_name2)),
stringsAsFactors = FALSE)
country_names_table <- sort(unique(country_names_all))
country_names <- country_names_table$state[match(country_codes, country_names_table$ccode)]
sub_edges_b <- unique(sub_edges)
sub_edgelist <- as.matrix(sub_edges_b)
attr(sub_edgelist, "n") <- N
attr(sub_edgelist, "vnames") <- country_names
sub_mat <- as.sociomatrix.sna(sub_edgelist)
sub_net <- as.network(sub_edgelist, matrix.type = "edgelist", directed = FALSE, multiple = FALSE, edge.check = TRUE)
}
plot_that <- function(sub,sub_title=""){
ggplot(sub, aes(x = x, y = y, xend = xend, yend = yend)) +
ggtitle(sub_title)+
geom_edges(alpha = 0.5, colour = "lightgray", size = 1) +
geom_nodetext_repel(mapping = aes(label = vertex.names),force = 5) +
geom_nodes() +
theme_blank()
}
central_mat <- function(sub_mat){
n_sub_mat <- nrow(sub_mat)
base_sub_df <- data.frame(Country = rownames(sub_mat),
Degree = degree(sub_mat, gmode = "graph"),
StdDegree = degree(sub_mat, gmode = "graph")/(n_sub_mat-1),
Betweenness = betweenness(sub_mat, gmode = "graph"),
StdBetweenness = betweenness(sub_mat, gmode = "graph")/((n_sub_mat-1)*(n_sub_mat-2)/2), stringsAsFactors = FALSE)
}
We make the following to test some subsets.
cw_net <- subseting(1946,1989)
now_net <- subseting(1991,2012)
cw_mat <- as.sociomatrix.sna(cw_net)
now_mat <- as.sociomatrix.sna(now_net)
cw_ego <- ego.extract(cw_net)
now_ego <- ego.extract(now_net)
set.seed(4)
cw_coord <- fortify(cw_net, layout = "kamadakawai")
now_coord <- fortify(now_net)
plot_that(cw_coord, "Network Showing Aliances during Cold War (1947-1991)")
plot_that(now_coord, "Network Showing Aliances Between 1990 and 2012")
Following the network that we plotted, it is imperative to understand the measures that come within this data set, therefore, understanding the 10 countries with elevated quantities of Degree, Betweenness and Closeness.
base_cw_df <- central_mat(cw_mat)
base_now_df <- central_mat(now_mat)
sort_cw_df <- base_cw_df[order(base_cw_df$StdBetweenness ,decreasing = TRUE),]
sort_now_df <- base_now_df[order(base_now_df$StdBetweenness ,decreasing = TRUE),]
sort_cw_df1 <- base_cw_df[order(base_cw_df$StdBetweenness ,decreasing = TRUE),]
sort_now_df1 <- base_now_df[order(base_now_df$StdBetweenness ,decreasing = TRUE),]
sort_cw_df2 <- base_cw_df[order(base_cw_df$StdDegree ,decreasing = TRUE),]
sort_now_df2 <- base_now_df[order(base_now_df$StdDegree ,decreasing = TRUE),]
kable(sort_cw_df1[1:10,], digits = 2, caption = "Betweenness cw")
| Country | Degree | StdDegree | Betweenness | StdBetweenness | |
|---|---|---|---|---|---|
| 38 | France | 19 | 0.17 | 1842.17 | 0.31 |
| 1 | United States of America | 48 | 0.44 | 1802.67 | 0.30 |
| 34 | United Kingdom | 17 | 0.15 | 1646.62 | 0.27 |
| 93 | Iraq | 18 | 0.16 | 1298.36 | 0.22 |
| 52 | Russia | 15 | 0.14 | 1061.99 | 0.18 |
| 2 | Canada | 39 | 0.35 | 925.00 | 0.15 |
| 63 | Mauritania | 26 | 0.24 | 480.63 | 0.08 |
| 74 | Gabon | 14 | 0.13 | 341.66 | 0.06 |
| 75 | Central African Republic | 14 | 0.13 | 341.66 | 0.06 |
| 76 | Chad | 14 | 0.13 | 341.66 | 0.06 |
kable(sort_now_df1[1:10,], digits = 2, caption = "Betweenness now")
| Country | Degree | StdDegree | Betweenness | StdBetweenness | |
|---|---|---|---|---|---|
| 39 | France | 19 | 0.15 | 2500.33 | 0.33 |
| 82 | Gabon | 11 | 0.09 | 2499.00 | 0.33 |
| 102 | Sudan | 26 | 0.21 | 2211.00 | 0.29 |
| 71 | Mauritania | 19 | 0.15 | 1275.00 | 0.17 |
| 1 | United States of America | 46 | 0.37 | 1142.00 | 0.15 |
| 2 | Canada | 44 | 0.35 | 945.00 | 0.12 |
| 85 | Congo | 17 | 0.14 | 448.00 | 0.06 |
| 94 | Angola | 17 | 0.14 | 448.00 | 0.06 |
| 83 | Central African Republic | 15 | 0.12 | 351.00 | 0.05 |
| 86 | Democratic Republic of the Congo | 15 | 0.12 | 351.00 | 0.05 |
kable(sort_cw_df2[1:10,], digits = 2, caption = "StdDegree cw")
| Country | Degree | StdDegree | Betweenness | StdBetweenness | |
|---|---|---|---|---|---|
| 1 | United States of America | 48 | 0.44 | 1802.67 | 0.30 |
| 2 | Canada | 39 | 0.35 | 925.00 | 0.15 |
| 5 | Haiti | 31 | 0.28 | 4.67 | 0.00 |
| 6 | Dominican Republic | 31 | 0.28 | 4.67 | 0.00 |
| 16 | Mexico | 31 | 0.28 | 4.67 | 0.00 |
| 17 | Guatemala | 31 | 0.28 | 4.67 | 0.00 |
| 18 | Honduras | 31 | 0.28 | 4.67 | 0.00 |
| 20 | Nicaragua | 31 | 0.28 | 4.67 | 0.00 |
| 21 | Costa Rica | 31 | 0.28 | 4.67 | 0.00 |
| 22 | Panama | 31 | 0.28 | 4.67 | 0.00 |
kable(sort_now_df2[1:10,], digits = 2, caption = "StdDegree now")
| Country | Degree | StdDegree | Betweenness | StdBetweenness | |
|---|---|---|---|---|---|
| 1 | United States of America | 46 | 0.37 | 1142 | 0.15 |
| 2 | Canada | 44 | 0.35 | 945 | 0.12 |
| 3 | Bahamas | 28 | 0.23 | 0 | 0.00 |
| 4 | Haiti | 28 | 0.23 | 0 | 0.00 |
| 5 | Dominican Republic | 28 | 0.23 | 0 | 0.00 |
| 6 | Jamaica | 28 | 0.23 | 0 | 0.00 |
| 8 | Barbados | 28 | 0.23 | 0 | 0.00 |
| 9 | Dominica | 28 | 0.23 | 0 | 0.00 |
| 10 | Grenada | 28 | 0.23 | 0 | 0.00 |
| 11 | St. Lucia | 28 | 0.23 | 0 | 0.00 |
ten_cw_df <- sort_cw_df[1:10,]
ten_now_df <- sort_now_df[1:10,]
It is highly pertinent to perceive the formal and informal power that certain countries can generate in the network, the graph shows in a mathematical order how particular countries can influence their corresponding alliances, for example, countries such as United States of America showcase great influence during and after the cold war period, meanwhile, Russia, United Kingdom and Iraq lose exposure and negotiation capacity after the conflict.
ggplot(data = ten_cw_df, aes(x = StdBetweenness, y =StdDegree , label = Country)) +
geom_point()+
geom_label_repel(size = 5)
ggplot(data = ten_now_df, aes(x = StdBetweenness, y =StdDegree , label = Country)) +
geom_point()+
geom_label_repel(size = 5)
Betweennes measure showcases how countries influence a group of other countries through their alliances or agreements. In general, the following graphs prove that after the cold war period, countries’ nodes lie shorter from each other which means a higher control of diplomatic information between countries and the materialization of informal power as it is.
ten_cw_country <- ten_cw_df$Country
ten_now_country <- ten_now_df$Country
ten_cw_mat <- cw_mat[ten_cw_country,ten_cw_country]
ten_cw_net <- as.network(ten_cw_mat, directed = FALSE, multiple = FALSE, edge.check = TRUE)
ten_now_mat <- now_mat[ten_now_country,ten_now_country]
ten_now_net <- as.network(ten_now_mat, directed = FALSE, multiple = FALSE, edge.check = TRUE)
plot_that(ten_cw_net, "Most StdBetweeness during the Cold War")
plot_that(ten_now_net,"Most StdBetweeness 1990 - 2012")
#We have here graphical representation of the countries with considerable betweenness during the cold war and afterwards its culmination. The graphs indicating the conflict period are labeled as "cw".
plot_that(ggnetwork(cw_ego$France),"France cw")
plot_that(ggnetwork(now_ego$France),"France")
plot_that(ggnetwork(cw_ego$`United States of America`),"United States of America cw")
plot_that(ggnetwork(now_ego$`United States of America`),"United States of America")
plot_that(ggnetwork(cw_ego$`United Kingdom`),"United Kingdom cw")
plot_that(ggnetwork(now_ego$`United Kingdom`),"United Kingdom")
plot_that(ggnetwork(cw_ego$Russia),"Russia cw")
plot_that(ggnetwork(now_ego$Russia),"Russia")
#library("igraph")
#library("remotes")
#library("RBioFabric")
#cw_graph <- intergraph::asIgraph(cw_net)
#class(cw_graph)
#bioFabric(cw_graph)
#for (variable in ten_cw_country) {
#}
#test <- cliques(cw_graph,max=25)
#plot_that(test)