Commit 611f4f5d authored by Houtan Bastani's avatar Houtan Bastani
Browse files

preprocessor: add use_calibration option for estimated_params_init block. closes #447, closes #512

parent 0fdc18e7
......@@ -4169,6 +4169,7 @@ end;
@end deffn
@deffn Block estimated_params_init ;
@deffnx Block estimated_params_init (@var{OPTIONS}@dots{});
This block declares numerical initial values for the optimizer when
these ones are different from the prior mean.
......@@ -4180,6 +4181,14 @@ stderr VARIABLE_NAME | corr VARIABLE_NAME_1, VARIABLE_NAME_2 | PARAMETER_NAME
, INITIAL_VALUE;
@end example
@optionshead
@table @code
@item use_calibration
Use the parameters from calibration as starting values for estimation.
@end table
@xref{estimated_params}, for the meaning and syntax of the various components.
@end deffn
......
......@@ -581,15 +581,20 @@ EstimatedParamsStatement::writeOutput(ostream &output, const string &basename) c
}
EstimatedParamsInitStatement::EstimatedParamsInitStatement(const vector<EstimationParams> &estim_params_list_arg,
const SymbolTable &symbol_table_arg) :
const SymbolTable &symbol_table_arg,
const bool use_calibration_arg) :
estim_params_list(estim_params_list_arg),
symbol_table(symbol_table_arg)
symbol_table(symbol_table_arg),
use_calibration(use_calibration_arg)
{
}
void
EstimatedParamsInitStatement::writeOutput(ostream &output, const string &basename) const
{
if (use_calibration)
output << "options_.use_calibration_initialization = 1;" << endl;
vector<EstimationParams>::const_iterator it;
for (it = estim_params_list.begin(); it != estim_params_list.end(); it++)
......
......@@ -290,9 +290,11 @@ class EstimatedParamsInitStatement : public Statement
private:
const vector<EstimationParams> estim_params_list;
const SymbolTable &symbol_table;
const bool use_calibration;
public:
EstimatedParamsInitStatement(const vector<EstimationParams> &estim_params_list_arg,
const SymbolTable &symbol_table_arg);
const SymbolTable &symbol_table_arg,
const bool use_calibration_arg);
virtual void writeOutput(ostream &output, const string &basename) const;
};
......
......@@ -90,7 +90,7 @@ class ParsingDriver;
%}
%token AIM_SOLVER ANALYTIC_DERIVATION AR AUTOCORR
%token BAYESIAN_IRF BETA_PDF BLOCK
%token BAYESIAN_IRF BETA_PDF BLOCK USE_CALIBRATION
%token BVAR_DENSITY BVAR_FORECAST
%token BVAR_PRIOR_DECAY BVAR_PRIOR_FLAT BVAR_PRIOR_LAMBDA
%token BVAR_PRIOR_MU BVAR_PRIOR_OMEGA BVAR_PRIOR_TAU BVAR_PRIOR_TRAIN
......@@ -1141,7 +1141,10 @@ estimated_elem3 : expression_or_empty COMMA expression_or_empty
;
estimated_params_init : ESTIMATED_PARAMS_INIT ';' estimated_init_list END ';'
{ driver.estimated_params_init(); };
{ driver.estimated_params_init(); }
| ESTIMATED_PARAMS_INIT '(' USE_CALIBRATION ')' ';' estimated_init_list END ';'
{ driver.estimated_params_init(true); }
;
estimated_init_list : estimated_init_list estimated_init_elem
{ driver.add_estimated_params_element(); }
......
......@@ -395,7 +395,7 @@ string eofbuff;
return token::CNUM;
}
<DYNARE_STATEMENT>banact {return token::BANACT;}
<DYNARE_BLOCK>use_calibration {return token::USE_CALIBRATION;}
<DYNARE_STATEMENT>output_file_tag {return token::OUTPUT_FILE_TAG;}
<DYNARE_STATEMENT>file_tag {return token::FILE_TAG;};
<DYNARE_STATEMENT>no_create_init {return token::NO_CREATE_INIT;};
......
......@@ -1209,9 +1209,9 @@ ParsingDriver::estimated_params()
}
void
ParsingDriver::estimated_params_init()
ParsingDriver::estimated_params_init(bool use_calibration)
{
mod_file->addStatement(new EstimatedParamsInitStatement(estim_params_list, mod_file->symbol_table));
mod_file->addStatement(new EstimatedParamsInitStatement(estim_params_list, mod_file->symbol_table, use_calibration));
estim_params_list.clear();
}
......
......@@ -391,7 +391,7 @@ public:
//! Writes estimated params command
void estimated_params();
//! Writes estimated params init command
void estimated_params_init();
void estimated_params_init(bool use_calibration = false);
//! Writes estimated params bound command
void estimated_params_bounds();
//! Adds a declaration for a user-defined external function
......
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