diff --git a/parser.src/ComputingTasks.cc b/parser.src/ComputingTasks.cc index 682abd15c..fd7e3e5eb 100644 --- a/parser.src/ComputingTasks.cc +++ b/parser.src/ComputingTasks.cc @@ -81,6 +81,20 @@ void ComputingTasks::runEstimation(string tmp1) *output << "dynare_estimation(var_list_);\n"; } +//------------------------------------------------------------------------------ +void ComputingTasks::runPriorAnalysis(string tmp1) +{ + *output << tmp1; + *output << "prior_analysis(var_list_);\n"; +} + +//------------------------------------------------------------------------------ +void ComputingTasks::runPosteriorAnalysis(string tmp1) +{ + *output << tmp1; + *output << "posterior_analysis(var_list_);\n"; +} + //------------------------------------------------------------------------------ void ComputingTasks::runRplot(string tmp1) { diff --git a/parser.src/DynareBison.yy b/parser.src/DynareBison.yy index 9b220e736..e79b88f0e 100644 --- a/parser.src/DynareBison.yy +++ b/parser.src/DynareBison.yy @@ -43,6 +43,7 @@ typedef pair ExpObj; %token CALIB CALIB_VAR CHECK CONF_SIG CORR COVAR %token DATAFILE DIAGNOSTIC DIFFUSE_D DOLLAR DR_ALGO DROP DSAMPLE DYN2VEC DYNASAVE DYNATYPE %token END ENDVAL EQUAL ESTIMATION ESTIMATED_PARAMS ESTIMATED_PARAMS_BOUNDS ESTIMATED_PARAMS_INIT +%token PRIOR_ANALYSIS POSTERIOR_ANALYSIS %token FILTERED_VARS FIRST_OBS %token FLOAT_NUMBER %token FORECAST FUNCTIONS @@ -108,6 +109,8 @@ typedef pair ExpObj; | simul | stoch_simul | estimation + | prior_analysis + | posterior_analysis | estimated_params | estimated_params_bounds | estimated_params_init @@ -876,6 +879,41 @@ typedef pair ExpObj; | o_noconstant ; + prior_analysis + : PRIOR_ANALYSIS '(' prior_posterior_options_list ')' ';' + {driver.run_prior_analysis();} + | PRIOR_ANALYSIS '(' prior_posterior_options_list ')' tmp_var_list ';' + {driver.run_prior_analysis();} + ; + + prior_posterior_options_list + : prior_posterior_options_list COMMA prior_posterior_options + | prior_posterior_options + ; + + prior_posterior_options + : o_nograph + | o_conf_sig + | o_prior_trunc + | o_bayesian_irf + | o_irf + | o_tex + | o_forecast + | o_smoother + | o_moments_varendo + | o_filtered_vars + | o_xls_sheet + | o_xls_range + | o_filter_step_ahead + ; + + posterior_analysis + : POSTERIOR_ANALYSIS '(' prior_posterior_options_list ')' ';' + {driver.run_posterior_analysis();} + | POSTERIOR_ANALYSIS '(' prior_posterior_options_list ')' tmp_var_list ';' + {driver.run_posterior_analysis();} + ; + list_optim_option : '\'' NAME '\'' COMMA '\'' NAME '\'' {driver.optim_options($2, $6, 2);} | '\'' NAME '\'' COMMA value {driver.optim_options($2, $5, 2);} diff --git a/parser.src/DynareFlex.ll b/parser.src/DynareFlex.ll index 0ca1d1b79..495eea938 100644 --- a/parser.src/DynareFlex.ll +++ b/parser.src/DynareFlex.ll @@ -63,6 +63,8 @@ int sigma_e = 0; periods {BEGIN DYNARE_STATEMENT; return token::PERIODS;} initvalf {BEGIN DYNARE_STATEMENT; return token::INITVALF;} estimation {BEGIN DYNARE_STATEMENT; return token::ESTIMATION;} +prior_analysis {BEGIN DYNARE_STATEMENT; return token::PRIOR_ANALYSIS;} +posterior_analysis {BEGIN DYNARE_STATEMENT; return token::POSTERIOR_ANALYSIS;} varobs {BEGIN DYNARE_STATEMENT; return token::VAROBS;} unit_root_vars {BEGIN DYNARE_STATEMENT; return token::UNIT_ROOT_VARS;} dyn2vec {BEGIN DYNARE_STATEMENT; return token::DYN2VEC;} @@ -98,6 +100,8 @@ int sigma_e = 0; histval {BEGIN DYNARE_BLOCK; return token::HISTVAL;} shocks {BEGIN DYNARE_BLOCK; return token::SHOCKS;} estimated_params {BEGIN DYNARE_BLOCK; return token::ESTIMATED_PARAMS;} + /* priors is an alias for estimated_params */ +priors {BEGIN DYNARE_BLOCK;return token::ESTIMATED_PARAMS;} estimated_params_init {BEGIN DYNARE_BLOCK; return token::ESTIMATED_PARAMS_INIT;} estimated_params_bounds {BEGIN DYNARE_BLOCK; return token::ESTIMATED_PARAMS_BOUNDS;} observation_trends {BEGIN DYNARE_BLOCK; return token::OBSERVATION_TRENDS;} diff --git a/parser.src/ParsingDriver.cc b/parser.src/ParsingDriver.cc index 06439d04d..a79b3da6c 100644 --- a/parser.src/ParsingDriver.cc +++ b/parser.src/ParsingDriver.cc @@ -597,6 +597,22 @@ ParsingDriver::run_estimation() computing_tasks.runEstimation(tmp); } +void +ParsingDriver::run_prior_analysis() +{ + tmp_symbol_table.set("var_list_"); + string tmp = tmp_symbol_table.get(); + computing_tasks.runPriorAnalysis(tmp); +} + +void +ParsingDriver::run_posterior_analysis() +{ + tmp_symbol_table.set("var_list_"); + string tmp = tmp_symbol_table.get(); + computing_tasks.runPosteriorAnalysis(tmp); +} + void ParsingDriver::optim_options(string *str1, string *str2, int task) { diff --git a/parser.src/include/ComputingTasks.hh b/parser.src/include/ComputingTasks.hh index 7b5fea040..73dfa08e8 100644 --- a/parser.src/include/ComputingTasks.hh +++ b/parser.src/include/ComputingTasks.hh @@ -92,6 +92,8 @@ public : void setOption(std::string iName, std::string iValue1, std::string iValue2); /*! Prints "dynare_estimation;" */ void runEstimation(std::string); + void runPriorAnalysis(std::string); + void runPosteriorAnalysis(std::string); void runRplot(std::string); /*! Prints some estimation initialisation */ void setEstimationInit(void); diff --git a/parser.src/include/ParsingDriver.hh b/parser.src/include/ParsingDriver.hh index ba35bbf64..99a382de5 100644 --- a/parser.src/include/ParsingDriver.hh +++ b/parser.src/include/ParsingDriver.hh @@ -228,6 +228,10 @@ public: void set_estimated_bounds_elements(); //! Runs estimation process void run_estimation(); + //! Runs prior_analysis(); + void run_prior_analysis(); + //! Runs posterior_analysis(); + void run_posterior_analysis(); //! Prints optimization options void optim_options(string *str1, string *str2, int task); //! Prints varops instructions