New Estimation Interface

Suggestions for a simplification of the estimation interface in Dynare and breaking very general commands with lots of options in several commands with more targeted scope.

set_time

This command allows to specify an initial date and a frequency for the data used by dynare or the data generated by dynare (this command is noit specific to estimation). There is only one input argument. The frequency is implicit.

Syntax examples

   set_time(1950Q3)

   set_time(1960)

   set_time(1971M5)

Preprocessor generated code

Instantiate an object from the dynDates class. This object, say initial_period, is stored in options_. If the command set_time is absent, default initial period is 1 (with yearly frequency). For the preceeding examples, the preprocessor should write in the main matlab file:

   options_.initial_period = dynDate('1950Q3');

   options_.initial_period = dynDate('1960');

   options_.initial_period = dynDate('1971M5');

the default being

   options_.initial_period = dynDate(1);

dataset

This command initializes the dataset (an object instantiated by dynSeries). The following options are available:

Syntax examples

   data(file=/home/stepan/Works/MZE/data/data.m)

   data(file=/home/stepan/Works/MZE/data/data.mat)

   data(file=/home/stepan/Works/MZE/data/data.xls)

In this case the implicit initial date is given by the set_time command, and all the observations are used. Input argument file is mandatory.

   data(file=/home/stepan/Works/MZE/data/data.xls,first_obs=1950Q1)

In this first example the beggining of the sample is specified by first_obs. By default, all the observations are used after this initial date. The frequency (quaterly, monthly or yearly data) is implicit. If the implicit frequency in the command data is inconsistent with the implicit frequency declared in set_time an error message must be issued by the preprocessor. If the initial date is anterior to the date specified by set_time, an error will be issued by the matlab code (using the dynDates class).

   data(file=/home/stepan/Works/MZE/data/data.xls,first_obs=1950Q1,last_obs=2000Q4)

or

   data(file=/home/stepan/Works/MZE/data/data.xls,first_obs=1950Q1,nobs=204)

In these two examples the last arguments (nobs or last_obs) are used to specify the last observation in the sample. If the implicit frequency is inconsistent with the implicit frequency declared in set_time or if nobs is not strictly positive, an error must be issued by the preprocessor.

Preprocessor generated code

All the options in the data command are saved as fields of options_.dataset. For the previous examples we would have:

   options_.dataset.file = '/home/stepan/Works/MZE/data/data.m';
   options_.dataset.first_obs = dynDate('1950Q1');
   options_.dataset.last_obs = dynDate('2000Q4');
   options_.dataset.nobs = 204;

The default values (written by the preprocessor, not defined in global_initialization) are:

   options_.dataset.first_obs = options_.initial_period;
   options_.dataset.last_obs = NaN;
   options_.dataset.nobs = NaN;
   options_.dataset.xls_sheet = NaN;
   options_.dataset.xls_range = NaN;

estimated_params

Rely on options names rather than argument position in the command line. This new interface would replace estimated_params_bounds and estimated_params_init. The following option names would be necessary

Syntax examples

The following instructions given as examples are to be used within the estimated_params block.

     alpha.prior(shape=beta,mean=0.3,variance=0.1^2);
     beta.prior = alpha.prior;

     alpha.prior(shape=beta,interval=[0.2,0.4,.9]);

with this syntax the prior is such that 90% of the prior mass lies between 0.2 and 0.4.

     beta.prior(shape=gamma,mode=4,variance=10,shift=+2);
     sigma.prior(shape=gamma,mode=-1,variance=5,shift=-2);

In the first case the default domain of the gamma distribution (the set of real positive numbers) is shifted towards infinity in the second case the same distribution is shifted towards minus infinity.

     plouf.prior(shape=uniform,domain=[.5,2]);
     fuolp.prior(shape=beta,mode=1.5,stdev=.05,domain=[1,2]);

