Simulation Input Configuration

How to configure a simulation?

Simulations are specified through two files:

  • config_input: to specify the parameters of the simulation
  • config_output: to specify output templates to produce to analyse the simulation resutls (see this page)

the config_input_MODEL.R file

Create your own config_input file

To configure the simulation, use the config_input_MODEL.R found in the configuration folder.

config_input_MODEL.R is meant to be a template, so it is advised to make a copy for your own usage.

Code
file.copy("configuration/config_input_MODEL.R",
          "configuration/config_input_MYSIMULATION.R")

Structure of the file

Basic parameters

The first section of the config_input file contains the basic parameters that need to be adapted for each simulation :

  • iso3: the country code, useful if using a ThreeME model, make sure ta version of ThreeME exists for the country in question
  • classification: if using a ThreeME model number of commodities and sectors with the following format cx_sy where x is the number of commodities and x the number of sectors. Check that the desired classification exists in the mdl files
  • model_folder: the folder where to find the mdl files (either training or threeme usually)
  • project_name: name to give your project, must be alphanumeric and underscore characters only. No accents. lowercase only
  • scenario_baseline : Name of the baseline scenario. By default it is “baseline-steady”. It may be modified if the baseline needs to integrate some user-specified trajectories of exogenous variables. All scenarii files are located in configuration/scenarii_calib
  • scenario: Name of scenario(s) to run. Make sure a file 2_calib_shock_NAMEOFSCENARIO exists in the configuration/scenarii_calib folders. Scenario naes must be alphanumeric and underscores in lowercase only. See this page for more info on scenario calibration. The scenario parameter can be a named vector in order to give more information about the scenario that can be reused in results outputs, e.g.:
Code
  scenario = c("ct1", "expg1") |> 
  set_names(c("Increase of carbon tax  ","Increase in government spending of 1% of GDP"))
  • baseyear: Input the base year used for the calibration data
  • lastyear: Last year of the simulations
  • shockyear: year of the shock. This is an optional parameter that can be called upon when calibrating shocks
  • max_lags: maximum lags used in the model, to know how far back the database must go in order for the solver to evaluate all model equations.
  • firstyear: By default this is baseyear - max_lags (rarely needs to be modified)
  • automated_shocks: Set to TRUE if you want to use automated shocks, that will read one unique shock scenario file that can run different calibrations according to the scenario name (needs further documentation)
  • variables_to_keep: Vector of variables to keep in the output. Input an empty vector (c()) in order to keep all variables.

Model file lists

The second sections contains mdl file lists. In three parts, there is: - list_files : basic files (maily for ThreeME, does not need to be modified) - calib_files: mdl files that contain data calibration equations - model_files: mdl files that contain the models equations.

mdl files are usually organised by blocs. For ThreeME some are required to function but other can be activated or switched out with alternate versions to test out different model structures. Usually, an mdl file that starts with Exception is a model block that will be specific to a shock or scenario that requires additional equations to function. ENDOFLINE.mdl is an empty mdl that must be inserted last in the vector.

Below are two examples, one for a simple training model and one for a ThreeME model

Code
lists_files <- c(
  "lists.mdl" 
)

## Calibration files
calib_files <- c(lists_files,
                 "03.1-calib.mdl",     # Close economy
                 "03.2-calib.mdl",     # Open economy
                 
                 "ENDOFLINE.mdl"       # ALL VERSIONS: empty file
                 
)

# Model files 
model_files = c(lists_files,
                
                "03.1-eq.mdl",         # Close economy 
                "03.2-eq.mdl",         # Close economy
                
                "ENDOFLINE.mdl"        # ALL VERSIONS: empty file
                
)

 

Code
## Lists files (warning: if more than one, place "lists.mdl" last)
lists_files = c(
    str_c("R_lists_", iso3,"_",classification, ".mdl"),             # ALL VERSIONS
    "lists.mdl"                                                     # ALL VERSIONS
  )

