GMM: introduce option analytic_standard_errors

issue#70
Johannes Pfeifer 2020-12-11 13:27:23 +01:00
parent 7baeda8b8d
commit 78f6d48601
5 changed files with 53 additions and 20 deletions

View File

@ -4738,20 +4738,35 @@ MethodOfMomentsStatement::checkPass(ModFileStructure &mod_file_struct, WarningCo
if (order > 2)
mod_file_struct.k_order_solver = true;
mod_file_struct.mom_order = order;
mod_file_struct.order_option = max(mod_file_struct.order_option, order);
}
if (options_list.string_options.find("datafile") == options_list.string_options.end())
{
cerr << "ERROR: The method_of_moments statement requires a data file to be supplied via the datafile option." << endl;
exit(EXIT_FAILURE);
}
{
cerr << "ERROR: The method_of_moments statement requires a data file to be supplied via the datafile option." << endl;
exit(EXIT_FAILURE);
}
if (options_list.string_options.find("mom.mom_method") == options_list.string_options.end())
{
cerr << "ERROR: The method_of_moments statement requires a method to be supplied via the mom_method option. Possible values are GMM or SMM." << endl;
exit(EXIT_FAILURE);
}
{
cerr << "ERROR: The method_of_moments statement requires a method to be supplied via the mom_method option. Possible values are GMM or SMM." << endl;
exit(EXIT_FAILURE);
}
if (auto it = options_list.string_options.find("mom.mom_method");
it != options_list.string_options.end() && it->second == "GMM")
mod_file_struct.GMM_present = true;
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);
}
}
void

View File

@ -141,8 +141,8 @@ class ParsingDriver;
%token VLISTLOG VLISTPER SPECTRAL_DENSITY INIT2SHOCKS
%token RESTRICTION RESTRICTION_FNAME CROSS_RESTRICTIONS NLAGS CONTEMP_REDUCED_FORM REAL_PSEUDO_FORECAST
%token DUMMY_OBS NSTATES INDXSCALESSTATES NO_BAYESIAN_PRIOR SPECIFICATION SIMS_ZHA
%token <string> ALPHA BETA ABAND NINV CMS NCMS CNUM GAMMA INV_GAMMA INV_GAMMA1 INV_GAMMA2 NORMAL UNIFORM EPS PDF FIG DR NONE PRIOR PRIOR_VARIANCE HESSIAN IDENTITY_MATRIX DIRICHLET DIAGONAL OPTIMAL GMM SMM
%token GSIG2_LMDM Q_DIAG FLAT_PRIOR NCSK NSTD WEIBULL WEIBULL_PDF
%token <string> ALPHA BETA ABAND NINV CMS NCMS CNUM GAMMA INV_GAMMA INV_GAMMA1 INV_GAMMA2 NORMAL UNIFORM EPS PDF FIG DR NONE PRIOR PRIOR_VARIANCE HESSIAN IDENTITY_MATRIX DIRICHLET DIAGONAL OPTIMAL
%token GSIG2_LMDM Q_DIAG FLAT_PRIOR NCSK NSTD WEIBULL WEIBULL_PDF GMM SMM
%token INDXPARR INDXOVR INDXAP APBAND INDXIMF INDXFORE FOREBAND INDXGFOREHAT INDXGIMFHAT
%token INDXESTIMA INDXGDLS EQ_MS FILTER_COVARIANCE FILTER_DECOMPOSITION SMOOTHED_STATE_UNCERTAINTY
%token EQ_CMS TLINDX TLNUMBER RESTRICTIONS POSTERIOR_SAMPLER_OPTIONS
@ -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 PENALIZED_ESTIMATOR VERBOSE
%token BARTLETT_KERNEL_LAG WEIGHTING_MATRIX WEIGHTING_MATRIX_SCALING_FACTOR ANALYTIC_STANDARD_ERRORS 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,6 +1289,7 @@ 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_bounded_shock_support
@ -3704,10 +3705,12 @@ o_weighting_matrix : WEIGHTING_MATRIX EQUAL vec_str { driver.option_vec_cellstr(
o_weighting_matrix_scaling_factor : WEIGHTING_MATRIX_SCALING_FACTOR EQUAL non_negative_number { driver.option_num("mom.weighting_matrix_scaling_factor", $3); };
o_analytic_standard_errors : ANALYTIC_STANDARD_ERRORS { driver.option_num("mom.analytic_standard_errors", "true"); };
o_mom_method : MOM_METHOD EQUAL GMM
{ driver.option_str("mom.mom_method", $3); }
{ driver.option_str("mom.mom_method", "GMM"); }
| MOM_METHOD EQUAL SMM
{ driver.option_str("mom.mom_method", $3); }
{ driver.option_str("mom.mom_method", "SMM"); }
;
o_penalized_estimator : PENALIZED_ESTIMATOR { driver.option_num("mom.penalized_estimator", "true"); };
o_verbose : VERBOSE { driver.option_num("mom.verbose", "true"); };

View File

@ -686,6 +686,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>mom_method {return token::MOM_METHOD; }
<DYNARE_STATEMENT>penalized_estimator {return token::PENALIZED_ESTIMATOR; }
<DYNARE_STATEMENT>verbose {return token::VERBOSE; }

View File

@ -748,10 +748,13 @@ ModFile::computingPass(bool no_tmp_terms, FileOutputType output, int params_deri
int derivsOrder = 1;
int paramsDerivsOrder = 0;
if (mod_file_struct.identification_present || mod_file_struct.estimation_analytic_derivation)
{
derivsOrder = 2;
paramsDerivsOrder = params_derivs_order;
}
derivsOrder = 2;
if (mod_file_struct.identification_present
|| mod_file_struct.estimation_analytic_derivation
|| (mod_file_struct.GMM_present && mod_file_struct.analytic_standard_errors_present))
paramsDerivsOrder = params_derivs_order;
static_model.computingPass(derivsOrder, paramsDerivsOrder, global_eval_context, no_tmp_terms, block, bytecode);
}
// Set things to compute for dynamic model
@ -775,14 +778,19 @@ ModFile::computingPass(bool no_tmp_terms, FileOutputType output, int params_deri
cerr << "ERROR: Incorrect order option..." << endl;
exit(EXIT_FAILURE);
}
int derivsOrder = max(mod_file_struct.order_option,
mod_file_struct.identification_order + 1); // See preprocessor#40
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
derivsOrder = max(mod_file_struct.order_option,
max(mod_file_struct.identification_order,mod_file_struct.mom_order) + 1); // See preprocessor#40
if (mod_file_struct.sensitivity_present || linear || output == FileOutputType::second)
derivsOrder = max(derivsOrder, 2);
if (mod_file_struct.estimation_analytic_derivation || output == FileOutputType::third)
derivsOrder = max(derivsOrder, 3);
int paramsDerivsOrder = 0;
if (mod_file_struct.identification_present || mod_file_struct.estimation_analytic_derivation)
if (mod_file_struct.identification_present
|| mod_file_struct.estimation_analytic_derivation
|| (mod_file_struct.GMM_present && mod_file_struct.analytic_standard_errors_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

@ -80,6 +80,12 @@ public:
bool k_order_solver{false};
//! Whether an method_of_moments statement is present
bool mom_estimation_present{false};
//! Whether an GMM-option is present
bool GMM_present{false};
//! Whether an analytic_standard_errors-option is present
bool analytic_standard_errors_present{false};
//! The maximum of the “order” option in method_of_moments statements
int mom_order{0};
//! Whether there is a calibrated measurement error
bool calibrated_measurement_errors{false};
//! Whether dsge_prior_weight was initialized as a parameter