Commit 8c2e9b3c authored by Sébastien Villemot's avatar Sébastien Villemot
Browse files

Improvements to smoother2histval (ref #594)

- fix handling of auxiliary variables related to lagged endogenous
- add preprocessor interface
- add histval_file
- add tests (for smoother2histval with outfile, and for histval_file)
parent 491e70ab
......@@ -2822,3 +2822,15 @@ CorrOptionsStatement::writeCOutput(ostream &output, const string &basename)
output << "msdsgeinfo->addMeasurementErrorCorrOption(new ModFileMeasurementErrorCorrOption(";
output << "index, index1, init));" << endl;
}
Smoother2histvalStatement::Smoother2histvalStatement(const OptionsList &options_list_arg) :
options_list(options_list_arg)
{
}
void
Smoother2histvalStatement::writeOutput(ostream &output, const string &basename) const
{
options_list.writeOutput(output, "options_smoother2histval");
output << "smoother2histval(options_smoother2histval);" << endl;
}
/*
* Copyright (C) 2003-2012 Dynare Team
* Copyright (C) 2003-2014 Dynare Team
*
* This file is part of Dynare.
*
......@@ -846,4 +846,13 @@ public:
virtual void writeOutput(ostream &output, const string &basename) const;
};
class Smoother2histvalStatement : public Statement
{
private:
const OptionsList options_list;
public:
Smoother2histvalStatement(const OptionsList &options_list_arg);
virtual void writeOutput(ostream &output, const string &basename) const;
};
#endif
......@@ -97,8 +97,8 @@ class ParsingDriver;
%token DEFAULT FIXED_POINT
%token FORECAST K_ORDER_SOLVER INSTRUMENTS SHIFT MEAN STDEV VARIANCE MODE INTERVAL SHAPE DOMAINN
%token GAMMA_PDF GRAPH GRAPH_FORMAT CONDITIONAL_VARIANCE_DECOMPOSITION NOCHECK STD
%token HISTVAL HOMOTOPY_SETUP HOMOTOPY_MODE HOMOTOPY_STEPS HOMOTOPY_FORCE_CONTINUE HP_FILTER HP_NGRID HYBRID
%token IDENTIFICATION INF_CONSTANT INITVAL INITVAL_FILE BOUNDS JSCALE INIT
%token HISTVAL HISTVAL_FILE HOMOTOPY_SETUP HOMOTOPY_MODE HOMOTOPY_STEPS HOMOTOPY_FORCE_CONTINUE HP_FILTER HP_NGRID HYBRID
%token IDENTIFICATION INF_CONSTANT INITVAL INITVAL_FILE BOUNDS JSCALE INIT INFILE INVARS
%token <string_val> INT_NUMBER
%token INV_GAMMA_PDF INV_GAMMA1_PDF INV_GAMMA2_PDF IRF IRF_SHOCKS IRF_PLOT_THRESHOLD IRF_CALIBRATION
%token KALMAN_ALGO KALMAN_TOL SUBSAMPLES OPTIONS TOLF
......@@ -110,14 +110,14 @@ class ParsingDriver;
%token <string_val> NAME
%token NAN_CONSTANT NO_STATIC NOBS NOCONSTANT NODISPLAY NOCORR NODIAGNOSTIC NOFUNCTIONS
%token NOGRAPH NOMOMENTS NOPRINT NORMAL_PDF SAVE_DRAWS
%token OBSERVATION_TRENDS OPTIM OPTIM_WEIGHTS ORDER OSR OSR_PARAMS MAX_DIM_COVA_GROUP ADVANCED
%token PARALLEL_LOCAL_FILES PARAMETERS PARAMETER_SET PARTIAL_INFORMATION PERFECT_FORESIGHT PERIODS PLANNER_OBJECTIVE PLOT_CONDITIONAL_FORECAST PLOT_PRIORS PREFILTER PRESAMPLE
%token OBSERVATION_TRENDS OPTIM OPTIM_WEIGHTS ORDER OSR OSR_PARAMS MAX_DIM_COVA_GROUP ADVANCED OUTFILE OUTVARS
%token PARALLEL_LOCAL_FILES PARAMETERS PARAMETER_SET PARTIAL_INFORMATION PERFECT_FORESIGHT PERIODS PERIOD PLANNER_OBJECTIVE PLOT_CONDITIONAL_FORECAST PLOT_PRIORS PREFILTER PRESAMPLE
%token PRINT PRIOR_MC PRIOR_TRUNC PRIOR_MODE PRIOR_MEAN POSTERIOR_MODE POSTERIOR_MEAN POSTERIOR_MEDIAN PRUNING
%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 ENDOGENOUS_TERMINAL_PERIOD
%token SMOOTHER SQUARE_ROOT_SOLVER STACK_SOLVE_ALGO STEADY_STATE_MODEL SOLVE_ALGO SOLVER_PERIODS
%token SMOOTHER SMOOTHER2HISTVAL 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_MODEL RAMSEY_POLICY PLANNER_DISCOUNT DISCRETIONARY_POLICY DISCRETIONARY_TOL
%token <string_val> TEX_NAME
......@@ -270,6 +270,8 @@ statement : parameters
| model_diagnostics
| moment_calibration
| irf_calibration
| smoother2histval
| histval_file
;
dsample : DSAMPLE INT_NUMBER ';'
......@@ -623,6 +625,10 @@ histval_list : histval_list histval_elem
histval_elem : symbol '(' signed_integer ')' EQUAL expression ';' { driver.hist_val($1, $3, $6); };
histval_file : HISTVAL_FILE '(' FILENAME EQUAL filename ')' ';'
{ driver.histval_file($5); }
;
model_options : BLOCK { driver.block(); }
| o_cutoff
| o_mfs
......@@ -2390,6 +2396,23 @@ irf_calibration_item : symbol COMMA symbol COMMA calibration_range ';'
{ driver.add_irf_calibration_item($1, $3, $6, $8); }
;
smoother2histval : SMOOTHER2HISTVAL ';'
{ driver.smoother2histval(); }
| SMOOTHER2HISTVAL '(' smoother2histval_options_list ')' ';'
{ driver.smoother2histval(); }
;
smoother2histval_options_list : smoother2histval_option COMMA smoother2histval_options_list
| smoother2histval_option
;
smoother2histval_option : o_infile
| o_invars
| o_period
| o_outfile
| o_outvars
;
o_dr_algo : DR_ALGO EQUAL INT_NUMBER {
if (*$3 == string("0"))
driver.warning("dr_algo option is now deprecated, and may be removed in a future version of Dynare");
......@@ -2841,6 +2864,12 @@ o_irf_plot_threshold : IRF_PLOT_THRESHOLD EQUAL non_negative_number { driver.opt
o_consider_all_endogenous : CONSIDER_ALL_ENDOGENOUS { driver.option_str("endo_vars_for_moment_computations_in_estimation", "all_endogenous_variables"); };
o_consider_only_observed : CONSIDER_ONLY_OBSERVED { driver.option_str("endo_vars_for_moment_computations_in_estimation", "only_observed_variables"); };
o_infile : INFILE EQUAL filename { driver.option_str("infile", $3); };
o_invars : INVARS EQUAL '(' symbol_list ')' { driver.option_symbol_list("invars"); };
o_period : PERIOD EQUAL INT_NUMBER { driver.option_num("period", $3); };
o_outfile : OUTFILE EQUAL filename { driver.option_str("outfile", $3); };
o_outvars : OUTVARS EQUAL '(' symbol_list ')' { driver.option_symbol_list("outvars"); };
range : symbol ':' symbol
{
$1->append(":");
......
......@@ -146,6 +146,7 @@ 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>bvar_forecast {BEGIN DYNARE_STATEMENT; return token::BVAR_FORECAST; }
<INITIAL>dynare_sensitivity {BEGIN DYNARE_STATEMENT; return token::DYNARE_SENSITIVITY;}
<INITIAL>initval_file {BEGIN DYNARE_STATEMENT; return token::INITVAL_FILE;}
<INITIAL>histval_file {BEGIN DYNARE_STATEMENT; return token::HISTVAL_FILE;}
<INITIAL>forecast {BEGIN DYNARE_STATEMENT; return token::FORECAST;}
<INITIAL>shock_decomposition {BEGIN DYNARE_STATEMENT; return token::SHOCK_DECOMPOSITION;}
<INITIAL>sbvar {BEGIN DYNARE_STATEMENT; return token::SBVAR;}
......@@ -166,6 +167,7 @@ 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>calib_smoother { BEGIN DYNARE_STATEMENT; return token::CALIB_SMOOTHER; }
<INITIAL>model_diagnostics {BEGIN DYNARE_STATEMENT; return token::MODEL_DIAGNOSTICS;}
<INITIAL>extended_path {BEGIN DYNARE_STATEMENT; return token::EXTENDED_PATH;}
<INITIAL>smoother2histval {BEGIN DYNARE_STATEMENT; return token::SMOOTHER2HISTVAL;}
<DYNARE_STATEMENT>; {
if (!sigma_e)
......@@ -532,7 +534,11 @@ 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>long_name {return token::LONG_NAME;}
<DYNARE_STATEMENT>consider_all_endogenous {return token::CONSIDER_ALL_ENDOGENOUS;}
<DYNARE_STATEMENT>consider_only_observed {return token::CONSIDER_ONLY_OBSERVED;}
<DYNARE_STATEMENT>infile {return token::INFILE;}
<DYNARE_STATEMENT>invars {return token::INVARS;}
<DYNARE_STATEMENT>period {return token::PERIOD;}
<DYNARE_STATEMENT>outfile {return token::OUTFILE;}
<DYNARE_STATEMENT>outvars {return token::OUTVARS;}
<DYNARE_STATEMENT>[\$][^$]*[\$] {
strtok(yytext+1, "$");
......
......@@ -341,6 +341,17 @@ InitvalFileStatement::writeOutput(ostream &output, const string &basename) const
<< "initvalf('" << filename << "');" << endl;
}
HistvalFileStatement::HistvalFileStatement(const string &filename_arg) :
filename(filename_arg)
{
}
void
HistvalFileStatement::writeOutput(ostream &output, const string &basename) const
{
output << "histvalf('" << filename << "');" << endl;
}
HomotopyStatement::HomotopyStatement(const homotopy_values_t &homotopy_values_arg,
const SymbolTable &symbol_table_arg) :
homotopy_values(homotopy_values_arg),
......
/*
* Copyright (C) 2003-2012 Dynare Team
* Copyright (C) 2003-2014 Dynare Team
*
* This file is part of Dynare.
*
......@@ -122,6 +122,15 @@ public:
virtual void writeOutput(ostream &output, const string &basename) const;
};
class HistvalFileStatement : public Statement
{
private:
const string filename;
public:
HistvalFileStatement(const string &filename_arg);
virtual void writeOutput(ostream &output, const string &basename) const;
};
class HomotopyStatement : public Statement
{
public:
......
......@@ -2679,3 +2679,16 @@ void ParsingDriver::end_irf_calibration()
irf_calibration_constraints.clear();
}
void
ParsingDriver::smoother2histval()
{
mod_file->addStatement(new Smoother2histvalStatement(options_list));
options_list.clear();
}
void
ParsingDriver::histval_file(string *filename)
{
mod_file->addStatement(new HistvalFileStatement(*filename));
delete filename;
}
......@@ -665,6 +665,9 @@ public:
void add_irf_calibration_item(string *endo, string *periods, string *exo, vector<string *> *range);
//! End a moment_calibration statement
void end_irf_calibration();
void smoother2histval();
void histval_file(string *filename);
};
#endif // ! PARSING_DRIVER_HH
Markdown is supported
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