# data
intermediate_transactions <- matrix(c(1, 2, 3, 4, 5, 6, 7, 8, 9), 3, 3)
total_production <- matrix(c(100, 200, 300), 1, 3)
exports <- matrix(c(10, 20, 30), 3, 1)
households <- matrix(as.numeric(4:6), 3, 1)
imports <- matrix(c(5, 10, 15), 1, 3)
jobs <- matrix(c(10, 12, 15), 1, 3)
taxes <- matrix(c(2, 5, 10), 1, 3)
wages <- matrix(c(11, 12, 13), 1, 3)
# a new iom instance can be created by passing just intermediate transactions and total production
my_iom <- iom$new(
"example_1",
intermediate_transactions,
total_production
)
# or by passing optional arguments
my_iom <- iom$new(
"example_2",
intermediate_transactions,
total_production,
household_consumption = households,
exports = exports,
imports = imports,
taxes = taxes,
wages = wages,
occupation = jobs
)
## ------------------------------------------------
## Method `iom$add`
## ------------------------------------------------
# data
intermediate_transactions <- matrix(c(1, 2, 3, 4, 5, 6, 7, 8, 9), 3, 3)
total_production <- matrix(c(100, 200, 300), 1, 3)
# instantiate iom object
my_iom <- iom$new("mock", intermediate_transactions, total_production)
# Create a dummy matrix
exports_data <- matrix(as.numeric(1:3), 3, 1)
# Add the matrix
my_iom$add("exports", exports_data)
## ------------------------------------------------
## Method `iom$remove`
## ------------------------------------------------
# data
intermediate_transactions <- matrix(c(1, 2, 3, 4, 5, 6, 7, 8, 9), 3, 3)
total_production <- matrix(c(100, 200, 300), 1, 3)
exports_data <- matrix(as.numeric(1:3), 3, 1)
# instantiate iom object
my_iom <- iom$new("mock", intermediate_transactions, total_production, exports = exports_data)
# Remove the matrix
my_iom$remove("exports")
## ------------------------------------------------
## Method `iom$update_final_demand_matrix`
## ------------------------------------------------
# data
intermediate_transactions <- matrix(c(1, 2, 3, 4, 5, 6, 7, 8, 9), 3, 3)
total_production <- matrix(c(100, 200, 300), 1, 3)
exports_data <- matrix(c(10, 20, 30), 3, 1)
households <- matrix(as.numeric(4:6), 3, 1)
# instantiate iom object
my_iom <- iom$new(
"mock",
intermediate_transactions,
total_production,
exports = exports_data,
household_consumption = households
)
# aggregate all final demand vectors
my_iom$update_final_demand_matrix()
# check final demand matrix
my_iom$final_demand_matrix
## ------------------------------------------------
## Method `iom$update_value_added_matrix`
## ------------------------------------------------
# data
intermediate_transactions <- matrix(c(1, 2, 3, 4, 5, 6, 7, 8, 9), 3, 3)
total_production <- matrix(c(100, 200, 300), 1, 3)
imports_data <- matrix(c(5, 10, 15), 1, 3)
taxes_data <- matrix(c(2, 5, 10), 1, 3)
# instantiate iom object
my_iom <- iom$new(
"mock",
intermediate_transactions,
total_production,
imports = imports_data,
taxes = taxes_data
)
# aggregate all value-added vectors
my_iom$update_value_added_matrix()
# check value-added matrix
my_iom$value_added_matrix
## ------------------------------------------------
## Method `iom$compute_tech_coeff`
## ------------------------------------------------
intermediate_transactions <- matrix(c(1, 2, 3, 4, 5, 6, 7, 8, 9), 3, 3)
total_production <- matrix(c(100, 200, 300), 1, 3)
# instantiate iom object
my_iom <- iom$new("test", intermediate_transactions, total_production)
# Calculate the technical coefficients
my_iom$compute_tech_coeff()
# show the technical coefficients
my_iom$technical_coefficients_matrix
## ------------------------------------------------
## Method `iom$compute_leontief_inverse`
## ------------------------------------------------
intermediate_transactions <- matrix(c(1, 2, 3, 4, 5, 6, 7, 8, 9), 3, 3)
total_production <- matrix(c(100, 200, 300), 1, 3)
# instantiate iom object
my_iom <- fio::iom$new("test", intermediate_transactions, total_production)
# calculate the technical coefficients
my_iom$compute_tech_coeff()
# calculate the Leontief inverse
my_iom$compute_leontief_inverse()
# show the Leontief inverse
my_iom$leontief_inverse_matrix
## ------------------------------------------------
## Method `iom$compute_multiplier_output`
## ------------------------------------------------
# data
intermediate_transactions <- matrix(c(1, 2, 3, 4, 5, 6, 7, 8, 9), 3, 3)
total_production <- matrix(c(100, 200, 300), 1, 3)
# instantiate iom object
my_iom <- fio::iom$new("test", intermediate_transactions, total_production)
# calculate the technical coefficients
my_iom$compute_tech_coeff()
# calculate the Leontief inverse
my_iom$compute_leontief_inverse()
# calculate the output multiplier
my_iom$compute_multiplier_output()
# show the output multiplier
my_iom$multiplier_output
## ------------------------------------------------
## Method `iom$compute_multiplier_employment`
## ------------------------------------------------
# data
intermediate_transactions <- matrix(c(1, 2, 3, 4, 5, 6, 7, 8, 9), 3, 3)
total_production <- matrix(c(100, 200, 300), 1, 3)
jobs_data <- matrix(c(10, 12, 15), 1, 3)
# instantiate iom object
my_iom <- fio::iom$new("test", intermediate_transactions, total_production, occupation = jobs_data)
# calculate the technical coefficients
my_iom$compute_tech_coeff()
# calculate the Leontief inverse
my_iom$compute_leontief_inverse()
# calculate the employment multiplier
my_iom$compute_multiplier_employment()
# show the employment multiplier
my_iom$multiplier_employment
## ------------------------------------------------
## Method `iom$compute_multiplier_wages`
## ------------------------------------------------
# data
intermediate_transactions <- matrix(c(1, 2, 3, 4, 5, 6, 7, 8, 9), 3, 3)
total_production <- matrix(c(100, 200, 300), 1, 3)
wages_data <- matrix(c(10, 12, 15), 1, 3)
# instantiate iom object
my_iom <- fio::iom$new("test", intermediate_transactions, total_production, wages = wages_data)
# calculate the technical coefficients
my_iom$compute_tech_coeff()
# calculate the Leontief inverse
my_iom$compute_leontief_inverse()
# calculate the wages multiplier
my_iom$compute_multiplier_wages()
# show the wages multiplier
my_iom$multiplier_wages
## ------------------------------------------------
## Method `iom$compute_multiplier_taxes`
## ------------------------------------------------
# data
intermediate_transactions <- matrix(c(1, 2, 3, 4, 5, 6, 7, 8, 9), 3, 3)
total_production <- matrix(c(100, 200, 300), 1, 3)
tax_data <- matrix(c(10, 12, 15), 1, 3)
# instantiate iom object
my_iom <- fio::iom$new("test", intermediate_transactions, total_production, taxes = tax_data)
# calculate the technical coefficients
my_iom$compute_tech_coeff()
# calculate the Leontief inverse
my_iom$compute_leontief_inverse()
# calculate the tax multiplier
my_iom$compute_multiplier_taxes()
# show the taxes multiplier
my_iom$multiplier_taxes
## ------------------------------------------------
## Method `iom$compute_field_influence`
## ------------------------------------------------
# data
intermediate_transactions <- matrix(c(1, 2, 3, 4, 5, 6, 7, 8, 9), 3, 3)
total_production <- matrix(c(100, 200, 300), 1, 3)
# instantiate iom object
my_iom <- fio::iom$new("test", intermediate_transactions, total_production)
# calculate the technical coefficients
my_iom$compute_tech_coeff()
# calculate the Leontief inverse
my_iom$compute_leontief_inverse()
# calculate field of influence
my_iom$compute_field_influence(epsilon = 0.01)
# show the field of influence
my_iom$field_influence
## ------------------------------------------------
## Method `iom$compute_key_sectors`
## ------------------------------------------------
# data
intermediate_transactions <- matrix(c(1, 2, 3, 4, 5, 6, 7, 8, 9), 3, 3)
total_production <- matrix(c(100, 200, 300), 1, 3)
# instantiate iom object
my_iom <- fio::iom$new("test", intermediate_transactions, total_production)
# calculate the technical coefficients
my_iom$compute_tech_coeff()
# calculate the Leontief inverse
my_iom$compute_leontief_inverse()
# calculate key sectors
my_iom$compute_key_sectors()
# show the key sectors
my_iom$key_sectors
## ------------------------------------------------
## Method `iom$compute_allocation_coeff`
## ------------------------------------------------
intermediate_transactions <- matrix(c(1, 2, 3, 4, 5, 6, 7, 8, 9), 3, 3)
total_production <- matrix(c(100, 200, 300), 1, 3)
# instantiate iom object
my_iom <- fio::iom$new("test", intermediate_transactions, total_production)
# Calculate the allocation coefficients
my_iom$compute_allocation_coeff()
# show the allocation coefficients
my_iom$allocation_coefficients_matrix
## ------------------------------------------------
## Method `iom$compute_ghosh_inverse`
## ------------------------------------------------
intermediate_transactions <- matrix(c(1, 2, 3, 4, 5, 6, 7, 8, 9), 3, 3)
total_production <- matrix(c(100, 200, 300), 1, 3)
# instantiate iom object
my_iom <- fio::iom$new("test", intermediate_transactions, total_production)
# Calculate the allocation coefficients
my_iom$compute_allocation_coeff()
# Calculate the Ghosh inverse
my_iom$compute_ghosh_inverse()
# show the Ghosh inverse
my_iom$ghosh_inverse_matrix
## ------------------------------------------------
## Method `iom$compute_hypothetical_extraction`
## ------------------------------------------------
# data
intermediate_transactions <- matrix(c(1, 2, 3, 4, 5, 6, 7, 8, 9), 3, 3)
total_production <- matrix(c(100, 200, 300), 1, 3)
exports_data <- matrix(c(5, 10, 15), 3, 1)
holsehold_consumption_data <- matrix(c(20, 25, 30), 3, 1)
operating_income_data <- matrix(c(2, 5, 10), 1, 3)
taxes_data <- matrix(c(1, 2, 3), 1, 3)
# instantiate iom object
my_iom <- fio::iom$new(
"test",
intermediate_transactions,
total_production,
exports = exports_data,
household_consumption = holsehold_consumption_data,
operating_income = operating_income_data,
taxes = taxes_data
)
# update value-added matrix
my_iom$update_value_added_matrix()
# update final demand matrix
my_iom$update_final_demand_matrix()
# calculate the technical coefficients
my_iom$compute_tech_coeff()
# calculate the Leontief inverse
my_iom$compute_leontief_inverse()
# calculate allocation coefficients
my_iom$compute_allocation_coeff()
# calculate Ghosh inverse
my_iom$compute_ghosh_inverse()
# calculate hypothetical extraction
my_iom$compute_hypothetical_extraction()
# show results
my_iom$hypothetical_extraction
## ------------------------------------------------
## Method `iom$set_max_threads`
## ------------------------------------------------
if (FALSE) {
intermediate_transactions <- matrix(c(1, 2, 3, 4, 5, 6, 7, 8, 9), 3, 3)
total_production <- matrix(c(100, 200, 300), 1, 3)
# instantiate iom object
my_iom <- fio::iom$new("test", intermediate_transactions, total_production)
# to run single threaded (sequential)
my_iom$set_max_threads(1L)
}
Run the code above in your browser using DataLab