We decided to use the dataset “alliances” from the xergm.common package. It contains the international defense alliance network among 164 countries, covering the years 1981–2000. This is an excerpt from a dataset that has been used in two published analyses. The full dataset (Cranmer, Desmarais and Menninga 2012; Cranmer, Desmarais and Kirlkand 2012) contains a large number of countries and a much longer time series.
The alliances dataset contains 5 main data structures:
is a list of network objects at 20 time points, 1981–2000, containing undirected defense alliance networks. A 1 indicates an alliance and 0 indicates no alliance. In addition to the yearly defense alliance network, it contains attributes for military capabilities (CINC) and governing regime type (“polity”). A higher CINC (Composite Index of National Capability) score indicates a more capable military state.Polity Score captures te regime authority spectrum on a 21-point scale ranging from -10 (hereditary monarchy) to +10 (consolidated democracy).
A 164 x 164 binary matrix in which a 1 indicates that two countries share a border.
A list of 20 matrices. Each element is the adjacency matrix from the previous year. This is used to model memory in the ties.
A list of 20 matrices. Each element is a matrix recording the number of shared partners between countries in the alliance network from the previous year.
A list of 20 matrices. Each element is a binary matrix that indicates whether two states were in a militarized interstate dispute in the respective year.
#extracting data
data("alliances", package = "xergm.common")
We chose to look at the years 1985 and 1995 since these were turbulent years due to the dissolution of USSR and we thought we could find some interesting patterns in the alliance network between these years.
#extracting attribute data for 1985 and 1995
ally_85 <- allyNet[[5]]
ally_95 <- allyNet[[15]]
ally_85_cinc <- ally_85%v%"cinc"
ally_95_cinc <- ally_95%v%"cinc"
ally_85_polity <- ally_85%v%"polity"
ally_95_polity <- ally_95%v%"polity"
#extracting relationship data for 1985 and 1995
LSP_85 <- as.matrix(LSP[[5]])
LSP_95 <- as.matrix(LSP[[15]])
war_85 <- as.matrix(warNet[[5]])
war_95 <- as.matrix (warNet[[15]])
ally_85 <- as.matrix(allyNet[[5]])
ally_95 <- as.matrix(allyNet[[15]])
#creating attrs df
attrs85 <- data.frame(cinc = ally_85_cinc, ally = ally_85_polity)
attrs95 <- data.frame(cinc = ally_95_cinc, ally = ally_95_polity)
rownames(attrs85) <- rownames(war_85)
rownames(attrs95) <- rownames(war_95)
head(LSP_85[,0:20])
## USA CAN CUB HAI DOM JAM TRI MEX GUA HON SAL NIC COS PAN COL VEN GUY
## USA 0 0 0 0 1 2 3 4 5 6 7 8 9 10 11 12 0
## CAN 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## CUB 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## HAI 0 0 0 0 0 1 2 3 4 5 6 7 8 9 10 11 0
## DOM 0 0 0 0 0 0 1 2 3 4 5 6 7 8 9 10 0
## JAM 0 0 0 0 0 0 0 1 2 3 4 5 6 7 8 9 0
## ECU PER BRA
## USA 13 14 15
## CAN 0 0 0
## CUB 0 0 0
## HAI 12 13 14
## DOM 11 12 13
## JAM 10 11 12
head(war_85[,0:20])
## USA CAN CUB HAI DOM JAM TRI MEX GUA HON SAL NIC COS PAN COL VEN GUY
## USA 0 1 1 0 0 0 0 0 0 0 0 1 0 1 0 0 0
## CAN 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## CUB 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0
## HAI 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## DOM 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## JAM 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## ECU PER BRA
## USA 1 1 0
## CAN 0 0 0
## CUB 0 0 0
## HAI 0 0 0
## DOM 0 0 0
## JAM 0 0 0
head(ally_85[,0:20])
## USA CAN CUB HAI DOM JAM TRI MEX GUA HON SAL NIC COS PAN COL VEN GUY
## USA 0 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 0
## CAN 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## CUB 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## HAI 1 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 0
## DOM 1 0 0 1 0 1 1 1 1 1 1 1 1 1 1 1 0
## JAM 1 0 0 1 1 0 1 1 1 1 1 1 1 1 1 1 0
## ECU PER BRA
## USA 1 1 1
## CAN 0 0 0
## CUB 0 0 0
## HAI 1 1 1
## DOM 1 1 1
## JAM 1 1 1
Each element is a binary matrix that indicates whether two states were in a militarized interstate dispute in the respective year.
g_WAR_85<- graph.adjacency(war_85, weighted = NULL, mode = 'undirected')
g_WAR_95<- graph.adjacency(war_95, weighted = NULL, mode = 'undirected')
vcount(g_WAR_85)
## [1] 164
ecount(g_WAR_85)
## [1] 171
vcount(g_WAR_95)
## [1] 164
ecount(g_WAR_95)
## [1] 192
164 countries are included in the dataset. There are 171 ongoing war in 1985 and 192 in 1995.
Network density is the portion of the potential connections in a network that are actual connections.In this context it is the probability that two random countries are at war.
edge_density(g_WAR_85, loops=TRUE)
## [1] 0.01263858
edge_density(g_WAR_95, loops=TRUE)
## [1] 0.01419069
The number increased from 1985 to 1995, indicating the world tension increases a little bit.
degree_WAR_85 <- igraph::degree(g_WAR_85)
nodeName <- V(g_WAR_85)$name
degree_dist_WAR_85 <- data.frame(nodeName, degree_WAR_85)
degree_dist_WAR_85 <- degree_dist_WAR_85[order(-degree_WAR_85),]
head(degree_dist_WAR_85,10)
## nodeName degree_WAR_85
## USA USA 15
## RUS RUS 14
## IRN IRN 13
## LIB LIB 12
## CUB CUB 10
## UGA UGA 10
## ISR ISR 10
## SAF SAF 9
## UKG UKG 8
## ANG ANG 8
degree_WAR_95 <- igraph::degree(g_WAR_95)
nodeName <- V(g_WAR_95)$name
degree_dist_WAR_95 <- data.frame(nodeName, degree_WAR_95)
degree_dist_WAR_95 <- degree_dist_WAR_95[order(-degree_WAR_95),]
head(degree_dist_WAR_95,10)
## nodeName degree_WAR_95
## IRQ IRQ 31
## YUG YUG 19
## USA USA 15
## RUS RUS 15
## IRN IRN 13
## FRN FRN 11
## TUR TUR 9
## HAI HAI 7
## UKG UKG 7
## SAF SAF 7
USA was involved in war with the largest number of countries (15) in 1985. Iraq was involved in war with the largest number of countries (31) in 1995.
degree_dist_WAR <- merge(x = degree_dist_WAR_85, y = degree_dist_WAR_95, by ="nodeName", all.x = TRUE)
degree_dist_WAR$difference <- (degree_dist_WAR$degree_WAR_95 - degree_dist_WAR$degree_WAR_85)
head(degree_dist_WAR,10)
## nodeName degree_WAR_85 degree_WAR_95 difference
## 1 AFG 3 7 4
## 2 ALB 1 3 2
## 3 ALG 3 0 -3
## 4 ANG 8 2 -6
## 5 ARG 5 3 -2
## 6 ARM 0 3 3
## 7 AUL 0 2 2
## 8 AUS 0 0 0
## 9 AZE 0 2 2
## 10 BAH 1 3 2
Iraq is the country with the biggest increase. (6 in 1985 to 31 in 1995) Cuba is the country wuth the biggest decrease. (10 in 1985 and 2 in 1995)
set.seed(1234)
plot(g_WAR_85)
set.seed(1234)
plot(g_WAR_95)
Local clustering coefficient here represents the likelihood of countries who are in war with the same particular country also have a militarized conflict with each other.
LocalCC_WAR_85<- transitivity(g_WAR_85, type="local")
LocalCC_WAR_85_df<- data.frame(nodeName, LocalCC_WAR_85)
LocalCC_WAR_85_df <- LocalCC_WAR_85_df[order(-LocalCC_WAR_85),]
head(LocalCC_WAR_85_df,10)
## nodeName LocalCC_WAR_85
## 2 CAN 1.0000000
## 18 ECU 1.0000000
## 74 MAA 1.0000000
## 123 JOR 1.0000000
## 129 KUW 1.0000000
## 156 MAL 1.0000000
## 50 GRC 0.6666667
## 113 ALG 0.6666667
## 145 JPN 0.6666667
## 158 PHI 0.6666667
LocalCC_WAR_95<- transitivity(g_WAR_95, type="local")
LocalCC_WAR_95_df<- data.frame(nodeName, LocalCC_WAR_95)
LocalCC_WAR_95_df <- LocalCC_WAR_95_df[order(-LocalCC_WAR_95),]
head(LocalCC_WAR_95_df,10)
## nodeName LocalCC_WAR_95
## 45 MAC 1.0000000
## 48 BOS 1.0000000
## 114 TUN 1.0000000
## 129 KUW 1.0000000
## 130 BAH 1.0000000
## 132 UAE 1.0000000
## 144 ROK 1.0000000
## 131 QAT 0.8333333
## 44 ALB 0.6666667
## 46 CRO 0.6666667
This value is 1 for Canada, Ecuador, Malaysia and Jordan have a high transitivity value of 1 in 1985. Similarly, Macedonia, Bosnia, Tunisia, Kuwait, Bahrain, United Arab Emirates and the Republic of Korea in 1995 have a transitivity of 1.
That is, if they and another country are in war with the same particular country, they definitely have a militarized conflict with each other. We see groups of country having a high transitivity in the middle east in 1995. This tells us that maybe there was a highly clustered conflict in the area at the time.
global - ratio of triangles (direction disregarded) to connected triples.
head(transitivity(g_WAR_85),10)
## [1] 0.1412556
head(transitivity(g_WAR_95),10)
## [1] 0.09850746
These values are low and tell us the war network was not very liekly to form clusters of wars. ## Ally Dataset Ally dataset contains undirected dense alliance networks.
g_ALLY_85<- graph.adjacency(ally_85, weighted = NULL, mode = 'undirected')
g_ALLY_95<- graph.adjacency(ally_95, weighted = NULL, mode = 'undirected')
vcount(g_ALLY_85)
## [1] 164
ecount(g_ALLY_85)
## [1] 623
vcount(g_ALLY_95)
## [1] 164
ecount(g_ALLY_95)
## [1] 674
Number of countries in a defense alliance network is 623 in 1985 and 674 in 1995.
head(edge_density(g_ALLY_85, loops=TRUE),10)
## [1] 0.04604582
head(edge_density(g_ALLY_95, loops=TRUE),10)
## [1] 0.04981523
The probability that two random countries are allied with each other increase from 0.046 in 1985 to 0.049 in 1995
degree_ALLY_85 <- igraph::degree(g_ALLY_85)
nodeName <- V(g_ALLY_85)$name
degree_dist_ALLY_85 <- data.frame(nodeName, degree_ALLY_85)
degree_dist_ALLY_85 <- degree_dist_ALLY_85[order(-degree_ALLY_85),]
head(degree_dist_ALLY_85,10)
## nodeName degree_ALLY_85
## USA USA 41
## HAI HAI 21
## DOM DOM 21
## JAM JAM 21
## TRI TRI 21
## MEX MEX 21
## GUA GUA 21
## HON HON 21
## SAL SAL 21
## NIC NIC 21
degree_ALLY_95 <- igraph::degree(g_ALLY_95)
nodeName <- V(g_ALLY_95)$name
degree_dist_ALLY_95 <- data.frame(nodeName, degree_ALLY_95)
degree_dist_ALLY_95 <- degree_dist_ALLY_95[order(-degree_ALLY_95),]
head(degree_dist_ALLY_95,10)
## nodeName degree_ALLY_95
## USA USA 40
## CAN CAN 36
## HAI HAI 23
## DOM DOM 23
## JAM JAM 23
## TRI TRI 23
## MEX MEX 23
## GUA GUA 23
## HON HON 23
## SAL SAL 23
USA has the most number of allies in both 1985 and 1995
degree_dist_ALLY <- merge(x = degree_dist_ALLY_85, y = degree_dist_ALLY_95, by ="nodeName", all.x = TRUE)
degree_dist_ALLY$difference <- (degree_dist_ALLY$degree_ALLY_95 - degree_dist_ALLY$degree_ALLY_85)
head(degree_dist_ALLY,10)
## nodeName degree_ALLY_85 degree_ALLY_95 difference
## 1 AFG 0 0 0
## 2 ALB 0 0 0
## 3 ALG 18 18 0
## 4 ANG 0 0 0
## 5 ARG 21 23 2
## 6 ARM 0 8 8
## 7 AUL 2 1 -1
## 8 AUS 0 0 0
## 9 AZE 0 9 9
## 10 BAH 18 18 0
Canada is the country with the biggest increase. (13 in 1985 to 36 in 1995) YPR is the country wuth the biggest decrease. (19 in 1985 to 0 in 1995)
set.seed(1234)
plot(g_ALLY_85)
set.seed(1234)
plot(g_ALLY_95)
Notice that subgroup clustered together in the lower right corner of the 1985 plot disappears in 1995.
Transitivity refers to the extent to which the relation that relates two nodes in a network that are connected by an edge is transitive.
LocalCC_ALLY_85<- transitivity(g_ALLY_85, type="local")
LocalCC_ALLY_85_df<- data.frame(nodeName, LocalCC_ALLY_85)
LocalCC_ALLY_85_df <- LocalCC_ALLY_85_df[order(-LocalCC_ALLY_85),]
head(LocalCC_ALLY_85_df,10)
## nodeName LocalCC_ALLY_85
## 2 CAN 1
## 4 HAI 1
## 5 DOM 1
## 6 JAM 1
## 7 TRI 1
## 8 MEX 1
## 9 GUA 1
## 10 HON 1
## 11 SAL 1
## 12 NIC 1
LocalCC_ALLY_95<- transitivity(g_ALLY_95, type="local")
LocalCC_ALLY_95_df<- data.frame(nodeName, LocalCC_ALLY_95)
LocalCC_ALLY_95_df <- LocalCC_ALLY_95_df[order(-LocalCC_ALLY_95),]
head(LocalCC_ALLY_95_df,10)
## nodeName LocalCC_ALLY_95
## 4 HAI 1
## 5 DOM 1
## 6 JAM 1
## 7 TRI 1
## 8 MEX 1
## 9 GUA 1
## 10 HON 1
## 11 SAL 1
## 12 NIC 1
## 13 COS 1
Countries with the same value of local clustering coefficient tends to be close to each other geographical and might in a same defense alliance network. (EG. Mideast, central america and north africa countries)
global - ratio of triangles (direction disregarded) to connected triples.
head(transitivity(g_ALLY_85),10)
## [1] 0.9299375
head(transitivity(g_ALLY_95),10)
## [1] 0.9103072
Considering the relationship between countries, we decided to look at the degree centrality(the communication between countries) and analyze betweenness centrality for ally network (which country has some unique position in forming alliances).
This network represents coutries who have militarized dispute.
deg_WAR85 <- igraph::degree(g_WAR_85,mode="all")
V(g_WAR_85)$size <- deg_WAR85 * 0.5
E(g_WAR_85)$arrow.size <- 0.2
E(g_WAR_85)$edge$color <- "gray"
set.seed(1234)
plot(g_WAR_85,layout=layout.fruchterman.reingold)
deg_WAR85 <- sort(deg_WAR85, decreasing = T)
head(deg_WAR85,10)
## USA RUS IRN LIB CUB UGA ISR SAF UKG ANG
## 15 14 13 12 10 10 10 9 8 8
The USA most actively participates in war during 1985, then is Russia, Iran, Libya, Cuba, Uganda, Israel… From the graph we could see more than half countries in our network are involved with wars, and most of them started a war with their neighbors or countries near them, and we think that is why Asian countries and African countries forming groups separately. Countries who are neutral, or didn`t participate in wars are spread around the group, like Czech or Austria as isolates. Those countries who have higher degree centrality are in the center of this network.
deg_WAR95 <- igraph::degree(g_WAR_95,mode="all")
V(g_WAR_95)$size <- deg_WAR95 * 0.5
E(g_WAR_95)$arrow.size <- 0.2
E(g_WAR_95)$edge$color <- "gray"
set.seed(1234)
plot(g_WAR_95,layout=layout.fruchterman.reingold)
deg_WAR95 <- sort(deg_WAR95, decreasing = T)
head(deg_WAR95,10)
## IRQ YUG USA RUS IRN FRN TUR HAI UKG SAF
## 31 19 15 15 13 11 9 7 7 7
Something worth notice here, in 1995, more countries have militarized dispute, which seems very different from 10 years ago. In 1995, Iran became the center of this war network, along with Iran and Turkey, they are surrounded by other countries. Another new center is Yugoslavia, who jumped to one of the countries who attended most of the militarized dispute. And the total number of the countries have ever attended in the war increases a lot. Which indicates the net is ‘growing’.
deg_ALLY85 <- igraph::degree(g_ALLY_85,mode="all")
V(g_ALLY_85)$size <- deg_ALLY85 * 0.3
E(g_ALLY_85)$arrow.size <- 0.2
E(g_ALLY_85)$edge$color <- "gray"
set.seed(1234)
plot(g_ALLY_85,layout=layout.fruchterman.reingold)
deg_ALLY85 <- sort(deg_ALLY85, decreasing = T)
deg_ALLY85
## USA HAI DOM JAM TRI MEX GUA HON SAL NIC COS PAN COL VEN ECU PER BRA BOL
## 41 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21
## PAR CHL ARG URU DJI LIB SUD YPR FRN SOM MOR ALG TUN IRQ SYR LEB JOR SAU
## 21 21 21 21 19 19 19 19 18 18 18 18 18 18 18 18 18 18
## YAR KUW BAH QAT UAE OMA SEN MAA NIR CDI BFO TOG CAN UKG NTH BEL SPN POR
## 18 18 18 18 18 18 15 14 14 14 14 14 13 13 13 13 13 13
## GFR ITA GRC NOR DEN GNB GAM BEN GUI LBR SIE GHA NIG TUR MLI GDR POL HUN
## 13 13 13 13 13 13 13 13 13 13 13 13 13 13 6 5 5 5
## CZE BUL ROM ETH AUL NEW GAB CEN KEN COM EGY ISR CHN PRK ROK JPN PAK PHI
## 5 5 5 3 2 2 1 1 1 1 1 1 1 1 1 1 1 1
## CUB GUY IRE SWZ GMY AUS CZR SLO ALB MAC CRO YUG BOS SLV CYP MLD RUS EST
## 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## LAT LIT UKR BLR ARM GRG AZE FIN SWD EQG CAO CHA CON DRC UGA TAZ BUI RWA
## 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## ERI ANG MZM ZAM ZIM MAW SAF NAM LES BOT SWA MAG MAS IRN YEM AFG TKM TAJ
## 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## KYR UZB KZK MON TAW IND BHU BNG MYA SRI NEP THI CAM LAO MAL SIN INS PNG
## 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## SOL FIJ
## 0 0
The graph shows 4 small groups who connected with each other, the USA and France located at the center of them, and they are surrounded by a lot of countries who are almost isolated. The USA has most allies, then are Haiti, Dominican Republic, Jamacia, Trinidad and Tobago, Mexico, Guatemala, and some countries from North and Central America, we consider the countries who have 21 alliance had formed a united alliance, so they are allies with people who joined the alliance. The USA is in different alliances, so it has the highest allies number. Another interesting point is, some countries such as Japan and Australia, they only connect with the USA. Besides we also could see countries tend to make an alliance based on their geographical positions.
deg_ALLY95 <- igraph::degree(g_ALLY_95,mode="all")
V(g_ALLY_95)$size <- deg_ALLY95 * 0.3
E(g_ALLY_95)$arrow.size <- 0.2
E(g_ALLY_95)$edge$color <- "gray"
set.seed(1234)
plot(g_ALLY_95,layout=layout.fruchterman.reingold)
deg_ALLY95 <- sort(deg_ALLY95, decreasing = T)
deg_ALLY95
## USA CAN HAI DOM JAM TRI MEX GUA HON SAL NIC COS PAN COL VEN GUY ECU PER
## 40 36 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23
## BRA BOL PAR CHL ARG URU FRN MAA DJI COM MOR ALG TUN LIB BAH SOM SUD IRQ
## 23 23 23 23 23 23 18 18 18 18 18 18 18 18 18 17 17 17
## SYR JOR SAU YEM KUW QAT UAE OMA SEN NIR CDI BFO TOG TUR UKG NTH BEL SPN
## 17 17 17 17 17 17 17 17 15 14 14 14 14 14 13 13 13 13
## POR GMY ITA GRC NOR DEN GNB GAM BEN GUI LBR SIE GHA NIG RUS AZE BLR ARM
## 13 13 13 13 13 13 13 13 13 13 13 13 13 13 10 9 8 8
## GRG TAJ KYR UZB KZK MLI PRK CUB HUN CZR SLO ROM GAB CEN TKM CHN ROK JPN
## 8 8 8 8 8 6 3 1 1 1 1 1 1 1 1 1 1 1
## PAK PHI AUL IRE SWZ GFR GDR POL AUS CZE ALB MAC CRO YUG BOS SLV CYP BUL
## 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## MLD EST LAT LIT UKR FIN SWD EQG CAO CHA CON DRC UGA KEN TAZ BUI RWA ETH
## 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## ERI ANG MZM ZAM ZIM MAW SAF NAM LES BOT SWA MAG MAS IRN EGY LEB ISR YAR
## 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## YPR AFG MON TAW IND BHU BNG MYA SRI NEP THI CAM LAO MAL SIN INS PNG NEW
## 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## SOL FIJ
## 0 0
The USA has the most allies and France still served as an important communicative bridge between some country groups. In 1995, Canada appeared to make great connections with other countries, it became the second largest node in this network. Some ties emerging from country groups who used to be isolated like West and North Africa, maybe it`s because they are close to each other and try to make contact. Here France is the bridge linked Africa and Europe and America.
For most countries, after 10 years they grow more international connections, France and Canada are the most highly connected country in our network at 1995, something interesting is the ally of New Zealand and Kenya drops to 0 at 1995.
We think that in ally network, communication bridge is very important, so betweenness centrality is something worth discussing.
bt_ALLY85 <- igraph::betweenness(g_ALLY_85)
V(g_ALLY_85)$size <- bt_ALLY85 * 0.01
E(g_ALLY_85)$arrow.size <- 0.2
E(g_ALLY_85)$edge$color <- "gray"
## Warning in eattrs[[name]][index] <- value: number of items to replace is
## not a multiple of replacement length
set.seed(1234)
plot(g_ALLY_85,layout=layout.fruchterman.reingold)
bt_ALLY85 <- sort(bt_ALLY85, decreasing = T)
head(bt_ALLY85,10)
## FRN USA DJI SEN ETH SUD
## 2084.000000 1651.000000 1260.000000 939.333333 80.000000 80.000000
## LIB YPR MAA NIR
## 78.000000 78.000000 1.333333 1.333333
bt_ALLY95 <- igraph::betweenness(g_ALLY_95)
V(g_ALLY_95)$size <- bt_ALLY95 * 0.01
E(g_ALLY_95)$arrow.size <- 0.2
E(g_ALLY_95)$edge$color <- "gray"
## Warning in eattrs[[name]][index] <- value: number of items to replace is
## not a multiple of replacement length
set.seed(1234)
plot(g_ALLY_95,layout=layout.fruchterman.reingold)
bt_ALLY95 <- sort(bt_ALLY95, decreasing = T)
head(bt_ALLY95,20)
## FRN CAN TUR AZE USA SEN
## 1354.161905 1031.809524 975.000000 912.000000 894.333333 775.066667
## BAH RUS MAA DJI COM PRK
## 526.133333 339.000000 242.038095 175.476190 175.476190 173.000000
## MOR ALG TUN LIB NIR CDI
## 53.542857 53.542857 53.542857 53.542857 1.333333 1.333333
## BFO TOG
## 1.333333 1.333333
After compared with different algorithms, we choose to use the fast greedy algorithm to do our community detection analysis. Initially, every vertex belongs to a separate community, and communities are merged iteratively such that each merge is locally optimal. It is a way of modularity, the idea is to maximize the internal connection and better our clustering result.
set.seed(1122)
fg <- fastgreedy.community(g_WAR_85)
plot (fg,g_WAR_85)
set.seed(1122)
fg_WAR95 <- fastgreedy.community(g_WAR_95)
plot (fg_WAR95,g_WAR_95)
set.seed(1122)
fg_ALLY85 <- fastgreedy.community(g_ALLY_85)
plot (fg_ALLY85,g_ALLY_85)
set.seed(1122)
fg_ALLY95 <- fastgreedy.community(g_ALLY_95)
plot (fg_ALLY95,g_ALLY_95)
library(Matrix)
full_war_85 <- forceSymmetric(war_85,uplo="U")
full_war_85 <- as.matrix(full_war_85)
full_war_95 <- forceSymmetric(war_95,uplo="U")
full_war_95 <- as.matrix(full_war_95)
library(sna)
eq<-equiv.clust(list(full_war_85,ally_85), mode="digraph")
plot(eq)
Looking at the cluster dendrogram for 1985, we can see two interesting facts. First, the United States seems to be different from the other countries. This could stem from the fact that the US was very active geo-politically in both Latin America and Europe, whereas other countries are only geo-poltically active in regions close to them. Second, there are several countries that the dendgrogram does not split up at all. These are the countries that were neither involved in war, nor part of a defense alliance. Next, let us look at the block modelling image matrix.
b<-blockmodel(full_war_85,eq,k=4)
bimage <- b$block.model
fw85 <- network(full_war_85,directed=FALSE)
den <- network.density(fw85)
bimage[bimage < den] <- 0
set.seed(1234)
gplot(bimage, diag=TRUE,
edge.lwd=bimage*0.03,
label=colnames(bimage),
vertex.cex=sqrt(table(b$block.membership))/2,
gmode="digraph", vertex.sides=50,label.pos = 4,
vertex.col=gray(1-diag(bimage)/2))
In the image matrix above, we see four blocks. Block 1 is connected to itself and to Block 2. Block 2 is connected to itself and Block 1 and 4. Block 4 is connected to itself and Block 3 and 2. Block 3 is only connected to itself. To get a better idea of how to interpret this, let us look at which countries are in which block.
# Get the countries from block 1
group1 <- b$order.vector[b$block.membership == 1]
colnames(full_war_85)[group1]
## [1] "USA" "ARG" "NIC" "VEN" "BRA" "MEX" "GUA" "BOL" "JAM" "URU" "PAR"
## [12] "TRI" "HAI" "DOM" "HON" "SAL" "COS" "COL" "CHL" "PER" "PAN" "ECU"
# Get the countries from block 2
group2 <- b$order.vector[b$block.membership == 2]
colnames(full_war_85)[group2]
## [1] "FRN" "UKG" "GRC" "TUR" "SPN" "POR" "DEN" "BEL" "GFR" "NOR" "ITA"
## [12] "CAN" "NTH"
# Get the countries from block 4
group4 <- b$order.vector[b$block.membership == 4]
colnames(full_war_85)[group4]
## [1] "LIB" "YPR" "YAR" "OMA" "LEB" "JOR" "DJI" "TUN" "SAU" "KUW" "UAE"
## [12] "BAH" "QAT" "IRQ" "SYR" "SOM" "SUD" "MOR" "ALG"
# Get the countries from block 3
group3 <- b$order.vector[b$block.membership == 3]
colnames(full_war_85)[group3]
## [1] "MLI" "NIG" "GHA" "TOG" "MAA" "BFO" "SEN" "SIE" "LBR" "GUI" "BEN"
## [12] "GNB" "GAM" "NIR" "CDI" "RUS" "IRN" "ISR" "EGY" "CEN" "DRC" "ZAM"
## [23] "ZIM" "SAF" "UGA" "CUB" "CON" "ANG" "CHN" "ROK" "JPN" "MAL" "PHI"
## [34] "BUL" "ROM" "CZE" "HUN" "GDR" "POL" "ETH" "KEN" "TAZ" "IND" "LAO"
## [45] "THI" "CAM" "PRK" "PAK" "AUL" "NEW" "AFG" "INS" "PNG" "LES" "MZM"
## [56] "BOT" "GAB" "COM" "CAO" "CHA" "ALB" "YUG" "GUY" "MYA" "BNG" "SRI"
## [67] "SWD" "CYP" "IRE" "FIJ" "SOL" "SIN" "NEP" "BHU" "TAW" "MON" "KZK"
## [78] "UZB" "KYR" "TAJ" "TKM" "YEM" "MAS" "MAG" "SWA" "NAM" "MAW" "ERI"
## [89] "RWA" "BUI" "EQG" "FIN" "AZE" "GRG" "ARM" "BLR" "UKR" "LIT" "LAT"
## [100] "EST" "MLD" "SLV" "BOS" "CRO" "MAC" "SLO" "CZR" "AUS" "SWZ" "GMY"
# Plot image matrix with labels
set.seed(1234)
gplot(bimage, diag=TRUE,
edge.lwd=0.3,
label=c('Block 1 - Americas', 'Block 2 - \nWestern Europe', 'Block 3 - \nRest of the world', 'Block 4 - \nNorth Africa/Middle East'),
vertex.cex=sqrt(table(b$block.membership))/2,
gmode="digraph", vertex.sides=50, label.pos = 4,
vertex.col=gray(1-diag(bimage)/2))
Once we include the labels, the interpretation becomes much easier. The Americas are connected to each other because of several wars and defense alliances going on in 1985. The Americas are also connected to Western Europe, mostly through the ties of the United States. Western Europe is connected to itself through defense alliances and to North Africa/Middle East because Western European countries had many colonies in North Africa/Middle East. North Africa/Middle East is connected to itself because of several wars going on in the region at the time. Overall, the block model highlights several interesting aspects of geo-political activities in 1985.
eq<-equiv.clust(list(full_war_95,ally_95), mode="digraph")
plot(eq)
The dendrogram of 1995 shows one significant difference compared to 1985. The United States are not split up separately at a high level anymore. This shows that the United States reduced its geo-political activities between 1985 and 1995. Let us see how that influenced the block modelling image matrix.
b<-blockmodel(full_war_95,eq,k=4)
bimage <- b$block.model
fw95 <- network(full_war_95,directed=FALSE)
den <- network.density(fw95)
bimage[bimage < den] <- 0
# Get the countries from block 1
group1 <- b$order.vector[b$block.membership == 1]
colnames(full_war_95)[group1]
## [1] "HAI" "ARG" "NIC" "PAN" "ECU" "PER" "COL" "VEN" "COS" "DOM" "URU"
## [12] "CHL" "PAR" "BOL" "BRA" "GUY" "GUA" "MEX" "JAM" "TRI" "HON" "SAL"
## [23] "USA" "CAN"
# Get the countries from block 2
group2 <- b$order.vector[b$block.membership == 2]
colnames(full_war_95)[group2]
## [1] "RUS" "AZE" "ARM" "KZK" "UZB" "TAJ" "KYR" "BLR" "GRG" "MAA" "GHA"
## [12] "TOG" "LBR" "SIE" "GNB" "GUI" "GAM" "BEN" "CDI" "NIG" "SEN" "NIR"
## [23] "BFO" "YUG" "IRN" "CHN" "PRK" "MLI" "EGY" "ISR" "DRC" "SAF" "AFG"
## [34] "IND" "PNG" "PAK" "BNG" "ROK" "JPN" "AUL" "THI" "MYA" "CAM" "LAO"
## [45] "TAW" "PHI" "MAL" "SIN" "MZM" "MAW" "UGA" "ETH" "ERI" "CRO" "BOS"
## [56] "ALB" "MAC" "HUN" "ROM" "INS" "SOL" "SRI" "YPR" "KEN" "RWA" "GAB"
## [67] "CEN" "CAO" "CYP" "BUL" "SLV" "CZR" "SLO" "SWD" "UKR" "LAT" "EST"
## [78] "POL" "MLD" "GDR" "IRE" "FIJ" "NEP" "BHU" "MON" "YAR" "MAS" "MAG"
## [89] "NAM" "BUI" "TAZ" "EQG" "FIN" "LIT" "AUS" "SWZ" "GFR" "SWA" "LES"
## [100] "BOT" "CUB" "CZE" "CON" "ANG" "ZAM" "ZIM" "TKM" "CHA" "LEB" "NEW"
# Get the countries from block 3
group3 <- b$order.vector[b$block.membership == 3]
colnames(full_war_95)[group3]
## [1] "FRN" "TUR" "UKG" "GRC" "NOR" "POR" "DEN" "SPN" "ITA" "BEL" "NTH"
## [12] "GMY"
# Get the countries from block 4
group4 <- b$order.vector[b$block.membership == 4]
colnames(full_war_95)[group4]
## [1] "IRQ" "LIB" "JOR" "QAT" "SAU" "BAH" "SUD" "SYR" "OMA" "KUW" "UAE"
## [12] "DJI" "COM" "SOM" "YEM" "TUN" "MOR" "ALG"
# Plot image matrix with labels
set.seed(1001)
gplot(bimage, diag=TRUE,
edge.lwd=bimage*0.03,
label=c('Block 1 - Americas', 'Block 2 - Rest of the world', 'Block 3 - Europe', 'Block 4 - North Africa/Middle East'),
vertex.cex=sqrt(table(b$block.membership))/2,
gmode="digraph", vertex.sides=50, label.pos = 2,
vertex.col=gray(1-diag(bimage)/2))
Compared to the image matrix for 1985, we can see several significant changes. First, the Americas are not connected to Europe anymore. As we saw in the dendrogram for 1995, this is because the United States stopped being geo-politically active in Europe. Second, the North Africa/Middle East is not connected to the rest of the world anymore. Western Europe is now connected to the rest of the world though and is also still connected to North Africa/Middle East. As mentioned before, this is because Europe had many former colonies in North Africa/Middle East.
Unlike the previous sections, we used the data for the entire ten-year period between 1985 and 1995 to give our model better information. Here, we create subset of all the networks for the mentioned time period.
allyNet_85_95 <- allyNet[c(5:15)]
#converting to networkdynamic data
allydyn_85_95 <- networkDynamic(network.list = allyNet[c(5:15)])
## Neither start or onsets specified, assuming start=0
## Onsets and termini not specified, assuming each network in network.list should have a discrete spell of length 1
## Argument base.net not specified, using first element of network.list instead
## Created net.obs.period to describe network
## Network observation period info:
## Number of observation spells: 1
## Maximal time range observed: 0 until 11
## Temporal mode: discrete
## Time unit: step
## Suggested time increment: 1
#we use the war data for 1984-1994 because we want information the war in the previous year
warNet_84_94 <- warNet[c(4:14)]
lNet_85_95 <- lNet[c(5:15)]
for (i in 1:11){
warNet_84_94[lower.tri(warNet_84_94)] = t(warNet_84_94)[lower.tri(warNet_84_94)]
lNet_85_95[lower.tri(lNet_85_95)] = t(lNet_85_95 )[lower.tri(lNet_85_95)]
}
We use the btergm package since this creates bootstrapped samples and creates the tergm model based on these repeated samples. Based on repeated iterations, we found the following model to have the least error. We ran the bootstrapping taking 50 samples from the alliance network between the years 1985-1995.
allymodel <- btergm(allyNet_85_95 ~ edges + triangles + gwesp(0, fixed = TRUE) + nodecov("polity") +
+ nodecov("cinc") + absdiff("polity") + absdiff("cinc") +
+ edgecov(contigMat)
+ edgecov(lNet_85_95)
+ edgecov(warNet_84_94), R = 50)
##
## Initial dimensions of the network and covariates:
## t=1 t=2 t=3 t=4 t=5 t=6 t=7 t=8 t=9 t=10 t=11
## allyNet_85_95 (row) 164 164 164 164 164 164 164 164 164 164 164
## allyNet_85_95 (col) 164 164 164 164 164 164 164 164 164 164 164
## contigMat (row) 164 164 164 164 164 164 164 164 164 164 164
## contigMat (col) 164 164 164 164 164 164 164 164 164 164 164
## lNet_85_95 (row) 164 164 164 164 164 164 164 164 164 164 164
## lNet_85_95 (col) 164 164 164 164 164 164 164 164 164 164 164
## warNet_84_94 (row) 164 164 164 164 164 164 164 164 164 164 164
## warNet_84_94 (col) 164 164 164 164 164 164 164 164 164 164 164
##
## All networks are conformable.
##
## Dimensions of the network and covariates after adjustment:
## t=1 t=2 t=3 t=4 t=5 t=6 t=7 t=8 t=9 t=10 t=11
## allyNet_85_95 (row) 164 164 164 164 164 164 164 164 164 164 164
## allyNet_85_95 (col) 164 164 164 164 164 164 164 164 164 164 164
## contigMat (row) 164 164 164 164 164 164 164 164 164 164 164
## contigMat (col) 164 164 164 164 164 164 164 164 164 164 164
## lNet_85_95 (row) 164 164 164 164 164 164 164 164 164 164 164
## lNet_85_95 (col) 164 164 164 164 164 164 164 164 164 164 164
## warNet_84_94 (row) 164 164 164 164 164 164 164 164 164 164 164
## warNet_84_94 (col) 164 164 164 164 164 164 164 164 164 164 164
##
## Starting pseudolikelihood estimation with 50 bootstrapping replications on a single computing core...
## Warning: `set_attrs()` is deprecated as of rlang 0.3.0
## This warning is displayed once per session.
## Done.
summary(allymodel)
## ==========================
## Summary of model fit
## ==========================
##
## Formula: allyNet_85_95 ~ edges + triangles + gwesp(0, fixed = TRUE) + nodecov("polity") + +nodecov("cinc") + absdiff("polity") + absdiff("cinc") + +edgecov(contigMat) + edgecov(lNet_85_95) + edgecov(warNet_84_94)
## Time steps: 11
## Bootstrapping sample size: 50
## Estimates and 95% confidence intervals:
## Estimate 2.5% 97.5%
## edges -10.5242598 -13.3143 -9.7582
## triangle 1.2621739 0.9786 1.5852
## gwesp.fixed.0 0.6937807 0.2054 1.5336
## nodecov.polity -0.0011437 -0.0446 0.0379
## nodecov.cinc 20.8909598 12.8237 34.0590
## absdiff.polity 0.0679585 0.0347 0.1076
## absdiff.cinc 4.1878504 -11.6255 12.5707
## edgecov.contigMat[[i]] 1.2316464 0.0563 2.7636
## edgecov.lNet_85_95[[i]] 9.1987301 8.3441 12.3436
## edgecov.warNet_84_94[[i]] -1.1943802 -2.6416 1.6616
Since we are not given a p-value in this summary, we estimate statistical significance by seeing if 0 is contained within the 95% confidence interval of the coefficient estimates. Although this is not the ideal method to estimate statistical significance, it will suffice for the purposes of this project.
Based on the above method, we find that nodecov.polity and absdiff.cinc are not significant. absdiff.polity is nearly 0.
We test the goodness of fit of our model by plotting the degree of simulated networks
gofmodel <- gof(allymodel, nsim = 50, statistics = c(deg))
##
## Starting GOF assessment on a single computing core....
##
## Initial dimensions of the network and covariates:
## t=1 t=2 t=3 t=4 t=5 t=6 t=7 t=8 t=9 t=10 t=11
## allyNet_85_95 (row) 164 164 164 164 164 164 164 164 164 164 164
## allyNet_85_95 (col) 164 164 164 164 164 164 164 164 164 164 164
## contigMat (row) 164 164 164 164 164 164 164 164 164 164 164
## contigMat (col) 164 164 164 164 164 164 164 164 164 164 164
## lNet_85_95 (row) 164 164 164 164 164 164 164 164 164 164 164
## lNet_85_95 (col) 164 164 164 164 164 164 164 164 164 164 164
## warNet_84_94 (row) 164 164 164 164 164 164 164 164 164 164 164
## warNet_84_94 (col) 164 164 164 164 164 164 164 164 164 164 164
##
## All networks are conformable.
##
## Dimensions of the network and covariates after adjustment:
## t=1 t=2 t=3 t=4 t=5 t=6 t=7 t=8 t=9 t=10 t=11
## allyNet_85_95 (row) 164 164 164 164 164 164 164 164 164 164 164
## allyNet_85_95 (col) 164 164 164 164 164 164 164 164 164 164 164
## contigMat (row) 164 164 164 164 164 164 164 164 164 164 164
## contigMat (col) 164 164 164 164 164 164 164 164 164 164 164
## lNet_85_95 (row) 164 164 164 164 164 164 164 164 164 164 164
## lNet_85_95 (col) 164 164 164 164 164 164 164 164 164 164 164
## warNet_84_94 (row) 164 164 164 164 164 164 164 164 164 164 164
## warNet_84_94 (col) 164 164 164 164 164 164 164 164 164 164 164
##
## No 'target' network(s) provided. Using networks on the left-hand side of the model formula as observed networks.
## Simulating 50 networks from the following formula:
## allyNet_85_95[[1]] ~ edges + triangles + gwesp(0, fixed = TRUE) + nodecov("polity") + nodecov("cinc") + absdiff("polity") + absdiff("cinc") + edgecov(contigMat[[1]]) + edgecov(lNet_85_95[[1]]) + edgecov(warNet_84_94[[1]])
## Warning: You appear to be calling simulate.formula() directly.
## simulate.formula() is a method, and will not be exported in a future
## version of 'ergm'. Use simulate() instead, or getS3method() if absolutely
## necessary.
## Simulating 50 networks from the following formula:
## allyNet_85_95[[2]] ~ edges + triangles + gwesp(0, fixed = TRUE) + nodecov("polity") + nodecov("cinc") + absdiff("polity") + absdiff("cinc") + edgecov(contigMat[[2]]) + edgecov(lNet_85_95[[2]]) + edgecov(warNet_84_94[[2]])
## Simulating 50 networks from the following formula:
## allyNet_85_95[[3]] ~ edges + triangles + gwesp(0, fixed = TRUE) + nodecov("polity") + nodecov("cinc") + absdiff("polity") + absdiff("cinc") + edgecov(contigMat[[3]]) + edgecov(lNet_85_95[[3]]) + edgecov(warNet_84_94[[3]])
## Simulating 50 networks from the following formula:
## allyNet_85_95[[4]] ~ edges + triangles + gwesp(0, fixed = TRUE) + nodecov("polity") + nodecov("cinc") + absdiff("polity") + absdiff("cinc") + edgecov(contigMat[[4]]) + edgecov(lNet_85_95[[4]]) + edgecov(warNet_84_94[[4]])
## Simulating 50 networks from the following formula:
## allyNet_85_95[[5]] ~ edges + triangles + gwesp(0, fixed = TRUE) + nodecov("polity") + nodecov("cinc") + absdiff("polity") + absdiff("cinc") + edgecov(contigMat[[5]]) + edgecov(lNet_85_95[[5]]) + edgecov(warNet_84_94[[5]])
## Simulating 50 networks from the following formula:
## allyNet_85_95[[6]] ~ edges + triangles + gwesp(0, fixed = TRUE) + nodecov("polity") + nodecov("cinc") + absdiff("polity") + absdiff("cinc") + edgecov(contigMat[[6]]) + edgecov(lNet_85_95[[6]]) + edgecov(warNet_84_94[[6]])
## Simulating 50 networks from the following formula:
## allyNet_85_95[[7]] ~ edges + triangles + gwesp(0, fixed = TRUE) + nodecov("polity") + nodecov("cinc") + absdiff("polity") + absdiff("cinc") + edgecov(contigMat[[7]]) + edgecov(lNet_85_95[[7]]) + edgecov(warNet_84_94[[7]])
## Simulating 50 networks from the following formula:
## allyNet_85_95[[8]] ~ edges + triangles + gwesp(0, fixed = TRUE) + nodecov("polity") + nodecov("cinc") + absdiff("polity") + absdiff("cinc") + edgecov(contigMat[[8]]) + edgecov(lNet_85_95[[8]]) + edgecov(warNet_84_94[[8]])
## Simulating 50 networks from the following formula:
## allyNet_85_95[[9]] ~ edges + triangles + gwesp(0, fixed = TRUE) + nodecov("polity") + nodecov("cinc") + absdiff("polity") + absdiff("cinc") + edgecov(contigMat[[9]]) + edgecov(lNet_85_95[[9]]) + edgecov(warNet_84_94[[9]])
## Simulating 50 networks from the following formula:
## allyNet_85_95[[10]] ~ edges + triangles + gwesp(0, fixed = TRUE) + nodecov("polity") + nodecov("cinc") + absdiff("polity") + absdiff("cinc") + edgecov(contigMat[[10]]) + edgecov(lNet_85_95[[10]]) + edgecov(warNet_84_94[[10]])
## Simulating 50 networks from the following formula:
## allyNet_85_95[[11]] ~ edges + triangles + gwesp(0, fixed = TRUE) + nodecov("polity") + nodecov("cinc") + absdiff("polity") + absdiff("cinc") + edgecov(contigMat[[11]]) + edgecov(lNet_85_95[[11]]) + edgecov(warNet_84_94[[11]])
## 11 networks from which simulations are drawn were provided.
## Processing statistic: Degree
plot(gofmodel)
We see that our model does a decent job of simulating degree of alliances in the network since the thick black line showing the observed network degree distribution is close to the medians in the box plots of the simulated networks.
From the above discussion, we found some interesting patterns in what drove wars and alliances in 1985-1995. These patterns consistently showed up in all the types of analysis we performed.