Type: Package
Title: Portfolio for Economic Complexity Analysis and Navigation
Version: 0.1.0
Maintainer: Shiying Xiao <shiying.xiao@outlook.com>
Description: A portfolio of tools for economic complexity analysis and industrial upgrading navigation. The package implements essential measures in international trade and development economics, including the relative comparative advantage (RCA), economic complexity index (ECI) and product complexity index (PCI). It enables users to analyze export structures, explore product relatedness, and identify potential upgrading paths grounded in economic theory, following the framework in Hausmann et al. (2014) <doi:10.7551/mitpress/9647.001.0001>.
License: GPL (≥ 3)
URL: https://github.com/Carol-seven/pecan
BugReports: https://github.com/Carol-seven/pecan/issues
Encoding: UTF-8
Imports: Rdpack, dplyr, tibble, tidyr
RoxygenNote: 7.3.3
RdMacros: Rdpack
Suggests: testthat (≥ 3.0.0)
Config/testthat/edition: 3
NeedsCompilation: no
Packaged: 2025-11-05 21:44:55 UTC; csxiao
Author: Shiying Xiao ORCID iD [aut, cre]
Depends: R (≥ 3.5.0)
Repository: CRAN
Date/Publication: 2025-11-10 08:30:07 UTC

Complexity Index

Description

Compute the economic complexity index (ECI) and the product complexity index (PCI) based on the RCA values.

Usage

complexity(RCAmat, method = c("eigen", "fc", "mr"), niter = 20, gamma = 1)

Arguments

RCAmat

An economy-by-product matrix with the RCA values.

method

A character string specifying the method to calculate:

  • "eigen": the eigenvector solution (Hausmann et al. 2014).

  • "fc": fitness-complexity method (Tacchella et al. 2012; Pugliese et al. 2016).

  • "mr": method of reflections (Hidalgo and Hausmann 2009; Caldarelli et al. 2012).

niter

An integer (default = 20) specifying the number of iterations for method = "fc" and method = "mr".

gamma

A numeric value (default = 1) specifying the tuning parameter for method = "fc".

Value

A list containing ECI and PCI.

References

Caldarelli G, Cristelli M, Gabrielli A, Pietronero L, Scala A, Tacchella A (2012). “A Network Analysis of Countries' Export Flows: Firm Grounds for the Building Blocks of the Economy.” PLoS ONE, 7(10), 1–11. doi:10.1371/journal.pone.0047278.

Hausmann R, Hidalgo CA, Bustos S, Coscia M, Simoes A, Yildirim MA (2014). The Atlas of Economic Complexity: Mapping Paths to Prosperity. The Mit Press, Cambridge, MA, USA. ISBN 9780262317719, doi:10.7551/mitpress/9647.001.0001.

Hidalgo CA, Hausmann R (2009). “The Building Blocks of Economic Complexity.” Proceedings of the National Academy of Sciences, 106(26), 10570–10575. doi:10.1073/pnas.0900943106.

Pugliese E, Zaccaria A, Pietronero L (2016). “On the Convergence of the Fitness-Complexity Algorithm.” The European Physical Journal Special Topics, 225(10), 1893–1911. doi:10.1140/epjst/e2015-50118-1.

Tacchella A, Cristelli M, Caldarelli G, Gabrielli A, Pietronero L (2012). “A New Metrics for Countries' Fitness and Products' Complexity.” Scientific Reports, 2(1), 723. doi:10.1038/srep00723.


Density and Distance

Description

Compute the density and distance (Hausmann and Klinger 2006) based on the RCA and proximity values.

Usage

densdist(RCAmat, PROXmat, measure = c("density", "distance"))

Arguments

RCAmat

An economy-by-product matrix with the RCA values.

PROXmat

A product-by-product matrix with the proximity values.

measure

A character string specifying the measure to compute:

  1. "density": the new product’s proximity to the economy's current export basket.

  2. "distance": the economy's ability to enter a specific product.

