Code
file.copy("configuration/config_input_MODEL.R",
"configuration/config_input_MYSIMULATION.R")Simulations are specified through two files:
config_input: to specify the parameters of the simulationconfig_output: to specify output templates to produce to analyse the simulation resutls (see this page)config_input_MODEL.R fileconfig_input fileTo 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.
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 questionclassification: 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 filesmodel_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 onlyscenario_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_calibscenario: 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.:baseyear: Input the base year used for the calibration datalastyear: Last year of the simulationsshockyear: year of the shock. This is an optional parameter that can be called upon when calibrating shocksmax_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.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
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
)
## 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
)The final part of the the configuration input file concerns solver options. Please note that these rarely need adjustment.
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)
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