Skip to content

ICIOReader

This module provides functionality for reading and processing OECD Inter-Country Input Output (ICIO) tables. It handles the complex task of managing multi-country, multi-industry economic relationships and transforming them into a format suitable for economic modeling.

The module centers around the ICIOReader class, which processes raw ICIO data and provides methods to: 1. Read and aggregate input-output relationships 2. Handle country-specific data transformations 3. Calculate economic indicators and flows 4. Convert between different time frequencies

Key features: - Support for multiple countries and industries - Flexible aggregation of sectors and regions - Exchange rate conversions - Time frequency adjustments - Trade flow calculations

Example
from pathlib import Path
from macro_data.readers.io_tables.icio_reader import ICIOReader

# Initialize reader with raw data
reader = ICIOReader.agg_from_csv(
    path=Path("icio_data.csv"),
    pivot_path=Path("pivoted_data.csv"),
    considered_countries=["FRA", "DEU"],
    industries=["C10T12", "C13T15"],
    year=2018,
    exchange_rates=exchange_rates_reader,
    imputed_rent_fraction={"FRA": 0.2, "DEU": 0.18},
    investment_fractions=investment_data
)

# Get processed data
fra_output = reader.get_total_output("FRA")
fra_imports = reader.get_imports("FRA")

ICIOReader

Reader and processor for OECD Inter-Country Input Output Tables.

This class reads and processes OECD ICIO tables, providing methods to: 1. Aggregate and normalize input-output relationships 2. Calculate trade flows and proportions 3. Extract industry-specific metrics 4. Convert annual values to sub-annual frequency

The reader handles: - Multi-country input-output relationships - Industry aggregation and mapping - Trade flow calculations - Value-added computations - Capital formation and investment - Government and household consumption - Exchange rate conversions

Attributes:

Name Type Description
iot DataFrame

The input-output table

considered_countries list[str]

Countries included in analysis

industries list[str]

Industries tracked in the model

imputed_rents dict[str, float]

Imputed rents by country

year int

Reference year for the data

investment_matrices dict

Investment allocation matrices

yearly_factor float

Factor to convert annual to sub-annual values

Methods

agg_from_csv(cls, path, pivot_path, considered_countries, aggregation_path, industries, year, exchange_rates, imputed_rent_fraction) Class method to aggregate the input-output table from CSV files (i.e. map unused countries to the ROW). read_df(path) Static method to read the input-output table from a CSV file. aggregate_io(considered_countries, df, aggregation) Static method to aggregate the input-output table. normalise_iot() Normalizes the input-output table by adjusting value-added. column_allc(country_name, symbol) Returns the sum of columns for a specific country and symbol. get_monthly_total_output(country_name) Returns the monthly total output for a specific country. get_monthly_intermediate_inputs_use(country_name) Returns the monthly intermediate inputs use for a specific country. get_monthly_intermediate_inputs_supply(country_name) Returns the monthly intermediate inputs supply for a specific country. get_monthly_intermediate_inputs_domestic(country_name) Returns the monthly domestic intermediate inputs for a specific country. get_monthly_capital_inputs(country_name) Returns the monthly capital inputs for a specific country. get_gfcf_column(country_name) Returns the Gross Fixed Capital Formation (GFCF) column for a specific country. get_monthly_capital_inputs_domestic(country_name) Returns the monthly domestic capital inputs for a specific country. get_monthly_value_added(country_name) Returns the monthly value added for a specific country. get_monthly_taxes_less_subsidies(country_name) Returns the monthly taxes less subsidies for a specific country. get_taxes_less_subsidies_rates(country_name) Returns the taxes less subsidies rates for a specific country. get_monthly_hh_consumption(country_name) Returns the monthly household consumption for a specific country. get_monthly_hh_consumption_domestic(country_name) Returns the monthly domestic household consumption for a specific country. get_hh_consumption_weights(country_name) Returns the household consumption weights for a specific country. get_monthly_govt_consumption(country_name) Returns the monthly government consumption for a specific country. get_monthly_govt_consumption_domestic(country_name) Returns the monthly domestic government consumption for a specific country. govt_consumption_weights(country_name) Returns the government consumption weights for a specific country. get_imports(country_name) Returns the imports for a specific country.

iot = iot instance-attribute
considered_countries = considered_countries instance-attribute
industries = industries instance-attribute
imputed_rents = imputed_rents instance-attribute
year = year instance-attribute
investment_matrices = {} instance-attribute
yearly_factor = yearly_factor instance-attribute
__init__(iot: pd.DataFrame, considered_countries: list[str], industries: list[str], imputed_rents: dict[str, float], year: int, yearly_factor: float = 4.0)

Initialize the ICIOReader.

Parameters:

Name Type Description Default
iot DataFrame

Input-output table

required
considered_countries list[str]

Countries to include