The default domain for the beta and uniform distribution is [0,1].

     alpha.options(bounds=[0 2],init=1,jscale=.1);
     beta.options(bounds=[0 1],init=.5,jscale=.3);
     sigma.options(init=.7,jscale=.1);

     alpha.subsamples(name1=1950Q3:1957Q4, name2=1958Q1:1983Q2, name3=1983Q3:2011Q2);
     std(e).subsamples(name1=1950Q3:1957Q4, name2=1958Q1:1983Q2, name3=1983Q3:2011Q2);
     corr(e,u).subsamples(name1=1950Q3:1957Q4, name2=1958Q1:1983Q2, name3=1983Q3:2011Q2);
     beta.subsamples = alpha.subsamples;
     std(u).subsamples = beta.subsamples;

     alpha.name1.prior(shape=normal,mode=0.30,stdev=.01);
     alpha.name2.prior(shape=normal,mode=0.33,stdev=.01);
     alpha.name3.prior(shape=normal,mode=0.40,stdev=.01);
     beta.name1.prior(shape=normal,mode=0.30,stdev=.01);
     beta.name2.prior(shape=normal,mode=0.33,stdev=.01);     
     beta.name3.prior(shape=normal,mode=0.40,stdev=.01);

     alpha.prior(shape=normal, mode=0.30, stdev=.01, regimes=[1,1,ALL]);
     alpha.prior(shape=normal, mode=0.33, stdev=.01, regimes=[1,2,ALL]);
     alpha.prior(shape=normal, mode=0.33, stdev=.01, regimes=[1,3,ALL]);

     std(e).prior(shape=beta,mean=0.3,variance=0.1^2);

e must be declared as an exogenous variable (varexo).

     corr(e,u).prior(shape=beta,mean=0.3,variance=0.1^2);

e and u must be declared as an exogenous variable (varexo).

     std(y).prior(shape=beta,mean=0.3,variance=0.1^2);

y is an endogenous variable and must be declared as an observed variable (varobs).

     corr(y,c).prior(shape=beta,mean=0.3,variance=0.1^2);

y and c are endogenous variables and must be declared as observed variables (varobs).

Preprocessor generated Matlab code

The preprocessor fills a new matlab structure called estimation_info. This structure is organized as follows:

  estimation_info.parameters.deep.nb = 3;
  estimation_info.parameters.list = char('alpha','beta','sigma')
  estimation_info.parameters.structural_innovation.nb = 2;
  estimation_info.parameters.structural_innovation.list = ĉhar('e','u');
  estimation_info.parameters.structural_innovation_corr.nb = 1;
  estimation_info.parameters.structural_innovation_corr.list = char('e___u');
  estimation_info.parameters.measurement_error.nb = 2;
  estimation_info.parameters.measurement_error.list = ĉhar('y','c');
  estimation_info.parameters.measurement_error_corr.nb = 1;
  estimation_info.parameters.measurement_error_corr.list = char('y___c');

If the some parameters are not stable across the whole sample, these parameters are specific to each subsample. For instance if we estimate the model with one structual break on parameter alpha, we would have instead:

  estimation_info.parameters.deep.nb = 5;
  estimation_info.parameters.list = char('alpha$1','alpha$2','alpha$3','beta','sigma');
  estimation_info.parameters.structural_innovation.nb = 2;
  estimation_info.parameters.structural_innovation.list = ĉhar('e','u');
  estimation_info.parameters.structural_innovation_corr.nb = 1;
  estimation_info.parameters.structural_innovation_corr.list = char('e___u');
  estimation_info.parameters.measurement_error.nb = 2;
  estimation_info.parameters.measurement_error.list = ĉhar('y','c');
  estimation_info.parameters.measurement_error_corr.nb = 1;
  estimation_info.parameters.measurement_error_corr.list = char('y___c');

where alpha$1, alpha$2 and alpha$3 correspond to alpha for the first, second and third subsamples.

  estimation_info.init.deep = [1.0; .5; .7 ];
  estimation_info.init.structural_innovation = [.01; .05];
  estimation_info.init.structural_innovation_corr = [.1];
  estimation_info.init.measurement_error = [.01; .07];
  estimation_info.init.measurement_error_corr = [-.1];

