diff --git a/ComputingTasks.cc b/ComputingTasks.cc index db29b6d9..51d623f6 100644 --- a/ComputingTasks.cc +++ b/ComputingTasks.cc @@ -4423,3 +4423,69 @@ Smoother2histvalStatement::writeJsonOutput(ostream &output) const } output << "}"; } + +GMMEstimationStatement::GMMEstimationStatement(const SymbolList &symbol_list_arg, + const OptionsList &options_list_arg) : + symbol_list(symbol_list_arg), + options_list(options_list_arg) +{ +} + +void +GMMEstimationStatement::writeOutput(ostream &output, const string &basename, bool minimal_workspace) const +{ + symbol_list.writeOutput("var_list_", output); + options_list.writeOutput(output); + output << "[M_, oo_, estim_params_, bayestopt_, dataset_, dataset_info] = " + << "GMM_SMM_estimation_core(var_list_, M_, options_, oo_, estim_params_, bayestopt_, dataset_, dataset_info, 'GMM');" << endl; +} + +void +GMMEstimationStatement::writeJsonOutput(ostream &output) const +{ + output << "{\"statementName\": \"gmm_estimation\""; + if (options_list.getNumberOfOptions()) + { + output << ", "; + options_list.writeJsonOutput(output); + } + if (!symbol_list.empty()) + { + output << ", "; + symbol_list.writeJsonOutput(output); + } + output << "}"; +} + +SMMEstimationStatement::SMMEstimationStatement(const SymbolList &symbol_list_arg, + const OptionsList &options_list_arg) : + symbol_list(symbol_list_arg), + options_list(options_list_arg) +{ +} + +void +SMMEstimationStatement::writeOutput(ostream &output, const string &basename, bool minimal_workspace) const +{ + symbol_list.writeOutput("var_list_", output); + options_list.writeOutput(output); + output << "[M_, oo_, estim_params_, bayestopt_, dataset_, dataset_info] = " + << "GMM_SMM_estimation_core(var_list_, M_, options_, oo_, estim_params_, bayestopt_, dataset_, dataset_info, 'SMM');" << endl; +} + +void +SMMEstimationStatement::writeJsonOutput(ostream &output) const +{ + output << "{\"statementName\": \"smm_estimation\""; + if (options_list.getNumberOfOptions()) + { + output << ", "; + options_list.writeJsonOutput(output); + } + if (!symbol_list.empty()) + { + output << ", "; + symbol_list.writeJsonOutput(output); + } + output << "}"; +} diff --git a/ComputingTasks.hh b/ComputingTasks.hh index bd58c215..37132114 100644 --- a/ComputingTasks.hh +++ b/ComputingTasks.hh @@ -1085,4 +1085,26 @@ public: virtual void writeJsonOutput(ostream &output) const; }; +class GMMEstimationStatement : public Statement +{ +private: + const SymbolList symbol_list; + const OptionsList options_list; +public: + GMMEstimationStatement(const SymbolList &symbol_list_arg, const OptionsList &options_list_arg); + virtual void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const; + virtual void writeJsonOutput(ostream &output) const; +}; + +class SMMEstimationStatement : public Statement +{ +private: + const SymbolList symbol_list; + const OptionsList options_list; +public: + SMMEstimationStatement(const SymbolList &symbol_list_arg, const OptionsList &options_list_arg); + virtual void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const; + virtual void writeJsonOutput(ostream &output) const; +}; + #endif diff --git a/DynareBison.yy b/DynareBison.yy index df616c75..2fe510d3 100644 --- a/DynareBison.yy +++ b/DynareBison.yy @@ -168,7 +168,7 @@ class ParsingDriver; %token SHOCK_DRAWS FREE_PARAMETERS MEDIAN DATA_OBS_NBR NEIGHBORHOOD_WIDTH PVALUE_KS PVALUE_CORR %token FILTERED_PROBABILITIES REAL_TIME_SMOOTHED PRIOR_FUNCTION POSTERIOR_FUNCTION SAMPLING_DRAWS %token PROPOSAL_TYPE PROPOSAL_UPPER_BOUND PROPOSAL_LOWER_BOUND PROPOSAL_DRAWS USE_MEAN_CENTER -%token ADAPTIVE_MH_DRAWS THINNING_FACTOR COEFFICIENTS_PRIOR_HYPERPARAMETERS +%token ADAPTIVE_MH_DRAWS THINNING_FACTOR COEFFICIENTS_PRIOR_HYPERPARAMETERS SMM_ESTIMATION GMM_ESTIMATION %token CONVERGENCE_STARTING_VALUE CONVERGENCE_ENDING_VALUE CONVERGENCE_INCREMENT_VALUE %token MAX_ITERATIONS_STARTING_VALUE MAX_ITERATIONS_INCREMENT_VALUE MAX_BLOCK_ITERATIONS %token MAX_REPEATED_OPTIMIZATION_RUNS FUNCTION_CONVERGENCE_CRITERION SAVE_REALTIME @@ -295,6 +295,8 @@ statement : parameters | perfect_foresight_solver | prior_function | posterior_function + | gmm_estimation + | smm_estimation | shock_groups ; @@ -1090,6 +1092,18 @@ perfect_foresight_solver_options : o_stack_solve_algo | o_pf_tolx ; +gmm_estimation : GMM_ESTIMATION '(' ')' ';' + { driver.gmm_estimation(); } + | GMM_ESTIMATION '(' ')' symbol_list ';' + { driver.gmm_estimation(); } + ; + +smm_estimation : SMM_ESTIMATION '(' ')' ';' + { driver.smm_estimation(); } + | SMM_ESTIMATION '(' ')' symbol_list ';' + { driver.smm_estimation(); } + ; + prior_function : PRIOR_FUNCTION '(' prior_posterior_function_options_list ')' ';' { driver.prior_posterior_function(true); } ; diff --git a/DynareFlex.ll b/DynareFlex.ll index 76e9686c..c8cbdf06 100644 --- a/DynareFlex.ll +++ b/DynareFlex.ll @@ -165,6 +165,8 @@ DATE -?[0-9]+([YyAa]|[Mm]([1-9]|1[0-2])|[Qq][1-4]|[Ww]([1-9]{1}|[1-4][0-9]|5[0-2 ms_variance_decomposition {BEGIN DYNARE_STATEMENT; return token::MS_VARIANCE_DECOMPOSITION;} conditional_forecast {BEGIN DYNARE_STATEMENT; return token::CONDITIONAL_FORECAST;} plot_conditional_forecast {BEGIN DYNARE_STATEMENT; return token::PLOT_CONDITIONAL_FORECAST;} +gmm_estimation {BEGIN DYNARE_STATEMENT; return token::GMM_ESTIMATION;} +smm_estimation {BEGIN DYNARE_STATEMENT; return token::SMM_ESTIMATION;} markov_switching {BEGIN DYNARE_STATEMENT; return token::MARKOV_SWITCHING;} svar {BEGIN DYNARE_STATEMENT; return token::SVAR;} diff --git a/ParsingDriver.cc b/ParsingDriver.cc index 41972786..41f8be66 100644 --- a/ParsingDriver.cc +++ b/ParsingDriver.cc @@ -2968,6 +2968,22 @@ ParsingDriver::perfect_foresight_solver() options_list.clear(); } +void +ParsingDriver::gmm_estimation() +{ + mod_file->addStatement(new GMMEstimationStatement(symbol_list, options_list)); + symbol_list.clear(); + options_list.clear(); +} + +void +ParsingDriver::smm_estimation() +{ + mod_file->addStatement(new SMMEstimationStatement(symbol_list, options_list)); + symbol_list.clear(); + options_list.clear(); +} + void ParsingDriver::prior_posterior_function(bool prior_func) { diff --git a/ParsingDriver.hh b/ParsingDriver.hh index 6a2da6ef..b0f2fb2b 100644 --- a/ParsingDriver.hh +++ b/ParsingDriver.hh @@ -761,6 +761,10 @@ public: void perfect_foresight_setup(); void perfect_foresight_solver(); void prior_posterior_function(bool prior_func); + //! GMM Estimation statement + void gmm_estimation(); + //! SMM Estimation statement + void smm_estimation(); }; #endif // ! PARSING_DRIVER_HH