tradeIndices

tradeIndices provides dependency-light R functions for frequently used international trade indicators. It accepts user-supplied numeric data, so the core calculations do not depend on an API key or internet connection.

Installation

install.packages("tradeIndices")

For the development source directory:

install.packages("path/to/tradeIndices", repos = NULL, type = "source")

Main indicators

Function Indicator
trade_openness() Exports plus imports as a share of GDP
trade_intensity() Bilateral export intensity
import_intensity() Bilateral import intensity
trade_concentration() HHI or normalized HHI
trade_diversification() HHI-, entropy-, or effective-number diversity
trade_diversification_index() Structural distance from a benchmark
export_similarity() Similarity between two export structures
trade_complementarity() Export-import structural complementarity
rca_balassa() Balassa revealed comparative advantage
grubel_lloyd() Product-level or aggregate intra-industry trade

Examples

library(tradeIndices)

trade_openness(
  exports = c(120, 135, 150),
  imports = c(100, 115, 125),
  gdp = c(500, 540, 590)
)

trade_intensity(
  bilateral_exports = 25,
  reporter_exports = 200,
  world_exports_to_partner = 400,
  world_exports = 5000
)

product_exports <- c(rice = 45, wheat = 25, tea = 20, spices = 10)
trade_concentration(product_exports)
trade_diversification(product_exports)

country_exports <- c(rice = 45, wheat = 25, tea = 20, spices = 10)
world_exports <- c(rice = 20, wheat = 35, tea = 15, spices = 30)

trade_diversification_index(country_exports, world_exports)
export_similarity(country_exports, world_exports)

Interpretation

Trade intensity greater than one indicates a bilateral export share exceeding the partner’s reference share in world imports. High HHI indicates concentration; high HHI-based or entropy-based diversity indicates a broader trade structure. The structural diversification index is a distance measure: higher values mean greater dissimilarity from the benchmark, not necessarily a more even export basket.