Differences between revisions 27 and 28
Revision 27 as of 2011-12-07 14:28:59
Size: 11343
Comment: Fixed typos.
Revision 28 as of 2011-12-08 10:11:16
Size: 11355
Comment:
Deletions are marked like this. Additions are marked like this.
Line 47: Line 47:
 * firstobs
 * lastobs
 * first_obs
 * last_obs
Line 69: Line 69:
   data(file=/home/stepan/Works/MZE/data/data.xls,firstobs=1950Q1)
}}}
In this first example the beggining of the sample is specified by '''firstobs'''. 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,firstobs=1950Q1,lastobs=2000Q4)
   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)
Line 77: Line 77:
   data(file=/home/stepan/Works/MZE/data/data.xls,firstobs=1950Q1,nobs=204)
}}}
In these two examples the last arguments ('''nobs''' or '''lastobs''') 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.
   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.
Line 86: Line 86:
   options_.dataset.firstobs = dynDate('1950Q1');
   options_.dataset.lastobs = dynDate('2000Q4');
   options_.dataset.first_obs = dynDate('1950Q1');
   options_.dataset.last_obs = dynDate('2000Q4');
Line 92: Line 92:
   options_.dataset.firstobs = options_.initial_period;
   options_.dataset.lastobs = NaN;
   options_.dataset.first_obs = options_.initial_period;
   options_.dataset.last_obs = NaN;

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

  • If the initial period is the third quarter of 1950 (quaterly data):

   set_time(1950Q3)
  • If the initial period is 1960 (yearly data implicitely assumed):

   set_time(1960)
  • If the initial period is the fifth month of 1971 (monthly data):

   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:

  • file
  • first_obs
  • last_obs
  • nobs
  • xls_sheet
  • xls_range

Syntax examples

  • Call with only one input argument:

   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.

  • Call with more than one input argument:

   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

  • For the declaration of the priors
    • shape, name of the prior distribution.

    • mean, mean of the prior distribution.

    • stdev, standard deviation of the prior distribution.

    • variance, variance of the prior distribution.

    • mode, mode of the prior distribution.

    • interval, specification of the prior distribution from the cumulative distribution function defining an interval covering an arbitrary percentage of the prior mass. See below for an example.

    • shift, to shift the domain a distribution. See below for an example (useless if the domain of the distribution is the set of real numbers).

    • domain, specify the domain of distributions with bounded support (uniform and beta).

  • For optimization options
    • boundaries, enforce the optimizer to look for a mode in a specified interval.

    • initial, initial value for the optimizer.

  • For the mcmc options
    • jscale, scale paramemeter for the jumping distribution specific to a parameter.

Syntax examples

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

  • Declaration of a prior for estimated parameter alpha, specified using mean and variance:

     alpha.prior(shape=beta,mean=0.3,variance=0.1^2);
  • Declaration of a prior for estimated parameter alpha, specified using the cumulative distribution function:

     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.

  • Shift the domain of a prior distribution:

     theta.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.

  • Specify the (non default) domain of a prior distribution with bounded support:

     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].

  • Declaration of the subsamples (must preceed the declaration of the priors):

     alpha.subsamples(name1=1950Q3:1957Q4, name2=1958Q1:1983Q2, name3=1983Q3:2011Q2)
  • Declaration of alpha's prior over different subsamples (must follow the declaration of the subsamples):

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

Preprocessor generated code

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

  • The first field is a structure specifying the parameters to be estimated.

  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('s1','s2');
  estimation_info.parameters.structural_innovation_corr.nb = 1;
  estimation_info.parameters.structural_innovation_corr.list = char('s1___s2');
  estimation_info.parameters.measurement_error.nb = 2;
  estimation_info.parameters.measurement_error.list = ĉhar('s3','s4');
  estimation_info.parameters.measurement_error_corr.nb = 1;
  estimation_info.parameters.measurement_error_corr.list = char('s3___s4');

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 = 4;
  estimation_info.parameters.list = char('alpha$1','alpha$2','beta','sigma');
  estimation_info.parameters.structural_innovation.nb = 2;
  estimation_info.parameters.structural_innovation.list = ĉhar('s1','s2');
  estimation_info.parameters.structural_innovation_corr.nb = 1;
  estimation_info.parameters.structural_innovation_corr.list = char('s1___s2');
  estimation_info.parameters.measurement_error.nb = 2;
  estimation_info.parameters.measurement_error.list = ĉhar('s3','s4');
  estimation_info.parameters.measurement_error_corr.nb = 1;
  estimation_info.parameters.measurement_error_corr.list = char('s3___s4');

where alpha$1 and alpha$2 are correspond to alpha for the first and second subsamples.

  • The second field is a structure specifying the initial conditions for the optimization routine.

  estimation_info.init.deep = [1.0; .5; .3 ];
  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; .5; .3 ];
  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.

  • The third field is a structure specifying the bounds for the optimization routine.

  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 the std. are 0 and Inf, default bounds for the deep parameters are -Inf and Inf (meaning no effective bounds for the optimization).

  • The fourth field is a structure describing the subsamples (if any). By default each estimated parameter is kept constant along the whole sample. For instance, if there is one unexpected break on the estimated parameter alpha, we would have:

  estimation_info.subsample.deep.alpha = [ '1950:Q1', '1980:Q2'; '1980Q3', '2000:Q4'];

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

  • An optional field is added if the model is estimated with a Bayesian approach. This field specifies the prior beliefs. For X = 'deep', 'structural_innovation', 'measurement_error', 'structural_innovation_corr' and 'measurement_error_corr' we have the following fields (n*1 vectors of doubles or n*2 vector of doubles):

   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

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