ecomplexity #
Economic complexity measures and the product-space map, in OCaml.
The Atlas of Economic Complexity reads a matrix of countries by the products
they export and asks which countries are specialised in what, how complex a
country's economy is, and which products sit close to the ones it already
makes. The same questions apply to any matrix of units by activities:
organisations by the software capabilities they hold, regions by the
industries they employ in, teams by the components they maintain. This
library computes the Atlas's measures over such a matrix and draws the
result as a product space.
- Specialisation: Balassa's revealed comparative advantage (RCA), and the
presence matrix of the entries where it reaches 1. - Complexity: diversity and ubiquity, the method of reflections (Hidalgo
and Hausmann 2009), and the economic and product complexity indices as the
Atlas computes them, from the second eigenvector of the unit by unit
matrix. - Relatedness: co-occurrence, proximity and density (Hidalgo, Klinger,
Barabasi and Hausmann 2007), and z-scores of co-occurrence against the
curveball null model (Strona et al. 2014), which keeps every unit's
diversity and every activity's ubiquity, as Alstott et al. (2017) use for
technology classes. - The product space: the maximum spanning tree of the proximity graph and
its strongest links, the threshold on those links that gives a chosen mean
degree, and a Fruchterman and Reingold force-directed layout. - Diversification: a unit's distance to each activity it does not hold,
its complexity outlook and the complexity outlook gain of each move, the
Atlas's opportunity value and gain (2011, Technical Box 5.4), and the
jumps ranked two ways: the low-hanging fruit by Pareto layer of short
distance against high complexity, the strategic bets among the longer
jumps by gain, each with the held activities nearest to it. - Maps:
Ecomplexity.Spaceis the map as data, with a JSON form;
ecomplexity.brrdraws it in the browser through js_of_ocaml, with nodes
coloured by group, edges weighted by proximity, details on hover and click,
search, a group filter, zoom and pan, a unit's holdings and a ranked list
of nodes;ecomplexity-pagewrites maps as one offline HTML page, and
ecomplexity-jumpsplaces one unit on the product space of a units by
activities volume matrix and writes the map of its jumps.
Usage #
# let volumes = [| [| 1.; 1.; 1. |]; [| 1.; 1.; 0. |]; [| 1.; 0.; 0. |] |];;
val volumes : float array array =
[|[|1.; 1.; 1.|]; [|1.; 1.; 0.|]; [|1.; 0.; 0.|]|]
# let m = Ecomplexity.(presence (rca volumes));;
val m : bool Ecomplexity.matrix =
[|[|false; true; true|]; [|true; true; false|]; [|true; false; false|]|]
# Ecomplexity.proximity m;;
- : float Ecomplexity.matrix =
[|[|0.; 0.5; 0.|]; [|0.5; 0.; 0.5|]; [|0.; 0.5; 0.|]|]
A unit with no activity, or an activity no unit has, has no complexity: the
complexity functions give it nan and rank the others as if it were not in
the matrix.
To draw a map, build an Ecomplexity.Space.t (or write its JSON form), then:
$ ecomplexity-page map.json -o map.html
The page embeds its script, its styles and the map, loads nothing from the
network, follows the reader's light or dark preference and fits a phone's
width.
Related work #
The Growth Lab's py-ecomplexity
and the R package
economiccomplexity
compute the same measures in Python and R; the Observatory of Economic
Complexity and the Atlas draw product spaces with D3. This library follows
the Atlas's definitions and orients the product complexity index as the
Atlas does: a complex product is one that complex economies make.