ct_hhi: Trade Concentration Index (HHI)

View source: R/analytics.R

ct_hhiR Documentation

Trade Concentration Index (HHI)

Description

Compute the Herfindahl-Hirschman Index measuring the concentration of a country's trade across partners or products.

Usage

ct_hhi(
  reporter,
  flow = "X",
  year = NULL,
  by = "partner",
  level = 2L,
  cache = TRUE
)

Arguments

reporter

Character. Reporter country ISO3 code.

flow

Character. "X" or "M". Default "X".

year

Integer. Year to query.

by

Character. Concentrate by "partner" or "product". Default "partner".

level

Integer. HS digit level (only used when by = "product"). Default 2.

cache

Logical. Default TRUE.

Details

HHI ranges from 0 (perfectly diversified) to 10,000 (single partner/product). Interpretation: < 1,500 = low concentration, 1,500-2,500 = moderate, > 2,500 = high.

Value

A data.frame with columns: year, hhi, concentration, n_items, top_item, top_share_pct.

Examples


op <- options(comtrade.cache_dir = tempdir())

# Export partner concentration
ct_hhi("AUS", flow = "X", year = 2023, by = "partner")

# Export product concentration
ct_hhi("AUS", flow = "X", year = 2023, by = "product")

options(op)


comtrade documentation built on April 13, 2026, 5:07 p.m.