Inferring comparative advantage via entropy maximization

We revise the procedure proposed by Balassa to infer comparative advantage, which is a standard tool in Economics to analyze specialization (of countries, regions, etc). Balassa’s approach compares a country’s export of a given product with what would be expected from a benchmark based on the total volumes of countries and product flows. Based on results in the literature, we show that implementing Balassa’s idea leads to conditions for estimating parameters conflicting with the information content of the model itself. Moreover, Balassa’s approach does not implement any statistical validation. Hence, we propose an alternative procedure to overcome such a limitation, based upon the framework of entropy maximization and implementing a proper test of hypothesis: the ‘key products’ of a country are, now, the ones whose production is significantly larger than expected, under a null-model constraining the same amount of information defining Balassa’s approach. What we found is that country diversification is always observed, regardless of the strictness of the validation procedure. Besides, the ranking of countries’ fitnesses is only partially affected by the details of the validation scheme employed for the analysis while large differences are found to affect the rankings of product complexities. The routine for implementing the entropy-based filtering procedures employed here is freely available through the official Python Package Index PyPI.


Introduction
The field of Economic Complexity has been steadily growing over the years.The first definition of an indicator for quantifying the complexity of the economy of a country is the so-called 'Economic Complexity Index' [1]; this first attempt has been followed by others, which have led to the definition of more sophisticated indicators such as the ones named Fitness [2,3].Their goal is to measure the capabilities of a national industrial system.In Economics, the standard approach to this task is that of collecting all the relevant information about the economic system under analysis, such as data about labour, the presence of infrastructures, pollution, schooling, taxes and so on -a way of proceeding which is known to be affected by several problems [4], as the one concerning the best way of combining such a large number of heterogeneous dimensions.The Economic Complexity approach, instead, rests upon the assumption that country capabilities are proxied by their competitiveness and economic productive advantage.
In standard Economics, the comparative advantage of a nation accounts for the endogenous nature of labour (and capital): as a consequence, each country is incentivised to employ its labour force in the most remunerative sectors ('decided' by its endogenous capabilities) while trading goods belonging to the others.Within this setting, each nation will limit its production of commodities to the aforementioned sectors, hence 'specialising' its export on few goods instead of 'diversifying' its productive portfolio.Balassa realised that a country comparative advantage can be estimated through data analysis, in particular the one about trade exchanges.According to his intuition, a country has a comparative advantage in producing a given set of goods if it exports them 'better than its competitors' whence the idea of estimating the competitiveness of a country, within a certain productive sector, by comparing its sector-specific export share with the one of the other world countries [5,6].The index introduced by Balassa, named Revealed Comparative Advantage (RCA) and extensively employed in the field of Economic Complexity [1,7,3,4] does not follow from any formal derivation, being simply deduced from a quite general rationale.In fact, it can be shown that Balassa's RCA is a comparison between the empirical value of a country-specific product export and its expected counterpart under a null-model preserving the total export of each country and the total export of each product [8,9,10].It is worth mentioning that the application of RCA goes far beyond international trade nowadays.Sometimes with different names, it has been applied to patenting data for technologies [11,12], employment data for sectoral studies [13] and scientific publication for science production [14,15].
In the present paper, we revise the Balassa's procedure.Firstly, we show that it is a comparison between the empirical value of a country-specific product export and the approximation of the outcome of the entropy-based Bipartite Weighted Configuration Model (BiWCM, introduced in [16]) in the so-called 'sparse' regime; the ingredients of the Bipartite Weighted Configuration Model are the ones originally used by Balassa to define RCA.Secondly, we will show that RCA is intrinsically biased.It was proved in the literature that there exists a set of null-models in which the definition of the null-model does not meet the maximum likelihood condition and that are, therefore, biased [17].Remarkably, RCA falls in this set, while "standard" entropy-based null-models (as BiWCM) are safe.Notably, when calculating the fitnesses of countries, i.e. the ability of countries of exporting the most exclusive products, the error made by using RCA is limited: the rankings obtained using different methods are highly correlated.Instead, the situation is different when considering the products' complexities: in this case, the correlations are much more limited.Third, we overcome the intrinsic limitation of Balassa's recipe, which prescribes to compare an empirical value with its expected counterpart (as noticed in [10], an overall poor validation from a statistical point of view), by proposing a proper test of hypothesis to be implemented by calculating the p-value of a country-specific product export.Specifically, the third point will be addressed by using probability distributions derived by maximising Shannon entropy in a constrained fashion, with the constraints representing the empirical properties to be preserved while randomising everything else [18]: in the specific case, the constraints coincide with the ingredients employed by Balassa to define the RCA, i.e. the total export per country and per product.
The sections of this paper are organized as follows: 'Methods' section is devoted to introduce maximum entropy benchmarks (in particular, two variants of the Bipartite Configuration Model for weighted networks) and re-framing the RCA-based validation procedure within such a framework.The 'Results' section is devoted to investigate the differences between the two different validation procedures (i.e.either the comparison of the empirical value with the statistical model's mean or the statistical validation) induced by the models considered for the present analysis.Finally, the 'Conclusions' section is devoted to summarise and discuss our results as well as some of their implications.

Methods
In the present section, we discuss entropy-based null-models for the analysis of complex networks and apply such a framework to tackle the problem of providing a statistically sound validation of a country's production.Specifically, we will consider the Bipartite Weighted Configuration Model with both discrete and continuous weights, respectively with the names BiWCM d and BiWCM c .Let us finally remark that BiWCM d was introduced earlier in the literature [16].

Entropy-based null-models: general framework
Entropy-based null-models represent benchmarks that are maximally random except for the constraints defining them.Let us start by defining the ensemble of graphs G, including all graphs having the same number of nodes of the real system (in the case of bipartite networks, the same number of nodes per layer) and a number of links that varies from zero to the maximum.Then, let us 'equip' this ensemble with a probability P (G), where G ∈ G is a member of the ensemble, and whose associated Shannon entropy reads If C(G) is a vector of quantities associated with each graph, we can maximise Shannon entropy while constraining the average values of C over the ensemble itself.The method of Lagrange multipliers amounts to maximising S defined as where θ is the vector of Lagrange multipliers associated with the constraints represented by C, C • is the value of the constraint and γ is the Lagrange multiplier associated with the normalization of the probability [19].The constrained maximization returns where Z = e γ+1 = G∈G e − θ• C(G) is the partition function.So far, we do not know the numerical value of the Lagrangian multipliers, since Eq.(3) describes only the exponential functional form of P (G).If we want to tailor our null-model on the real system -for instance, to spot behaviours that deviate from what is encoded in the constraints-, we require that C equate the empirical values of the constraints C * , or, otherwise stated to put C • = C * in Eq.(2) (hereafter, quantities denoted by an asterisk * will indicate values measured on the real system).Remarkably, it can be proven that, in this case, the maximum-likelihood estimation of the Lagrange multipliers leads precisely to the condition [17]: Solving Eq.( 4) typically implies solving a system of non-linear, coupled equations whose number is proportional to the number of nodes of the network under analysis: in what follows, we will describe an algorithm to numerically solve Eq.(4).

Entropy-based null-models for bipartite weighted networks
Let us call the two layers of a bipartite network and ⊥ and indicate their dimensions as N and N ⊥ , respectively.A bipartite weighted network is completely defined by its weighted biadjacency matrix W, i.e. a N × N ⊥ matrix whose generic entry w iα is 0 if no connection is present between i ∈ and α ∈ ⊥; otherwise, w iα is positive and captures the intensity of the interaction between the same two nodes.In case of discrete weights, w iα is an integer and coincides with the number of parallel edges between i and α; otherwise, w iα is a real number.The strengths are defined as the marginals of W, i.e. as s i = α∈⊥ w iα , ∀ i and σ α = i∈ w iα , ∀ α.

2.2.1.
Discrete Bipartite Weighted Configuration Model The Discrete Bipartite Weighted Configuration Model was introduced in [16].Following the procedure sketched in Subsection 2.1, we impose the node strengths of both layers as constraints: where G W is a generic weighted graph belonging to the ensemble G W , θ i and η α are the Lagrange multipliers associated, respectively, with s i and σ α .Equation (3), then, reads since weights are discrete, one finds the expression in turn inducing which allows us to interpret the probability of a graph G W ∈ G W as the product of probabilities whose generic functional form reads q BiWCMc (w iα ) = e −(θ i +ηα)w iα [1 − e −(θ i +ηα) ].
(9) ‡ As in subsection 2.1, quantities denoted by an asterisk * are the ones observed in the real system.
As stressed in the subsection above, the condition for the numerical determination of the Lagrange multipliers is equivalent at maximising the likelihood [17] (please refer to Appendix Appendix A for the algorithms used to numerically solve the system above).Since q BiWCM d (w iα ) obeys a geometric distribution, the statistical validation of a generic, empirical entry w * iα leads to recover an expression for the associated p-value reading

Continuous Bipartite Weighted Configuration Model
Let us now consider our entropy-based framework in case weights are treated as continuous variables.To the best of our knowledge, such a null-model has not been defined yet and represents the bipartite analogue of the model introduced in [20].The Hamiltonian defined in Eq.( 5) remains the same, the only difference being the nature of the weights.In order to calculate the partition function, we need to integrate, now, finding an expression inducing a probability per graph reading therefore, the probability density function associated with the entry w iα is simply Again, to obtain the values of the Lagrange multipliers {θ i } i∈ and {η α } α∈⊥ , we impose that and such a condition is equivalent to maximising the likelihood [17] (please refer to Appendix Appendix B for the algorithms used to solve the system above numerically).Since q BiWCMc (w iα ) obeys an exponential distribution, the statistical validation of a generic, empirical entry w * iα leads to recover an expression for the associated p-value reading Even if the functional form of Eq.( 14) is the same of Eq.( 10), it is worth remembering that, in general, the numerical values of the Lagrange multipliers are different in the two cases.

Final remarks
First, we have implemented the BiWCM d and the BiWCM c solvers distributed as updates of the NEMtropy § and the bicm Python packages.Second, in the 'dense' regime, i.e. for 'small' Lagrange multipliers, the BiWCM d and the BiWCM c are indistinguishable: in fact, in the 'dense' regime, Eq.( 8) can be approximated as i,α i.e. an expression bearing the same functional form of Eq.( 12).As a consequence, Eq.( 9) becomes which is solved by the Lagrange multipliers associated with the BiWCM c (see Eq.( 13)).An analogous consideration holds for σ α .In the systems we tested, the numerical differences between the Lagrange multipliers of the BiWCM d and the ones of the BiWCM c are of the order of 10 −8 , implying that the difference between their probabilities is out of the numerical precision, using double precision floats: therefore, in what follows we will just focus on the performance of the BiWCM c .Second, we explicitly notice that there exist entropy-based null-models that are able to account both for the weights and for the topology (i.e. for the number of connections of each node, disregarding its strength) of the network: see, for instance [21].Nevertheless, we prefer to neglect this information, here, as it was missing from Balassa's original proposal as well.
where W * = i∈ s * i = α∈⊥ σ * α and retain the corresponding link if the empirical value equals or exceeds it.In formulas Looking back at Eq.s(9), we realize that w Balassa iα coincides with w iα BiWCM d in the 'sparse' regime, i.e. for 'large' Lagrange multipliers, which ensure that 1 − e −(θ i +ηα) 1: in this case, in fact, In this sense, Balassa's validation adopts the approximated BiWCM d as a benchmark, an identification that does not hold when the BiWCM c is considered (in fact, the probability distribution of the BiWCM d is indistinguishable from the one of the BiWCM c only in the 'dense' regime, i.e. for 'small' θ i and η α ).

'Dressed' RCA-based validation
Entropy-based null-models maximise Shannon entropy while constraining the expected value of a number of network properties: as such, they represent a quite natural framework to carry out unbiased inference.In the present section, we exploit their statistical properties by 'dressing' Balassa's threshold with the probability distributions characterising the BiWCM d and the BiWCM c .Operatively, we follow the strategy proposed in [16] ¶ and solve the equations ( • are the average over the ensemble with the probability defined by the present nullmodel) to obtain the numerical values of the parameters in both cases and implement the corresponding validation algorithm.¶ Here, the model induced by such a strategy is named Maximum-Entropy Capital Asset Pricing Model (MECAPM).The present paper, however, does not deal with financial systems, whence our choice of renaming it Discrete Maximum-Entropy RCA (MERCA d ).Analogously, its continuous counterpart will be named Weighted Maximum Entropy RCA (MERCA c ).
Discrete Maximum-Entropy RCA (MERCA d ) model.Calculating the probability per graph within the MERCA d framework is pretty straightforward, following the same steps used to get the probabilities per graph in Eq.( 8).In fact, as in the case of the BiWCM d , the weight-specific probability distribution is a geometric one.P-values can be calculated as in Eq.( 10), i.e.
Continuous Maximum-Entropy RCA (MERCA c ) model.In this second case, the derivation of the probability per graph follows from Eq.( 12).In fact, and the p-value associated with the generic weight reads:

2.3.3.
Final remarks Let us comment on the maximum-likelihood procedure introduced in subsection 2.1.As stressed in [17], likelihood maximisation reveals the presence of biases whenever the condition imposed to maximise the likelihood does not agree with the requirement of the model definition.In these cases, in fact, the maximisation of the likelihood returns a different set of conditions to be satisfied by the model parameters.Instead, "usual" entropy-based null-models, i.e. those for which the constraints are fixed by the observed network (i.e.C = C * ) are unbiased since likelihood maximisation can be proven to be equivalent to the aforementioned set of conditions.MERCA models, while following from the maximisation of the entropy, lie somewhere in between the two cases above, since likelihood maximisation would require w iα MERCA• = w * iα , ∀ i, α while the models impose In fact, if we are interested in imposing constraints on weights, using some hypothesis is necessary since it ensures that our validation procedure will not lead to trivial results, as it would happen by constraining the expected value of each pair-specific weight to match the empirical one.Otherwise stated, we are interested in finding significant 'deviations' from a model's expectations while solving the maximum-likelihood set of conditions would not lead, by definition, to any significant deviation.In any case, MERCA models satisfy the constraints defining BiWCMs: and analogously for σ α MERCA• , ∀ α.In this sense, the MERCA models contain the same constraints of BiWCM models, but they are, at the same time, more restrictive (since constraints are per link, instead of per node) and not "centred" on the real system (since the likelihood maximisation condition does not match with the definition of the model).
Second, as for the BiWCM d and the BiWCM c , we observed no differences between the probabilities calculated using the MERCA d model and the MERCA c model, up to the numerical precision of a double-float representation.Therefore, in what follows we will just focus on the performance of the MERCA c model.

Testing multiple hypotheses via FDR
When validating several hypotheses, the effect due to the number of tests carried out at the same time plays a role and not accounting for it may lead to a large number of false positives [22].Among the different techniques that have been proposed to correctly tackle this problem, we opt for the one named False Discovery Rate (FDR), able to control the percentage of false positives [22].In a nutshell, this procedure prescribes sorting the p-values associated with the hypotheses to be tested (say n) in increasing order, i.e.

p-value
Upon choosing a significance level (say α), a global threshold α FDR = îα/n remains defined where î is the greatest i that satisfies the relationship (to be noticed that α represents the significance level of the whole set of hypotheses, every single link being validated by employing the lower threshold α FDR ).In what follows, we will set α = 0.05.

Comparing different validation procedures
Balassa's original procedure can be generalised in different ways: (i) the first one prescribes to deem country i as 'competitive' in exporting product α if the amount of the exported product is simply above the average.In formulas, where µ − null-model indicates that we are using the mean of the distribution defining the specific 'null-model'; (ii) the second one prescribes to deem country i as 'competitive' in exporting product α if the amount of the exported product is statistically significant.In formulas, where α − null-model indicates that we are carrying out a proper statistical validation, comparing the observations with the distribution defining the specific 'null-model'.
Summarising, we have 2 different validation procedures (the µ− and the α−ones) and 2 different null-models (the MERCA c and the BiWCM c , since in the regime of our analyses their discrete versions are indistinguishable from them).

Results
Our analysis focuses on the bipartite representation of International Trade, i.e. the bipartite network of countries (on one layer) and exported products (on the opposite layer).Country i is connected with product α if i exports α, the weight w iα is the volume of the export in dollars.More concretely, we will consider the COMTRADE export + , classified according to HS2012 and pre-processed.The overall numbers of countries and categories of products are 169 and 5, 206, respectively.Moreover, we will just focus on the matrices obtained for 2015 as the other years are basically characterised by the same patterns.

Comparing validated matrices
First, let us notice that different validation methods induce different link densities: as Fig. 1 shows, µ−MERCA c (i.e.Balassa's RCA-based validation, panel a, blue dots) induces a connectance around 0.10 throughout the entire dataset, while µ−BiWCM c (panel b, blue dots) induces a connectance which is steadily around 0.09.Being defined by a set of N × N ⊥ conditions on the weights, one may expect the µ−MERCA c to provide a stricter validation than the BiWCM c which, in turn, is defined by a set of 'just' N + N ⊥ conditions.However, while the constraints defining the BiWCM c reflect properly empirical quantities, this is not the case for the MERCA c : in fact, the N ×N ⊥ conditions reading w iα MERCAc = s * i σ * α /W * , ∀ i, α provide estimations which may perform poorly in reproducing the corresponding empirical quantities.
The situation is different when coming to consider the α−validation: indeed, the α−MERCA c (panel a, red dots) validates 18, 861 links against the 19, 938 ones validated by the α−BiWCM c (panel b, red dots).In principle, one would have expected to observe a larger number of links populating the matrix validated by employing the α−MERCA c .
+ https://comtradeplus.un.org/As the number of p-values which are lower than, say, 0.05 is slightly larger for MERCA c (38, 833) than for BiWCM c (38, 732), such an effect is due to correcting for multiple hypotheses (it can be shown that p-values differing for less than α/n are either both validated or both non validated by FDR [23]).
For what concerns the number of empty columns, α−MERCA c does not validate 633 products while α−BiWCM c does not validate 65 products.However, non-validated columns (under both α−MERCA c and α−BiWCM c ) are distributed across the entire range of strengths, even if they are more present among the largest ones.
Overall, nearly two-thirds of the links validated by the µ−MERCA c are also vali-dated by the µ−BiWCM c and roughly half of the links validated by the α−MERCA c are also validated by the α−BiWCM c .
The validated matrices in Fig. 1 are reordered according to the fitness and complexity rankings (Appendix Appendix C), respectively for countries and products, calculated on the µ−validated matrices.It is worth to notice that the triangular shape is emphasised more within the framework induced by µ−BiWCM c than within the one induced by µ−MERCA c : in fact, the stable Nested Overlap and Decreasing Fill (sNODF) [24], i.e. a variation of the measure proposed in [25], amounts at 0.24 when computed on the matrices validated by the µ−BiWCM c and 0.21 when computed on the matrices validated by the µ−MERCA c .Such a result still holds true when a stricter validation procedure is employed: in fact, the α−validated links in the network still display a clearly nested structure with the value of sNODF being larger for the BiWCM c (0.109) than for MERCA c (0.056).
In Fig. 1, we have coloured the µ−validated links in blue and those which are also α−validated in red, each line representing a validated export whose thickness is proportional to the corresponding total amount (products are reordered according to the complexity ranking calculated on the corresponding matrix).As the export baskets of the single countries confirm, the validated matrix using the BiWCM c is sparser than the one validated using its MERCA counterpart, returning the picture of countries focusing on a smaller set of products.For example, according to the export basket validated by µ−MERCA c , Tunisia is able to afford the production of items across the whole spectrum of goods, while such production is much more limited according to the export basket validated by µ−BiWCM c .An analogous consideration holds true for Jamaica.
For what concerns α−validated export baskets, MERCA-induced export baskets of small-and medium-fitness countries include more products of small complexity than the export baskets of high-fitness countries.BiWCM c -induced export baskets complement this picture: while small-and medium-fitness countries still include products of small complexity, a strong signal concerning the presence of high-complexity products in the export basket of the high-fitness countries becomes now visible.

Comparing Fitnesses and Complexities calculated on differently validated matrices
Generally speaking, the values of fitness and complexity [2,3] used to reorder the rows and the columns of the validated matrices are different for different matrices; nevertheless, similarities exist.For example, the Spearman correlation coefficient between the vectors of fitnesses calculated on different matrices is always larger than 0.8, i.e. the ranking induced by the fitnesses on different, validated matrices is nearly the same; moreover, the values of the correlation coefficients are basically constant for the entire dataset, indicating that the (small) differences between fitness-induced rankings FITNESS Table 1.Spearman correlation coefficients among the Fitnesses and Complexities computed using the various validation procedure for the year 2015 of our dataset.The correlation is nearly constant during the entire dataset.
are quite stable.Still, the distribution of fitnesses obtained by running stricter statistical validations becomes more peaked in correspondence of the most important exporters (e.g.China).On the other hand, the Spearman correlation coefficient between the vectors of complexities is much lower, lying between 0.48 and 0.73 -a piece of evidence confirming the noisy character of complexities.Table 1 reports the correlations for 2015 as the other years are characterised by very similar values.

Filtering real data
Null-models are often used to assess the significance of a given structure or signal in the network.In Economic Complexity, RCA is used to 'filter' the signal of comparative advantage by discounting the size of countries and products in the global market.In this section, we provide a visual example of this filtering process carried out by BiWCM c on the same matrix widely used in this framework.
In order to explore the properties of the BiWCM c in more detail, a comparison between the expected values output by the model (panel a) and the empirical values (panel b) is displayed in Fig. 2. The most striking difference is the triangular and nested structure of the real data that completely vanishes in the expected values.As anticipated in the Methods section, this is not surprising: for each couple of non-isolated nodes, the expected weight is non-zero, see Eq.s( 9) and ( 13).Such behaviour derives from the definition of the null-models considered, only discounting strength sequences that are continuous variables and not the node's degrees.Other entropy-based null-models available in the literature are able to discount both the information from topology (i.e. the node's degrees) and the weights (i.e. the strengths), see for instance [21], although the topology is often inferred from the weights and is not available independently.However, the scope of the present manuscript is to re-interpret Balassa's approach in a proper framework, keeping only the minimal null-model, while further developments will be scrutinized in future works.
In panel c) shows the values of 1 − p-value BiWCMc (w iα ) as a measure of signal's strength for trade: higher values mean an exceeding trade that is not explained simply by a random allocation of the strengths.Countries and products are reordered on the basis of the Fitnesses and Complexities calculated on the 1-p-value matrix, for a visual impact of the picture.From Fig. 2, the most unexpected links of the network are those in the high-complexity regions.Such an effect is due to the nature of our model: BiWCM c distributes the strengths of the nodes among more links than those that actually exist in the real data, since w iα BiWCMc = 0 for non-isolated nodes.High-complexity (lowubiquity) products have very few links distributed among only high-fitness countries and their actual values are much higher than the predictions of BiWCM c , see panel d).
Remarkably, the order of Fitness and Complexity calculated on the matrix in panel c) and on the RCA matrix (µ validated MERCA) are highly correlated, with a Spearman correlation of 0.981.
Summarising, so far we got two main insights about the model and system: BiWCM c can be used as a more refined, unbiased null-model to infer significant trades not explained simply by the strengths of nodes.Furthermore, as expected, it holds similar, but not equivalent, results to RCA in terms of shape of the matrix 1 − p-value and numerical values of Fitness and Complexity.

