A reasoning of economic complexity based on simulated general equilibrium international trade model

By simulating a multi-country general equilibrium international trade model, we investigate how the economic complexity index (ECI) and fitness index (FI) are related directly to economic fundamentals with a clear basis in theory. The model is based on Eaton and Kortum (2002 Econometrica 70 1741–79) and combines factor endowment (Heckscher-Ohlin) and technological (Ricardian) reasons for specialization, which further determines economic complexity across countries. First, we find that FI performs better than ECI in explaining the real-world specialization pattern, where successful countries not only produce complex products due to the comparative advantage but also tend to produce a wide range of possible products due to the absolute advantage. Second, we highlight that the predictive power of various economic complexity measures for income is crucially sensitive to other factors that shift marginal cost from its efficient level in manufacturing sectors. The essence


Introduction
Research on why some countries are better at producing some products than others has been constantly pursued by economists, as its answer could reveal some fundamental source for economic growth (e.g. Hall and Jones (1999), Lin (2012), Sutton and Trefler (2016)). To approach this question, one intriguing method that leverages bipartite international trade networks to characterize and understand economic complexity has been employed in countless explorations to measure a country's relative ability to produce a good. Two famous measures are the economic complexity index ((ECI), Hidalgo and Hausmann (2009), Hausmann and Hidalgo (2011)) and the fitness index ((FI), Tacchella et al (2012)). Essentially, the high complexity of an economy is associated with the better capability of the country to export complex products. A by now well-established empirical stylized fact is that countries specializing in more sophisticated goods, i.e. with greater ECI or FI, are associated with faster economic growth in the subsequent period. For example, Cristelli et al (2015) find that fitness can help to quantify the hidden growth potential of countries via a fitness-income plane, and Sbardella et al (2018) point out that the fitness plays a crucial role in fostering economic growth in the aspect of GDP per capita, capital intensity, employment ratio, etc. However, it remains less clear regarding how the underlying logic is reflected in the general equilibrium of international trade and what precisely these economic complexity indicators measure, since they are all based on an intuitive narrative structure.
In this paper, by simulating a multi-country general equilibrium international trade model, we investigate how economic complexity measures are related directly to economic fundamentals with a clear basis in theory. To this end, we base the analysis on a computable model of trade which has neoclassical features, such as multiple sectors, perfectly competitive markets, constant returns to scale, and multiple factors that are mobile between sectors but fixed for a country. In the model, we allow a nation's comparative advantage to depend on factor endowment and technological and factor intensity, so that the model combines factor endowment (Heckscher-Ohlin) and technological (Ricardian) reasons for specialization, which further determines economic complexity across countries. A key feature of the model is that it relies on the framework of Eaton and Kortum (2002) that offers compact and elegant expressions for sector prices and bilateral trade flows.
Our simulated world consists of multiple countries, and each country has multiple sectors and is endowed with two main factors, which we label labor and capital. Industries differ in labor intensity and are sorted in labor intensity from the largest, which represents labor-intensive sectors such as textiles, to the smallest, which represents capital-intensive sectors such as machinery production. To be consistent with the empirical facts that developed countries are relatively more abundant in capital endowments than developing countries (Gapinski 1996, Debaere 2003, Limam and Miller 2004, we label countries that are endowed with more capital as more developed economies. Each country has idiosyncratic productivity in producing different sectors, where we make the more developed countries have a higher average productivity level across all sectors, as captured by the greater value of technology parameter in Eaton and Kortum (2002). Therefore, under this setting, the global trade pattern will be determined by the comparative advantage resulting from relative factor prices as predicted by Heckscher-Ohlin theory and relative productivity driven by Ricardian forces. A country will specialize in industries with relatively better technology or cheaper factor costs.
We compute various complexity measures with trade flows and compare them to the exact model fundamentals. To do so, we first apply ECI and FI algorithm to the international trade data from the United Nations Comtrade Database for years between 2005 and 2015. We find that the FI performs better than ECI in explaining the real-world specialization pattern. The reason is that the data frequently reveals abnormal situations where countries with low ECI have RCA in most complex products. In contrast, the FI measure gives a well-shaped triangular specialization matrix indicating that countries with higher FI tend to produce more complex and wider range of possible products. The performance difference is likely explained by the algorithms on which the two indexes are computed. As suggested by the ECI algorithm, countries with high ECI specialize in only certain complex products, while real data strongly points to the essential role of diversification. That is, successful countries not only produce complex products due to the comparative advantage but also tend to produce a wide range of possible products due to the absolute advantage 3 .
Next, we compare the performance between ECI and FI in the simulated equilibrium. In the symmetric case where production efficiency parameter 4 is assumed to be identical across countries and sectors, countries tend to specialize in the range of sectors where they have a comparative advantage, leading to those capital-abundant countries being the main exporters of capital-intensive goods. As suggested by the method of reflections for ECI, the capital-abundant countries are computed to have greater complexity as they produce capital-intensive goods that are assumed to be more sophisticated than labor-intensive ones 5 . However, this symmetric economy with Heckscher-Ohlin forces specifically gives rise to the diagonal-shaped specialization matrix. To capture the diversification pattern across countries and sectors, and make our simulated economy more in line with the actual data, we further allow the production efficiency to differ by country and sector. By adding the absolute advantage in capital-abundant countries and assuming that capital-intensive products are more difficult to produce, our model manages to generate a triangular-shaped specialization matrix that is consistent with the real world. 3 Absolute advantage refers to the ability to produce more of a good or service than a competitor, while comparative advantage is the ability to produce a good or service for a lower opportunity cost than a competitor. Adam Smith first alluded to the concept of absolute advantage in his 1776 publication The Wealth of Nations and looked at the efficiency of producing a single product. David Ricardo developed the theory of comparative advantage in 1817 to explain why countries can engage in international trade and produce certain products with low opportunity costs, even though they have low production efficiency in all products. 4 Following Eaton and Kortum (2002), we assume that the countries' productivity follows Frééchet distribution that is governed by the production efficiency parameter T s i and dispersion parameter θ. A greater production efficiency parameter implies that high-productivity draws are more likely in this country. 5 As implied by the ECI algorithm, a country's complexity and product complexity are inter-determined by each other. The ECI of a country is the average complexity of products in which the country specializes; the complexity of a product is determined by the average complexity of its producers. In practice, the method of reflections in Hausmann et al (2007Hausmann et al ( , 2014, Hausmann and Hidalgo (2011) also requires the assumption that the more developed economy, such as the United States, has a higher value of ECI. The reason is that the product of minus one and ECI remains an eigenvector to the system of equations that forms method of reflection. Without such an assumption, it cannot rule out the case where more developed countries, such as the United States, could have a smaller value of economic complexity, which is entirely inconsistent with the empirical facts. Furthermore, we find that the predictive power of various economic complexity measures is crucially sensitive to distortions in manufacturing sectors, which lead to a country's revealed comparative advantage not reflecting the true comparative advantage determined by its factor endowments and production technology. For instance, by increasing the variable marginal cost of labor-intensive goods in the country that endows the median level of capital and has relatively similar input costs of producing both labor-and capital-intensive goods, we find the specialization pattern of the economy moves towards capital-intensive goods as their production costs become lower. At the same time, the national income falls. In contrast, with the distortion, the country has a higher ECI since it produces more capital-intensive goods 6 . The essence of such an issue lies in the assumption that the RCA correctly reflects a country's real capability of specialization across different goods. However, in the presence of distortions, there would exist a gap between the core idea of learning the national complexity from RCA and the fact that a revealed specialized pattern in data may not necessarily suggest a country's real capability, which is ubiquitous across developing countries (Rauch 1999, Rose 2000, Lin 2009). One important source of such distortion is the transaction cost, which leads to the latent comparative advantage, e.g. determined by a country's factor endowment, failing to be turned into the RCA in the market 7 . In addition, we find that FI is less sensitive to such distortions.
Our paper contributes to several strands of literature. First, leveraging a structural model and simulation, we systematically investigate how economic complexity measures are related to economic fundamentals. Thus, our work is closely related to the recent explorations focusing on the motivating rationale, theoretical foundations, and principles of economic complexity. For instance, Hidalgo and Hausmann (2009) develop the idea of endowments of capabilities which could be defined as a broad set of skills required for production. Since then, it has attracted much theoretical exploration on the relationship between complexity metrics and endowments of capabilities, such as the seminal work Tacchella et al (2013). Our work stands among recent attempts that focus on the motivating rationale, theoretical foundations, and principles of economic complexity. Specifically, with a simulated general equilibrium model, our paper systematically investigates how economic complexity measures relate to economic fundamentals. The common feature of country capabilities is that it is intangible and abstract-it cannot help to relate complexity measures directly to economic fundamentals in data that has a clear basis in economic theory. So complementing Hidalgo and Hausmann (2009)   who assume that countries will be able to produce products if all of the relative capabilities are available, our analysis is based on an economic model where 'production capabilities' are well defined. For instance, 'production capability' is directly captured by the margin costs, which further depend on factor endowments and factor intensity in production. In equilibrium, countries will precisely specialize in industries where their abundant factors are intensively used in production. Hence, country capability (in Hidalgo and Hausmann (2009)  ) can be interpreted as the abundance of factors that are intensively required in producing particular products. In addition, under the assumption of the capability-based approach, one can only get limited information about whether a country can produce a certain product through the tripartite structure. In contrast, we can precisely measure a country's industry-specific export performance with the model, i.e. the Balassa revealed comparative advantage. Further, with lab-type experiments, we could obtain a better sense of to what extent countries specialize in particular industries because their factor endowment structure is congruent with the factor intensity in producing those industries' products, both of which we can precisely measure in the real world. Therefore, our approach provides a new structural reason for the capability-based approach and economic complexity metrics.
On the methodology side, our analysis is built on the framework of Eaton and Kortum (2002), and is closely related to subsequent works that extend the Eaton and Kortum (2002) to multiple sectors, such as Arkolakis et al (2009), Costinot et al (2010, Caliendo and Parro (2011). Our paper differs from and complements these studies by introducing country heterogeneity in factor endowments and defining sectors according to the factor intensity of production technology so that the model additionally takes into account factor endowment (Heckscher-Ohlin) forces on top of technological (Ricardian) reasons for specialization. 6 One example of distortions that increase variable marginal cost is to impose a tax on the production of the good. In the model, the country with median capital has relatively similar input costs of producing labor-and capital-intensive goods, so its ECI ranks roughly at the median. Therefore, the impact of price distortions on these countries could be better captured by the deviating trend of economic outcomes after the change. Alternatively, countries with high (low) complexity rank could have mechanical rank change whose trend is downward (upward) in response to external shocks. 7 Ciaian et al (2008) observed that the factor content between the export and import of agricultural products in Central and Eastern European (CEE) countries is quite similar, and suggests that there is a general lack of agricultural specialization due to the transaction costs and imperfect markets, which distorted the agricultural specialization and organization in CEE. Other factors that may affect a country's specialization across industries include state's interventions, such as the comparative-advantage-defying strategy (Lin 2009), information costs (Rauch 1999, Evans 2003, Chen 2004, monetary unions (Rose 2000), and entry costs due to contract incompleteness (Roberts and Tybout 1997).
The prediction of trade in our model is closer to Shikher (2011), which also combines the technological (Ricardian) and factor endowment (Heckscher-Ohlin) reasons as the source of comparative advantage for global specialization. The simulation-based approach is widely used such as in Eliasson and Mattsson (2001), Bird and Manning (2008), Berger and Troost (2014), Chen et al (2017), Orkoh et al (2022). Particularly, using a simulation approach similar to ours, Shikher (2011) studies the effects of technology and capital stock on trade.
Our focus on the bipartite trade network and on the specialization pattern across countries echoes another literature that investigates the reliability and stability of complexity measures, including ECI and FI. This literature emphasizes the impact of trade networks on the centrality measures (Tacchella et al 2012, Morrison et al 2017. Complementing previous works, we find that FI performs reasonably well by highlighting the role of diversification in the real economy where countries with higher FI produce more complex and a wider range of possible products, and a triangular-shaped matrix could well represent the corresponding global specialization pattern. In contrast, ECI, developed by Hidalgo and Hausmann (2009), is limited in its performance as it can only depict a simplified scenario where the diversification channel is shut down. This is achieved by assuming identical production efficiency across countries and sectors. Consequently, the comparative advantage determined by factor endowments becomes the sole determinant in global trade.
Finally, our counterfactual analysis relates to the literature that emphasizes the role of countries' capability of enabling the latent comparative advantages of industries to their competitive advantage in the market, where the latent comparative advantages depend on a country's endowment structure (Lin 2009, Stiglitz 2011, Ju et al 2015. Via counterfactual simulation, we find that the measure of economic complexity would be less informative for inferring a country's latent comparative advantages if its factor endowment is incongruent with the production structure of an economy.
The rest of the paper is organized as follows. Section 2 introduces the model used for simulation. Section 3 summarizes the results, and section 4 concludes.

A simulated general equilibrium model
The simulation model is a neoclassical model of trade with multiple sectors, perfectly competitive markets, constant returns to scale, and two factors of production (labor and capital) that are mobile across sectors but not mobile across countries. There are N countries and S sectors. We denote countries by i (exporters) and n (importers) and sectors by s. Production functions of different sectors are assumed to be constant return to scale and differ in capital intensity. Each country has its own set of factor endowments and idiosyncratic productivity in producing different sectors, whereas the more developed country has higher average productivity across all sectors. The model builds on the Ricardian trade model of Eaton and Kortum (2002) and Caliendo and Parro (2011), and it combines factor endowment (Heckscher-Ohlin) and technological (Ricardian) forces for forming comparative advantage. One advantage of the model framework is that it allows easy incorporation of distortions that affect production across countries.

Model environment 2.1.1. Households
In each country n, there is a measure of L n representative households that maximize utility by consuming final goods C s n . The preferences of the households U n is a CES aggregator 8 over the bundle of final goods C s n : where ϵ ⩾ 1 is the elasticity of substitutions across sectors, and a greater value of ϵ means that products of different sectors are more substitutable with each other. The production of final goods uses intermediate inputs, which we specify below.

Intermediate goods
In this section, we introduce the production structure for intermediate input producers. A continuum of intermediate goods j ∈ [0, 1] is produced in sector s, and the production technology of an intermediate good j is Cobb-Douglas using labor and capital: where L s i (j) is labor and K s i (j) is capital in sector s used for the production of intermediate good j. The parameter α s ⩾ 0 captures the cost share of capital in sector s used in producing intermediate good j. The specification of Cobb-Douglas allows us to intuitively identify the capital intensity of sector s by the parameter α s alone. Finally, z s i (j) denotes the production efficiency of country i in producing good j in sector s As the production function of intermediate input satisfies constant return to scale, and the market is perfectly competitive, the marginal cost of good j of sector s in country i is then c s i /z s i (j), where c s i is the cost of input bundle, which is expressed as where r i is the rent rate of capital, and w i is the wage of labor in the country i.

Consumption goods
Producers of consumption goods in sector s and country n supply Q s n at minimum cost by purchasing intermediate goods j from the lowest cost suppliers across countries. Following Caliendo and Parro (2011), we assume that the production of Q s n is governed by the CES aggregator: where σ > 0 is the elasticity of substitution across intermediate goods, andq s n (j) is the demand for intermediate goods j from the suppliers with the lowest cost. The first order conditions to the profit maximization problem of the composite intermediate goods producers give the following demand for intermediate good where P s n is the price index for composite intermediate inputs: and p s n (j) denotes the lowest price of intermediate good j across all countries. Composite intermediate goods from sector s are used as final goods in consumption C s n .

Price index
There are two sources of price distortions: exogenous trade costs and some exogenous distortions at the sector level 10 . The trade cost reflects geographic barriers in exporting and importing products in the global market. We follow the conventional assumption made by Samuelson that the trade cost is iceberg-type. Specifically, if d ni = d, it suggests that delivering a unit of product from country i to the country n requires producing and shipping d units in the country i. In addition to trade costs, our model introduces other shifters (τ s ni ) to production costs so that prices deviate from their efficient level for traded intermediate goods. We combine both price distortions by κ s ni : is what buyers in country n would pay if they choose to buy the goods j in sector s from country i. Since the same intermediate goods from different countries are perfect substitutes, buyers pay for the goods j in sector s at p s n (j), the lowest price across all exporters i, which is expressed as Following Eaton and Kortum (2002), we assume that the production efficiency z s i (j) of country i in producing good j in sector s is the realization of a Fréchet distribution (also called the Type II extreme value distribution), with CDF being F s i (z) = e −T s i z −θ , with technology parameter T s i and dispersion parameter θ. According to Eaton and Kortum (2002), a bigger T s i implies that a high efficiency draw of z s i (j) is more likely, making the average production efficiency higher, a notion of absolute advantage, while a bigger θ implies less variability of production efficiency, a notion of comparative advantage. Specifically, z s i (j) (production efficiency) has geometric mean (the nth root of the product of n numbers) exp{γ/θ + ln T s i /θ} and its log has standard deviation π/(θ √ 6), where γ = 0.577 is the Euler constant and π = 3.14. We assume that the distributions of production efficiency z s i (j) are independent across goods, sectors, and countries with 1 + θ ⩾ σ 11 . Then the price of composite intermediate goods is given by 12 Consumers purchase final goods at prices P s n . With the CES form preferences, the consumption price index in country n is given by where P n measures the total living cost in country n.

Expenditure shares and trade balance
Total expenditure on sector s goods in country n is given by X s n = P s n Q s n . Denote X s ni the expenditure in country n of sector s that is from country i. It follows that country n's expenditure share of goods from i are given by π s ni = X s ni /X s n . According to the property of Fréchet distribution, we can derive expenditure shares as With CES form preference, country n's expenditure on goods s is given by where I n = w n L n + r n K n represents the total expenditure in country n, which equals to the sum of labor wage and capital rent 13 . Finally, using the expressions of expenditures and trade deficit we have that This condition reflects that country n's total expenditure minus its trade deficits equals the sum of each country's total expenditure on goods from country n. For simplicity, we assume in our simulation that countries have equal imports and exports, i.e. a zero balance of trade, so that D n = 0, ∀n. 11 We must restrict 1 + θ ⩾ σ in order to have a well defined price index as shown in (2). 12 appendix 'Distribution of Prices and Expenditure Shares' presents a detailed derivation of the distribution of prices and how to solve for the price index (equation (2)) as well as the expenditure shares (equation (4)). 13 If the distortions τ s ni are in the form of tariffs, the distortions would generate tariff revenues that are re-distributed to households. Therefore, total income In would include the tariff revenues Rn. In particular,

Definition of equilibrium
We refer to Caliendo and Parro (2011) and characterize the equilibrium of the model as follows.
Definition 1. Given L n , K n , α s , {T s n }, {d ni }, and {τ s ni }, an equilibrium is a wage vector w ∈ R N ++ , and rent vector r ∈ R N ++ that satisfy equilibrium conditions (1)-(6) for all j and n.

Specialization, ECI, and FI
According to the methodology introduced by Hausmann et al (2007,2014), Hausmann and Hidalgo (2011), Tacchella et al (2012), the complex trade network is generated using the classic measure of RCA. Formally, the RCA of the product (sector) s in the country i in our model can be expressed as: where Y is = N n=1 X s n π s ni is the export of product s by country i. According to the formula, a country exporting more than her 'fair share' of total exports of a given product has a revealed comparative advantage in that sector, and the 'fair share' is the share of the country's exports in the global market. This specialization pattern is represented by a N × S matrix M, and M is = 1 if RCA is > 1 and 0 otherwise. Therefore, one can compute a country's diversity and product's ubiquity measure by summing M is across rows and columns respectively: The ECI algorithm is designed under the assumption that the complexity of a country is the average complexity of products in which the country specializes; the complexity of a product is determined by the average complexity of its producers 14 . The calculation can be expressed by the following system 15 : After enough iterations, both k (n) i and k (n) s converge to two sets of fixed points, which measure the economic complexity of a country and product, respectively. However, it has been discussed in Cristelli et al (2013) that the asymptotic convergence of k (n) i would be a single value for all countries. We instead consider substituting k (n) s into k (n) i , therefore the fixed points of the system of equations in (8) can be re-written in the following matrix format Equation (9) is satisfied when k are both a vector of ones, which corresponds to the eigenvector ofM i i ′ associated with the largest eigenvalue. Since this eigenvector does not provide information, we instead use ⃗ K, the eigenvector associated with the second largest eigenvalue, which provides the largest variation in the system to measure complexity. Thus, ECI is based on normalizing the eigenvector ⃗ K, expressed as: The FI algorithm is only superficially similar to the ECI algorithm: 'Fit' countries are defined as producing many 'Complex' products, while non-'Complex' products are defined as being produced by 14 Pietronero et al (2017) proposed a paradox in which country A exports ten products whose complexity goes from 1 to 10, and country B exports only one product with a complexity equal to 6. The ECI algorithm would assign a complexity of 5.5 to country A and 6 to country B. This is counter-intuitive since a country that makes many products, also of very high complexity, and including the one with complexity of 6, is ranked below the one that produces only this product with complexity of 6. 15 The initial conditions of F

The parameters of simulation
We perform simulation exercises under different scenarios to provide an overview of how the model generates the specialization pattern in production across countries and consequently inferences the national ECI and FI. First, we simulate the labor and capital in N = 100 countries where labor is fixed, and capital endowments increase with index n in the form of K n = 500n/N. S = 500 sectors are simulated with different capital shares, expressed as α s = s/S. As for ϵ, the elasticity of substitution across sectors, we use the median elasticity of HTS goods in Weinstein and Broda (2004) as a proxy, which is estimated to be 3. Then, we follow the calibration of Caliendo and Parro (2011) and set the dispersion parameter of production efficiency θ to be 6, and make the elasticity of substitution across intermediate goods σ = 6, so that the condition 1 + θ ⩾ σ holds.
For simplicity, we assume identical iceberg cost among countries, i.e. d ni = 1.3 for n ̸ = i, and that price distortion τ s ni is equal to zero. Furthermore, we assume that the production efficiency T s n , is given by T n × T s . The supermodularity of this function will lead to complementarity between national production efficiency and sector production efficiency. National production efficiency T n = (1 + γ 1 ) n , where a positive γ 1 captures the absolute advantage in capital abundant countries. Similarly, sectoral production efficiency is expressed as T s = (1 + γ 2 ) s , and a negative γ 2 means that it is more complex to produce capital intensive goods. Table 1 displays the parameter used in the baseline simulation.

Solving the model
We use different parameter settings for different scenarios. In each scenario, to solve for equilibrium, we first guess a wages vector w = (w 1 , . . . , w N ) and rents vector r = (r 1 , . . . , r N ), e.g. w = r = 1. Conditional on the vector of wages and rents, the equilibrium conditions (1) and (2) give the solution for the cost of the input bundle c s n (w, r) and price P s n (w, r) in each sector s and country n that are consistent with the vector of wage w and rent r. Then, we use the calculated P s n (w, r) to solve P n (w, r) using (3), and use c s n (w, r) to solve for π s ni (w, r) by (4). Given π s ni (w, r), we solve for total expenditure in each sector s and country n X s n (w, r) using (5). Substituting π s ni (w, r), X s n (w, r), P s n (w, r), P n (w, r) into equation (6) we verify whether the trade balance condition holds. If not, we update our guess of w and r according to the trade surplus/deficits by country until the trade balance condition is satisfied. The procedure follows the algorithm developed by Caliendo and Parro (2011). Take the convergence algorithm for wage vector for instance, the updating rule is specified as follows: where λ is a constant factor parameter that we adjust to make w ′ n converges to w n . A similar process can be applied to the rent vector r to obtain the solution. The convergence of the above algorithm is ensured by Allen et al (2019), who confirmed the uniqueness and existence of equilibrium for a wide range of quantitative models, including the model setting used in this paper.
Given the solved w * and r * , we calculate the corresponding π s ni (w * , r * ) and X s n (w * , r * ), using which we obtain the Y is , export of product s by country i, and construct the equilibrium RCA matrix by (7) as well as the specialization matrix {M cp }. Finally, we can compute the metrics of ECI and FI according to (8) and (11), respectively.

Empirical facts
To characterize the specialization pattern in production for each country, we use international trade flow data that are readily available from the United Nations Comtrade Database for years between 2005 and 2015, which provides export and import values at the product-country-year level for all international transactions. We include a wide coverage of countries and define a product as a Harmonized System (HS) 4-digit code in our analysis. Finally, we are left with 117 countries and 1239 products in our sample. Figure 1 shows the specialization pattern generated by the trade flow data in 2005, 2010, and 2015, respectively. Suppose we order countries and products by ECI metrics from the smallest to the largest. In that case, we see from parts (a), (c), and (e) that countries with high complexity tend to produce complex products. Yet, we can also observe that there are abnormal cases where the high-complexity countries produce simple products, and likewise, some complex products are produced by low-complexity countries. When we turn to see the specialization matrix where countries are sorted by FI metrics as shown in the right panel, parts (b), (d), and (f) display the triangular-shaped specialization matrix, indicating that successful countries tend to produce a wide range of possible products. Furthermore, we do not observe that countries with low fitness produce a high-complexity product. This performance difference could be explained by the fact in real economy that successful countries not only produce products with high complexity but also produce a wide range of products due to absolute advantage. Hence, the method of reflections of linear ECI algorithm would give misleading information about the ranking of countries and products and result in the abnormal cases we observe in parts (a), (c), and (e) as described above. On the other hand, the nonlinear FI algorithm gives higher weight to countries with low fitness when calculating the product complexity and therefore gives a well-ordered triangular matrix and is more in line with real economy.

Simulation results
In this section, we study how ECI and FI are related to various economic fundamentals with simulated trade flows. First, we analyze the simulated specialization pattern across countries in the simple symmetric case that creates an economy where international trade is driven by Heckscher-Ohlin forces. That is, we assume away the country and sectoral heterogeneity in production efficiency, i.e. γ 1 = γ 2 = 0, so that T n = 1 for all countries and T s = 1 for all sectors. Hence, the production efficiency parameter T s n = 1 and there is no absolute advantage of any country in any products. Figure 2 shows the Q-Q Plot of percentiles of the simulated data set against the percentiles of the real data, where both the trade flow and RCA are compared in natural-log units. The plot produces an approximately straight fitted line, suggesting that the simulated data follows a similar distribution to that of real data. Figure 3 illustrates the RCA matrix of trade flow where we arrange countries by rows and products by columns. Countries and sectors are sorted in capital endowment and intensity, from the smallest to the largest. Consistent with the Heckscher-Ohlin theory, a country exports products that use its abundant factor intensively: labor-abundant countries take advantage of the low cost of labor and develop labor-intensive sectors, while capital-abundant countries specialize in capital-intensive sectors. Figure 4 reports the relationship between countries' ECI, Fitness, diversity, and income. Consistent with our setting, the capital-abundant countries tend to have higher income since income increases with country index n, where a bigger number indicates a more capital-abundant country. It has been well documented in   Countries and sectors are sorted in capital endowment and intensity, from the smallest to the largest. White is used as the dividing color to distinguish whether the RCA value of a product in a country is greater than one or not. Figure 4. Simulated ECI, Fitness, diversity, and income for different countries in the symmetric case (T s n = 1). In black are the metrics of ECI and Fitness, accordingly to the left y-axis; in grey are the economic outcomes, including countries' diversity and income.
the previous literature that country complexity is strongly correlated with income and is useful for predicting economic growth (Tacchella et al 2012, Hausmann et al 2014, Cristelli et al 2015, Sbardella et al 2018. A similar pattern is observed in our simulation-there is a positive correlation between ECI, Fitness, and income. However, we can see from figure 4 that Fitness is not very correlated with income. This could be due to the choice of symmetric parameters in this model, which creates a Ricardian world where the specialization caused by comparative advantage is the only driver of global trade. However, FI should not work in this case as it is designed to capture the role of diversification since successful countries not only produce complex products due to comparative advantage but also tend to produce a wide range of possible products due to absolute advantage.

Specialization and diversification
Next, we compare the specialization pattern ordered by ECI with that ordered by FI. As shown in figure 5, the specialization matrix is diagonal-shaped after we sort countries according to ECI metrics. If we sort countries and products according to the simulated FI, we do not observe the triangular-shaped specialization matrix as displayed in figure 1.
The performance difference in the specialization matrix between figures 5(a) and (b) is likely explained by the role of diversification versus specialization in shaping the trade pattern. In the symmetric case, the Heckscher-Ohlin forces dominate the simulated economy, where countries tend to specialize in the range of sectors where they have a comparative advantage, and it leads to the capital-abundant countries being the main exporters of capital-intensive goods. In practice, the method of reflections also requires the assumption that the more developed economy, such as the United States, has a higher value of ECI 16 . As suggested by this assumption the capital-abundant countries are computed to have greater complexity as they produce capital-intensive goods that are assumed to be more sophisticated than labor-intensive ones, leading to a diagonal-shaped matrix in figure 5(a). Under the dominant forces of Heckscher-Ohlin which states that a capital-abundant country will export the capital-intensive good and that the labor-abundant country will export the labor-intensive good, there are no countries that can produce significantly more or fewer products, nor are there any products that can be produced by significantly more or fewer countries, making it difficult for the FI algorithm to distinguish between 'Fit' and non-'Fit' countries, as well as 'Complex' and non-'Complex' products. According to our simulation, there are 75 out of 100 countries whose diversity is between 200 and 300 and 480 out of 500 products whose ubiquity is between 40 and 70. These numbers are captured by the specialization matrix observed in figure 5(b), hardly making the specialization matrix look like an upper triangular as displayed in the right panels of figure 1 when the matrix is ordered by the FI index.
However, the actual data pattern is strongly pointing to the essential role of diversification in shaping trade, with high-fitness countries producing a broad range of products due to the absolute advantage. To capture the role of diversification and make our simulated economy more in line with the actual data, we now allow the production efficiency parameter T s n to differ by country and sector. That is, we let γ 1 = 0.1 and γ 2 = −0.1, so that national production efficiency T n = (1 + 0.1) n capture the absolute advantage in capital-abundant countries. Besides, sectoral production efficiency T s = (1 − 0.1) s , so it is more challenging to produce capital-intensive products. Under this parameter setting, our simulated equilibrium yields the specialization pattern presented in figure 6. The simulated specialization matrix of figure 6 shows that developed countries with abundant capital not only produce complex products due to the comparative advantage, but also produce a wide range of possible products due to their high production efficiency. Hence, we observe a triangular-shaped specialization matrix that is more consistent with the actual trade data.

Parameter sensitivity
A key determinant of the specialization pattern is the parameter θ, the shape parameter of the Fréchet distribution of the stochastic production efficiency. It plays a vital role in shaping the expenditure share in equation (4). Another parameter to be considered is ϵ, the demand elasticity of substitution across sectors. In this section, we discuss how these parameters shape the specialization and diversification patterns by checking the robustness of the results with respect to changing θ and ϵ under γ 1 = 0.1 and γ 2 = −0.1.
The variability of the stochastic production efficiency becomes less as θ increases, making international trade between different countries less likely to occur. Therefore, when θ increases from 3 to 9, countries are more likely to produce specific goods with comparative advantages rather than absolute advantages. Hence, we can see from figure 7 that labor-abundant countries produce a wider range of labor-intensive goods while capital-abundant countries reduce their production of labor-intensive goods as θ increases.
When ϵ is set to be 1, the CES preference of the households U n degenerates to the case of Cobb-Douglas, with an equal share of expenditure on each sector for all the countries 17 . As ϵ increases, the consumption goods between sectors are less differentiated and are more substitutable. Therefore, as ϵ increases from 1 to 5, the capital-abundant countries can make better use of their absolute advantage to produce and export a broader range of capital-intensive goods with low production costs. In contrast, labor-abundant countries produce less labor-intensive goods since they have a greater demand for imported capital-intensive goods that have lower costs and are more able to substitute labor-intensive goods.

Price distortions
Finally, we consider the impact of sector-specific price distortion, a way to mimic the case when a country's revealed comparative advantage fails to reflect the true comparative advantage that is determined by its endowment and production technology on various economic outcomes 18 . Specifically, we introduce distortions that increase the variable marginal cost of labor-intensive goods in the country with the median capital endowment 19 . Such change can be realized by making τ s ni > 1 for i ∈ {49, 50, 51, 52} and s ∈ {1, 2, . . . , S/2}. Intuitively, the change lowers the incentive of median countries to produce labor-intensive goods as their production costs become relatively higher. Figure 8 compares the specialization matrix before and after the distortions. The matrix is divided into four different color regions, labeled x → y and x, y ∈ {0, 1}, representing the value of the specialization matrix before and after the shock. Country-product pairs in the dark red (blue) region, labeled 1 → 1 (0 → 0), mean that the country has remained a significant exporter (non-exporter) of the product after the shock. Country-product pairs in the light red (blue) region, labeled 0 → 1 (1 → 0), mean that the country becomes an exporter (non-exporter) of the product. According to the figure, the specialization pattern of the median countries, i.e. the horizontal bar of countries indexed as {49, 50, 51, 52}, moves towards capital-intensive goods.
] 1/n . 18 One example of such distortions includes the comparative-advantage-defying (CAD) strategy, which was adopted by many developing countries. The CAD strategy involves developing advanced capital-intensive (heavy) industries that are not consistent with their comparative advantage, which is determined by their factor endowments (Lin and Tan 1999, Lin 2003, Lin et al 2021. 19 In the model, the country with median capital endowment has relatively similar input costs of producing labor-and capital-intensive goods, so its ECI ranks roughly at the median. Therefore, the impact of price distortions on these countries could be better captured by the deviating trend of economic outcomes after the change. Alternatively, countries with high (low) complexity rank could have mechanical rank change whose trend is downward (upward) in response to external shocks.

Figure 7.
Specialization matrix under different parameter settings. Countries and sectors are sorted according to capital endowment and capital intensity from the smallest to the largest, respectively. The parameter ϵ is set as 1, 3, 5, respectively, and the θ belongs to 3, 6, and 9. Figure 8. Ordered specialization matrix before and after price distortion. The matrix is divided into four different color regions, labeled x → y and x, y ∈ {0, 1}, representing the value of the specialization matrix before and after the shock. Country-product pairs in the dark red (blue) region, labeled 1 → 1 (0 → 0), mean that the country has remained a significant exporter (non-exporter) of the product after the shock. Country-product pairs in the light red (blue) region, labeled 0 → 1 (1 → 0), mean that the country becomes an exporter (non-exporter) of the product.
Furthermore, we focus on the effect of these price distortions on ECI, FI, and other outcome variables in the equilibrium. Figure 9 presents the simulated results after we introduce distortions. Comparing to the baseline results in figure 4, we find that the main changes occur in the shaded area of the graph-countries with price distortions see a decline in income, diversity, and FI, while the ECI increases. The reason is that countries with price distortions specialize in more capital-intensive sectors. In contrast, FI is less sensitive to distortions. The essence of such an issue lies in the assumption that the RCA correctly reflects a country's real capability of specialization across different goods. However, in the presence of distortions, there would exist a gap between the core idea of learning the national complexity from RCA, and the fact that a revealed specialized pattern in data may not necessarily suggest a country's real capability, which is ubiquitous across developing countries (Rauch 1999, Rose 2000, Lin 2009). Figure 9. Simulated ECI, FI, diversity, and income for different countries after distortion. Shaded areas represent countries with price distortions. In black are the metrics of ECI and Fitness, accordingly to the left y-axis; in grey are the economic outcomes, including countries' diversity and income.

Conclusion
This paper uses simulation to investigate how the economic complexity measures are related directly to economic fundamentals with a clear basis in theory. The distinguishing feature of the model developed for simulations is that it explains intra-industry trade by producer heterogeneity on the industry level using the framework of Eaton and Kortum (2002). While the paper focus on the specialization pattern and how it relates to complexity across countries, the rich structure of the model allows one to investigate various aspects of the economy.
One of the key results of the paper is that the FI performs better than ECI in explaining the real-world specialization pattern. The performance difference is likely explained by the algorithms on which the two indexes are computed. As suggested by the method of reflections for ECI, countries with high ECI specialize in only certain types of complex products, while real data are strongly pointing to the essential role of diversification. That is, successful countries are likely to produce complex products via comparative advantage on the one hand, and they also tend to produce a wide range of possible products due to absolute advantage on the other. Hence, FI, developed by Tacchella et al (2012), is more reliable in explaining the economic activities characterized by diversified production.
Finally, the paper analyzes how distortions affect the predicting power of economic complexity measures for income differences. By raising the variable marginal cost of labor-intensive goods in the country with the median capital endowment, we find the specialization pattern of the economy moves towards capital-intensive goods, and at the same time, the national income falls. In contrast, with the distortion, the country has a higher ECI since it produces more capital-intensive goods. The evidence suggests that the measure of economic complexity could be biased and that one should interpret the economic complexity measures with caution, because of the inherent existence of distortions in the world. How to improve the existing approach used for computing economic complexity measures that are robust to distortions will be left for future studies.

Data availability statement
The data cannot be made publicly available upon publication because no suitable repository exists for hosting data in this field of study. The data that support the findings of this study are available upon reasonable request from the authors.
Plug the demand function ofq s n (j 2 ) into Q s n to get optimal indirect utility function Appendix B. Distribution of prices and expenditure shares Following Eaton and Kortum (2002), we assume that the production efficiency z s i (j) of country i in producing good j in sector s is the realization of a Fréchet distribution (also called the Type II extreme value distribution), with CDF being F s i (z) = e −T s i z −θ . Therefore, the cost of purchasing an intermediate good j in sector s from country i to country n, is the realization of the random variable p s ni (j) = Note that p s n (j) has a Fréchet distribution with location parameter Φ s n and shape parameter θ. The moment generating condition for x = − ln p s n (j) is E[e tx ] = Γ(1 − t/θ)(Φ s n ) t/θ . (See Eaton and Kortum 2002). Replace x by p s n (j), E[p s n (j) −t ] = Γ(1 − t/θ)(Φ s n ) t/θ .