or with the structural break on alpha:

  estimation_info.init.deep = [1.0; 1.1; .9; .5; .7 ];
  estimation_info.init.structural_innovation = [.01; .05];
  estimation_info.init.structural_innovation_corr = [.1];
  estimation_info.init.measurement_error = [.01; .07];
  estimation_info.init.measurement_error_corr = [-.1];

If there is no estimated measurement errors in the model (ie estimation_info.parameters.measurement_error.nb=0) the estimation_info.init.measurement_error and estimation_info.init.measurement_error_corr are set to a empty matrices.

  estimation_info.bounds.deep = [0, 2; 0, 1; -Inf, Inf];
  estimation_info.bounds.structural_innovation = [0, .01; 0, Inf];
  estimation_info.bounds.structural_innovation_corr = [-1 1];
  estimation_info.bounds.measurement_error = [0 Inf; 0 Inf];
  estimation_info.bounds.measurement_error_corr = [-1 1];

Default bounds for estimated standard deviations or variance are 0 and Inf. Default bounds for estimated correlations are -1 and 1. Default bounds for estimated deep parameters are -Inf and Inf (meaning no effective bounds for the optimization).

  estimation_info.subsample.deep.alpha = [ '1950:Q3', '1957:Q4'; '1958Q1', '1983:Q2'; '1983Q3', '2011Q2'];

If there is no unexpected break on the estimated deep parameters then estimation_info.subsample.deep is an empty matrix.

   estimation_info.prior.shape.X
   estimation_info.prior.mean.X
   estimation_info.prior.stdev.X
   estimation_info.prior.variance.X
   estimation_info.prior.mode.X
   estimation_info.prior.interval.X
   estimation_info.prior.shift.X
   estimation_info.prior.domain.X
   estimation_info.prior.jscale.X

To provide the structures above, the preprocessor will first generate code in the form:

   estimation_info.parameter(i).prior.name = alpha;
   estimation_info.parameter(i).prior.shape = 2;
   estimation_info.parameter(i).prior.mean = 3;
   ...
   estimation_info.structural_innovation(i).prior.name = e;
   estimation_info.structural_innovation(i).prior.shape = 2;
   estimation_info.structural_innovation(i).prior.mean = 0.3;
   ...
   estimation_info.measurement_error(i).prior.name = y;
   estimation_info.measurement_error(i).prior.shape = 2;
   estimation_info.measurement_error(i).prior.mean = 0.3;
   ...
   estimation_info.structural_innovation_corr(i).prior.name1 = e;
   estimation_info.structural_innovation_corr(i).prior.name2 = u;
   estimation_info.structural_innovation_corr(i).prior.shape = 2;
   estimation_info.structural_innovation_corr(i).prior.mean = 0.3;
   ...
   estimation_info.measurement_error_corr(i).prior.name1 = y;
   estimation_info.measurement_error_corr(i).prior.name2 = c;
   estimation_info.measurement_error_corr(i).prior.shape = 2;
   estimation_info.measurement_error_corr(i).prior.mean = 0.3;

This format is easier for the user to understand if she would like to modify the <modfilename>.m file or programmatically create her own process for interacting with the Dynare Matlab code. Further, self-contained structures are better organized than the parallel arrays mentioned above. A routine will be created to transform this input into the aforementioned parallel array format, which is easier to use in the backend.

Preprocessor generated C code for MS-DSGE

As C++ output needs to be produced for the MS-DSGE code, the prior declaration will be stored as an object of the Prior Class, StdPrior Class or the CorrPrior Class, depending on the form the prior statement took (param.prior(...), std(exo/endo var).prior(...) or corr(endo/exo,endo/exo).prior(...)). In addition to declaring one of the aforementioned objects for each of the prior statements and organizing them into vectors, the following will also be provided by the preprocessor:

DynareWiki: NewEstimation (last edited 2012-03-26 15:15:22 by HoutanBastani)