vtra.mrio package

Submodules

vtra.mrio.functions module

MRIO utility functions

aggregate_table(vnm_IO, vnm_IO_rowcol, in_million=True)[source]

Aggregate national Input-Output table to the amount of sectors used in the multiregional Input-Output table.

Parameters
  • vnm_IO - pandas dataframe of national Input-Output table
  • vnm_IO_rowcol - pandas dataframe with all sectors in the national Input-Output table
  • in_million - Specify whether we want to divide the table by 1000000, to have values in millions. The default value is set to True
Outputs
  • pandas Dataframe with aggregated national Input-Output table
create_indices(data_path, provinces, write_to_csv=True)[source]

Create list of indices required to disaggregate the national table to the different regions.

Parameters
  • data_path - String name of data path
  • provinces - pandas DataFrame with provincial/regional data
  • write_to_csv - Boolean to specify whether you want to save output to .csv files. The default value is set to True
Outputs
  • set of .csv files with indices proxy data
create_level14_proxies(data_path, od_table, own_production_ratio=0.8, write_to_csv=True)[source]

Function to create the level14 proxies, required to disaggregate the national table.

Parameters
  • data_path - String name of data path
  • od_table - pandas DataFrame with the Origin-Destination matrix
  • own_production_ratio - Specify how much supply and demand is locally supplied and used, and how much is imported/exported. The default is set to 0.8
  • write_to_csv - Boolean to specify whether you want to save output to .csv files. The default value is set to True
Outputs
  • set of .csv files with level 14 proxy data
create_proxies(data_path, notrade=False, own_production_ratio=0.9, min_rice=True)[source]

Create all proxies required in the disaggregation process.

Parameters
  • data_path - String name of data path
  • notrade - Boolean to specify whether we should include trade in the disaggregation. This should be set to True in the first step of the disaggregation. The default is set to False
  • min_rice - Boolean to determine whether you want to use the minimal rice value or the maximum rice value from the flow analysis. The default is set to True
  • own_production_ratio - Specify how much supply and demand is locally supplied and used, and how much is imported/exported. The default is set to 0.8
Outputs
  • all proxy level .csv files.
create_regional_proxy(data_path, regions, write_to_csv=True)[source]

Function to create the proxy to disaggregate the national table to the different regions.

Parameters
  • data_path - String name of data path
  • regions - pandas DataFrame with provincial/regional data
  • write_to_csv - Boolean to specify whether you want to save output to .csv files. The default value is set to True
Outputs
  • set of .csv files with regional proxy data
create_sector_proxies(data_path, regions, write_to_csv=True)[source]

Create sector proxies required to disaggregate the national table to the different sectors in each region.

Parameters
  • data_path - String name of data path
  • regions - pandas DataFrame with provincial/regional data
  • write_to_csv - Boolean to specify whether you want to save output to .csv files. The default value is set to True
Outputs
  • set of .csv files with sector proxy data
create_zero_proxies(data_path, od_table, notrade=False, write_to_csv=True)[source]

Function to create the trade proxies, required to disaggregate the national table.

Parameters
  • data_path - String name of data path
  • od_table - pandas DataFrame with the Origin-Destination matrix
  • notrade - Boolean to specify whether we should include trade in the disaggregation. This should be set to True in the first step of the disaggregation. The default is set to False
  • write_to_csv - Boolean to specify whether you want to save output to .csv files. The default value is set to True
Outputs
  • set of .csv files with level 14 proxy data
estimate_gva(regions, in_million=True)[source]

Functions to estimate the Gross Value Added for each sector in each province.

Parameters
  • regions - pandas DataFrame with provincial/regional data
Outputs
  • list with GVA values per sector in each province
get_final_sector_classification()[source]

Return the list of sectors to be used in the new multiregional Input-Output table.

Outputs:
  • list of sectors
get_trade_value(x, sum_use, sector, own_production_ratio=0.8)[source]

Function to get the trade value between a certain origin and destination.

Parameters
  • x - row in Origin-Destination dataframe
  • sum_use - total use in a certain destination
  • own_production_ratio - Specify how much supply and demand is locally supplied and used, and how much is imported/exported. The default is set to 0.8
Outputs
  • returns trade value
is_balanced(io_table)[source]

Function to check if Input-Output table is balanced.

Parameters
  • io_table - Input-Output table.
Outputs
  • return print statement if table is balanced.
load_od(data_path, min_rice=True)[source]

Load national Origin-Destination matrix as pandas DataFrame.

Parameters
  • data_path - String name of data path
  • min_rice - Boolean to determine whether you want to use the minimal rice value or the maximum rice value from the flow analysis. The default is set to True
Outputs
  • pandas DataFrame with national Origin-Destination matrix
load_output(data_path, provinces, notrade=True)[source]

