New perfect_foresight_with_expectation_errors_{setup,solver} commands

var-models
Sébastien Villemot 2021-07-09 17:14:22 +02:00
parent 365fb27f3d
commit 6aeef11bb2
No known key found for this signature in database
GPG Key ID: 2CECE9350ECEBE4A
7 changed files with 128 additions and 2 deletions

View File

@ -232,6 +232,60 @@ PerfectForesightSolverStatement::writeJsonOutput(ostream &output) const
output << "}";
}
PerfectForesightWithExpectationErrorsSetupStatement::PerfectForesightWithExpectationErrorsSetupStatement(OptionsList options_list_arg) :
options_list{move(options_list_arg)}
{
}
void
PerfectForesightWithExpectationErrorsSetupStatement::writeOutput(ostream &output, const string &basename, bool minimal_workspace) const
{
options_list.writeOutput(output);
output << "perfect_foresight_with_expectation_errors_setup;" << endl;
}
void
PerfectForesightWithExpectationErrorsSetupStatement::writeJsonOutput(ostream &output) const
{
output << R"({"statementName": "perfect_foresight_with_expectation_errors_setup")";
if (options_list.getNumberOfOptions())
{
output << ", ";
options_list.writeJsonOutput(output);
}
output << "}";
}
PerfectForesightWithExpectationErrorsSolverStatement::PerfectForesightWithExpectationErrorsSolverStatement(OptionsList options_list_arg) :
options_list(move(options_list_arg))
{
}
void
PerfectForesightWithExpectationErrorsSolverStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings)
{
mod_file_struct.perfect_foresight_solver_present = true;
}
void
PerfectForesightWithExpectationErrorsSolverStatement::writeOutput(ostream &output, const string &basename, bool minimal_workspace) const
{
options_list.writeOutput(output);
output << "perfect_foresight_with_expectation_errors_solver;" << endl;
}
void
PerfectForesightWithExpectationErrorsSolverStatement::writeJsonOutput(ostream &output) const
{
output << R"({"statementName": "perfect_foresight_with_expectation_errors_solver")";
if (options_list.getNumberOfOptions())
{
output << ", ";
options_list.writeJsonOutput(output);
}
output << "}";
}
PriorPosteriorFunctionStatement::PriorPosteriorFunctionStatement(const bool prior_func_arg,
OptionsList options_list_arg) :
prior_func{prior_func_arg},

View File

