preprocessor: add basic gmm smm statements, add options later. #1530
parent
6c9c01fe09
commit
51ee883f21
|
@ -4423,3 +4423,69 @@ Smoother2histvalStatement::writeJsonOutput(ostream &output) const
|
||||||
}
|
}
|
||||||
output << "}";
|
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 << "}";
|
||||||
|
}
|
||||||
|
|
|
@ -1085,4 +1085,26 @@ public:
|
||||||
virtual void writeJsonOutput(ostream &output) const;
|
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
|
#endif
|
||||||
|
|
|
@ -168,7 +168,7 @@ class ParsingDriver;
|
||||||
%token SHOCK_DRAWS FREE_PARAMETERS MEDIAN DATA_OBS_NBR NEIGHBORHOOD_WIDTH PVALUE_KS PVALUE_CORR
|
%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 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 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 CONVERGENCE_STARTING_VALUE CONVERGENCE_ENDING_VALUE CONVERGENCE_INCREMENT_VALUE
|
||||||
%token MAX_ITERATIONS_STARTING_VALUE MAX_ITERATIONS_INCREMENT_VALUE MAX_BLOCK_ITERATIONS
|
%token MAX_ITERATIONS_STARTING_VALUE MAX_ITERATIONS_INCREMENT_VALUE MAX_BLOCK_ITERATIONS
|
||||||
%token MAX_REPEATED_OPTIMIZATION_RUNS FUNCTION_CONVERGENCE_CRITERION SAVE_REALTIME
|
%token MAX_REPEATED_OPTIMIZATION_RUNS FUNCTION_CONVERGENCE_CRITERION SAVE_REALTIME
|
||||||
|
@ -295,6 +295,8 @@ statement : parameters
|
||||||
| perfect_foresight_solver
|
| perfect_foresight_solver
|
||||||
| prior_function
|
| prior_function
|
||||||
| posterior_function
|
| posterior_function
|
||||||
|
| gmm_estimation
|
||||||
|
| smm_estimation
|
||||||
| shock_groups
|
| shock_groups
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -1090,6 +1092,18 @@ perfect_foresight_solver_options : o_stack_solve_algo
|
||||||
| o_pf_tolx
|
| 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 ')' ';'
|
prior_function : PRIOR_FUNCTION '(' prior_posterior_function_options_list ')' ';'
|
||||||
{ driver.prior_posterior_function(true); }
|
{ driver.prior_posterior_function(true); }
|
||||||
;
|
;
|
||||||
|
|
|
@ -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
|
||||||
<INITIAL>ms_variance_decomposition {BEGIN DYNARE_STATEMENT; return token::MS_VARIANCE_DECOMPOSITION;}
|
<INITIAL>ms_variance_decomposition {BEGIN DYNARE_STATEMENT; return token::MS_VARIANCE_DECOMPOSITION;}
|
||||||
<INITIAL>conditional_forecast {BEGIN DYNARE_STATEMENT; return token::CONDITIONAL_FORECAST;}
|
<INITIAL>conditional_forecast {BEGIN DYNARE_STATEMENT; return token::CONDITIONAL_FORECAST;}
|
||||||
<INITIAL>plot_conditional_forecast {BEGIN DYNARE_STATEMENT; return token::PLOT_CONDITIONAL_FORECAST;}
|
<INITIAL>plot_conditional_forecast {BEGIN DYNARE_STATEMENT; return token::PLOT_CONDITIONAL_FORECAST;}
|
||||||
|
<INITIAL>gmm_estimation {BEGIN DYNARE_STATEMENT; return token::GMM_ESTIMATION;}
|
||||||
|
<INITIAL>smm_estimation {BEGIN DYNARE_STATEMENT; return token::SMM_ESTIMATION;}
|
||||||
|
|
||||||
<INITIAL>markov_switching {BEGIN DYNARE_STATEMENT; return token::MARKOV_SWITCHING;}
|
<INITIAL>markov_switching {BEGIN DYNARE_STATEMENT; return token::MARKOV_SWITCHING;}
|
||||||
<INITIAL>svar {BEGIN DYNARE_STATEMENT; return token::SVAR;}
|
<INITIAL>svar {BEGIN DYNARE_STATEMENT; return token::SVAR;}
|
||||||
|
|
|
@ -2968,6 +2968,22 @@ ParsingDriver::perfect_foresight_solver()
|
||||||
options_list.clear();
|
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
|
void
|
||||||
ParsingDriver::prior_posterior_function(bool prior_func)
|
ParsingDriver::prior_posterior_function(bool prior_func)
|
||||||
{
|
{
|
||||||
|
|
|
@ -761,6 +761,10 @@ public:
|
||||||
void perfect_foresight_setup();
|
void perfect_foresight_setup();
|
||||||
void perfect_foresight_solver();
|
void perfect_foresight_solver();
|
||||||
void prior_posterior_function(bool prior_func);
|
void prior_posterior_function(bool prior_func);
|
||||||
|
//! GMM Estimation statement
|
||||||
|
void gmm_estimation();
|
||||||
|
//! SMM Estimation statement
|
||||||
|
void smm_estimation();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ! PARSING_DRIVER_HH
|
#endif // ! PARSING_DRIVER_HH
|
||||||
|
|
Loading…
Reference in New Issue