Read output from disaggregation process and translate to usable pandas DataFrame

Parameters
  • data_path - String name of data path
  • provinces - pandas DataFrame with provincial/regional data
  • notrade - Boolean to specify whether we should include trade in the disaggregation. This should be set to True in the first step of the disaggregation. The default is set to False
Outputs
  • pandas DataFrame with disaggregated Input-Output table
load_provincial_stats(data_path)[source]

Load shapefile with provincial-level data.

Parameters
  • data_path - String name of data path
Outputs
  • geopandas GeoDataFrame with provincial data.
load_sectors(data_path)[source]

Load national Input-Output table and extracted all sectors

Parameters
  • data_path - String name of data path
Outputs
  • pandas Dataframe with all sectors in national Input-Output table
load_table(data_path)[source]

Load national Input-Output table as pandas dataframe.

Parameters
  • file_path - String name of data path
Outputs
  • pandas Dataframe with Input-Output table that is going to be used
map_regions()[source]

Create dictionary to map regions to consistent format.

Outputs
  • dictionary to map regions to consistent format
map_sect_vnm_to_eng()[source]

Convert vietnamese sector names to simple sector classification.

Outputs
  • dictionary to map vietnamese sectors to simple sector names.
map_sectors(vnm_IO_rowcol)[source]

Map the sectors of the loaded national Input-Output table to the sectors which are going to used in the multiregional Input-Output table.

Parameters
  • vnm_IO_rowcol - pandas dataframe with all sectors in the national Input-Output table.
Outputs
  • dictionary to map row sectors
  • dictionary to map column sectors
map_sectors_to_od(od_table)[source]

Create dictionary to map products from national Origin-Destination matrix to sector classification for the Input-Output table.

Parameters
  • od_table - pandas DataFrame with the Origin-Destination matrix
Outputs
  • dictionary to map goods to sectors.

vtra.mrio.ras_method module

RAS Method

Purpose

Estimate a new matrix X with exogenously given row and column totals that is a close as possible to a given original matrix X0 using the Generalized RAS (GRAS) approach

Usage

X = gras(X0, u, v) OR [X, r, s] = gras(X0, u, v) with or without eps included as the fourth argument, where

Input

  • X0 = benchmark (base) matrix, not necessarily square
  • u = column vector of (new) row totals
  • v = column vector of (new) column totals
  • eps = convergence tolerance level; if empty, the default threshold is 0.1e-5 (=0.000001)

Output

  • X = estimated/adjusted/updated matrix
  • r = substitution effects (row multipliers)
  • s = fabrication effects (column multipliers)

References

  1. Junius T. and J. Oosterhaven (2003), The solution of updating or regionalizing a matrix with both positive and negative entries, Economic Systems Research, 15, pp. 87-96.
  2. Lenzen M., R. Wood and B. Gallego (2007), Some comments on the GRAS method, Economic Systems Research, 19, pp. 461-465.
  3. Temurshoev, U., R.E. Miller and M.C. Bouwmeester (2013), A note on the GRAS method, Economic Systems Research, 25, pp. 361-367.
invd(x)[source]

Extract projection, data bands numbers and valuees from raster

Parameters
  • file_path - String name of input GeoTff file path
Outputs
  • counts - Number of bans in raster
  • crs - Projection system of raster
  • data_vals - Numpy array of raster values
ras_method(X0, u, v, eps=1e-05)[source]

Extract projection, data bands numbers and valuees from raster

Parameters
  • file_path - String name of input GeoTff file path
Outputs
  • counts - Number of bans in raster
  • crs - Projection system of raster
  • data_vals - Numpy array of raster values

vtra.mrio.run_mrio module

Run MRIO

main()[source]
mrio_to_excel(Xin, min_rice=True)[source]

Save the newly created multiregional Input-Output table to Excel, in the format required for the MRIA calculation.

Parameters
  • Xin - pandas DataFrame of the new multiregional Input-Output table
  • min_rice - Boolean to determine whether you want to use the minimal rice value or the maximum rice value from the flow analysis. The default is set to True
Outputs
  • .xlsx file with the multiregional Input-Output table
run_mrio_disaggregate(notrade=False, min_rice=True, own_production_ratio=0.8)[source]

This function will disaggregate the (single-region) national Input-Output table to a provincial multiregional Input-Output table

Parameters
  • notrade - Boolean to specify whether we should include trade in the disaggregation. This should be set to True in the first step of the disaggregation. The default is set to False
  • min_rice - Boolean to determine whether you want to use the minimal rice value or the maximum rice value from the flow analysis. The default is set to True
  • own_production_ratio - Specify how much supply and demand is locally supplied and used, and how much is imported/exported. The default is set to 0.8
Outputs
  • .csv file containing the new multiregional Input-Output table.
  • pandas DataFrame with a multiregional Input-Output table