API reference
ICIO.ICIO — Module
ICIOFast value-added and Global Value Chain (GVC) decompositions of Inter-Country Input-Output (ICIO) tables, following the Borin & Mancini (2019) framework implemented by the Stata icio command (Belotti, Borin & Mancini 2021).
Workflow:
using ICIO
m = read_icio_csv("EM_2015.csv", "EM_countrylist.csv") # or load_icio(VA, FD, T; regions, sectors)
decompose(m; level = :country, perspective = :world, approach = :sink) # 9-term corrected KWW
decompose(m; level = :sector) # 13-term exporter/source
decompose(m; level = :bilateral) # 13-term, per importerLoading a table
ICIO.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.
ICIO.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.
ICIO.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
ICIO.decompose — Function
decompose(m::ICIOModel; level = :country, perspective = :exporter, approach = :source)Decompose gross exports into value-added / GVC components, returning a tidy DataFrame.
level = :country— one row per exporting country.perspective = :world, approach = :sink→ 9 terms (corrected KWW / Borin-Mancini).perspective = :exporter, approach = :source(default) → 13 terms.
level = :sector— one row per exporting country-sector (:exporter/:source, 13 terms).level = :bilateral— one row per exporter-sector × importer (:exporter/:source, 13 terms), excluding own-country destinations.
Columns are absolute values (same currency units as the table). See read_icio_csv and load_icio for constructing m, and decompose over a Dict of years for batch processing.
decompose(years::AbstractDict; 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.
ICIO.decompose_country — Function
Convenience wrapper: decompose(m; level=:country, …).
ICIO.decompose_sector — Function
Convenience wrapper: decompose(m; level=:sector).
ICIO.decompose_bilateral — Function
Convenience wrapper: decompose(m; level=:bilateral).