Value

A economy-by-product matrix with the measured values.

References

Hausmann R, Klinger B (2006). “Structural Transformation and Patterns of Comparative Advantage in the Product Space.” Technical Report CID Working Paper No. 128, Harvard University. https://nrs.harvard.edu/urn-3:HUL.InstRepos:42482330.


Diversity and Ubiquity

Description

Compute the diversity/diversification and ubiquity (Hidalgo 2009) based on the RCA values.

Usage

divubq(RCAmat, measure = c("diversity", "ubiquity"))

Arguments

RCAmat

An economy-by-product matrix with the RCA values.

measure

A character string specifying the measure to compute:

  1. "diversity": the number of products that an economy produces.

  2. "ubiquity": the number of economies that export that product.

Value

A numeric vector with the measured values.

References

Hidalgo CA (2009). “The Dynamics of Economic Complexity and the Product Space over a 42 year period.” Technical Report CID Working Paper No. 189, Harvard University. https://dash.harvard.edu/handle/1/37366208.


PRODY and EXPY

Description

Compute the PRODY and EXPY (Hausmann et al. 2007) based on export and gross domestic product (GDP) data.

Usage

productivity(
  expData,
  gdpData,
  measure = c("prody", "expy"),
  econ = "economy",
  prod = "product",
  exp = "export",
  gdp = "GDP"
)

Arguments

expData

A data frame or matrix containing the export data.

  • If a data frame, it should have columns representing economies, products, and export values.

  • If a matrix, it should be an economy-by-product matrix with export values.

gdpData

A data frame containing the GDP data.

measure

A character string specifying the measure to compute:

  1. "prody": the income/productivity level.

  2. "expy": the income/productivity level of a country's export basket.

econ

A character string (default = "economy") specifying the column name for economies when expData is a data frame.

prod

A character string (default = "product") specifying the column name for products when expData is a data frame.

exp

A character string (default = "export") specifying the column name for export values when expData is a data frame.

gdp

A character string (default = "GDP") specifying the column name for GDP values when gdpData is a data frame.

Value

A numeric vector with the measured values.

References

Hausmann R, Hwang J, Rodrik D (2007). “What You Export Matters.” Journal of Economic Growth, 12(1), 1–25. doi:10.1007/s10887-006-9009-4.


Proximity

Description

Compute the proximity (Hidalgo et al. 2007) based on the RCA values.

Usage

proximity(RCAmat)

Arguments

RCAmat

An economy-by-product matrix with the RCA values.

Value

A product-by-product matrix with the proximity values.

References

Hidalgo CA, Klinger B, Barabási A, Hausmann R (2007). “The Product Space Conditions the Development of Nations.” Science, 317(5837), 482–487. doi:10.1126/science.1144581.


Revealed Comparative Advantage Index / Balassa Index

Description

Compute the revealed comparative advantage (RCA) index (Balassa 1965) for a given dataset.

Usage

rca(
  data,
  binary = TRUE,
  threshold = 1,
  econ = "economy",
  prod = "product",
  exp = "export"
)

Arguments

data

A data frame or matrix containing the data.

  • If a data frame, it should have columns representing economies, products, and export values.

  • If a matrix, it should be an economy-by-product matrix with export values.

binary

A boolean (default = TRUE) specifying whether to return binary RCA values (1 if RCA >= threshold, 0 otherwise).

threshold

A numeric value (default = 1) specifying the threshold for binary RCA values.

econ

A character string (default = "economy") specifying the column name for economies when data is a data frame.

prod

A character string (default = "product") specifying the column name for products when data is a data frame.

exp

A character string (default = "export") specifying the column name for export values when data is a data frame.

Value

An economy-by-product matrix with the RCA values.

References

Balassa B (1965). “Trade Liberalisation and “Revealed” Comparative Advantage.” The Manchester School, 33(2), 99–123. doi:10.1111/j.1467-9957.1965.tb00050.x.