Functions

GlobalTradeAnalysisProjectModelV7.aggregate_dataMethod
    aggregate_data(; hData, hParameters, hSets, comMap, regMap, endMap)

Aggregates data, parameters and sets based on the provided mapping vectors.

Args:

  • hData: a dictionary of GTAP data (arrays) with the names as found in HAR files
  • hParameters: a dictionary of GTAP parameters (arrays) with the names as found in HAR files
  • hSets: a dictionary of GTAP sets (vectors of strings) with the names as found in HAR files
  • comMap: a mapping vector (NamedVector) which provides for each element in set comm the desired aggregate name
  • regMap: a mapping vector (NamedVector) which provides for each element in set reg the desired aggregate name
  • endMap: a mapping vector (NamedVector) which provides for each element in set endw the desired aggregate name

Retruns:

A named tuple with elements hData, hParameters, hSets containing the aggregated data

Example:

julia (; hData, hParameters, hSets) = aggregate_data(hData=data, hParameters=parameters, hSets=sets, comMap=comMap, regMap=regMap, endMap=endMap)

source
GlobalTradeAnalysisProjectModelV7.aggregate_data_legacyMethod
    aggregate_data_legacy(; hData, hParameters, hSets, comMap, regMap, endMap)

Aggregates data, parameters and sets based on the provided mapping vectors while incorporating an error in aggregation found in GTAPAgg2 or FlexAgg, where three parameters (i.e., ESUBM, ESUBD and ESUBV) are aggregated globally even though they are defined as region-specific

Args:

  • hData: a dictionary of GTAP data (arrays) with the names as found in HAR files
  • hParameters: a dictionary of GTAP parameters (arrays) with the names as found in HAR files
  • hSets: a dictionary of GTAP sets (vectors of strings) with the names as found in HAR files
  • comMap: a mapping vector (NamedVector) which provides for each element in set comm the desired aggregate name
  • regMap: a mapping vector (NamedVector) which provides for each element in set reg the desired aggregate name
  • endMap: a mapping vector (NamedVector) which provides for each element in set endw the desired aggregate name

Retruns:

A named tuple with elements hData, hParameters, hSets containing the aggregated data

Example:

julia (; hData, hParameters, hSets) = aggregate_data_legacy(hData=data, hParameters=parameters, hSets=sets, comMap=comMap, regMap=regMap, endMap=endMap)

source
GlobalTradeAnalysisProjectModelV7.build_model!Method
build_model!(mc; max_iter=50, constr_viol_tol=1e-8, bound_push=1e-15)

Builds the GTAP model in the provided model container (mc) which has an empty Ipopt model. This function is not typically called by the user; instead, it is invoked by generate_initial_model(). However, if the user wishes to change the model, he or she can extend this function.

Args:

  • mc: a model container

Optional args:

  • max_iter: maximum number of iterations
  • constr_viol_tol: accuracy for constraint satisfaction
  • bound_push: mandatory move of the starting values from constraint bounds

Retruns:

Nothing but it modifies the mc object, adding on the existing model element

Example:

julia build_model!(mc)

source
GlobalTradeAnalysisProjectModelV7.calculate_expenditureMethod
    calculate_expenditure(; sets, data0, data1, parameters, max_iter=50, constr_viol_tol=1e-5, bound_push=1e-15)

Calculate the expenditure at post simulation utility (in data1) at original prices (data0)

Args:

  • sets: a dictionary of sets
  • data0: a dictionary of data from baseline solution
  • data1: a dictionary of data from simulation solution
  • parameters: a dictionary of parameters

Optional args:

  • max_iter: maximum number of iterations
  • constr_viol_tol: accuracy for constraint satisfaction
  • bound_push: mandatory move of the starting values from constraint bounds

Returns:

A vector of expenditures.

source
GlobalTradeAnalysisProjectModelV7.calculate_gdpMethod
calculate_gdp(; sets, data0, data1)

Calculate GDP from post-simulation quantities at pre-simulation prices.

Args:

  • sets: a dictionary of sets
  • data0: a dictionary of data from baseline solution
  • data1: a dictionary of data from simulated solution
source
GlobalTradeAnalysisProjectModelV7.generate_calibration_inputsMethod
generate_calibration_inputs(model_container, start_data)

Produces the required inputs for default calibration. The calibration is focused on the value flows in the GTAP database.

Args:

  • model_container: the model container with the current model
  • start_data: a dictionary with the data representing the desired calibration level

Returns

A named tuple with two elements: fixed_calibration containing the closure, and data_calibration containing the desired calibration data.

source
GlobalTradeAnalysisProjectModelV7.generate_initial_modelMethod
generate_initial_model(; hSets, hData, hParameters)

Produces an initial model container based on data, parameters and sets.

Args:

  • hSet: a dictionary of sets
  • hData: a dictionary of data
  • hParameters: a dictionary of parameters

Returns:

A model container with the following elements:

  • model: an empty Ipopt model
  • data: a dictionary of data (variables in the model)
  • parameters: a dictionary of parameter values
  • sets: a dictionary of sets
  • fixed: a dictionary of Boolean arrays defining the closure of the model (exogenous/fixed variables)
  • lower: a dictionary of lower bounds for model variables
  • upper: a dictionary of upper bounds for model variables

Example:

$julia generate_initial_model(; hSets, hData, hParameters)$

source
GlobalTradeAnalysisProjectModelV7.generate_starting_valuesMethod
generate_starting_values(; hSets, hData, hParameters)

Produces starting values for all required variables in the model. This is typically not called by the user; instead, this is invoked in the process of producing the initial model.

Args:

  • hSets: a dictionary of sets
  • hData: a dictionary of data
  • hParameters: a dictionary of parameters

Returns:

A named tuple with six elements: sets sets, parameters parameters, data data, closure fixed, lower bounds lower, and upper bounds upper

source
GlobalTradeAnalysisProjectModelV7.get_sample_dataMethod
get_sample_data()

Returns a small sample data set from publicly available version 9 of the GTAP database.

Args:

  • None

Retruns:

A named tuple with

  • hData: a dictionary with sample aggregated data
  • hParamters: a dictionary with sample aggregated parameters
  • hSets: a dictionary with sample aggregated sets

Example:

julia (; hData, hParameters, hSets) = get_sample_data()

source
GlobalTradeAnalysisProjectModelV7.rebuild_model!Method
rebuild_model(mc; calibration = false)

Rebuilds the model, typically to create a slimmer model without calibration equations

Args:

  • mc: model container
  • calibration: include calibration equations

Returns:

An updated model container

Example:

$julia rebuild_model!(mc)$

source
GlobalTradeAnalysisProjectModelV7.run_model!Method
run_model!(model_container; max_iter=50, constr_viol_tol=1e-8, bound_push=1e-15)

Runs the model (modelcontainer.model) by executing these steps: (1) set all starting values to those found in the data (modelcontainer.data), (2) fix all variables that are specified as exogenous (modelcontainer.fixed), (3) solve the model, (4) load all variable values to the data (modelcontainer.data)

Args:

  • model_container: model container

Optional args:

  • max_iter: maximum number of iterations
  • constr_viol_tol: accuracy for constraint satisfaction
  • bound_push: mandatory move of the starting values from constraint bounds
source