Add new command "calib_smoother"

Closes: #233
issue#70
Sébastien Villemot 2012-05-30 16:28:00 +02:00
parent 78bd465294
commit 381c6aeee8
6 changed files with 59 additions and 1 deletions

View File

@ -2300,3 +2300,19 @@ OptionsEqualStatement::writeOutput(ostream &output, const string &basename) cons
output << lhs_field << " = " << rhs_field << ";" << endl;
}
CalibSmootherStatement::CalibSmootherStatement(const SymbolList &symbol_list_arg,
const OptionsList &options_list_arg)
: symbol_list(symbol_list_arg), options_list(options_list_arg)
{
}
void
CalibSmootherStatement::writeOutput(ostream &output, const string &basename) const
{
options_list.writeOutput(output);
symbol_list.writeOutput("var_list_", output);
output << "options_.mode_compute = 0;" << endl
<< "options_.smoother = 1;" << endl
<< "dynare_estimation(var_list_);" << endl;
}

View File

@ -508,6 +508,17 @@ public:
virtual void writeOutput(ostream &output, const string &basename) const;
};
class CalibSmootherStatement : public Statement
{
private:
const SymbolList symbol_list;
const OptionsList options_list;
public:
CalibSmootherStatement(const SymbolList &symbol_list_arg,
const OptionsList &options_list_arg);
virtual void writeOutput(ostream &output, const string &basename) const;
};
class SvarIdentificationStatement : public Statement
{
public:

View File

@ -95,7 +95,7 @@ class ParsingDriver;
%token BVAR_PRIOR_DECAY BVAR_PRIOR_FLAT BVAR_PRIOR_LAMBDA
%token BVAR_PRIOR_MU BVAR_PRIOR_OMEGA BVAR_PRIOR_TAU BVAR_PRIOR_TRAIN
%token BVAR_REPLIC BYTECODE
%token CHANGE_TYPE CHECK CONDITIONAL_FORECAST CONDITIONAL_FORECAST_PATHS CONF_SIG CONSTANT CONTROLLED_VAREXO CORR COVAR CUTOFF
%token CALIB_SMOOTHER CHANGE_TYPE CHECK CONDITIONAL_FORECAST CONDITIONAL_FORECAST_PATHS CONF_SIG CONSTANT CONTROLLED_VAREXO CORR COVAR CUTOFF
%token DATAFILE FILE DOUBLING DR_ALGO DROP DSAMPLE DYNASAVE DYNATYPE CALIBRATION
%token END ENDVAL EQUAL ESTIMATION ESTIMATED_PARAMS ESTIMATED_PARAMS_BOUNDS ESTIMATED_PARAMS_INIT
%token FILENAME FILTER_STEP_AHEAD FILTERED_VARS FIRST_OBS LAST_OBS SET_TIME
@ -268,6 +268,7 @@ statement : parameters
| ms_forecast
| ms_irf
| ms_variance_decomposition
| calib_smoother
;
dsample : DSAMPLE INT_NUMBER ';'
@ -2113,6 +2114,25 @@ steady_state_equation : symbol EQUAL expression ';'
{ driver.add_steady_state_model_equal_multiple($5); }
;
calib_smoother : CALIB_SMOOTHER ';'
{ driver.calib_smoother(); }
| CALIB_SMOOTHER '(' calib_smoother_options_list ')' ';'
{ driver.calib_smoother(); }
| CALIB_SMOOTHER symbol_list ';'
{ driver.calib_smoother(); }
| CALIB_SMOOTHER '(' calib_smoother_options_list ')' symbol_list ';'
{ driver.calib_smoother(); }
;
calib_smoother_options_list : calib_smoother_option COMMA calib_smoother_options_list
| calib_smoother_option
;
calib_smoother_option : o_filtered_vars
| o_filter_step_ahead
| o_datafile
;
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");

View File

@ -156,6 +156,7 @@ string eofbuff;
<INITIAL>svar {BEGIN DYNARE_STATEMENT; return token::SVAR;}
<INITIAL>external_function {BEGIN DYNARE_STATEMENT; return token::EXTERNAL_FUNCTION;}
/* End of a Dynare statement */
<INITIAL>calib_smoother { BEGIN DYNARE_STATEMENT; return token::CALIB_SMOOTHER; }
<DYNARE_STATEMENT>; {
if (!sigma_e)

View File

@ -1932,6 +1932,14 @@ ParsingDriver::conditional_forecast_paths()
det_shocks.clear();
}
void
ParsingDriver::calib_smoother()
{
mod_file->addStatement(new CalibSmootherStatement(symbol_list, options_list));
symbol_list.clear();
options_list.clear();
}
expr_t
ParsingDriver::add_model_equal(expr_t arg1, expr_t arg2)
{

View File

@ -514,6 +514,8 @@ public:
void conditional_forecast_paths();
//! Plot conditional forecast statement
void plot_conditional_forecast(string *periods = NULL);
//! Smoother on calibrated models
void calib_smoother();
//! Writes token "arg1=arg2" to model tree
expr_t add_model_equal(expr_t arg1, expr_t arg2);
//! Writes token "arg=0" to model tree