simulate the impact of shocks to exogenous variables with a model
simul_result=simul_shock(model,db,startdate,enddate,arg1,...,argn)
* model = a model typed list created by the function create_model
* db = a tsmat, containing values for endogenous, exoegnous and residuals variables
* startdate = a string, the starting date of the simulation
* enddate = a string, the end date of the simulation
* arg1,...,argn = arguments that can be:
- the string 'from=xxx' where xxx is the date from which data should be kept (if before the starting date)
- the string 'to=xxx' where xxx is the date to which data should be kept (if after the ending date)
- the string 'lag=xxx' where xxx is the lag applied to the data in the data tsmat to provide starting values the simulation programs (0 if you want to use the current values in the baseline, 1 if you want to use lagged simulated values -default)
- a list with 3 elements: a string vector (maybe of size 1), indicating the variables that are shocked
- a string, indicating, indicating how the variables are shocked ('pcer' for a deviation by a percentage, 'er' for a deviation by a given amount, 'ts' to susbtitue the values taken from a ts to the values in the databse)
- either a real containing the percentage shock (when 2nd arg set to 'pcer'), the deviation (when 2nd arg set to 'er'); a string vector of the same size as the first arg, containing the names of the ts used to replace the values in the database, or a ts (only if the first arg has size one)
- any option to simulate
* simul_result = a results tlist, containing the results of the simulation
global GROCERDIR // load the model small load(GROCERDIR+'\data\small.dat') // load the database small_db load(GROCERDIR+'\data\small_cale.dat') small_cale_db=small_cale('simulation results') // make a 1% shock on the world demand variable (variable demmon) with model small, database small_cale_db // over the period 1981q1 to 2006q4, keeping historical values from 1980q1 to 1980q4 sh_demmon=simul_shock(small,small_cale_db,'1981q1','2006q4',list('demmon','pcer',1),'from=1980q1') // make a 50K shock on the labour supply (variable tc_ls_d1) with model small, database small_cale_db // over the period 1981q1 to 2006q4, keepping historical values from 1980q1 to 1980q4 // extract from database small_cale_db variables td_p51g_d1, td_pib3 and td_p51g_d5: tsmat2ts(small_cale_db,['td_p51g_d1';'td_p51g_d3';'td_pib3';'td_p51g_d5']) // create a dummy with 1 values over the simulation period, 0 before: post80q1=dummy(['1978q1';'2006q4'],['1980q1';'2006q4']); // create the new variable: sh_td_p51g_d1= td_p51g_d1+0.01*td_pib3/td_p51g_d5*post80q1; // make a 1% of GDP shock on public investment (variable td_p51g_d1) sh_p51g=simul_shock(small,small_cale_db,'1981q1','2006q4',... list('td_p51g_d1','ts',sh_td_p51g_d1),'from=1980q1') sh_ls=simul_shock(small,small_cale_db,'1981q1','2006q4',list('tc_ls_d1','er',50),'from=1980q1') | ![]() | ![]() |