required
industries list[str]

Industries to track

required
imputed_rents dict[str, float]

Imputed rents by country

required
year int

Reference year

required
yearly_factor float

Factor to convert annual to sub-annual values. Defaults to 4.0 (quarterly).

4.0
agg_from_csv(path: Path, pivot_path: Path, considered_countries: list[str] | list[Country | str], industries: list[str], year: int, exchange_rates: ExchangeRatesReader, imputed_rent_fraction: dict[str, float], investment_fractions: dict[Country | str, dict[str, float]], yearly_factor: float = 4.0, proxy_country_dict: Optional[dict[str | Country, str | Country]] = None, aggregation_type: Optional[Literal['All', 'Aggregate']] = None) -> ICIOReader classmethod

Create an ICIOReader instance from CSV data with aggregation.

This factory method reads raw ICIO data, performs necessary aggregations and normalizations, and returns a configured ICIOReader instance.

Parameters:

Name Type Description Default
path Path

Path to raw ICIO CSV file

required
pivot_path Path

Path to save/load pivoted data

required
considered_countries list[str | Country]

Countries to include

required
industries list[str]

Industries to track

required
year int

Reference year

required
exchange_rates ExchangeRatesReader

Exchange rate data

required
imputed_rent_fraction dict[str, float]

Rent fractions by country

required
investment_fractions dict[Country | str, dict[str, float]]

Investment splits

required
yearly_factor float

Annual to sub-annual conversion. Defaults to 4.0 (quarterly).

4.0
proxy_country_dict Optional[dict]

Country mapping for missing data

None
aggregation_type Optional[Literal['All', 'Aggregate']]

Aggregation method

None

Returns:

Name Type Description
ICIOReader ICIOReader

Configured reader instance

read_df(path: Path | str) -> pd.DataFrame staticmethod
aggregate_io(considered_countries: list[str], df: pd.DataFrame, aggregation: Optional[dict[str, list[str]]] = None) -> pd.DataFrame staticmethod

Take an input output table and aggregate it. Pairs of (country, industry) identifiers for every entry are aggregated, countries may be aggregated into "ROW", the rest-of-the-world super-category. industries are mapped according to an AGG_DICT dictionary, that has pairs like 'A': ['A01', 'A02', 'A03'] indicating that these three industries go into industry A.

Parameters

considered_countries : list[str] list of countries considered for the aggregation df : pd.DataFrame Input output table aggregation: dict industrial aggregation dictionary

Returns

pd.DataFrame the aggregated io-table.

column_allc(country_name: str, symbol: str) -> pd.Series

Sum columns across all countries for a specific symbol.

Aggregates values across all countries (including ROW) for a given country and symbol combination.

Parameters:

Name Type Description Default
country_name str

Target country

required
symbol str

Column identifier (e.g., "Household Consumption")

required

Returns:

Type Description
Series

pd.Series: Summed values across all countries

get_total_output(country_name: str) -> np.ndarray

Get total output by industry for a country.

Parameters:

Name Type Description Default
country_name str

Country to get output for

required

Returns:

Type Description
ndarray

np.ndarray: Total output values by industry, converted to sub-annual frequency

get_total_output_series(country_name: str) -> pd.Series

Get total output by industry as a pandas Series.

Parameters:

Name Type Description Default
country_name str

Country to get output for

required

Returns:

Type Description
Series

pd.Series: Total output values by industry, converted to sub-annual frequency

get_output_shares_dict(country_name: str) -> dict[str, pd.Series]

Calculate output shares for aggregated industry sectors.

Computes the proportion of output each sub-sector contributes to its aggregated sector total.

Parameters:

Name Type Description Default
country_name str

Country to analyze

required

Returns:

Type Description
dict[str, Series]

dict[str, pd.Series]: Mapping of aggregate sectors to sub-sector shares

get_consumption_shares_series(country_name: str) -> pd.Series

Calculate consumption shares for each industry.

Computes the proportion of total consumption each industry represents within its aggregate sector.

Parameters:

Name Type Description Default
country_name str

Country to analyze

required

Returns:

Type Description
Series

pd.Series: Industry-level consumption shares

get_intermediate_inputs_use(country_name: str) -> np.ndarray

Get intermediate inputs used by each industry.

Computes the total intermediate inputs used by each industry in the country, including both domestic and imported inputs.

Parameters:

Name Type Description Default
country_name str

Country to analyze

required

Returns:

Type Description
ndarray

np.ndarray: Matrix of intermediate input usage, converted to sub-annual frequency

get_intermediate_inputs_supply(country_name: str) -> np.ndarray

Get intermediate inputs supplied by each industry.

Computes the total intermediate inputs supplied by each industry in the country to all other industries, both domestic and foreign.

Parameters:

Name Type Description Default
country_name str

Country to analyze

required

Returns:

