Bridging nestedness and economic complexity in multilayer world trade networks

Understanding the complexity of international trading is critical for a variety of issues ranging from quantifying the competitiveness of individual nations to forecasting the collective evolution of the world economy. Despite the significant progress made in this direction, the international trading system is mainly modeled with a single network in the previous works such as the monopartite product space network and the bipartite country-product network to capture economic complexity. In order to better capture the more detailed dynamics, we characterize the international trading system with a multilayer network with each layer representing the transnational trading relations of a product. This framework immediately reveals the nested structure in each layer and accordingly allows us to develop an alternative measure of the complexity of products. The metric provides a ranking of products’ complexity more consistent with common understanding. The nested structure of a network layer seems to correlate with the asymmetric export relations resulted from the technology barriers, and the evolution of product complexity indicates that the growth of product nestedness is faster than the relevance decay. Finally, we remark a comparison of trade competitive by nestedness between China and the United States to explore the evolution of the economy industries, and the aggregated nestedness index can predict a nation’s future economic growth.


Introduction
A natural way of representing international trade flows is through complex networks (De Benedictis and Tajoli, 2011;Fronczak and Fronczak, 2012;Nemeth and Smith, 1985;Smith and White, 1992). The key advantage of this approach is that it captures the complex structure of the interactions between a large number of economic agents, which brings solutions to a variety of issues in observation, modeling, and prediction (Fagiolo et al., 2013;Medo et al., 2018;Saracco et al., 2015Saracco et al., , 2016Schweitzer et al., 2009;Squartini et al., 2018Squartini et al., , 2015. In recent works, substantial effort has been devoted to analyzing the structural characteristics of the world trade data as it is closely connected to the economic development of countries (Cristelli et al., 2015;Hartmann et al., 2017;Hausmann et al., 2014;Hidalgo and Hausmann, 2009;Hidalgo et al., 2007;Tacchella et al., 2012). The related works form a new research field called economic complexity, which aims to understand the emergent complex behaviors in economic systems via the tools developed in complexity science (Hidalgo, 2018;Mealy et al., 2019;Tacchella et al., 2018). The data was modeled with a country-product bipartite network with links representing export relations. A remarkable finding is that the network exhibits a hierarchically nested structure, which is already widely observed economic systems originated form ecological systems (Bastolla et al., 2009;König et al., 2014;Rohr et al., 2014), and how nestedness emerges and what is its determinants raises a lot of concentration (James et al., 2012;Jonhson et al., 2013;Payrato-Borras et al., 2019). Recently, the review (Mariani et al., 2019) surveys nestedness from variegated disciplines, including statistical physics, graph theory, ecology, and theoretical economics.
Given an adjacent matrix by a network of interacting nodes, a perfectly nested matrix can be described as the entries in each successive row and column are, respectively, a strict subset of those in the previous row and column (Almeida-Neto et al., 2008) as seen in Fig. 1a. In ecological systems, a nested pattern in mutualistic networks promotes biodiversity and preserves structural stability (Bastolla et al., 2009;Rohr et al., 2014). In economic systems, the function of the nested structure is not yet clear, but this feature has already inspired many methods quantifying different aspects of these systems. Issues include exploring the nested nature of the observed networks (de Jeude et al., 2019;König et al., 2014;Lee, 2016;Solé-Ribalta et al., 2018), as well as predicting the evolution of industrial ecosystems (Brintrup et al., 2015;Bustos et al., 2012;Saavedra et al., 2014). The representation of the international trading data with country-product bipartite networks overly simplifies the system. The countryproduct bipartite network only consists of the products that each country exports, but neglects the information of which countries these products are shipped to. Attempts have also been made to construct a multilayer network in which the nodes are the countries, the layers are the industries, and links can be established from sellers to buyers within and across industries (Alves et al., 2019;Barigozzi et al., 2010;Mastrandrea et al., 2014). The advantage of modeling a complex system as a multilayer network is to gain information that cannot be captured if individual layers are taken in isolation. The methods for analyzing multilayer networks such as community detection, cascading failure, node centrality, and network reducibility have developed rapidly in recent years (Boccaletti et al., 2014). In this work, we focus on the Fig. 1 Nestedness in multilayer networks. a, b Three representations of matrices, respectively, correspond to none, moderate, perfect nested network. These three networks have the same number of nodes and links. In each matrix, the rows and columns have been ranked by the number of ones (i.e., degree). In a perfectly nested matrix, the upper-left triangle would be full of elements and the lower-right triangle would have no elements. c The matrices are representations of the different layers of world trade networks which, respectively, correspond to the network of Bovine, Typewriters, and Medical Instruments. The nestedness of matrices (NODF) is 0.12, 0.37, and 0.60, respectively. The curve is the distribution of nestedness calculated by 786 matrices of products.
within-layer nestedness of the multilayer world trade network, and find that the nestedness of a layer network is a proper method to quantify the product's complexity. For the highly complex products, only the countries with advanced technologies can produce them and export them to further countries, resulting from a nested network structure. We then use the nestedness to investigate the evolution of product complexity. Further, we analyze that the competitiveness of a country with different nested products and then take a comparison of trade competitive of countries between China and United States. In addition, we propose a aggregated nestedness index to predict a nation's future economic growth.

Methods
The world trade datasets of different products between countries by years from publicly available databases (Data source is seen in section Data Availability). The data comprises 261 countries and 786 products (categories) from 1976 to 2014. For a detailed introduction to datasets, one can refer to Supplementary S1. The trade flow is used to construct a multilayer network in which each layer is a directed network representing the export and import relations of a product. Each layer trading network can be characterized by a matrix with each element as is the dollar volume of a product p exported from the exporter c to the importer c 0 . To define the presence and the absence of the element in a matrix, we employ z-score to parameterize the volume of the trade flow to determine whether a trade flow can be considered significant or not. Mathematically, z ¼ ðv p cc 0 À <v p >Þ=σ p , where <v p > and σ p are, respectively, the mean and standard deviation of the dollar volume of a sample product p of the world trade network. Thus, we can obtain a binary matrix by a threshold of z. If z ≥ 0, v p cc 0 ¼ 1, otherwise v p cc 0 ¼ 0. Through these operations, we can build the multilayer world trade network.
We mainly focus on the nested structure of the multilayer world trade network. The nestedness of a network layer can be detected from its adjacency matrix. In a perfectly nested matrix, the elements in each sequential row are a strict subset of those in the upper row, while the elements in each sequential column are a strict subset of those in the upper column. A typical feature of a nested network in visualization is that the adjacency matrix shows a clear triangular pattern. There are also numerous metrics to quantify the nestedness of a matrix (Almeida-Neto et al., 2008;Bastolla et al., 2009;Beckett et al., 2014). Figure 1a illustrates the adjacency matrices of three toy networks with the same number of elements but the different level of nestedness. The rows and columns of these matrices are both reordered by descending degree (k). The matrix on the right is a fully nested matrix, while the matrix on the left has no nested feature. The network visualizations of these three matrices are given in Fig. 1b. Although the number of nodes and links are the same in these networks, the level of nestedness is totally different as the nestedness is determined by the particular directionality of links.
Here, we introduce a simple and widely used metric named Nested Overlap and Decreasing Fill (NODF) η( Almeida-Neto et al., 2008). η ranges from 0 to 1, with 1 indicating a perfectly nested structure and 1 indicating a none nested. The NODF calculation starts with a simple description: after sorting the adjacent matrix by descending indegree and outdegree, respectively, the nestedness of a pair of nodes is defined as Here N ij is the number of the commonly connected nodes shared by node i and node j. Thus, the nestedness of the matrix is the average of total pairs of nestedness. The step by step calculation is illustrated in Supplementary S2. According to the NODF metric, the nestedness of three toy networks, respectively, corresponds to 0, 0.5, 1 as shown in Fig. 1a. Thereupon we further quantify the nestedness in each layer of the multilayer world trade network with the NODF metric and report the distribution of nestedness calculated by 786 matrices of products in Fig. 1c. One can see that the nestedness of 786 layers varies significantly. The nestedness is <0.2 or >0.6, which account for <5%, but >10% in [0.3, 0.5]. For instance, the matrices are representations of the different layer of world trade networks which, respectively, corresponds to the network of Bovine, Typewriters, and Medical Instruments. The visualization of these three network is also shown in Supplementary Fig. S4. The nestedness of Bovine, Motorcycles, and Medical Instruments is 0.12, 0.35, and 0.60, respectively, which locates in the low, medium, and high areas of nestedness distribution.

Results
Nestedness characterizes product complexity. A number of metrics have been developed to quantify the competitiveness of countries and the complexity of products, with the iterative processes on the country-product bipartite networks. Examples include the measurements of ubiquity and diversity (Hidalgo and Hausmann, 2009;Hidalgo et al., 2007), eigenvector-based complexity index (ECI) (Hartmann et al., 2017;Hausmann et al., 2014;Hidalgo and Hausmann, 2009), and fitness and complexity index (FCI) (Cristelli et al., 2015;Tacchella et al., 2012), which are, respectively, introduced in Supplementary S4. As an alternative metric, we aim to employ the nestedness of a network layer to quantify the complexity of the corresponding product. This is motivated by the previous examples of Bovine, Typewriters, and Medical Instruments in Fig. 1c. In agreement with the recent advance in the economic complexity (Hidalgo, 2018;Tacchella et al., 2018), the low complexity products do not have a strong technology barrier, so almost all country could produce and export them. In this case, the structure of the trading network is mainly determined by the geographic location (Fujita et al., 1999) and a nested structure is not expected. However, for the highcomplexity products, only the countries with advanced technologies can produce them and export them to further countries.
It is well known that the technology barrier extensively exists in world trade due to the sophisticated technologies hold by some countries (Hausmann et al., 2014). The complex products are produced by a small number of countries and exported to other countries that do not hold the technology. This implies that the large out-degree countries in the layers with high nestedness are the countries possessing advanced technologies. To confirm this point, we consider the technology achievement index (TAI), which is widely used to measure the capacity of a country in technological innovations by the United Nations Development Program (Desai et al., 2002;Nasir et al., 2011). We compute the mean TAI of countries with top 10 out-degree in each layer, with the results presented in Fig. 2a and Supplementary S5.1. It is clear that 〈TAI〉 increases with η, which indicates that the products in the trading network with high nestedness indeed export from the high-technology countries to other countries. Moreover, the hightechnology barrier in international trade will result in the emergence of high asymmetry in the network of highcomplexity products. As shown in Fig. 2(b), the asymmetry of a network is captured by the dispersion of in-out degree as , where k in i and k out i represent indegree and outdegree, and N is the number of nodes. Asy ≥ 0. If Asy = 0, the indegree of each node equals the outdegree. An undirected network is perfectly symmetry (Asy = 0) as seen in Fig. 2(b). In an asymmetric network, the indegree of nodes is not consistent with outdegree and Asy > 0. We calculate the asymmetry of the network layer corresponding to each product. In Fig. 2(c), one can see that the asymmetry of products is positively correlated with the nestedness η of their trading networks, indicating that higher nestedness reflects the stronger asymmetric property of the complex products. In addition, bright points in Fig. 2(c) are the mean asymmetry of the 786 products belonging to different sectors whose name is seen in subfigure (d). The sectors (8, 7, 5, 6) of the machinery and chemicals with high nestedness are more asymmetric than the sectors (3, 4, 2, 0, 1) of raw materials (such as beverages and tobacco, food, crude inedible materials, mineral fuels, lubricants, animal and vegetable oils, fats and waxes) with low nestedness. The above analysis indicates that the nestedness of the trading network is strongly connected with the complexity of the traded product.
To validate the nestedness as a measure of product complexity, we compare the mean nestedness value of different types of products. The 786 products are classified into 10 sectors by Standard International Trade Classification (SITC) (classification of the product as seen in Supplementary Table S3). For each sector we compute ηðsÞ h i ¼ P i2s ηðiÞ=Nði 2 sÞ, where i is a product of sector s, η(i) is nestedness value of product i, N(i ∈ s) is the number of products belonging to the sector s. In Figure 2d, one can see that nestedness gives a reasonable ranking of these product sectors. Specifically, the sectors (8, 7, 5, 6) include machinery and chemicals are large nestedness, while the nestedness of the sectors (3, 4, 2, 0, 1) of raw materials (such as beverages and tobacco, food, crude inedible materials, mineral fuels, lubricants, animal and vegetable oils, fats and waxes) are lower. It is interesting that sector 9 (Commodities and transactions not classified elsewhere in the SITC) ranks in the middle position. In addition, we give the distribution of products in each sector in Supplementary Fig. S9.
We also illustrate the detailed top-10 most and last-10 worst complex products in Table 1. In top 10 nestedness ranking list, we find that these 10 products are sophisticated machinery, but last-10 products are those raw materials, but corresponding to the measurements of ubiquity, ECI, and FCI, their top 10 lists appear a few primary products like Castor Oil, Raw Cork, Miscellaneous printed matter as shown in Supplementary Table S4 and S5. In addition, we also find the low correlation between nestedness and the measurements of ubiquity, ECI, and FCI as seen in Supplementary Fig. S10, which we think the principle of nested structure could be independent from the other measurements. These results could provide clear evidence that nestedness can give an alternative quantification of products' complexity.
We use the nestedness to investigate the evolution of product complexity, and take the highest nested product types at different levels and observe the evolution of their average nestedness from 1986 to 2014 as shown in Fig. 3a. The four subplots, respectively, reveal the nestedness of the four levels, 8 Miscellaneous manufactured articles, 87 Professional, scientific, controlling instruments, apparatus, nes, 874 Measuring, checking, analysis, Fig. 2 Detection of product complexity. a The countries with advanced technologies in a nested matrix. We use the TAI index to measuring the technology achievement of nations (Desai et al., 2002;Nasir et al., 2011). The higher TAI indicates the higher national technological capability of a country. <TAI> top10 is the mean TAI of the countries with the top 10 out-degree in each layer. b The asymmetry of a network that characterizes the dispersion between the node's indegree and outdegree. The asymmetry of a directed network is 2, but the asymmetry of an indirected network is 0. c The asymmetry of nested networks. Gray points correspond to 786 products. Bright points are the mean asymmetry of the products belonging to different sectors. Red numbers correspond to sector numbers in subfigure (d). d Red points are the mean nestedness value of products from ten sectors classified according to the SITC code (detailed introduction seen in Supplementary Table S3). Black points are nestedness value of 786 products. ARTICLE HUMANITIES AND SOCIAL SCIENCES COMMUNICATIONS | https://doi.org/10.1057/s41599-020-00651-3 controlling instruments, nes, parts and the detailed 7 products contained by 874. We can observe that the nested structure of commodities at different levels is changing over time. On the whole, the nested structure is weakening. However, for products with the most nested structure, their changes are small. To quantify the nestedness evolution of the products, we consider top-20 products Ω at time t The first level products that can be regarded as ten sectors. (ii) 2-digit. We select the highest nested sector in the first level, i.e., nine miscellaneous manufactured articles. The ninth sector is subdivided into eight divisions. (iii) 3-digit. We also select the highest nested division in the second level that is 87 Professional, scientific, controlling instruments, apparatus, nes. The group can be subdivided into four groups. (iv) 4-digit. At last, we again select the highest nested group, which is 874 Measuring, checking, analysis, controlling instruments, nes, parts. This subgroup consists of seven products.  where rank(i, t) and rank(i, t + Δt) are, respectively, the ranking position of the product i at time t and t + Δt. Figure 3b shows the value of the top-20 products v under different Δt with the data from 1986 to 2005. We find that v rises fast but decay slowly. The trend is more pronounced when Δt is larger. At the same time, we compute the mean value of v by averaging two decades data. As shown in Fig. 3c, we can see a clearer trend that 〈v〉 is asymmetric between Δt < 0 and Δt > 0, indicating that the growth of product nestedness is faster than the relevance decay. We could suggest the trend that the product complexity would decline over time that depends on an advance of science and technology.
Quantifying economic competitiveness between China and the United States. We remark that the competitiveness of a country can also be measured based on the nestedness of the products exported. For a given product, if a country can export the product to more countries, this country occupies more market share. Thus, we can directly compute the number of countries that a country exports to in a given product's network layer as its trade competitiveness with respect to this product (κðc; pÞ ¼ P c 0 M cc 0 ðpÞ). Following the train of thought, we compare the trade competitiveness of the United States and China limited to a year 2010 as shown in Fig. 4a. We could find that China has the trade competitiveness of the products whose nestedness ranges from 0.35 to 0.5, corresponding to the products such as footwear, motorcycles, and electronics. While, the United States takes a distinct advantage of raw materials with η < 0.35 and sophisticated products with η > 0.5. In general, the competitiveness of these two countries is increasing with the complexity of products.
In addition, we analyze the evolution of trade competitive with the nested products for the United States and China. We first normalized the nestedness values in a given year according ηði; tÞ ¼ ηði; tÞ= maxðfηði; tÞgÞ. We also compare a given trade competitive to the country with highest trade advantage according toκðc; tÞ ¼ κðc; tÞ= maxðfκðc; tÞgÞ. Thus, if the normalized trade competitive is closer to 1, the country has stronger trade competitive. In Fig. 4b, c, the heatmap depicts the evolution of trade competitive with different nested products between China and the United States. One can find that these two countries have different trends in evolution. From 1976 to 2014, the United States always keeps great trade competitiveness, especially keeps greater trade competitiveness in raw materials with low nestedness and sophisticated products with high nestedness. While China's trade competitiveness gradually become great after 1990, especially after 2005, The high-nested product of trade competitiveness become stronger. These may be found that the trade advantage of China boosts to the top level in recent two decades could due to the economic take-off.
Predicting some representative economic indexes. Finally, we can extend the trade competitiveness κ(c, p) in single-network layer to the whole multilayer network, and define the global trade competitiveness as GTC(c) = ∑ p κ(c, p)η(p), where η(p) is the nestedness of the product p. Therefore, GTC(c) is the weighted sum of κ(c, p) by η(p) of all the product p that c exports. We first examine the prediction power of GTC by analyzing the correlation between GTC and some representative economic indexes (GDP, GDPpc, GDP(PPP), GDP(PPP)pc) 1 . Figure 5a displays the correlation ρ between countries' GTC in a certain year and their economic indexes after Δt years. One can see that ρ with GDP and GDP(PPP) is generally higher compared to that with GDPpc and GDP(PPP)pc. It also shows that ρ, in general, has a maximum value roughly 10 years later (Δt = 10) except the correlation to GDP(PPP). The high correlation between the economic indexes and GTC indicates that the prediction of economic growth can be applied to a simple linear regression model (Hidalgo and Hausmann, 2009). We give the range prediction under each bin of real growth as shown in Fig. 5b. The red labels are the prediction of G20 (except EU). The scatter plot of the predicted GDPpc growth and the real GDPpc growth exhibits a strong correlation. In fast-developing countries such as China and India, the actual growth rate is higher than predicted. In developed countries with slow growth such as the United States, Japan, and the United Kingdom, the predicted value is higher than the actual growth rate. Except these countries, We can still make good predictions for the countries like Russia, Canada, Australia, Turkey and others. More detailed discussion of the prediction power of GTC is given in SI7, Figs. S12 and S13. With regard to strengthening prediction power, this may require considering more factors or distinguishing different development models to predict economic growth.

Conclusions and discussions
The economic networks from massive data analysis, theory encompassing the appropriate description of economic agents and their interactions give a systemic understanding of global effects as a view of a single network like the monopartite product space network (Hidalgo et al., 2007;König et al., 2014) and the country-product bipartite network (Cristelli et al., 2015;Hartmann et al., 2017;Hausmann et al., 2014;Hidalgo and Hausmann, 2009;Tacchella et al., 2012). Although these works provide metrics that can quantify the economic complexity with the information of network structure, the networks they used overly simplify the international trading systems. As a remedy, we constructed a multilayer network in which the trading relations of each product are represented in the corresponding layer. We used the international trade datasets, which consist of both imports and exports relations to build multilayer world trade networks. We observed that each layer of the multilayer world trade network immediately revealed the nested structure in each layer and accordingly, which allowed us to develop a measure of the complexity of products. To validate the nestedness as a measure of product complexity, we compared the mean nestedness value of different types of products. The metric provided a ranking of products' complexity more consistent with common understanding.
The nested structure of a network layer seemed to correlate with the asymmetric export relations resulted from the technology barriers. We also used the nestedness to investigate the evolution of product complexity, and took the highest nested product types at different levels and observe the evolution of their average nestedness from 1986 to 2014. The evolution of product complexity indicated that the growth of product nestedness was faster than the relevance decay. Further, we remarked that the competitiveness of a country can also be measured based on the nestedness of the products exported and gave a comparison of trade competitive of countries between China and United States. Lastly, we extended nestedness index to predict a nation's future economic growth.
Our work could bridge nestedness and economic complexity in multilayer world trade networks and enriches numerous extensions. As we have shown with our illustration of nested structure, which can characterize product complexity, we could bring solutions to other economic systems in observation and modeling. Especially, as we known, a lot of emerging trade barriers resulting from political conflict or a pandemic like the COVID-19, the nestedness could provide a way of thinking about the structural characteristics of the world trade data. Although, the aggregated nestedness index is trying to quantify the competitiveness of individual nations and forecast the collective evolution of the world economy, it is well worth mining. There also are other open questions to ask for future study. For instance, we mainly focus on the utilization of nestedness, but what are the mechanisms that lead to the substantially triangular structure of the matrix remains unclear. In addition, we just used a commonly adopted metric to measure the nestedness of a network. How to design a better metric to capture nestedness more accurately that is still worth studying. These similar issues have received substantial attention in socioeconomic systems, because it would be a solution for disentangling the conditions of global stability in socioeconomic systems when bursting perturbations and instability like financial crises, national bailouts and social events (Gao et al., 2016;Helbing, 2013;Saavedra et al., 2014;Schweitzer et al., 2009).

Data availability
The datasets used to support the findings of this study are available from the website (https://comtrade.un.org/) or an alternative data source (http://atlas.media.mit.edu/en/resources/ data/).  We give the range prediction under each bin of real growth. The red labels are the prediction of G20 (except EU).
Parity (GDP(PPP)) states that exchange rates between currencies are in equilibrium when their purchasing power is the same in each of the two countries. GDP(PPP) per capita (GDP(PPP)pc) is GDP converted to international dollars using purchasing power parity rates and divided by total population