MoM: Add option analytic_jacobian

issue#70
Willi Mutschler 2021-01-08 15:04:13 +01:00 committed by Sébastien Villemot
parent 8e03f17350
commit a87b2753ed
No known key found for this signature in database
GPG Key ID: 2CECE9350ECEBE4A
5 changed files with 29 additions and 12 deletions

View File

@ -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

View File

@ -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

View File

@ -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; }

View File

@ -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)

View File

@ -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