API reference
GlobalValueChains.GlobalValueChains — Module
GlobalValueChainsFast value-added and Global Value Chain (GVC) decompositions following the Borin & Mancini (2019) framework implemented by the Stata icio command (Belotti, Borin & Mancini 2021).
Supports the full set of icio perspectives/approaches: exporter (source & sink), world (source & sink), self (sectoral / sectoral-bilateral) export perimeters at the country, sector and bilateral levels, plus the importer-perspective decomposition of gross imports.
Workflow:
using GlobalValueChains
m = read_icio_csv("EM_2015.csv", "EM_countrylist.csv") # or load_icio(VA, FD, T; regions, sectors)
decompose(m) # 13-term exporter/source, by country
decompose(m; perspective = :world, approach = :sink) # 9-term corrected KWW
decompose(m; level = :sector) # 13-term exporter/source by country-sector
decompose(m; level = :bilateral, approach = :sink) # 10-term exporter/sink (adds VAXIM), per importer
decompose(m; level = :bilateral, perspective = :self) # sectoral-bilateral (sectbil) perimeter
decompose(m; flow = :imports) # importer-perspective imports, by countrySee decompose for the complete table of supported flow/level/perspective/approach combinations.
Loading a table
GlobalValueChains.load_icio — Function
load_icio(VA, FD, T; regions, sectors, X = nothing)Build an ICIOModel from the three core matrices, mirroring decompr's load_tables_vectors:
T—GN×GNintermediate transactions (T[i,j]= inputs from country-sectoriused byj).FD—GN×Gfinal demand (FD[i,r]= final goodsiabsorbed in countryr).VA— length-GNvalue added, ornothingto use the icio residualX .- vec(sum(T;dims=1)).
regions (length G) and sectors (length N) are country/industry names. X (output) is computed as rowSums(T) + rowSums(FD) when not supplied.
Note: to reproduce icio exactly, value added is the column residual of the table. Passing a VA that differs from X .- colSums(T) makes column sums of V*B deviate from 1 (so DC + FC may differ slightly from gross exports) — faithful to the supplied data.
GlobalValueChains.read_icio_csv — Function
read_icio_csv(table_csv, countrylist_csv; sectors = nothing, X = nothing, VA = nothing)Load an ICIOModel from the icio CSV format used by the Stata icio command and produced by STATA_ICIO_CSVs_V2.R:
table_csv— headerlessGN × (GN + G)matrix[T | FD]: the firstGNcolumns are the intermediate transactionsT, the lastGcolumns the final demandFD(one per country).countrylist_csv— headerless one-column file ofGcountry codes (e.g. ISO3).
The number of sectors is inferred as N = GN / G. sectors names the industries and may be a vector of N codes, a path to a headerless one-column CSV of sector codes (like countrylist_csv), or nothing (defaults to "sector1"…"sectorN"). Supplying the real sector codes means every output DataFrame carries them in from_sector from the start. By default value added is the icio column residual (X .- colSums(T)), reproducing icio exactly; pass VA/X to override.
GlobalValueChains.ICIOModel — Type
ICIOModelHolds an Inter-Country Input-Output table and all matrices/vectors precomputed once and reused across decompositions. Construct with load_icio or read_icio_csv.
Fields of interest: G (countries), N (sectors), GN = G*N, regions, sectors, X (output), V (value-added coefficients), A, B (global Leontief inverse), L (block-diagonal local Leontief), E (total exports), ESR (bilateral exports by destination, GN×G), FD (final demand by absorbing country, GN×G).
Decompositions
GlobalValueChains.decompose — Function
decompose(m::ICIOModel; flow = :exports, level = :country,
perspective = :exporter, approach = :source)Decompose gross trade into value-added / GVC components (Borin & Mancini 2019), returning a tidy DataFrame. Mirrors the Stata icio command's perspectives and approaches.
flow = :exports (default) decomposes exports:
level | perspective | approach | terms | description |
|---|---|---|---|---|
:country | :exporter | :source(=sink) | 13 | gexp dc dva vax davax ref ddc fc fva fdc gvc gvcb gvcf |
:country | :world | :source | 9 | world perimeter, FVA at first foreign crossing (eq. 52) |
:country | :world | :sink | 9 | world perimeter, corrected KWW (eq. 54) |
:sector | :exporter | :source | 13 | country perimeter, sectoral breakdown |
:sector | :exporter | :sink | 9 | gexp dc dva vax ref ddc fc fva fdc |
:sector | :self | — | 9 | sectoral (sectexp) perimeter |
:bilateral | :exporter | :source | 13 | one row per exporter-sector × importer (r≠s) |
:bilateral | :exporter | :sink | 10 | adds vaxim (DVA absorbed by direct importer, eq. 39) |
:bilateral | :self | — | 9 | sectoral-bilateral (sectbil) perimeter |
The :source approach records value added the first time it leaves country s's border (suited to production-linkage / GVC analysis); :sink records it the last time (suited to final-demand analysis). At the whole-country exporter perimeter the two coincide. The :self perimeter uses the broader Johnson (2018) / Los et al. (2016) value-added notion (DVA★ ⊇ DVAsource, DVAsink). :world is available at the country level only.
flow = :imports decomposes a country's gross imports from the importer perspective (eq. 51):
level | terms | description |
|---|---|---|
:country | gimp va dc | one row per importer |
:bilateral | va dc | one row per (importer, value-added origin); sums over origin to imports |
Columns are absolute values (same currency units as the table). See read_icio_csv / load_icio to construct m, and decompose over a Dict of years for batches.
decompose(years::AbstractDict; flow = :exports, level = :country,
perspective = :exporter, approach = :source)Batch version: years maps a year (or any label) to an ICIOModel. Runs the decomposition for each, prepends a :year column, and vertically concatenates the results (rows ordered by sorted year). Mirrors the foreach y in $years loop of ICIO_decomp.do.
GlobalValueChains.decompose_country — Function
Convenience wrapper for decompose at level=:country.
GlobalValueChains.decompose_sector — Function
Convenience wrapper for decompose at level=:sector.
GlobalValueChains.decompose_bilateral — Function
Convenience wrapper for decompose at level=:bilateral.
GlobalValueChains.decompose_imports — Function
Convenience wrapper for the import decomposition (flow=:imports).