top of page

Complexity - Ressources

The Stata package: history and current version

I first released the complexity package on SSC in 2019. Its original purpose was to provide Stata users with a simple and accessible way to compute economic complexity measures in the spirit of Hidalgo and Hausmann.

In 2025, I released a substantially updated version of the package.

Since its first release, complexity has evolved considerably. This page reviews the main changes and provides a real-data example of how the package can be used.

To install or update the package, type within Stata:

ssc install complexity, replace

The package now includes several important extensions:

  • It offers two alternative methods for computing Economic Complexity: the Method of Reflections and the eigenvector method, as well as one important derived measure from the literature, the Fitness index.

  • The input no longer needs to be restricted to Revealed Comparative Advantage tables. More generally, the package can work with any measure of performance across activities, such as export values, employment, or innovation indicators.

  • Input data can now be provided either as a varlist or directly through Stata or Mata matrices.

  • The package is now fully autonomous and no longer depends on additional packages such as moremata.

  • It also computes additional relatedness-based measures, including coherence (an index of intra-relatedness) and the Complexity Outlook Index (a measure of complexity potential).

  • Finally, the package can return the adjacency matrices of the feature space, such as the product space.

 

A simple example

To illustrate the package, I use 2023 export values by country and product (HS07 4-digit level, from BACI), contained in the attached file Exports2023HS4d.csv

After importing in into Stata, to compute the Economic Complexity Index, run:

reshape wide Xij, i(iso3) j(HS)
* First transform the dataset from long format into a wide specialization matrix

complexity, varlist(Xij*)

The following examples show some additional options:

complexity, varlist(Xij*) diversity outlook
* Computes diversity and Complexity Outlook indices in addition to ECI

complexity, varlist(Xij*) method(mr) iterations(40)
* Computes ECI using the Method of Reflections

complexity, varlist(Xij*) method(fitness)
* Computes the Fitness index

The resulting rankings are broadly consistent with those commonly reported in the literature and in public rankings, with countries such as Switzerland, Japan, Korea, and Germany appearing among the most complex economies in 2023.

I hope the package will be useful for researchers interested in computing complexity measures from different types of specialization data—exports, employment, innovation, and more—at different scales and for different units of analysis, including countries, regions, firms, or other organizations.

For more details, see the help file and the full article.

 

bottom of page