Commit e2d9f247 authored by ferhat's avatar ferhat
Browse files

The previous syntax used to call the conditional forecast using the extended...

The previous syntax used to call the conditional forecast using the extended path method was problematic. It does not allow to match the endogenous and the shock that are flipped. This is problematic as soon as the forecast periods are heterogeneous or the type of expectation (surprise or perfect foresight) are different. We get rid of the previous syntax.
parent 4d95aa8d
......@@ -89,7 +89,7 @@ class ParsingDriver;
%token BVAR_PRIOR_MU BVAR_PRIOR_OMEGA BVAR_PRIOR_TAU BVAR_PRIOR_TRAIN
%token BVAR_REPLIC BYTECODE ALL_VALUES_REQUIRED
%token CALIB_SMOOTHER CHANGE_TYPE CHECK CONDITIONAL_FORECAST CONDITIONAL_FORECAST_PATHS CONF_SIG CONSTANT CONTROLLED_VAREXO CORR COVAR CUTOFF CYCLE_REDUCTION LOGARITHMIC_REDUCTION
%token DATAFILE FILE DETERMINISTIC DOUBLING DR_CYCLE_REDUCTION_TOL DR_LOGARITHMIC_REDUCTION_TOL DR_LOGARITHMIC_REDUCTION_MAXITER DR_ALGO DROP DSAMPLE DYNASAVE DYNATYPE CALIBRATION DIFFERENTIATE_FORWARD_VARS
%token DATAFILE FILE DOUBLING DR_CYCLE_REDUCTION_TOL DR_LOGARITHMIC_REDUCTION_TOL DR_LOGARITHMIC_REDUCTION_MAXITER DR_ALGO DROP DSAMPLE DYNASAVE DYNATYPE CALIBRATION DIFFERENTIATE_FORWARD_VARS
%token END ENDVAL EQUAL ESTIMATION ESTIMATED_PARAMS ESTIMATED_PARAMS_BOUNDS ESTIMATED_PARAMS_INIT EXTENDED_PATH ENDOGENOUS_PRIOR
%token FILENAME FILTER_STEP_AHEAD FILTERED_VARS FIRST_OBS LAST_OBS SET_TIME
%token <string_val> FLOAT_NUMBER DATES
......@@ -115,8 +115,8 @@ class ParsingDriver;
%token <string_val> QUOTED_STRING
%token QZ_CRITERIUM QZ_ZERO_THRESHOLD FULL DSGE_VAR DSGE_VARLAG DSGE_PRIOR_WEIGHT TRUNCATE
%token RELATIVE_IRF REPLIC SIMUL_REPLIC RPLOT SAVE_PARAMS_AND_STEADY_STATE PARAMETER_UNCERTAINTY
%token SHOCKS SHOCK_DECOMPOSITION SIGMA_E SIMUL SIMUL_ALGO SIMUL_SEED SIMULATION_TYPE ENDOGENOUS_TERMINAL_PERIOD
%token SMOOTHER SQUARE_ROOT_SOLVER STACK_SOLVE_ALGO STEADY_STATE_MODEL STOCHASTIC SOLVE_ALGO SOLVER_PERIODS
%token SHOCKS SHOCK_DECOMPOSITION SIGMA_E SIMUL SIMUL_ALGO SIMUL_SEED ENDOGENOUS_TERMINAL_PERIOD
%token SMOOTHER SQUARE_ROOT_SOLVER STACK_SOLVE_ALGO STEADY_STATE_MODEL SOLVE_ALGO SOLVER_PERIODS
%token STDERR STEADY STOCH_SIMUL SURPRISE SYLVESTER SYLVESTER_FIXED_POINT_TOL REGIMES REGIME
%token TEX RAMSEY_POLICY PLANNER_DISCOUNT DISCRETIONARY_POLICY DISCRETIONARY_TOL
%token <string_val> TEX_NAME
......@@ -877,12 +877,6 @@ period_list : period_list COMMA INT_NUMBER
{ driver.add_period($1); }
;
expectation_type : PERFECT_FORESIGHT
{ driver.add_expectation_pf(true); }
| SURPRISE
{ driver.add_expectation_pf(false); }
;
sigma_e : SIGMA_E EQUAL '[' triangular_matrix ']' ';' { driver.do_sigma_e(); };
value_list : value_list COMMA '(' expression ')'
......@@ -2233,7 +2227,6 @@ conditional_forecast_option : o_periods
| o_conf_sig
| o_controlled_varexo
| o_parameter_set
| o_simulation_type
;
plot_conditional_forecast : PLOT_CONDITIONAL_FORECAST symbol_list ';'
......@@ -2252,8 +2245,6 @@ conditional_forecast_paths_shock_list : conditional_forecast_paths_shock_elem
conditional_forecast_paths_shock_elem : VAR symbol ';' PERIODS period_list ';' VALUES value_list ';'
{ driver.add_det_shock($2, true); }
| VAR symbol ';' PERIODS period_list ';' VALUES value_list ';' EXPECTATION expectation_type ';'
{ driver.add_det_shock($2, true); }
;
steady_state_model : STEADY_STATE_MODEL ';' { driver.begin_steady_state_model(); }
......@@ -2563,11 +2554,6 @@ o_parameter_set : PARAMETER_SET EQUAL PRIOR_MODE
| PARAMETER_SET EQUAL CALIBRATION
{ driver.option_str("parameter_set", "calibration"); }
;
o_simulation_type : SIMULATION_TYPE EQUAL DETERMINISTIC
{ driver.option_str("simulation_type", "deterministic"); }
| SIMULATION_TYPE EQUAL STOCHASTIC
{ driver.option_str("simulation_type", "stochastic"); }
;
o_ms_drop : DROP EQUAL INT_NUMBER { driver.option_num("ms.drop", $3); };
o_ms_mh_replic : MH_REPLIC EQUAL INT_NUMBER { driver.option_num("ms.mh_replic", $3); };
o_freq : FREQ EQUAL INT_NUMBER
......
......@@ -505,9 +505,6 @@ DATE -?[0-9]+([YyAa]|[Mm]([1-9]|1[0-2])|[Qq][1-4]|[Ww]([1-9]{1}|[1-4][0-9]|5[0-2
<DYNARE_STATEMENT>posterior_mode {return token::POSTERIOR_MODE; }
<DYNARE_STATEMENT>posterior_mean {return token::POSTERIOR_MEAN; }
<DYNARE_STATEMENT>posterior_median {return token::POSTERIOR_MEDIAN; }
<DYNARE_STATEMENT>simulation_type {return token::SIMULATION_TYPE; }
<DYNARE_STATEMENT>deterministic {return token::DETERMINISTIC; }
<DYNARE_STATEMENT>stochastic {return token::STOCHASTIC; }
<DYNARE_STATEMENT>k_order_solver {return token::K_ORDER_SOLVER; }
<DYNARE_STATEMENT>filter_covariance {return token::FILTER_COVARIANCE; }
<DYNARE_STATEMENT>filter_decomposition {return token::FILTER_DECOMPOSITION; }
......@@ -537,8 +534,6 @@ DATE -?[0-9]+([YyAa]|[Mm]([1-9]|1[0-2])|[Qq][1-4]|[Ww]([1-9]{1}|[1-4][0-9]|5[0-2
<DYNARE_BLOCK>stderr {return token::STDERR;}
<DYNARE_BLOCK>values {return token::VALUES;}
<DYNARE_BLOCK>corr {return token::CORR;}
<DYNARE_BLOCK>surprise {return token::SURPRISE;}
<DYNARE_BLOCK>perfect_foresight {return token::PERFECT_FORESIGHT;}
<DYNARE_BLOCK>periods {return token::PERIODS;}
<DYNARE_BLOCK>cutoff {return token::CUTOFF;}
<DYNARE_BLOCK>mfs {return token::MFS;}
......
......@@ -670,12 +670,10 @@ ParsingDriver::add_det_shock(string *var, bool conditional_forecast)
v.push_back(dse);
}
det_shocks[symb_id].first = v;
det_shocks[symb_id].second = det_shocks_expectation_pf;
det_shocks[symb_id] = v;
det_shocks_periods.clear();
det_shocks_values.clear();
det_shocks_expectation_pf = false;
delete var;
}
......@@ -795,12 +793,6 @@ ParsingDriver::add_value(string *v)
det_shocks_values.push_back(id);
}
void
ParsingDriver::add_expectation_pf(bool pf)
{
det_shocks_expectation_pf = pf;
}
void
ParsingDriver::begin_svar_identification()
{
......
......@@ -134,8 +134,6 @@ private:
vector<pair<int, int> > det_shocks_periods;
//! Temporary storage for values of deterministic shocks
vector<expr_t> det_shocks_values;
//! Temporary storage for perfect foresight of deterministic shocks in conditional forecast
bool det_shocks_expectation_pf;
//! Temporary storage for variances of shocks
ShocksStatement::var_and_std_shocks_t var_shocks;
//! Temporary storage for standard errors of shocks
......@@ -215,7 +213,7 @@ private:
bool nostrict;
public:
ParsingDriver(WarningConsolidation &warnings_arg, bool nostrict_arg) : det_shocks_expectation_pf(false), warnings(warnings_arg), nostrict(nostrict_arg) { };
ParsingDriver(WarningConsolidation &warnings_arg, bool nostrict_arg) : warnings(warnings_arg), nostrict(nostrict_arg) { };
//! Starts parsing, and constructs the MOD file representation
/*! The returned pointer should be deleted after use */
......@@ -347,8 +345,6 @@ public:
//! Adds a deterministic shock value
/*! \param v a string containing a (possibly negative) numeric constant */
void add_value(string *v);
//! Adds a expectation type for conditional forecast with deterministic simulation
void add_expectation_pf(bool pf);
//! Writes a Sigma_e block
void do_sigma_e();
//! Ends row of Sigma_e block
......
......@@ -44,11 +44,11 @@ AbstractShocksStatement::writeDetShocks(ostream &output) const
bool exo_det = (symbol_table.getType(it->first) == eExogenousDet);
int set_shocks_index = ((int) mshocks) + 2 * ((int) exo_det);
for (size_t i = 0; i < it->second.first.size(); i++)
for (size_t i = 0; i < it->second.size(); i++)
{
const int &period1 = it->second.first[i].period1;
const int &period2 = it->second.first[i].period2;
const expr_t value = it->second.first[i].value;
const int &period1 = it->second[i].period1;
const int &period2 = it->second[i].period2;
const expr_t value = it->second[i].value;
if (period1 == period2)
{
......@@ -339,7 +339,7 @@ ConditionalForecastPathsStatement::checkPass(ModFileStructure &mod_file_struct,
it != paths.end(); it++)
{
int this_path_length = 0;
const vector<AbstractShocksStatement::DetShockElement> &elems = it->second.first;
const vector<AbstractShocksStatement::DetShockElement> &elems = it->second;
for (int i = 0; i < (int) elems.size(); i++)
// Period1 < Period2, as enforced in ParsingDriver::add_period()
this_path_length = max(this_path_length, elems[i].period2);
......@@ -368,16 +368,14 @@ ConditionalForecastPathsStatement::writeOutput(ostream &output, const string &ba
if (it == paths.begin())
{
output << "constrained_vars_ = " << it->first +1 << ";" << endl;
output << "constrained_perfect_foresight_ = " << it->second.second << ";" << endl;
}
else
{
output << "constrained_vars_ = [constrained_vars_; " << it->first +1 << "];" << endl;
output << "constrained_perfect_foresight_ = [constrained_perfect_foresight_; " << it->second.second << "];" << endl;
}
const vector<AbstractShocksStatement::DetShockElement> &elems = it->second.first;
const vector<AbstractShocksStatement::DetShockElement> &elems = it->second;
for (int i = 0; i < (int) elems.size(); i++)
for (int j = elems[i].period1; j <= elems[i].period2; j++)
{
......
......@@ -41,7 +41,7 @@ public:
};
//The boolean element indicates if the shock is a surprise (false) or a perfect foresight (true) shock.
//This boolean is used only in case of conditional forecast with extended path method (simulation_type = deterministic).
typedef map<int, pair< vector<DetShockElement>, bool> > det_shocks_t;
typedef map<int, vector<DetShockElement> > det_shocks_t;
protected:
//! Is this statement a "mshocks" statement ? (instead of a "shocks" statement)
const bool mshocks;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment