Scenarii calibration

1 Introduction

A simulation exercise is generally characterized by the construction of two scenarios. A first so-called reference which will serve as a point of comparison for the so-called alternative scenario which integrates variations in the expression of its parameters and whose interest is to be able to discern their effect on the model. The shock scripts are located in the ThreeME_V3/configurations/scenarii_calib/ folder.

1.1 Calibration files

Calibration happens in the folder configuration/scenarii_calib. Inside you would find two main types of R scripts, the ones that are used to calibrate baselines and those employed to calibrate shocks. You can identify them by their names which starts with “1_calib_baseline” or “2_calib_shock”. After these common name basis, you would find the baseline name or the shock code. The shock code is usually composed by three or four letters that account for the name of the shock. Sometimes there are numbers as well that refer to the magnitud of the shock (for example, ct1 accounts for an increase of the carbon tax by 1 point of GDP)

  • You should always keep the same name structure for the calibration files

1.2 Creating a shock

Shocks are defined in two main different ways:

  • Loading and xlsx or csv file containing the evolution of the variable that we want to shock over the time
  • Coding the shock in R in the same file

In both cases, an R dataframe is created. This data frame contains one column that accounts for the years and as much as columns as variables are shocked.

2 Examples

2.1 Loading an excel sheet

this shock_ch data.frame can also be generated from an excel file which groups the modified parameters.

In the folder data/input/ is located a excel workbook scenarii_inputs_ademe.xlsx constituted of different sheets, each one being dedicated to specific shock. First column Loaded = 1 indicates which exogenous is activated into the shock by filling the corresponding row with a 1. First row indicates which periods are covered by the shock,

The table is then read using the load_excel_calibration() function in order to make the modifications presented in the first step.

# Load an excel sheet containing the evolution of the exogenous variable
shock_ch <- load_excel_calibration(excel_sheet = "data/input/France/scenarii_inputs_ademe.xlsx",
                                       sheet_to_load = "carbontax100",
                                       stop_if_calib_fail = FALSE,
                                       check_tol = 10e-8,
                                       keep_baseyear_calib_data = TRUE)

2.2 Shock coded in R

Calibrating a shock from R allows you to modify the model parameters on which the shock is applied using a script.The first step allows you to select all the parameters and variables necessary for the calibration of this shock in the calib_new_base database.

Calibrating a shock from R allows you to modify the model parameters on which the shock is applied using a script.The first step allows you to select all the parameters and variables necessary for the calibration of this shock in the calib_new_base database.

# Define the series necessary to calibrate the scenario  
series <- c("GDP" ,"EMS_CI_CO2","EMS_MAT_CO2", "EMS_Y_CO2", "EMS_CH_CO2", "rco2tax_vol")   %>% tolower
 
# Load the selected series for the range baseyear:lastyear
selection <- calib_new_base %>% select(year,all_of(series))

The second step consists of selecting then modifying the chosen parameters from a mutate() function and defining a shock_ch data.frame containing the new parameter values modified within the framework of the alternative scenario.

## Change in exogenous variables using formulas

shock_ch <- mutate(selection,
                   ems_taxbasis = ems_ci_co2 + ems_mat_co2 + ems_y_co2+ems_ch_co2,
                   rco2tax_vol = ifelse(year >= shockyear, 
                                        rco2tax_vol + 0.01*gdp[which(year == shockyear)]/ems_taxbasis[which(year==shockyear)], rco2tax_vol)
                            ) %>% select(year, rco2tax_vol) 

shock_ch is then called by the 02_calibrating_baseline_shock.R script as part of the model simulation

NB: It is possible to combine several shocks from different sources using the merge() function

3 Calibration bubble

When coding a shock with R, we should create an environment with the elements that we need to calibrate our shock. This can be done from the Main.R file, starting by uncommenting the following lines:

## 1. OPTIONAL Prepare the baseline and/or shock calibration file , uncomment the lines

## >>>>>>> uncomment start
calibration_bubble <- calibration_environment(baseline_calibration = FALSE)
list2env(calibration_bubble, envir = globalenv())
### You may now open the relevant scenario config file to edit and test it
rm(list = names(calibration_bubble))
## <<<<<<< uncomment end

We should then run the uncommented lines and see the new elements appear in our RStudio Environment. A calibration data base has been created and we can use it for our tests. It is named as calib_new_base. All elements necessary for testing are in the calibration_bubble list. The command line list2env(calibration_bubble, envir = globalenv()) puts all elements of the list in the global environment, including calib_new_base.