diff --git a/src/ComputingTasks.cc b/src/ComputingTasks.cc index b8f558fbdf6dfc834cc8f592c858f76c231c1dc3..75ae03e88001d0d68d17a6faf1b0a973e378e18e 100644 --- a/src/ComputingTasks.cc +++ b/src/ComputingTasks.cc @@ -4761,12 +4761,22 @@ MethodOfMomentsStatement::checkPass(ModFileStructure &mod_file_struct, WarningCo if (auto it = options_list.num_options.find("mom.analytic_standard_errors"); it != options_list.num_options.end() && it->second == "true") mod_file_struct.analytic_standard_errors_present = true; - + if (!mod_file_struct.GMM_present && mod_file_struct.analytic_standard_errors_present) { cerr << "ERROR: The analytic_standard_errors statement requires the GMM option." << endl; exit(EXIT_FAILURE); - } + } + + if (auto it = options_list.num_options.find("mom.analytic_jacobian"); + it != options_list.num_options.end() && it->second == "true") + mod_file_struct.analytic_jacobian_present = true; + + if (!mod_file_struct.GMM_present && mod_file_struct.analytic_jacobian_present) + { + cerr << "ERROR: The analytic_jacobian statement requires the GMM option." << endl; + exit(EXIT_FAILURE); + } } void diff --git a/src/DynareBison.yy b/src/DynareBison.yy index b1eddc75966d4b54ff9a166708799225411e4771..e19e73255ba3a3a8f9ca7c5df664fd0653a881bf 100644 --- a/src/DynareBison.yy +++ b/src/DynareBison.yy @@ -167,7 +167,7 @@ class ParsingDriver; %token RANDOM_FUNCTION_CONVERGENCE_CRITERION RANDOM_PARAMETER_CONVERGENCE_CRITERION /* Method of Moments */ %token METHOD_OF_MOMENTS MOM_METHOD -%token BARTLETT_KERNEL_LAG WEIGHTING_MATRIX WEIGHTING_MATRIX_SCALING_FACTOR ANALYTIC_STANDARD_ERRORS PENALIZED_ESTIMATOR VERBOSE +%token BARTLETT_KERNEL_LAG WEIGHTING_MATRIX WEIGHTING_MATRIX_SCALING_FACTOR ANALYTIC_STANDARD_ERRORS ANALYTIC_JACOBIAN PENALIZED_ESTIMATOR VERBOSE %token SIMULATION_MULTIPLE MOM_SEED SEED BOUNDED_SHOCK_SUPPORT ADDITIONAL_OPTIMIZER_STEPS MOM_SE_TOLX SE_TOLX MOM_BURNIN BURNIN %token EQTAGS STEADY_STATE_GROWTH %token ANALYTICAL_GIRF IRF_IN_PERCENT EMAS_GIRF EMAS_DROP EMAS_TOLF EMAS_MAX_ITER @@ -1289,13 +1289,12 @@ method_of_moments_option : o_mom_method | o_verbose | o_weighting_matrix | o_weighting_matrix_scaling_factor - | o_analytic_standard_errors - | o_additional_optimizer_steps - | o_prefilter + | o_mom_se_tolx + | o_mom_burnin | o_bounded_shock_support | o_mom_seed | o_simulation_multiple - | o_mom_burnin + | o_analytic_standard_errors | o_dirname | o_graph_format | o_nodisplay @@ -1307,13 +1306,15 @@ method_of_moments_option : o_mom_method | o_first_obs | o_logdata | o_nobs + | o_prefilter | o_xls_sheet | o_xls_range - | o_huge_number | o_mode_compute + | o_additional_optimizer_steps | o_optim | o_silent_optimizer - | o_mom_se_tolx + | o_huge_number + | o_analytic_jacobian | o_aim_solver | o_dr | o_dr_cycle_reduction_tol @@ -3710,6 +3711,8 @@ o_weighting_matrix_scaling_factor : WEIGHTING_MATRIX_SCALING_FACTOR EQUAL non_ne o_analytic_standard_errors : ANALYTIC_STANDARD_ERRORS { driver.option_num("mom.analytic_standard_errors", "true"); }; +o_analytic_jacobian : ANALYTIC_JACOBIAN { driver.option_num("mom.analytic_jacobian", "true"); }; + o_mom_method : MOM_METHOD EQUAL GMM { driver.option_str("mom.mom_method", "GMM"); } | MOM_METHOD EQUAL SMM diff --git a/src/DynareFlex.ll b/src/DynareFlex.ll index 7ae7b4c260014206c6cc906ec48ba26de04f20d8..124f8c9625d677ce1f8926ea16ff61652a76189c 100644 --- a/src/DynareFlex.ll +++ b/src/DynareFlex.ll @@ -682,6 +682,7 @@ DATE -?[0-9]+([ya]|m([1-9]|1[0-2])|q[1-4]) <DYNARE_STATEMENT>weighting_matrix {return token::WEIGHTING_MATRIX; } <DYNARE_STATEMENT>weighting_matrix_scaling_factor {return token::WEIGHTING_MATRIX_SCALING_FACTOR; } <DYNARE_STATEMENT>analytic_standard_errors {return token::ANALYTIC_STANDARD_ERRORS; } +<DYNARE_STATEMENT>analytic_jacobian {return token::ANALYTIC_JACOBIAN; } <DYNARE_STATEMENT>mom_method {return token::MOM_METHOD; } <DYNARE_STATEMENT>penalized_estimator {return token::PENALIZED_ESTIMATOR; } <DYNARE_STATEMENT>verbose {return token::VERBOSE; } diff --git a/src/ModFile.cc b/src/ModFile.cc index 239308e72524553c0c7a721ecdea4ba52bb15bf3..a32dc93b9c124d00ec2c6cba5b391ab262240289 100644 --- a/src/ModFile.cc +++ b/src/ModFile.cc @@ -752,7 +752,7 @@ ModFile::computingPass(bool no_tmp_terms, OutputType output, int params_derivs_o if (mod_file_struct.identification_present || mod_file_struct.estimation_analytic_derivation - || (mod_file_struct.GMM_present && mod_file_struct.analytic_standard_errors_present)) + || (mod_file_struct.GMM_present && (mod_file_struct.analytic_standard_errors_present || mod_file_struct.analytic_jacobian_present))) paramsDerivsOrder = params_derivs_order; static_model.computingPass(derivsOrder, paramsDerivsOrder, global_eval_context, no_tmp_terms, block, bytecode); @@ -786,7 +786,8 @@ ModFile::computingPass(bool no_tmp_terms, OutputType output, int params_derivs_o exit(EXIT_FAILURE); } int derivsOrder = max(mod_file_struct.order_option,mod_file_struct.identification_order + 1); // See preprocessor#40 - if (mod_file_struct.GMM_present && mod_file_struct.analytic_standard_errors_present) //analytic standard errors require one order more + if (mod_file_struct.GMM_present + && (mod_file_struct.analytic_standard_errors_present || mod_file_struct.analytic_jacobian_present)) //analytic_standard_errors or analytic_jacobian require one order more derivsOrder = max(mod_file_struct.order_option, max(mod_file_struct.identification_order,mod_file_struct.mom_order) + 1); // See preprocessor#40 @@ -797,7 +798,7 @@ ModFile::computingPass(bool no_tmp_terms, OutputType output, int params_derivs_o int paramsDerivsOrder = 0; if (mod_file_struct.identification_present || mod_file_struct.estimation_analytic_derivation - || (mod_file_struct.GMM_present && mod_file_struct.analytic_standard_errors_present)) + || (mod_file_struct.GMM_present && (mod_file_struct.analytic_standard_errors_present || mod_file_struct.analytic_jacobian_present))) paramsDerivsOrder = params_derivs_order; dynamic_model.computingPass(true, derivsOrder, paramsDerivsOrder, global_eval_context, no_tmp_terms, block, use_dll, bytecode, linear_decomposition); if (linear && mod_file_struct.ramsey_model_present) diff --git a/src/Statement.hh b/src/Statement.hh index 99d2bbb7ce5ec6f7ad59c842efa505a46efe4720..4c143daddf45ce5fc8f5c72527f05c654c5b9d68 100644 --- a/src/Statement.hh +++ b/src/Statement.hh @@ -84,6 +84,8 @@ public: bool GMM_present{false}; //! Whether an analytic_standard_errors-option is present bool analytic_standard_errors_present{false}; + //! Whether an analytic_jacobian-option is present + bool analytic_jacobian_present{false}; //! The maximum of the “order” option in method_of_moments statements int mom_order{0}; //! Whether there is a calibrated measurement error