From 051213f7987597719dd50eab2cce2289fb88953d Mon Sep 17 00:00:00 2001 From: ferhat Date: Mon, 28 Oct 2013 14:22:23 +0100 Subject: [PATCH 1/3] Add a flag for calib_smoother command and apply a setup similar to the one used for stoch_simul command: - Add auxiliary variables for leaded and lagged exogenous - Set the cutoff applied to the Jacobian at zero for the static and the dynamic models --- preprocessor/ComputingTasks.cc | 6 ++++++ preprocessor/ComputingTasks.hh | 1 + preprocessor/ModFile.cc | 15 ++++++++++----- preprocessor/Statement.cc | 3 ++- preprocessor/Statement.hh | 2 ++ 5 files changed, 21 insertions(+), 6 deletions(-) diff --git a/preprocessor/ComputingTasks.cc b/preprocessor/ComputingTasks.cc index 458a1db26..9434b315b 100644 --- a/preprocessor/ComputingTasks.cc +++ b/preprocessor/ComputingTasks.cc @@ -2411,6 +2411,12 @@ CalibSmootherStatement::CalibSmootherStatement(const SymbolList &symbol_list_arg { } +void +CalibSmootherStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings) +{ + mod_file_struct.calib_smoother_present = true; +} + void CalibSmootherStatement::writeOutput(ostream &output, const string &basename) const { diff --git a/preprocessor/ComputingTasks.hh b/preprocessor/ComputingTasks.hh index 926e082d2..59c6a264e 100644 --- a/preprocessor/ComputingTasks.hh +++ b/preprocessor/ComputingTasks.hh @@ -516,6 +516,7 @@ private: public: CalibSmootherStatement(const SymbolList &symbol_list_arg, const OptionsList &options_list_arg); + virtual void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings); virtual void writeOutput(ostream &output, const string &basename) const; }; diff --git a/preprocessor/ModFile.cc b/preprocessor/ModFile.cc index 4ef0ab43a..631dc4fa4 100644 --- a/preprocessor/ModFile.cc +++ b/preprocessor/ModFile.cc @@ -123,7 +123,8 @@ ModFile::checkPass() || mod_file_struct.estimation_present || mod_file_struct.osr_present || mod_file_struct.ramsey_policy_present - || mod_file_struct.discretionary_policy_present; + || mod_file_struct.discretionary_policy_present + || mod_file_struct.calib_smoother_present; // Allow empty model only when doing a standalone BVAR estimation if (dynamic_model.equation_number() == 0 @@ -318,7 +319,8 @@ ModFile::transformPass(bool nostrict) || mod_file_struct.estimation_present || mod_file_struct.osr_present || mod_file_struct.ramsey_policy_present - || mod_file_struct.discretionary_policy_present) + || mod_file_struct.discretionary_policy_present + || mod_file_struct.calib_smoother_present) { // In stochastic models, create auxiliary vars for leads and lags greater than 2, on both endos and exos dynamic_model.substituteEndoLeadGreaterThanTwo(false); @@ -423,7 +425,8 @@ ModFile::computingPass(bool no_tmp_terms) { if (mod_file_struct.stoch_simul_present || mod_file_struct.estimation_present || mod_file_struct.osr_present - || mod_file_struct.ramsey_policy_present || mod_file_struct.identification_present) + || mod_file_struct.ramsey_policy_present || mod_file_struct.identification_present + || mod_file_struct.calib_smoother_present) static_model.set_cutoff_to_zero(); const bool static_hessian = mod_file_struct.identification_present @@ -437,7 +440,8 @@ ModFile::computingPass(bool no_tmp_terms) if (mod_file_struct.simul_present || mod_file_struct.check_present || mod_file_struct.stoch_simul_present || mod_file_struct.estimation_present || mod_file_struct.osr_present - || mod_file_struct.ramsey_policy_present || mod_file_struct.identification_present) + || mod_file_struct.ramsey_policy_present || mod_file_struct.identification_present + || mod_file_struct.calib_smoother_present) { if (mod_file_struct.simul_present) dynamic_model.computingPass(true, false, false, false, global_eval_context, no_tmp_terms, block, use_dll, byte_code); @@ -445,7 +449,8 @@ ModFile::computingPass(bool no_tmp_terms) { if (mod_file_struct.stoch_simul_present || mod_file_struct.estimation_present || mod_file_struct.osr_present - || mod_file_struct.ramsey_policy_present || mod_file_struct.identification_present) + || mod_file_struct.ramsey_policy_present || mod_file_struct.identification_present + || mod_file_struct.calib_smoother_present) dynamic_model.set_cutoff_to_zero(); if (mod_file_struct.order_option < 1 || mod_file_struct.order_option > 3) { diff --git a/preprocessor/Statement.cc b/preprocessor/Statement.cc index 59021287b..af77dc246 100644 --- a/preprocessor/Statement.cc +++ b/preprocessor/Statement.cc @@ -47,7 +47,8 @@ ModFileStructure::ModFileStructure() : dsge_var_estimated(false), bayesian_irf_present(false), estimation_data_statement_present(false), - last_markov_switching_chain(0) + last_markov_switching_chain(0), + calib_smoother_present(false) { } diff --git a/preprocessor/Statement.hh b/preprocessor/Statement.hh index cd3fd5cf3..493dabfab 100644 --- a/preprocessor/Statement.hh +++ b/preprocessor/Statement.hh @@ -57,6 +57,8 @@ public: bool planner_objective_present; //! Whether an extended_path statement is present bool extended_path_present; + //! Whether a calib_smoother statement is present + bool calib_smoother_present; //! The value of the "order" option of stoch_simul, estimation, osr, ramsey_policy //! Derivation order /*! First initialized to zero. If user sets order option somewhere in the MOD file, it will be equal to the maximum of order options. Otherwise will default to 2 */ From f4cee9d5e508faa4ee2037e29b633119d337a7cb Mon Sep 17 00:00:00 2001 From: ferhat Date: Mon, 28 Oct 2013 14:26:42 +0100 Subject: [PATCH 2/3] Corrects a bug in the way to test for the presence of the global variables --- mex/sources/bytecode/bytecode.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mex/sources/bytecode/bytecode.cc b/mex/sources/bytecode/bytecode.cc index 5a08c6754..98ee11402 100644 --- a/mex/sources/bytecode/bytecode.cc +++ b/mex/sources/bytecode/bytecode.cc @@ -363,7 +363,7 @@ Get_Arguments_and_global_variables(int nrhs, } } *M_ = mexGetVariable("global", "M_"); - if (M_ == NULL) + if (*M_ == NULL) { ostringstream tmp; tmp << " in main, global variable not found: M_\n"; @@ -371,14 +371,14 @@ Get_Arguments_and_global_variables(int nrhs, } /* Gets variables and parameters from global workspace of Matlab */ *oo_ = mexGetVariable("global", "oo_"); - if (oo_ == NULL) + if (*oo_ == NULL) { ostringstream tmp; tmp << " in main, global variable not found: oo_\n"; throw FatalExceptionHandling(tmp.str()); } *options_ = mexGetVariable("global", "options_"); - if (options_ == NULL) + if (*options_ == NULL) { ostringstream tmp; tmp << " in main, global variable not found: options_\n"; From 37876b2c2bacc170f73952193724c98607cceade Mon Sep 17 00:00:00 2001 From: ferhat Date: Mon, 28 Oct 2013 16:41:21 +0100 Subject: [PATCH 3/3] Comment the trend test for a balance growth path => problematic with eLogTrend --- preprocessor/ModFile.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/preprocessor/ModFile.cc b/preprocessor/ModFile.cc index 631dc4fa4..61b551d48 100644 --- a/preprocessor/ModFile.cc +++ b/preprocessor/ModFile.cc @@ -416,8 +416,8 @@ ModFile::computingPass(bool no_tmp_terms) // Mod file may have no equation (for example in a standalone BVAR estimation) if (dynamic_model.equation_number() > 0) { - if (nonstationary_variables) - trend_dynamic_model.runTrendTest(global_eval_context); + /*if (nonstationary_variables) + trend_dynamic_model.runTrendTest(global_eval_context);*/ // Compute static model and its derivatives dynamic_model.toStatic(static_model);