## Calibration files (used to initialize variables)
calib_files = c(lists_files,
  str_c("data/R_Calibration_", iso3,"_",classification,"_",baseyear, ".mdl"),   # ALL VERSIONS
  "data/parameters.mdl",                     # ALL VERSIONS
     
  ## Calibration of elasticity of substitutions (Producer)
  "data/elasticities.mdl",                   # ALL VERSIONS
  "data/Exception_NestedCES_data.mdl",     # NESTED CES (PRODUCER) VERSION
  "data/round0.mdl",                         # ALL VERSIONS
  "data/Prices_data.mdl",                    # ALL VERSIONS
  "data/SU_data.mdl",                        # ALL VERSIONS
  "data/Special_data.mdl",                   # ALL VERSIONS
  "data/Other_data.mdl",                     # ALL VERSIONS
  "data/Exception_taxes_prices_data.mdl",    # ALL VERSIONS (when commodity tax rate per user)
  
  ## Optional Consumer blocks
  # "data/Exception_ConsumerNested_data.mdl",  # NESTED CES (CONSUMER) VERSION

  "data/Exception_Other_data.mdl",           # ALL VERSIONS
  # "data/Exception_energybalance_simple.mdl",  # ALL VERSIONS: Only net energy production (Y_TOE). Gross primary energy 
  
  "ENDOFLINE.mdl"                          # ALL VERSIONS
)

# Model files 
model_files = c(lists_files,
  "SU.mdl",                     # ALL VERSIONS 
  "Prices.mdl",                 # ALL VERSIONS
  "Producer.mdl",               # ALL VERSIONS
  "Consumer.mdl",               # ALL VERSIONS
  "Government.mdl",             # ALL VERSIONS
  "Trade_inter.mdl",            # ALL VERSIONS
  "Demography.mdl",             # ALL VERSIONS
  "Adjustments.mdl",            # ALL VERSIONS
  "Verif.mdl",                  # ALL VERSIONS
  "ghg_emissions.mdl",          # ALL VERSIONS
  
  # Option energy balance blocks
  "energybalance.mdl",          # ALL VERSIONS

  ## Exception files ALWAYS at the end because of the @overs
  # "Exception_taxes_prices.mdl",           # ALL VERSIONS
  "Exception_taxes_prices_new.mdl",           # New version where taxes are divided by different users
  # "Exception_NestedCES.mdl",            # NESTED CES (PRODUCER) VERSION
  # "Exception_ConsumerNested.mdl",       # NESTED CES (CONSUMER) VERSION

  "Exception_Other.mdl",                   # ALL VERSIONS
  
  
  "ENDOFLINE.mdl"                          # ALL VERSIONS
)

Solver options

The final part of the the configuration input file concerns solver options. Please note that these rarely need adjustment.

Common to all solvers

  • Rsolver: If TRUE, will try to Use R solver if possible; If FALSE EViews will be used

  • warning: If TRUE, will provide solver warning messages.

  • tolerance_calib_check: Tolerance threshold

  • skip_compiler: Set to TRUE to skip the compiler part. However, you’ll need to ensure to have the correct model.prg and calib.csv files in the src/compiler folder

  • recompile_model:If FALSE, the model will be sourced from its last saved version. In the case of multiple scenarii, the model is never recompiled between shocks

  • output_saved: either put c() to produce only the disaggegated base or use part (or all) of c("com","sec","sec_com") to save all three types of reaggregated database.

  • path_eviews_exe: Set manually the location of the EViews.exe

  • eviews_timeout: Define the maximum number of second R waits for the E-views simulation # (0 = no time out)

R solver options

  • rcpp_option: Use an Rcpp based solver (faster in resolution but requires installation of the correct librairies)
  • use.superlu: If the C library superlu is installed, switch to TRUE, otherwise FALSE
    • Specify if there is special configuration necessary to use superlu ie
Code
if(use.superlu == TRUE){ 
  Sys.setenv("CPATH"="/opt/homebrew/include")
  Sys.setenv("LIBRARY_PATH"="/opt/homebrew/lib")
  Sys.setenv("PKG_LIBS"="-lsuperlu")
}