From 0f8c5ef22443b2cbb3c77bda5e7e0adb57f35dfb Mon Sep 17 00:00:00 2001 From: Houtan Bastani <houtan@dynare.org> Date: Wed, 9 Jan 2019 15:19:30 +0100 Subject: [PATCH] substitute leads/lags appropriately when identification or sensitivity statements are present. #1631 Effective cherry pick of https://git.dynare.org/Dynare/preprocessor/commit/4c71d143f3fec395989950de51e7dee5836a37db --- preprocessor/ComputingTasks.cc | 3 ++- preprocessor/ModFile.cc | 10 +++++++--- preprocessor/Statement.cc | 3 ++- preprocessor/Statement.hh | 4 +++- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/preprocessor/ComputingTasks.cc b/preprocessor/ComputingTasks.cc index 8f098f0855..d4e715709f 100644 --- a/preprocessor/ComputingTasks.cc +++ b/preprocessor/ComputingTasks.cc @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2017 Dynare Team + * Copyright (C) 2003-2019 Dynare Team * * This file is part of Dynare. * @@ -663,6 +663,7 @@ DynareSensitivityStatement::checkPass(ModFileStructure &mod_file_struct, Warning if (it != options_list.num_options.end() && it->second == "1") mod_file_struct.identification_present = true; + mod_file_struct.sensitivity_present = true; } void diff --git a/preprocessor/ModFile.cc b/preprocessor/ModFile.cc index 8983b5e6a7..044ebb5e45 100644 --- a/preprocessor/ModFile.cc +++ b/preprocessor/ModFile.cc @@ -1,5 +1,5 @@ /* - * Copyright (C) 2006-2017 Dynare Team + * Copyright (C) 2006-2019 Dynare Team * * This file is part of Dynare. * @@ -129,7 +129,9 @@ ModFile::checkPass(bool nostrict) || mod_file_struct.osr_present || mod_file_struct.ramsey_policy_present || mod_file_struct.discretionary_policy_present - || mod_file_struct.calib_smoother_present; + || mod_file_struct.calib_smoother_present + || mod_file_struct.identification_present + || mod_file_struct.sensitivity_present; // Allow empty model only when doing a standalone BVAR estimation if (dynamic_model.equation_number() == 0 @@ -407,7 +409,9 @@ ModFile::transformPass(bool nostrict, bool compute_xrefs) || mod_file_struct.osr_present || mod_file_struct.ramsey_policy_present || mod_file_struct.discretionary_policy_present - || mod_file_struct.calib_smoother_present) + || mod_file_struct.calib_smoother_present + || mod_file_struct.identification_present + || mod_file_struct.sensitivity_present) { // In stochastic models, create auxiliary vars for leads and lags greater than 2, on both endos and exos dynamic_model.substituteEndoLeadGreaterThanTwo(false); diff --git a/preprocessor/Statement.cc b/preprocessor/Statement.cc index e1f9a01129..34077fa3f1 100644 --- a/preprocessor/Statement.cc +++ b/preprocessor/Statement.cc @@ -1,5 +1,5 @@ /* - * Copyright (C) 2006-2017 Dynare Team + * Copyright (C) 2006-2019 Dynare Team * * This file is part of Dynare. * @@ -38,6 +38,7 @@ ModFileStructure::ModFileStructure() : bvar_present(false), svar_identification_present(false), identification_present(false), + sensitivity_present(false), estimation_analytic_derivation(false), partial_information(false), k_order_solver(false), diff --git a/preprocessor/Statement.hh b/preprocessor/Statement.hh index 83dce960a4..f319256476 100644 --- a/preprocessor/Statement.hh +++ b/preprocessor/Statement.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2006-2017 Dynare Team + * Copyright (C) 2006-2019 Dynare Team * * This file is part of Dynare. * @@ -68,6 +68,8 @@ public: bool svar_identification_present; //! Whether an identification statement is present or the identification option of dynare_sensitivity statement is equal to one bool identification_present; + //! Whether a sensitivity statement is present + bool sensitivity_present; //! Whether the option analytic_derivation is given to estimation bool estimation_analytic_derivation; //! Whether the option partial_information is given to stoch_simul/estimation/osr/ramsey_policy -- GitLab