Discussion and conclusions
The analysis of the bipartite representation of International Trade, placing countries on one layer and their exported products on the other one, provides particularly useful information to infer the industrial capabilities of countries [1,2,3,4].Typically, analyses are carried out on a binarised version of this data, that focuses on the export of products for which countries have a comparative advantage.According to Balassa's idea, a country i that exports a selected product α 'more than expected', under a model informed by just the total export of i and the total export of α, proves to have a comparative advantage for what concerns the export of α [5].Balassa's implementation of the aforementioned idea prescribes comparing the empirical value of the export of α with a benchmark that is defined by the product of the total export of i, i.e. s i , and the total export of α, i.e. σ α .
With the present manuscript, we have shown that following Balassa's rationale, it is possible to define an entropy-based benchmark preserving the same information ad- vocated by Balassa: indeed, maximising Shannon entropy while constraining the total export of each country and the total export of each product [18] leads to (both the discrete and the continuous variants of) the Bipartite Configuration Model for weighted networks (hereafter, BiWCM ).Remarkably, the discrete (or multilink) variant of the Bipartite Configuration Model and the one originally proposed by Balassa do not differ much in the so-called 'sparse' regime (i.e. when the weights are 'small').
Two choices are, then, viable: implementing either the benchmark characterised by the simplest functional form (i.e. the original Balassa's one) or the one grounded in statistical theory, although mathematically more complicated (i.e. the one based upon the BiWCM).The difference between the two, however, is not merely formal: on the one hand, 'dressing' Balassa's proposal with a probability distribution, following the same procedure as for the BiWCM, leads to a statistical model not (intended to) maximising the probability of observing the real matrix.In this sense, the 'dressed' Balassa's proposal is a benchmark tailored on the observed system, still not 'centred' on it.On the other hand, "standard" entropy-based null-models are unbiased in the sense explained in [17]: the condition returned by the likelihood maximisation (i.e. the maximisation of the probability of observing the real weighted bipartite network) agrees with the model definition.
Such a difference has practical implications when implementing the different validation procedures considered in the present work.
When calculating the fitnesses of countries, the error made by using plain RCA turns out to be limited as the rankings obtained using different methods are highly correlated; the situation is different when considering the complexities of products, whose rankings are less correlated.More specifically, the limits of the export baskets are neater in the matrix binarised by employing the BiWCM c ; such behaviour is captured by the nestedness of the biadjacency matrix: in fact, we observed that a BiWCM c -induced binarisation returns a sNODF [24] which is more than 10% larger than the value measured on the matrix binarised according to the plain RCA.
Our framework also allows us to implement proper statistical filtering by validating the p-values associated with the observations -in a sense, implementing a sort of 'statistically significant comparative advantage' -instead of just retaining weights which are larger than expected.Countries' diversification is still evident; here, however, we also observe an excess of validated entries among the products exporting which a country is particularly efficient: specifically, while for 'average' countries the statistically validated products are distributed across the entire export basket, for the fittest ones this effect is observed more frequently for the most complex products [26].
Summarising, we have provided a different interpretation of Balassa's recipe for comparative advantage and proposed rigorous statistical validation.Although embodying Balassa's general rationale, our approach is well grounded and clearly shows that using different procedures has implications for the interpretation of the data.Notably, the differences are minimal for the evaluation of the fitnesses of countries while they are more relevant for the evaluation of the complexities of products.

Appendix A. Numerical methods to get Lagrange multipliers of the BiWCM d
As stated in the main text, to find the numerical values of the Lagrangian multipliers θ i and η α of the BiWCM d , we have to maximize the log-likelihood of the observed strength sequence.The log-likelihood reads: To maximize the likelihood in (A.1), we compute its gradient and find its roots.Its gradient reads: Indeed, finding the root of the gradient is equivalent to solve the constraint in Eq. 9.
In the following, we will present the formulas for the Fixed-point and the Newton's methods to solve it.

Fixed-point
Numerically, the system of equations in (9) can be solved using the fixed-point method, i.e. using the iteration until convergence, as proposed in Ref.s [27,28].
The Jacobian associated to the map defined by the Eq.s A.3 reads:

Fixed-point
In this case, we solve the system of equations iteratively, as has been already done for binary bipartite graphs [28].We can impose 3) The Jacobian associated to the transformation above reads: with the identification Var[w 2 .

Newton's method
As mentioned above, the system of equations in (13) represents the maximisation of the log-likelihood associated with the probability defined in Eq. 12.The Hessian associated with the transformation reads However, its convergence can still be slow.Thus, in this case, the default method we implemented in our solvers is the fixed-point strategy, which turns out to be faster and more accurate in the case of the BiWCM c .

2. 3 .
Revising the RCA-based validation 2.3.1.Balassa's RCA-based thresholding As mentioned in the Introduction, Balassa's thresholding procedure prescribes to compare the generic entry w * iα with the threshold

Figure 1 .
Figure 1.Top panels: Matrices representing the adjacency matrix of the Bipartite Network of the export of International Trade for the year 2015 of our dataset.Panel a) shows the M µ−MERCAc = M µ−RCA matrix: blue dots are validated exclusively by µ − MERCA c , red ones are validated also by α − MERCA c .Panel b) shows the M µ−BiWCMc matrix and the color codes the statistical validation: blue dots are validated exclusively by µ−BiWCM c , red ones are validated also by α−BiWCM c .Each matrix is re-ordered following the Fitness and Complexity ranking evaluated on the µ−validated matrix.Bottom panels: bars representing the basket of products of a few samples from the matrices above.

Figure 2 .
Figure 2. Real Vs expected trade flows.a) Expected value of trade flows given by Eq.(13).b) Real trade value.c) 1 − p-value BiWCMc (w iα ) given by Eq.(14) as a measure of surprise of exceeding value of real data.d) Logarithm of the ratio 1+w * 1+ w BiWCMc where we added 1 to every entry to avoid infinities and the logarithm of zero issues.All matrices have the same ordering, given by the ranking of Fitness and Complexity calculated with the matrix in panel c).