diff --git a/ComputingTasks.cc b/ComputingTasks.cc index 42c9af2e..dda585d4 100644 --- a/ComputingTasks.cc +++ b/ComputingTasks.cc @@ -581,15 +581,20 @@ EstimatedParamsStatement::writeOutput(ostream &output, const string &basename) c } EstimatedParamsInitStatement::EstimatedParamsInitStatement(const vector &estim_params_list_arg, - const SymbolTable &symbol_table_arg) : + const SymbolTable &symbol_table_arg, + const bool use_calibration_arg) : estim_params_list(estim_params_list_arg), - symbol_table(symbol_table_arg) + symbol_table(symbol_table_arg), + use_calibration(use_calibration_arg) { } void EstimatedParamsInitStatement::writeOutput(ostream &output, const string &basename) const { + if (use_calibration) + output << "options_.use_calibration_initialization = 1;" << endl; + vector::const_iterator it; for (it = estim_params_list.begin(); it != estim_params_list.end(); it++) diff --git a/ComputingTasks.hh b/ComputingTasks.hh index 59c6a264..156a3421 100644 --- a/ComputingTasks.hh +++ b/ComputingTasks.hh @@ -290,9 +290,11 @@ class EstimatedParamsInitStatement : public Statement private: const vector estim_params_list; const SymbolTable &symbol_table; + const bool use_calibration; public: EstimatedParamsInitStatement(const vector &estim_params_list_arg, - const SymbolTable &symbol_table_arg); + const SymbolTable &symbol_table_arg, + const bool use_calibration_arg); virtual void writeOutput(ostream &output, const string &basename) const; }; diff --git a/DynareBison.yy b/DynareBison.yy index fbf097eb..1612ee70 100644 --- a/DynareBison.yy +++ b/DynareBison.yy @@ -90,7 +90,7 @@ class ParsingDriver; %} %token AIM_SOLVER ANALYTIC_DERIVATION AR AUTOCORR -%token BAYESIAN_IRF BETA_PDF BLOCK +%token BAYESIAN_IRF BETA_PDF BLOCK USE_CALIBRATION %token BVAR_DENSITY BVAR_FORECAST %token BVAR_PRIOR_DECAY BVAR_PRIOR_FLAT BVAR_PRIOR_LAMBDA %token BVAR_PRIOR_MU BVAR_PRIOR_OMEGA BVAR_PRIOR_TAU BVAR_PRIOR_TRAIN @@ -106,7 +106,7 @@ class ParsingDriver; %token HISTVAL HOMOTOPY_SETUP HOMOTOPY_MODE HOMOTOPY_STEPS HOMOTOPY_FORCE_CONTINUE HP_FILTER HP_NGRID HYBRID %token IDENTIFICATION INF_CONSTANT INITVAL INITVAL_FILE BOUNDS JSCALE INIT %token INT_NUMBER -%token INV_GAMMA_PDF INV_GAMMA1_PDF INV_GAMMA2_PDF IRF IRF_SHOCKS +%token INV_GAMMA_PDF INV_GAMMA1_PDF INV_GAMMA2_PDF IRF IRF_SHOCKS IRF_PLOT_THRESHOLD %token KALMAN_ALGO KALMAN_TOL SUBSAMPLES OPTIONS TOLF %token LAPLACE LIK_ALGO LIK_INIT LINEAR LOAD_IDENT_FILES LOAD_MH_FILE LOAD_PARAMS_AND_STEADY_STATE LOGLINEAR LYAPUNOV %token LYAPUNOV_FIXED_POINT_TOL LYAPUNOV_DOUBLING_TOL LYAPUNOV_SQUARE_ROOT_SOLVER_TOL LOG_DEFLATOR LOG_TREND_VAR LOG_GROWTH_FACTOR MARKOWITZ MARGINAL_DENSITY MAX MAXIT @@ -990,6 +990,7 @@ stoch_simul_primary_options : o_dr_algo | o_dr_cycle_reduction_tol | o_dr_logarithmic_reduction_tol | o_dr_logarithmic_reduction_maxiter + | o_irf_plot_threshold ; stoch_simul_options : stoch_simul_primary_options @@ -1136,7 +1137,10 @@ estimated_elem3 : expression_or_empty COMMA expression_or_empty ; estimated_params_init : ESTIMATED_PARAMS_INIT ';' estimated_init_list END ';' - { driver.estimated_params_init(); }; + { driver.estimated_params_init(); } + | ESTIMATED_PARAMS_INIT '(' USE_CALIBRATION ')' ';' estimated_init_list END ';' + { driver.estimated_params_init(true); } + ; estimated_init_list : estimated_init_list estimated_init_elem { driver.add_estimated_params_element(); } @@ -1562,6 +1566,7 @@ estimation_options : o_datafile | o_taper_steps | o_geweke_interval | o_mcmc_jumping_covariance + | o_irf_plot_threshold ; list_optim_option : QUOTED_STRING COMMA QUOTED_STRING @@ -2689,6 +2694,7 @@ o_mcmc_jumping_covariance : MCMC_JUMPING_COVARIANCE EQUAL HESSIAN | MCMC_JUMPING_COVARIANCE EQUAL filename { driver.option_str("MCMC_jumping_covariance", $3); } ; +o_irf_plot_threshold : IRF_PLOT_THRESHOLD EQUAL non_negative_number { driver.option_num("impulse_responses.plot_threshold", $3); }; range : symbol ':' symbol { diff --git a/DynareFlex.ll b/DynareFlex.ll index 160a47d5..18064298 100644 --- a/DynareFlex.ll +++ b/DynareFlex.ll @@ -397,7 +397,7 @@ string eofbuff; return token::CNUM; } banact {return token::BANACT;} - +use_calibration {return token::USE_CALIBRATION;} output_file_tag {return token::OUTPUT_FILE_TAG;} file_tag {return token::FILE_TAG;}; no_create_init {return token::NO_CREATE_INIT;}; @@ -569,6 +569,7 @@ string eofbuff; mh_recover {return token::MH_RECOVER;} planner_discount {return token::PLANNER_DISCOUNT;} calibration {return token::CALIBRATION;} +irf_plot_threshold {return token::IRF_PLOT_THRESHOLD;} equation {return token::EQUATION;} exclusion {return token::EXCLUSION;} diff --git a/ModFile.cc b/ModFile.cc index 1abb76ce..1a1b7e3e 100644 --- a/ModFile.cc +++ b/ModFile.cc @@ -703,7 +703,15 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all, bool no_log, b if (block && !byte_code) mOutputFile << "rmpath " << basename << ";" << endl; - mOutputFile << "save('" << basename << "_results.mat', 'oo_', 'M_', 'options_');" << endl; + mOutputFile << "save('" << basename << "_results.mat', 'oo_', 'M_', 'options_');" << endl + << "if exist('estim_params_', 'var') == 1" << endl + << " save('" << basename << "_results.mat', 'estim_params_', '-append');" << endl << "end" << endl + << "if exist('bayestopt_', 'var') == 1" << endl + << " save('" << basename << "_results.mat', 'bayestopt_', '-append');" << endl << "end" << endl + << "if exist('dataset_', 'var') == 1" << endl + << " save('" << basename << "_results.mat', 'dataset_', '-append');" << endl << "end" << endl + << "if exist('estimation_info', 'var') == 1" << endl + << " save('" << basename << "_results.mat', 'estimation_info', '-append');" << endl << "end" << endl; config_file.writeEndParallel(mOutputFile); diff --git a/ParsingDriver.cc b/ParsingDriver.cc index 645546df..24d42a70 100644 --- a/ParsingDriver.cc +++ b/ParsingDriver.cc @@ -1209,9 +1209,9 @@ ParsingDriver::estimated_params() } void -ParsingDriver::estimated_params_init() +ParsingDriver::estimated_params_init(bool use_calibration) { - mod_file->addStatement(new EstimatedParamsInitStatement(estim_params_list, mod_file->symbol_table)); + mod_file->addStatement(new EstimatedParamsInitStatement(estim_params_list, mod_file->symbol_table, use_calibration)); estim_params_list.clear(); } diff --git a/ParsingDriver.hh b/ParsingDriver.hh index 8ad5a9f0..0e17805f 100644 --- a/ParsingDriver.hh +++ b/ParsingDriver.hh @@ -394,7 +394,7 @@ public: //! Writes estimated params command void estimated_params(); //! Writes estimated params init command - void estimated_params_init(); + void estimated_params_init(bool use_calibration = false); //! Writes estimated params bound command void estimated_params_bounds(); //! Adds a declaration for a user-defined external function