Type Description
ndarray

np.ndarray: Matrix of intermediate input supply, converted to sub-annual frequency

get_intermediate_inputs_domestic(country_name: str) -> np.ndarray

Get domestic intermediate inputs for each industry.

Computes the intermediate inputs used within the same country, excluding imports.

Parameters:

Name Type Description Default
country_name str

Country to analyze

required

Returns:

Type Description
ndarray

np.ndarray: Matrix of domestic intermediate inputs, converted to sub-annual frequency

get_capital_inputs(country_name: str) -> np.ndarray

Get total capital inputs by industry.

Computes the total fixed capital formation (investment) from all sources for each industry.

Parameters:

Name Type Description Default
country_name str

Country to analyze

required

Returns:

Type Description
ndarray

np.ndarray: Capital input values by industry, converted to sub-annual frequency

get_firm_capital_inputs(country_name: str) -> np.ndarray

Get capital inputs used by firms.

Computes the capital inputs used by firms in each industry, excluding household and government capital formation.

Parameters:

Name Type Description Default
country_name str

Country to analyze

required

Returns:

Type Description
ndarray

np.ndarray: Firm capital inputs by industry, converted to sub-annual frequency

get_household_capital_inputs(country_name: str) -> np.ndarray

Get capital inputs used by households.

Computes household fixed capital formation (e.g., housing investment) by industry.

Parameters:

Name Type Description Default
country_name str

Country to analyze

required

Returns:

Type Description
ndarray

np.ndarray: Household capital inputs by industry, converted to sub-annual frequency

get_gfcf_column(country_name: str) -> np.ndarray

Get Gross Fixed Capital Formation (GFCF) column.

Retrieves the raw GFCF values for each industry before splitting between firms, households, and government.

Parameters:

Name Type Description Default
country_name str

Country to analyze

required

Returns:

Type Description
ndarray

np.ndarray: GFCF values by industry, converted to sub-annual frequency

get_capital_inputs_domestic(country_name: str) -> np.ndarray

Get domestic capital inputs by industry.

Computes fixed capital formation using only domestically produced capital goods.

Parameters:

Name Type Description Default
country_name str

Country to analyze

required

Returns:

Type Description
ndarray

np.ndarray: Domestic capital inputs by industry, converted to sub-annual frequency

get_value_added(country_name: str) -> np.ndarray

Get value added by industry.

Computes the value added (contribution to GDP) for each industry in the specified country.

Parameters:

Name Type Description Default
country_name str

Country to analyze

required

Returns:

Type Description
ndarray

np.ndarray: Value added by industry, converted to sub-annual frequency

get_value_added_series(country_name: str) -> pd.Series

Get value added by industry as a pandas Series.

Computes the value added (contribution to GDP) for each industry, returned as a labeled Series.

Parameters:

Name Type Description Default
country_name str

Country to analyze

required

Returns:

Type Description
Series

pd.Series: Value added by industry, converted to sub-annual frequency

get_taxes_less_subsidies(country_name: str) -> np.ndarray

Get net taxes (taxes less subsidies) by industry.

Computes the net taxes (taxes minus subsidies) for each industry in the specified country.

Parameters:

Name Type Description Default
country_name str

Country to analyze

required

Returns:

Type Description
ndarray

np.ndarray: Net taxes by industry, converted to sub-annual frequency

get_taxes_less_subsidies_rates(country_name: str) -> np.ndarray

Calculate net tax rates by industry.

Computes the ratio of net taxes (taxes minus subsidies) to total output for each industry.

Parameters:

Name Type Description Default
country_name str

Country to analyze

required

Returns:

Type Description
ndarray

np.ndarray: Net tax rates by industry

get_hh_consumption(country_name: str) -> np.ndarray

Get total household consumption by industry.

Computes household consumption from all sources (domestic and imported) for each industry.

Parameters:

Name Type Description Default
country_name str

Country to analyze

required

Returns:

Type Description
ndarray

np.ndarray: Household consumption by industry, converted to sub-annual frequency

get_hh_consumption_series(country_name: str) -> pd.Series

Get household consumption by industry as a pandas Series.

Computes total household consumption (domestic and imported) by industry, returned as a labeled Series.

Parameters:

Name Type Description Default
country_name str

Country to analyze

required

Returns:

Type Description
Series

pd.Series: Household consumption by industry, converted to sub-annual frequency

get_hh_consumption_domestic(country_name: str) -> np.ndarray

Get domestic household consumption by industry.

Computes household consumption of domestically produced goods and services for each industry.

Parameters:

Name Type Description Default
country_name str

Country to analyze

required

Returns:

Type Description
ndarray

np.ndarray: Domestic household consumption by industry, converted to sub-annual frequency

get_hh_consumption_weights(country_name: str) -> np.ndarray

Calculate household consumption weights by industry.