@ -83,6 +83,27 @@ public:
void writeJsonOutput(ostream &output) const override;
};
class PerfectForesightWithExpectationErrorsSetupStatement : public Statement
{
private:
const OptionsList options_list;
public:
explicit PerfectForesightWithExpectationErrorsSetupStatement(OptionsList options_list_arg);
void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
void writeJsonOutput(ostream &output) const override;
};
class PerfectForesightWithExpectationErrorsSolverStatement : public Statement
{
private:
const OptionsList options_list;
public:
explicit PerfectForesightWithExpectationErrorsSolverStatement(OptionsList options_list_arg);
void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings) override;
void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
void writeJsonOutput(ostream &output) const override;
};
class PriorPosteriorFunctionStatement : public Statement
{
private:

View File

@ -110,6 +110,7 @@ class ParsingDriver;
%token DETERMINISTIC_TRENDS OBSERVATION_TRENDS OPTIM OPTIM_WEIGHTS ORDER OSR OSR_PARAMS MAX_DIM_COVA_GROUP ADVANCED OUTFILE OUTVARS OVERWRITE DISCOUNT OCCBIN
%token PARALLEL_LOCAL_FILES PARAMETERS PARAMETER_SET PARTIAL_INFORMATION PERIODS PERIOD PLANNER_OBJECTIVE PLOT_CONDITIONAL_FORECAST PLOT_PRIORS PREFILTER PRESAMPLE
%token PERFECT_FORESIGHT_SETUP PERFECT_FORESIGHT_SOLVER NO_POSTERIOR_KERNEL_DENSITY FUNCTION
%token PERFECT_FORESIGHT_WITH_EXPECTATION_ERRORS_SETUP PERFECT_FORESIGHT_WITH_EXPECTATION_ERRORS_SOLVER
%token PRINT PRIOR_MC PRIOR_TRUNC PRIOR_MODE PRIOR_MEAN POSTERIOR_MODE POSTERIOR_MEAN POSTERIOR_MEDIAN MLE_MODE PRUNING PARTICLE_FILTER_OPTIONS
%token <string> QUOTED_STRING
%token QZ_CRITERIUM QZ_ZERO_THRESHOLD DSGE_VAR DSGE_VARLAG DSGE_PRIOR_WEIGHT TRUNCATE PIPE_E PIPE_X PIPE_P
@ -166,7 +167,7 @@ class ParsingDriver;
%token PARAMETER_CONVERGENCE_CRITERION NUMBER_OF_LARGE_PERTURBATIONS NUMBER_OF_SMALL_PERTURBATIONS
%token NUMBER_OF_POSTERIOR_DRAWS_AFTER_PERTURBATION MAX_NUMBER_OF_STAGES
%token RANDOM_FUNCTION_CONVERGENCE_CRITERION RANDOM_PARAMETER_CONVERGENCE_CRITERION NO_INIT_ESTIMATION_CHECK_FIRST_OBS
%token HETEROSKEDASTIC_FILTER TIME_SHIFT STRUCTURAL
%token HETEROSKEDASTIC_FILTER TIME_SHIFT STRUCTURAL TERMINAL_STEADY_STATE_AS_GUESS_VALUE
/* Method of Moments */
%token METHOD_OF_MOMENTS MOM_METHOD
%token BARTLETT_KERNEL_LAG WEIGHTING_MATRIX WEIGHTING_MATRIX_SCALING_FACTOR ANALYTIC_STANDARD_ERRORS ANALYTIC_JACOBIAN PENALIZED_ESTIMATOR VERBOSE
@ -316,6 +317,8 @@ statement : parameters
| histval_file
| perfect_foresight_setup
| perfect_foresight_solver
| perfect_foresight_with_expectation_errors_setup
| perfect_foresight_with_expectation_errors_solver
| prior_function
| posterior_function
| method_of_moments
@ -1334,6 +1337,34 @@ perfect_foresight_solver_options : o_stack_solve_algo
| o_print
;
perfect_foresight_with_expectation_errors_setup : PERFECT_FORESIGHT_WITH_EXPECTATION_ERRORS_SETUP ';'
{ driver.perfect_foresight_with_expectation_errors_setup(); }
| PERFECT_FORESIGHT_WITH_EXPECTATION_ERRORS_SETUP '(' perfect_foresight_with_expectation_errors_setup_options_list ')' ';'
{ driver.perfect_foresight_with_expectation_errors_setup(); }
;
perfect_foresight_with_expectation_errors_setup_options_list : perfect_foresight_with_expectation_errors_setup_options_list COMMA perfect_foresight_with_expectation_errors_setup_options
| perfect_foresight_with_expectation_errors_setup_options
;
perfect_foresight_with_expectation_errors_setup_options : o_periods
| o_datafile
;
perfect_foresight_with_expectation_errors_solver : PERFECT_FORESIGHT_WITH_EXPECTATION_ERRORS_SOLVER ';'
{ driver.perfect_foresight_with_expectation_errors_solver(); }
| PERFECT_FORESIGHT_WITH_EXPECTATION_ERRORS_SOLVER '(' perfect_foresight_with_expectation_errors_solver_options_list ')' ';'
{ driver.perfect_foresight_with_expectation_errors_solver(); }
;
perfect_foresight_with_expectation_errors_solver_options_list : perfect_foresight_with_expectation_errors_solver_options_list COMMA perfect_foresight_solver_options
| perfect_foresight_with_expectation_errors_solver_options
;
perfect_foresight_with_expectation_errors_solver_options : o_pfwee_terminal_steady_state_as_guess_value
| perfect_foresight_solver_options
;
method_of_moments : METHOD_OF_MOMENTS ';'
{ driver.method_of_moments(); }
| METHOD_OF_MOMENTS '(' method_of_moments_options_list ')' ';'
@ -3798,6 +3829,7 @@ o_colormap : COLORMAP EQUAL symbol { driver.option_num("plot_shock_decomp.colorm
o_icd_colormap : COLORMAP EQUAL symbol { driver.option_num("initial_condition_decomp.colormap",$3); };
o_no_init_estimation_check_first_obs : NO_INIT_ESTIMATION_CHECK_FIRST_OBS { driver.option_num("no_init_estimation_check_first_obs", "true"); };
o_heteroskedastic_filter : HETEROSKEDASTIC_FILTER { driver.option_num("heteroskedastic_filter", "true"); };
o_pfwee_terminal_steady_state_as_guess_value : TERMINAL_STEADY_STATE_AS_GUESS_VALUE { driver.option_num("pfwee.terminal_steady_state_as_guess_value", "true"); };
// Some options to "method_of_moments"
o_bartlett_kernel_lag : BARTLETT_KERNEL_LAG EQUAL INT_NUMBER { driver.option_num("mom.bartlett_kernel_lag", $3); };

View File

@ -185,6 +185,8 @@ DATE -?[0-9]+([ya]|m([1-9]|1[0-2])|q[1-4])
<INITIAL>smoother2histval {BEGIN DYNARE_STATEMENT; return token::SMOOTHER2HISTVAL;}
<INITIAL>perfect_foresight_setup {BEGIN DYNARE_STATEMENT; return token::PERFECT_FORESIGHT_SETUP;}
<INITIAL>perfect_foresight_solver {BEGIN DYNARE_STATEMENT; return token::PERFECT_FORESIGHT_SOLVER;}
<INITIAL>perfect_foresight_with_expectation_errors_setup {BEGIN DYNARE_STATEMENT; return token::PERFECT_FORESIGHT_WITH_EXPECTATION_ERRORS_SETUP;}
<INITIAL>perfect_foresight_with_expectation_errors_solver {BEGIN DYNARE_STATEMENT; return token::PERFECT_FORESIGHT_WITH_EXPECTATION_ERRORS_SOLVER;}
<INITIAL>compilation_setup {BEGIN DYNARE_STATEMENT; return token::COMPILATION_SETUP;}
<DYNARE_STATEMENT>; {
@ -797,6 +799,7 @@ DATE -?[0-9]+([ya]|m([1-9]|1[0-2])|q[1-4])
<DYNARE_STATEMENT>irf_plot_threshold {return token::IRF_PLOT_THRESHOLD;}
<DYNARE_STATEMENT>no_homotopy {return token::NO_HOMOTOPY;}
<DYNARE_STATEMENT>particle_filter_options {return token::PARTICLE_FILTER_OPTIONS;}
<DYNARE_STATEMENT>terminal_steady_state_as_guess_value {return token::TERMINAL_STEADY_STATE_AS_GUESS_VALUE;}
<DYNARE_BLOCK>stderr_multiples {return token::STDERR_MULTIPLES;}
<DYNARE_BLOCK>diagonal_only {return token::DIAGONAL_ONLY;}

View File

@ -3186,6 +3186,20 @@ ParsingDriver::perfect_foresight_solver()
options_list.clear();
}
void
ParsingDriver::perfect_foresight_with_expectation_errors_setup()
{
mod_file->addStatement(make_unique<PerfectForesightWithExpectationErrorsSetupStatement>(options_list));
options_list.clear();
}
void
ParsingDriver::perfect_foresight_with_expectation_errors_solver()
{
mod_file->addStatement(make_unique<PerfectForesightWithExpectationErrorsSolverStatement>(options_list));
options_list.clear();
}
void
ParsingDriver::method_of_moments()
{

View File

@ -863,6 +863,8 @@ public:
void histval_file();
void perfect_foresight_setup();
void perfect_foresight_solver();
void perfect_foresight_with_expectation_errors_setup();
void perfect_foresight_with_expectation_errors_solver();
void prior_posterior_function(bool prior_func);
//! Method of Moments estimation statement
void method_of_moments();

View File

@ -36,7 +36,7 @@ public:
bool check_present{false};
//! Whether steady is present
bool steady_present{false};
//! Whether a perfect_foresight_solver/simul statement is present
//! Whether a perfect_foresight_solver/simul/perfect_foresight_with_expectation_errors_solver statement is present
bool perfect_foresight_solver_present{false};
//! Whether a stoch_simul statement is present
bool stoch_simul_present{false};