World trade networks

The world trade data set consists of a small sample of world trade networks for the years 2001-2014, and pre-computed subgraph counts of a larger set of world trade networks (1985–2014). The world trade networks are based on the data set from [Feenstra et al., 2005] for the years 1985-2000 and on the United Nations division COMTRADE for the years 2001-2014.

For an introduction to NetEmd and its variants see "Simple and quick (default) usage 1: pairwise comparisons".

For many to many comparisons see Simple and quick (default) usage 3: many to many comparisons

For other vignettes in this package see the "Menu".

Loading world trade network data included in the package

The package contains the world trade networks and pre-computed subgraph/graphlet counts in the R data object worldtradesub. This object contains a list of two lists. The first list is worldtradesub$wtnets which contains a small sample of the trade networks (2001-2014) and the second worldtradesub$Counts which contains pre-computed counts for a larger set of trade networks going from 1985 to 2014.

  library("netdist")
  library("igraph")
  data(worldtradesub)
  summary(worldtradesub)
  wtnets<- worldtradesub$wtnets
  summary(wtnets)

These world trade networks are denser than typically sparse social networks. For example, the edge density for the network in 2001 is r igraph::graph.density(worldtradesub$wtnets$wtn2001). Here is a plot of this network highlighting the relatively large number of edges:

  plot(wtnets$wtn2001,vertex.size=5,vertex.label.cex=0.4)

Generate NetEmd measures between each pair of query graphs

In this example NetEmd will consider orbit counts of subgraphs containing up to 5 nodes. If NetEmd is to be called a single time, then the command netemd_many_to_many(graphs = wtnets) would suffice. The following code provides such an example:

  # As the trade networks are considerable dense, this example first considers a small number of networks.
  #This example may take some minutes to run.
  netemd_result <- netemd_many_to_many(graphs = wtnets[1:4],mc.cores = 1)

  print(netemd_result)

However, if there are pre-computed counts or features NetEmd can be called via these features instead.

Pre-computing subgraph counts

World trade networks consist of relatively dense networks, thus leading to longer computational times for the calculation of the subgraph counts. Hence, it is advisable to pre-compute counts in case there is a need to call NetEmd multiple times. This may, for example, be the case when adding a new network to the data set. The following illustrates the extraction of subgraph counts for the small network sample.

# This example may take more than a few minutes to run  (approx. 20 mins) , and it is not necessary to run it for the upcoming examples as a larger set of counts has been already computed.
if(FALSE){# It is not necessary to run, as these counts are already available in.
    Counts <- list()
    for(i in 1:length(wtnets)){
      Counts[[ names(wtnets)[i] ]] <- count_orbits_per_node(graph = wtnets[[i]],max_graphlet_size = 5)
    }
}

Now, with pre-computed counts NetEmd can be calculated more rapidly as the computations of the counts are often the bottle neck in the computational time of NetEmd. NetEmd will be called r length(worldtradesub$Counts) * (length(worldtradesub$Counts) - 1)/2 times in order to obtain all pairwise comparisons between the trade networks from 1985 to 2014 (networks with pre-computed subgraph counts):

  # The pre-computed counts already in the package
  Counts <- worldtradesub$Counts

  #Calling NetEmd 
  netemd_result <- netemd_many_to_many(dhists = Counts ,mc.cores = 1)

  #Results
  netemd_matrix <- cross_comp_to_matrix(measure = netemd_result$netemds, cross_comparison_spec = netemd_result$comp_spec)

  print(netemd_matrix[1:10,1:5])

Evidence of change in world trade

Based on the comparison of the world trade networks across the years, we can identify periods of time where possible considerable changes in world trade have occurred. The following heat map clearly shows the existence of two potential changes in the world trade system, and which correspond to 1995-1996 and 2010-2011.

  netemd.plot(netemdlist=netemd_result,clustering_method="ward.D",main="NetEmd",docluster = FALSE)

The World Trade Organization (WTO) said the following about these years:


Bibliography



alan-turing-institute/network-comparison documentation built on June 7, 2022, 10:41 p.m.