Computes the proportion of total household consumption represented by each industry.

Parameters:

Name Type Description Default
country_name str

Country to analyze

required

Returns:

Type Description
ndarray

np.ndarray: Household consumption weights by industry

get_govt_consumption(country_name: str) -> np.ndarray

Get total government consumption by industry.

Computes government consumption from all sources (domestic and imported) for each industry.

Parameters:

Name Type Description Default
country_name str

Country to analyze

required

Returns:

Type Description
ndarray

np.ndarray: Government consumption by industry, converted to sub-annual frequency

get_govt_consumption_domestic(country_name: str) -> np.ndarray

Get domestic government consumption by industry.

Computes government consumption of domestically produced goods and services for each industry.

Parameters:

Name Type Description Default
country_name str

Country to analyze

required

Returns:

Type Description
ndarray

np.ndarray: Domestic government consumption by industry, converted to sub-annual frequency

govt_consumption_weights(country_name: str) -> np.ndarray

Calculate government consumption weights by industry.

Computes the proportion of total government consumption represented by each industry.

Parameters:

Name Type Description Default
country_name str

Country to analyze

required

Returns:

Type Description
ndarray

np.ndarray: Government consumption weights by industry

get_imports(country_name: str) -> pd.Series

Calculate total imports by industry.

Computes the sum of imports from all other countries (including ROW) for each industry.

Parameters:

Name Type Description Default
country_name str

Country to analyze

required

Returns:

Type Description
Series

pd.Series: Import values by industry, converted to sub-annual frequency

get_exports(country_name: str) -> pd.Series

Calculate total exports by industry.

Computes the sum of exports to all other countries (including ROW) for each industry.

Parameters:

Name Type Description Default
country_name str

Country to analyze

required

Returns:

Type Description
Series

pd.Series: Export values by industry, converted to sub-annual frequency

get_trade(start_country: str, end_country: str) -> pd.Series

Calculate bilateral trade flows between two countries.

Computes the trade flow from the start country to the end country for each industry.

Parameters:

Name Type Description Default
start_country str

Exporting country

required
end_country str

Importing country

required

Returns:

Type Description
Series

pd.Series: Trade values by industry, converted to sub-annual frequency

get_origin_trade_proportions() -> pd.DataFrame

Calculate trade proportions from origin country perspective.

Computes the fraction of each industry's imports that comes from each source country, including domestic production.

Returns:

Type Description
DataFrame

pd.DataFrame: Multi-indexed DataFrame with trade proportions Index levels: [start_country, end_country, industry]

get_destination_trade_proportions() -> pd.DataFrame

Calculate trade proportions from destination country perspective.

Computes the fraction of each industry's exports that goes to each destination country, including domestic consumption.

Returns:

Type Description
DataFrame

pd.DataFrame: Multi-indexed DataFrame with trade proportions Index levels: [start_country, end_country, industry]

get_intermediate_inputs_matrix(country_name: str) -> pd.DataFrame

Calculate the intermediate inputs coefficient matrix.

Computes the technical coefficients matrix showing the amount of intermediate inputs required per unit of output for each industry.

Parameters:

Name Type Description Default
country_name str

Country to analyze

required

Returns:

Type Description
DataFrame

pd.DataFrame: Matrix of input-output coefficients

get_capital_inputs_matrix(country_name: str, capital_stock: np.ndarray) -> pd.DataFrame

Calculate the capital inputs coefficient matrix.

Computes the matrix showing how capital from each industry is used in the production processes of other industries, normalized by capital stock.

Parameters:

Name Type Description Default
country_name str

Country to analyze

required
capital_stock ndarray

Current capital stock by industry

required

Returns:

Type Description
DataFrame

pd.DataFrame: Matrix of capital input coefficients

get_capital_inputs_depreciation(country_name: str, capital_compensation: np.ndarray) -> pd.DataFrame

Calculate the capital depreciation matrix.

Computes the matrix of depreciation rates for capital used in each industry, normalized by total output and adjusted for capital compensation.

Parameters:

Name Type Description Default
country_name str

Country to analyze

required
capital_compensation ndarray

Capital compensation by industry

required

Returns:

Type Description
DataFrame

pd.DataFrame: Matrix of capital depreciation rates, converted to sub-annual frequency

get_updated_dictionary() -> dict

Get updated industry aggregation dictionary.

Returns a mapping of aggregate sectors to their constituent sub-sectors based on the current industry list.

Returns:

Name Type Description
dict dict

Mapping of aggregate sectors to lists of sub-sectors

get_inverse_updated_dictionary() -> dict

Get inverse industry aggregation dictionary.

Returns a mapping of sub-sectors to their parent aggregate sectors, inverting the standard aggregation hierarchy.

Returns:

Name Type Description
dict dict

Mapping of sub-sectors to their aggregate sectors