Dynare estimation in different sub-samples

Hello,

I have a dynare mod file where I solve, estimate, and simulate a model. The thing is that I want to do some robustness exercises. For this, I want to estimate the model for the whole sample, half of the sample, and the last half. The idea is to see how different the model implies the shocks. How could I do this? Attached I have my mod file. I create an object called time_cut_index which determines how the sub-sample is formed.

Thanks in advance!
REmodel.mod (18.3 KB)
ven_calibration.mat (1.8 KB)
arg_calibration.mat (1.8 KB)
ven_bayesian_estimation_data.csv (6.8 KB)
arg_bayesian_estimation_data.csv (11.8 KB)

You should simply set first_obs and nobs accordingly. That can be done with a macro.

Dear jpfeifer,

Thanks for your answer. Let me add some info regarding my question. I am running this model for two countries, so I have created two files: ven_calibration.mat and arg_calibration.mat. In each file, I have included a date indicating when a structural change was detected, what should I do to run a Bayesian analysis for the whole sample, the sample previous to the structural break, and after?

I have wrote this code:

% Get the time cut date
time_cut = dates(calib.date_cut);
initial_date = dataset_.dates(1);
time_cut_index = find(dataset_.dates == time_cut);

Estimation for the whole sample

@#if VENEZUELA == 1
    estimation(order=1, 
               mode_compute=6,  
               datafile='DATA\ven_bayesian_estimation_data.csv', 
               mh_replic=20000, 
               mh_nblocks=5, 
               mh_jscale=0.5, 
               bayesian_irf, 
               irf=20, 
               conf_sig=0.95, 
               mh_drop=0.25,
               consider_all_endogenous);
    calib_smoother(datafile='DATA\ven_bayesian_estimation_data.csv');
@#endif

@#if ARGENTINA == 1
    estimation(order=1, 
               mode_compute=6,  
               datafile='DATA\arg_bayesian_estimation_data.csv', 
               mh_replic=20000, mh_nblocks=5, 
               mh_jscale=0.5, 
               bayesian_irf,
               irf=20, 
               conf_sig=0.95, 
               mh_drop=0.25,
               consider_all_endogenous);
    calib_smoother(datafile='DATA\arg_bayesian_estimation_data.csv');
@#endif

Estimation for the sub-sample previous to the structural break

% Bayesian Estimation For the calm period

@#if VENEZUELA == 1
    estimation(order=1, 
               mode_compute=6,  
               datafile='DATA\ven_bayesian_estimation_data.csv', 
               mh_replic=20000, 
               mh_nblocks=5, 
               mh_jscale=0.5, 
               bayesian_irf, 
               irf=20, 
               conf_sig=0.95, 
               mh_drop=0.25,
               nobs= time_cut_index,
               consider_all_endogenous);
@#endif

@#if ARGENTINA == 1
    estimation(order=1, 
               mode_compute=6,  
               datafile='DATA\arg_bayesian_estimation_data.csv', 
               mh_replic=20000, 
               mh_nblocks=5, 
               mh_jscale=0.5, 
               bayesian_irf,
               irf=20, 
               conf_sig=0.95, 
               mh_drop=0.25,
               nobs= time_cut_index,
               consider_all_endogenous);
@#endif

Estimation for the sub-sample after the structural break:

@#if VENEZUELA == 1
    estimation(order=1, 
               mode_compute=6,  
               datafile='DATA\ven_bayesian_estimation_data.csv', 
               mh_replic=20000, 
               mh_nblocks=5, 
               mh_jscale=0.5, 
               bayesian_irf, 
               irf=20, 
               conf_sig=0.95, 
               mh_drop=0.25,
               first_obs= time_cut_index,
               consider_all_endogenous);
@#endif

@#if ARGENTINA == 1
    estimation(order=1, 
               mode_compute=6,  
               datafile='DATA\arg_bayesian_estimation_data.csv', 
               mh_replic=20000, mh_nblocks=5, 
               mh_jscale=0.5, 
               bayesian_irf,
               irf=20, 
               conf_sig=0.95, 
               mh_drop=0.25,
               first_obs= time_cut_index,
               consider_all_endogenous);
@#endif

Look That I have using the time_cut_index (which tells me the position where the break happens In the times series) in the first sub-sample as the number of obs to use and in the second sub-sample as the first observation to use. The problem is that I am having problems running the mod file. I have tried defining tiime_cut_index in the macro like:

@# define time_cut_index = find(dataset_.dates == time_cut);

and then adding it like:

 first_obs=  @{time_cut_index}
nobs=  @{time_cut_index}

But I have not succeed. Hope you can help me.

The problem is that all preprocessor commands must be known at runtime of the preprocessor. You should simply hardcode the number of observations in the country calibration, potentially as a vector and loop over them.