v4 parser: added code for estimated_params_init and estimated_params_bounds

git-svn-id: https://www.dynare.org/svn/dynare/dynare_v4@499 ac1d8469-bf42-47a9-8791-bf33cf982152
time-shift
michel 2005-10-17 19:55:03 +00:00
parent 93ac640dec
commit ef17942b99
5 changed files with 121 additions and 1 deletions

View File

@ -131,7 +131,7 @@ void ComputingTasks::setEstimatedElements(void)
{
if (!SymbolTable::Exist(EstimParams->name))
{
string msg = "Unknown symbol : "+EstimParams->name;
string msg = "Unknown symbol: "+EstimParams->name;
error(msg.c_str());
}
if (SymbolTable::isReferenced(EstimParams->name) == eNotReferenced)
@ -178,6 +178,110 @@ void ComputingTasks::setEstimatedElements(void)
EstimParams->p3 << " " << EstimParams->p4 << " " << EstimParams->jscale << "];\n";
EstimParams->clear();
}
//------------------------------------------------------------------------------
void ComputingTasks::setEstimatedInitElements(void)
{
if (!SymbolTable::Exist(EstimParams->name))
{
string msg = "Unknown symbol: "+EstimParams->name;
error(msg.c_str());
}
if (SymbolTable::isReferenced(EstimParams->name) == eNotReferenced)
{
return;
}
if ((EstimParams->init_val).size() == 0)
{
EstimParams->init_val = EstimParams->mean;
}
if (EstimParams->type < 3)
{
if( SymbolTable::getType(EstimParams->name) == eExogenous)
{
*output << "tmp1 = find(estim_params_.var_exo(:,1)==" << SymbolTable::getID(EstimParams->name)+1 << ");\n";
*output << "estim_params_.var_exo(tmp1,2) = " << EstimParams->init_val << ";\n";
}
else if ( SymbolTable::getType(EstimParams->name) == eEndogenous)
{
*output << "tmp1 = find(estim_params_.var_endo(:,1)==" << SymbolTable::getID(EstimParams->name)+1 << ");\n";
*output << "estim_params_.var_endo(tmp1,2) = " << EstimParams->init_val << ";\n";
}
else if ( SymbolTable::getType(EstimParams->name) == eParameter)
{
*output << "tmp1 = find(estim_params_.param_vals(:,1)==" << SymbolTable::getID(EstimParams->name)+1 << ");\n";
*output << "estim_params_.param_vals(tmp1,2) = " << EstimParams->init_val << ";\n";
}
}
else
{
if( SymbolTable::getType(EstimParams->name) == eExogenous)
{
*output << "tmp1 = find((estim_params_.corrx(:,1)==" << SymbolTable::getID(EstimParams->name)+1 << ")) & (estim_params_.corrx(:,2)==SymbolTable::getID(EstimParams->name2)+1);\n";
*output << "estim_params_.corrx(tmp1,3) = " << EstimParams->init_val << ";\n";
}
else if ( SymbolTable::getType(EstimParams->name) == eEndogenous)
{
*output << "tmp1 = find((estim_params_.corrn(:,1)==" << SymbolTable::getID(EstimParams->name)+1 << ")) & (estim_params_.corrn(:,2)==" << SymbolTable::getID(EstimParams->name2)+1 << ";\n";
*output << "estim_params_.corrx(tmp1,3) = " << EstimParams->init_val << ";\n";
}
}
EstimParams->clear();
}
//------------------------------------------------------------------------------
void ComputingTasks::setEstimatedBoundsElements(void)
{
if (!SymbolTable::Exist(EstimParams->name))
{
string msg = "Unknown symbol: "+EstimParams->name;
error(msg.c_str());
}
if (SymbolTable::isReferenced(EstimParams->name) == eNotReferenced)
{
return;
}
if ((EstimParams->init_val).size() == 0)
{
EstimParams->init_val = EstimParams->mean;
}
if (EstimParams->type < 3)
{
if( SymbolTable::getType(EstimParams->name) == eExogenous)
{
*output << "tmp1 = find(estim_params_.var_exo(:,1)==" << SymbolTable::getID(EstimParams->name)+1 << ");\n";
*output << "estim_params_.var_exo(tmp1,3) = " << EstimParams->low_bound << ";\n";
*output << "estim_params_.var_exo(tmp1,4) = " << EstimParams->up_bound << ";\n";
}
else if ( SymbolTable::getType(EstimParams->name) == eEndogenous)
{
*output << "tmp1 = find(estim_params_.var_endo(:,1)==" << SymbolTable::getID(EstimParams->name)+1 << ");\n";
*output << "estim_params_.var_endo(tmp1,3) = " << EstimParams->low_bound << ";\n";
*output << "estim_params_.var_endo(tmp1,4) = " << EstimParams->up_bound << ";\n";
}
else if ( SymbolTable::getType(EstimParams->name) == eParameter)
{
*output << "tmp1 = find(estim_params_.param_vals(:,1)==" << SymbolTable::getID(EstimParams->name)+1 << ");\n";
*output << "estim_params_.param_vals(tmp1,3) = " << EstimParams->low_bound << ";\n";
*output << "estim_params_.param_vals(tmp1,4) = " << EstimParams->up_bound << ";\n";
}
}
else
{
if( SymbolTable::getType(EstimParams->name) == eExogenous)
{
*output << "tmp1 = find((estim_params_.corrx(:,1)==" << SymbolTable::getID(EstimParams->name)+1 << ")) & (estim_params_.corrx(:,2)==SymbolTable::getID(EstimParams->name2)+1);\n";
*output << "estim_params_.corrx(tmp1,4) = " << EstimParams->low_bound << ";\n";
*output << "estim_params_.corrx(tmp1,5) = " << EstimParams->up_bound << ";\n";
}
else if ( SymbolTable::getType(EstimParams->name) == eEndogenous)
{
*output << "tmp1 = find((estim_params_.corrn(:,1)==" << SymbolTable::getID(EstimParams->name)+1 << ")) & (estim_params_.corrn(:,2)==" << SymbolTable::getID(EstimParams->name2)+1 << ";\n";
*output << "estim_params_.corrx(tmp1,4) = " << EstimParams->low_bound << ";\n";
*output << "estim_params_.corrx(tmp1,5) = " << EstimParams->up_bound << ";\n";
}
}
EstimParams->clear();
}
//-----------------------------------------------------------------------
void ComputingTasks::set_trend_element (string name, string expression)
{
//Testing if symbol exists

View File

@ -643,7 +643,9 @@
;
estimated_init_list : estimated_init_list estimated_init_elem
{_parser->set_estimated_init_elements();}
| estimated_init_elem
{_parser->set_estimated_init_elements();}
;
estimated_init_elem : STDERR NAME COMMA value ';'
@ -668,7 +670,9 @@
;
estimated_bounds_list : estimated_bounds_list estimated_bounds_elem
{_parser->set_estimated_bounds_elements();}
| estimated_bounds_elem
{_parser->set_estimated_bounds_elements();}
;
estimated_bounds_elem : STDERR NAME COMMA value COMMA value ';'

View File

@ -463,6 +463,14 @@ void dynare::parser::set_estimated_elements(void)
{
computing_tasks.setEstimatedElements();
}
void dynare::parser::set_estimated_init_elements(void)
{
computing_tasks.setEstimatedInitElements();
}
void dynare::parser::set_estimated_bounds_elements(void)
{
computing_tasks.setEstimatedBoundsElements();
}
void dynare::parser::set_unit_root_vars()
{
tmp_symbol_table.set("options_.unit_root_vars");

View File

@ -98,6 +98,8 @@ class ComputingTasks
void setOptimOptions(std::string str1, std::string str2, int task);
/*! Prints estimated elements */
void setEstimatedElements(void);
void setEstimatedInitElements(void);
void setEstimatedBoundsElements(void);
void setEstimationStandardError(void);
void set_trend_element(std::string, std::string);

View File

@ -223,6 +223,8 @@ namespace dynare
void estimation_init(void);
/*! Writes instructions for estimated elements */
void set_estimated_elements(void);
void set_estimated_init_elements(void);
void set_estimated_bounds_elements(void);
/*! Runs estimation process */
void run_estimation(void);
/*! Prints optimization options */