2008-01-11 14:42:14 +01:00
|
|
|
/*
|
2011-01-10 12:25:42 +01:00
|
|
|
* Copyright (C) 2003-2011 Dynare Team
|
2008-01-11 14:42:14 +01:00
|
|
|
*
|
|
|
|
* This file is part of Dynare.
|
|
|
|
*
|
|
|
|
* Dynare is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* Dynare is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
2006-11-05 00:31:17 +01:00
|
|
|
*/
|
2008-01-11 14:42:14 +01:00
|
|
|
|
2008-06-28 13:20:45 +02:00
|
|
|
#include <cstdlib>
|
2009-04-28 18:21:39 +02:00
|
|
|
#include <cassert>
|
2006-11-05 00:31:17 +01:00
|
|
|
#include <iostream>
|
|
|
|
#include <sstream>
|
|
|
|
|
|
|
|
using namespace std;
|
2006-12-12 12:54:30 +01:00
|
|
|
|
2006-11-05 00:31:17 +01:00
|
|
|
#include "ComputingTasks.hh"
|
2006-12-12 12:54:30 +01:00
|
|
|
#include "Statement.hh"
|
|
|
|
|
2009-09-02 15:36:56 +02:00
|
|
|
SteadyStatement::SteadyStatement(const OptionsList &options_list_arg) :
|
|
|
|
options_list(options_list_arg)
|
2006-12-12 12:54:30 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2009-06-30 17:07:09 +02:00
|
|
|
void
|
|
|
|
SteadyStatement::checkPass(ModFileStructure &mod_file_struct)
|
|
|
|
{
|
2010-01-08 12:06:25 +01:00
|
|
|
mod_file_struct.steady_present = true;
|
2009-06-30 17:07:09 +02:00
|
|
|
}
|
|
|
|
|
2006-12-12 12:54:30 +01:00
|
|
|
void
|
2006-12-19 00:28:52 +01:00
|
|
|
SteadyStatement::writeOutput(ostream &output, const string &basename) const
|
2006-12-12 12:54:30 +01:00
|
|
|
{
|
|
|
|
options_list.writeOutput(output);
|
|
|
|
output << "steady;\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
CheckStatement::CheckStatement(const OptionsList &options_list_arg) :
|
|
|
|
options_list(options_list_arg)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-12-19 00:28:52 +01:00
|
|
|
CheckStatement::writeOutput(ostream &output, const string &basename) const
|
2006-11-05 00:31:17 +01:00
|
|
|
{
|
2006-12-12 12:54:30 +01:00
|
|
|
options_list.writeOutput(output);
|
2011-09-17 12:51:36 +02:00
|
|
|
output << "check(M_,options_,oo_);\n";
|
2006-11-05 00:31:17 +01:00
|
|
|
}
|
|
|
|
|
2006-12-17 15:59:39 +01:00
|
|
|
void
|
|
|
|
CheckStatement::checkPass(ModFileStructure &mod_file_struct)
|
|
|
|
{
|
|
|
|
mod_file_struct.check_present = true;
|
|
|
|
}
|
|
|
|
|
2008-08-29 14:31:25 +02:00
|
|
|
ModelInfoStatement::ModelInfoStatement(const OptionsList &options_list_arg) :
|
2008-08-25 17:06:36 +02:00
|
|
|
options_list(options_list_arg)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2009-12-16 18:13:23 +01:00
|
|
|
void
|
|
|
|
ModelInfoStatement::checkPass(ModFileStructure &mod_file_struct)
|
2008-08-25 17:06:36 +02:00
|
|
|
{
|
2008-08-28 15:20:34 +02:00
|
|
|
//mod_file_struct.model_info_present = true;
|
2008-08-25 17:06:36 +02:00
|
|
|
}
|
|
|
|
|
2009-12-16 18:13:23 +01:00
|
|
|
void
|
|
|
|
ModelInfoStatement::writeOutput(ostream &output, const string &basename) const
|
2008-08-25 17:06:36 +02:00
|
|
|
{
|
|
|
|
options_list.writeOutput(output);
|
|
|
|
output << "model_info();\n";
|
|
|
|
}
|
|
|
|
|
2009-09-02 18:44:15 +02:00
|
|
|
SimulStatement::SimulStatement(const OptionsList &options_list_arg) :
|
|
|
|
options_list(options_list_arg)
|
2006-11-05 00:31:17 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2006-12-15 12:44:58 +01:00
|
|
|
void
|
|
|
|
SimulStatement::checkPass(ModFileStructure &mod_file_struct)
|
|
|
|
{
|
|
|
|
mod_file_struct.simul_present = true;
|
|
|
|
}
|
|
|
|
|
2006-12-12 12:54:30 +01:00
|
|
|
void
|
2006-12-19 00:28:52 +01:00
|
|
|
SimulStatement::writeOutput(ostream &output, const string &basename) const
|
2006-11-05 00:31:17 +01:00
|
|
|
{
|
2006-12-12 12:54:30 +01:00
|
|
|
options_list.writeOutput(output);
|
2010-09-24 11:07:43 +02:00
|
|
|
output << "simul();\n";
|
2007-02-22 00:28:16 +01:00
|
|
|
}
|
|
|
|
|
2008-04-07 15:14:40 +02:00
|
|
|
StochSimulStatement::StochSimulStatement(const SymbolList &symbol_list_arg,
|
2009-09-02 18:44:15 +02:00
|
|
|
const OptionsList &options_list_arg) :
|
2008-04-07 15:14:40 +02:00
|
|
|
symbol_list(symbol_list_arg),
|
2009-09-02 18:44:15 +02:00
|
|
|
options_list(options_list_arg)
|
2006-11-05 00:31:17 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2006-12-15 12:44:58 +01:00
|
|
|
void
|
|
|
|
StochSimulStatement::checkPass(ModFileStructure &mod_file_struct)
|
|
|
|
{
|
2008-09-29 12:16:13 +02:00
|
|
|
mod_file_struct.stoch_simul_present = true;
|
2007-02-08 12:56:46 +01:00
|
|
|
|
|
|
|
// Fill in option_order of mod_file_struct
|
2010-09-16 19:00:48 +02:00
|
|
|
OptionsList::num_options_t::const_iterator it = options_list.num_options.find("order");
|
2007-02-08 12:56:46 +01:00
|
|
|
if (it != options_list.num_options.end())
|
2009-12-16 18:13:23 +01:00
|
|
|
mod_file_struct.order_option = max(mod_file_struct.order_option, atoi(it->second.c_str()));
|
2008-11-04 12:00:54 +01:00
|
|
|
|
2009-10-20 18:55:31 +02:00
|
|
|
// Fill in mod_file_struct.partial_information
|
|
|
|
it = options_list.num_options.find("partial_information");
|
|
|
|
if (it != options_list.num_options.end() && it->second == "1")
|
|
|
|
mod_file_struct.partial_information = true;
|
2009-12-09 12:50:58 +01:00
|
|
|
|
|
|
|
// Option k_order_solver (implicit when order >= 3)
|
|
|
|
it = options_list.num_options.find("k_order_solver");
|
|
|
|
if ((it != options_list.num_options.end() && it->second == "1")
|
|
|
|
|| mod_file_struct.order_option >= 3)
|
|
|
|
mod_file_struct.k_order_solver = true;
|
2010-05-31 18:38:49 +02:00
|
|
|
|
|
|
|
// Check that option "pruning" is not used with k-order
|
|
|
|
it = options_list.num_options.find("pruning");
|
|
|
|
if ((it != options_list.num_options.end() && it->second == "1")
|
|
|
|
&& mod_file_struct.k_order_solver)
|
|
|
|
{
|
|
|
|
cerr << "ERROR: in 'stoch_simul', you cannot use option 'pruning' with 'k_order_solver' option or with 3rd order approximation" << endl;
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
2011-02-04 12:38:12 +01:00
|
|
|
|
|
|
|
// Workaround for ticket #157
|
|
|
|
it = options_list.num_options.find("periods");
|
|
|
|
if (it != options_list.num_options.end() && atoi(it->second.c_str()) > 0
|
|
|
|
&& mod_file_struct.histval_present)
|
|
|
|
{
|
|
|
|
cerr << "ERROR: the 'periods' option of 'stoch_simul' is not compatible with a 'histval' block" << endl;
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
2006-12-15 12:44:58 +01:00
|
|
|
}
|
|
|
|
|
2006-12-12 12:54:30 +01:00
|
|
|
void
|
2006-12-19 00:28:52 +01:00
|
|
|
StochSimulStatement::writeOutput(ostream &output, const string &basename) const
|
2006-11-05 00:31:17 +01:00
|
|
|
{
|
2006-12-12 12:54:30 +01:00
|
|
|
options_list.writeOutput(output);
|
2008-04-07 15:14:40 +02:00
|
|
|
symbol_list.writeOutput("var_list_", output);
|
2009-09-02 18:44:15 +02:00
|
|
|
output << "info = stoch_simul(var_list_);" << endl;
|
2006-11-05 00:31:17 +01:00
|
|
|
}
|
|
|
|
|
2008-05-01 14:04:48 +02:00
|
|
|
ForecastStatement::ForecastStatement(const SymbolList &symbol_list_arg,
|
2009-01-23 11:59:37 +01:00
|
|
|
const OptionsList &options_list_arg) :
|
2008-05-01 14:04:48 +02:00
|
|
|
symbol_list(symbol_list_arg),
|
|
|
|
options_list(options_list_arg)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ForecastStatement::writeOutput(ostream &output, const string &basename) const
|
|
|
|
{
|
|
|
|
options_list.writeOutput(output);
|
|
|
|
symbol_list.writeOutput("var_list_", output);
|
|
|
|
output << "info = forecast(var_list_,'simul');\n";
|
|
|
|
}
|
|
|
|
|
2008-04-07 15:14:40 +02:00
|
|
|
RamseyPolicyStatement::RamseyPolicyStatement(const SymbolList &symbol_list_arg,
|
2007-02-05 10:55:41 +01:00
|
|
|
const OptionsList &options_list_arg) :
|
2008-04-07 15:14:40 +02:00
|
|
|
symbol_list(symbol_list_arg),
|
2007-01-04 15:42:27 +01:00
|
|
|
options_list(options_list_arg)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
RamseyPolicyStatement::checkPass(ModFileStructure &mod_file_struct)
|
|
|
|
{
|
2008-09-29 12:16:13 +02:00
|
|
|
mod_file_struct.ramsey_policy_present = true;
|
2007-02-08 12:56:46 +01:00
|
|
|
|
2007-04-30 14:09:05 +02:00
|
|
|
/* Fill in option_order of mod_file_struct
|
|
|
|
Since ramsey policy needs one further order of derivation (for example, for 1st order
|
|
|
|
approximation, it needs 2nd derivatives), we add 1 to the order declared by user */
|
2010-09-16 19:00:48 +02:00
|
|
|
OptionsList::num_options_t::const_iterator it = options_list.num_options.find("order");
|
2007-02-08 12:56:46 +01:00
|
|
|
if (it != options_list.num_options.end())
|
2008-11-04 11:52:06 +01:00
|
|
|
{
|
|
|
|
int order = atoi(it->second.c_str());
|
|
|
|
if (order > 1)
|
|
|
|
{
|
|
|
|
cerr << "ERROR: ramsey_policy: order > 1 is not yet implemented" << endl;
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
mod_file_struct.order_option = max(mod_file_struct.order_option, order + 1);
|
|
|
|
}
|
2008-11-04 12:00:54 +01:00
|
|
|
|
2009-10-20 18:55:31 +02:00
|
|
|
// Fill in mod_file_struct.partial_information
|
|
|
|
it = options_list.num_options.find("partial_information");
|
|
|
|
if (it != options_list.num_options.end() && it->second == "1")
|
|
|
|
mod_file_struct.partial_information = true;
|
2009-12-09 12:50:58 +01:00
|
|
|
|
|
|
|
// Option k_order_solver (implicit when order >= 3)
|
|
|
|
it = options_list.num_options.find("k_order_solver");
|
|
|
|
if ((it != options_list.num_options.end() && it->second == "1")
|
|
|
|
|| mod_file_struct.order_option >= 3)
|
|
|
|
mod_file_struct.k_order_solver = true;
|
2007-01-04 15:42:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
RamseyPolicyStatement::writeOutput(ostream &output, const string &basename) const
|
|
|
|
{
|
|
|
|
options_list.writeOutput(output);
|
2008-04-07 15:14:40 +02:00
|
|
|
symbol_list.writeOutput("var_list_", output);
|
2007-06-17 15:06:50 +02:00
|
|
|
output << "ramsey_policy(var_list_);\n";
|
2007-01-04 15:42:27 +01:00
|
|
|
}
|
|
|
|
|
2011-03-13 21:19:55 +01:00
|
|
|
DiscretionaryPolicyStatement::DiscretionaryPolicyStatement(const SymbolList &symbol_list_arg,
|
|
|
|
const OptionsList &options_list_arg) :
|
|
|
|
symbol_list(symbol_list_arg),
|
|
|
|
options_list(options_list_arg)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DiscretionaryPolicyStatement::checkPass(ModFileStructure &mod_file_struct)
|
|
|
|
{
|
|
|
|
mod_file_struct.discretionary_policy_present = true;
|
|
|
|
|
|
|
|
/* Fill in option_order of mod_file_struct
|
|
|
|
Since discretionary policy needs one further order of derivation (for example, for 1st order
|
|
|
|
approximation, it needs 2nd derivatives), we add 1 to the order declared by user */
|
|
|
|
OptionsList::num_options_t::const_iterator it = options_list.num_options.find("order");
|
|
|
|
if (it != options_list.num_options.end())
|
|
|
|
{
|
|
|
|
int order = atoi(it->second.c_str());
|
|
|
|
if (order > 1)
|
|
|
|
{
|
|
|
|
cerr << "ERROR: discretionary_policy: order > 1 is not yet implemented" << endl;
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
mod_file_struct.order_option = max(mod_file_struct.order_option, order + 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Fill in mod_file_struct.partial_information
|
|
|
|
it = options_list.num_options.find("partial_information");
|
|
|
|
if (it != options_list.num_options.end() && it->second == "1")
|
|
|
|
mod_file_struct.partial_information = true;
|
|
|
|
|
|
|
|
// Option k_order_solver (implicit when order >= 3)
|
|
|
|
it = options_list.num_options.find("k_order_solver");
|
|
|
|
if ((it != options_list.num_options.end() && it->second == "1")
|
|
|
|
|| mod_file_struct.order_option >= 3)
|
|
|
|
mod_file_struct.k_order_solver = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DiscretionaryPolicyStatement::writeOutput(ostream &output, const string &basename) const
|
|
|
|
{
|
|
|
|
options_list.writeOutput(output);
|
|
|
|
symbol_list.writeOutput("var_list_", output);
|
|
|
|
output << "discretionary_policy(var_list_);\n";
|
|
|
|
}
|
|
|
|
|
2008-04-07 15:14:40 +02:00
|
|
|
EstimationStatement::EstimationStatement(const SymbolList &symbol_list_arg,
|
2010-06-11 21:19:30 +02:00
|
|
|
const OptionsList &options_list_arg,
|
|
|
|
const SymbolTable &symbol_table_arg) :
|
2008-04-07 15:14:40 +02:00
|
|
|
symbol_list(symbol_list_arg),
|
2010-06-11 21:19:30 +02:00
|
|
|
options_list(options_list_arg),
|
|
|
|
symbol_table(symbol_table_arg)
|
2006-11-05 00:31:17 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2006-12-15 12:44:58 +01:00
|
|
|
void
|
|
|
|
EstimationStatement::checkPass(ModFileStructure &mod_file_struct)
|
|
|
|
{
|
2008-09-29 12:16:13 +02:00
|
|
|
mod_file_struct.estimation_present = true;
|
2007-02-08 12:56:46 +01:00
|
|
|
|
|
|
|
// Fill in option_order of mod_file_struct
|
2010-09-16 19:00:48 +02:00
|
|
|
OptionsList::num_options_t::const_iterator it = options_list.num_options.find("order");
|
2007-02-08 12:56:46 +01:00
|
|
|
if (it != options_list.num_options.end())
|
2009-12-16 18:13:23 +01:00
|
|
|
mod_file_struct.order_option = max(mod_file_struct.order_option, atoi(it->second.c_str()));
|
2009-10-20 18:55:31 +02:00
|
|
|
|
|
|
|
// Fill in mod_file_struct.partial_information
|
|
|
|
it = options_list.num_options.find("partial_information");
|
|
|
|
if (it != options_list.num_options.end() && it->second == "1")
|
|
|
|
mod_file_struct.partial_information = true;
|
2010-06-11 21:19:30 +02:00
|
|
|
|
|
|
|
it = options_list.num_options.find("dsge_var");
|
|
|
|
if (it != options_list.num_options.end())
|
2011-07-12 16:02:20 +02:00
|
|
|
// Ensure that irf_shocks & dsge_var have not both been passed
|
|
|
|
if (options_list.symbol_list_options.find("irf_shocks") != options_list.symbol_list_options.end())
|
|
|
|
{
|
|
|
|
cerr << "The irf_shocks and dsge_var options may not both be passed to estimation." << endl;
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
// Fill in mod_file_struct.dsge_var_calibrated
|
|
|
|
mod_file_struct.dsge_var_calibrated = it->second;
|
2010-06-11 21:19:30 +02:00
|
|
|
|
|
|
|
// Fill in mod_file_struct.dsge_var_estimated
|
2010-09-16 19:00:48 +02:00
|
|
|
OptionsList::string_options_t::const_iterator it_str = options_list.string_options.find("dsge_var");
|
2010-06-11 21:19:30 +02:00
|
|
|
if (it_str != options_list.string_options.end())
|
|
|
|
mod_file_struct.dsge_var_estimated = true;
|
|
|
|
|
|
|
|
// Fill in mod_file_struct.bayesian_irf_present
|
|
|
|
it = options_list.num_options.find("bayesian_irf");
|
|
|
|
if (it != options_list.num_options.end() && it->second == "1")
|
|
|
|
mod_file_struct.bayesian_irf_present = true;
|
|
|
|
|
|
|
|
it = options_list.num_options.find("dsge_varlag");
|
|
|
|
if (it != options_list.num_options.end())
|
2011-02-04 16:25:38 +01:00
|
|
|
if (mod_file_struct.dsge_var_calibrated.empty()
|
|
|
|
&& !mod_file_struct.dsge_var_estimated)
|
2010-06-11 21:19:30 +02:00
|
|
|
{
|
|
|
|
cerr << "ERROR: The estimation statement requires a dsge_var option to be passed "
|
|
|
|
<< "if the dsge_varlag option is passed." << endl;
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
2011-02-04 16:25:38 +01:00
|
|
|
if (!mod_file_struct.dsge_var_calibrated.empty()
|
|
|
|
&& mod_file_struct.dsge_var_estimated)
|
2010-06-11 21:19:30 +02:00
|
|
|
{
|
|
|
|
cerr << "ERROR: An estimation statement cannot take more than one dsge_var option." << endl;
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
2006-12-15 12:44:58 +01:00
|
|
|
}
|
|
|
|
|
2006-12-12 12:54:30 +01:00
|
|
|
void
|
2006-12-19 00:28:52 +01:00
|
|
|
EstimationStatement::writeOutput(ostream &output, const string &basename) const
|
2006-11-05 00:31:17 +01:00
|
|
|
{
|
2006-12-12 12:54:30 +01:00
|
|
|
options_list.writeOutput(output);
|
2008-04-07 15:14:40 +02:00
|
|
|
symbol_list.writeOutput("var_list_", output);
|
2006-12-12 12:54:30 +01:00
|
|
|
output << "dynare_estimation(var_list_);\n";
|
2006-11-05 00:31:17 +01:00
|
|
|
}
|
|
|
|
|
2007-10-02 16:05:16 +02:00
|
|
|
DynareSensitivityStatement::DynareSensitivityStatement(const OptionsList &options_list_arg) :
|
|
|
|
options_list(options_list_arg)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2009-10-14 18:16:43 +02:00
|
|
|
void
|
|
|
|
DynareSensitivityStatement::checkPass(ModFileStructure &mod_file_struct)
|
|
|
|
{
|
2010-09-16 19:00:48 +02:00
|
|
|
OptionsList::num_options_t::const_iterator it = options_list.num_options.find("identification");
|
2009-10-14 18:16:43 +02:00
|
|
|
if (it != options_list.num_options.end()
|
|
|
|
&& it->second == "1")
|
|
|
|
mod_file_struct.identification_present = true;
|
|
|
|
}
|
|
|
|
|
2007-10-02 16:05:16 +02:00
|
|
|
void
|
|
|
|
DynareSensitivityStatement::writeOutput(ostream &output, const string &basename) const
|
|
|
|
{
|
2009-12-16 18:13:23 +01:00
|
|
|
options_list.writeOutput(output, "options_gsa");
|
2008-04-05 12:52:58 +02:00
|
|
|
output << "dynare_sensitivity(options_gsa);" << endl;
|
2007-10-02 16:05:16 +02:00
|
|
|
}
|
|
|
|
|
2008-04-07 15:14:40 +02:00
|
|
|
RplotStatement::RplotStatement(const SymbolList &symbol_list_arg,
|
2006-12-12 12:54:30 +01:00
|
|
|
const OptionsList &options_list_arg) :
|
2008-04-07 15:14:40 +02:00
|
|
|
symbol_list(symbol_list_arg),
|
2006-12-12 12:54:30 +01:00
|
|
|
options_list(options_list_arg)
|
2006-11-05 00:31:17 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2006-12-12 12:54:30 +01:00
|
|
|
void
|
2006-12-19 00:28:52 +01:00
|
|
|
RplotStatement::writeOutput(ostream &output, const string &basename) const
|
2006-11-05 00:31:17 +01:00
|
|
|
{
|
2006-12-12 12:54:30 +01:00
|
|
|
options_list.writeOutput(output);
|
2008-04-07 15:14:40 +02:00
|
|
|
symbol_list.writeOutput("var_list_", output);
|
2006-12-12 12:54:30 +01:00
|
|
|
output << "rplot(var_list_);\n";
|
2006-11-05 00:31:17 +01:00
|
|
|
}
|
|
|
|
|
2006-12-12 12:54:30 +01:00
|
|
|
PeriodsStatement::PeriodsStatement(int periods_arg) : periods(periods_arg)
|
2006-11-25 18:55:02 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2006-12-12 12:54:30 +01:00
|
|
|
void
|
2006-12-19 00:28:52 +01:00
|
|
|
PeriodsStatement::writeOutput(ostream &output, const string &basename) const
|
2006-11-25 18:55:02 +01:00
|
|
|
{
|
2006-12-12 12:54:30 +01:00
|
|
|
output << "options_.periods = " << periods << ";" << endl;
|
2006-11-25 18:55:02 +01:00
|
|
|
}
|
|
|
|
|
2006-12-12 12:54:30 +01:00
|
|
|
DsampleStatement::DsampleStatement(int val1_arg) : val1(val1_arg), val2(-1)
|
2006-11-05 00:31:17 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2006-12-12 12:54:30 +01:00
|
|
|
DsampleStatement::DsampleStatement(int val1_arg, int val2_arg) : val1(val1_arg), val2(val2_arg)
|
2006-11-05 00:31:17 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2006-12-12 12:54:30 +01:00
|
|
|
void
|
2006-12-19 00:28:52 +01:00
|
|
|
DsampleStatement::writeOutput(ostream &output, const string &basename) const
|
2006-11-05 00:31:17 +01:00
|
|
|
{
|
2006-12-12 12:54:30 +01:00
|
|
|
if (val2 < 0)
|
2008-12-08 17:19:59 +01:00
|
|
|
output << "dsample(" << val1 << ");" << endl;
|
2006-12-12 12:54:30 +01:00
|
|
|
else
|
2008-12-08 17:19:59 +01:00
|
|
|
output << "dsample(" << val1 << ", " << val2 << ");" << endl;
|
2006-12-12 12:54:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
EstimatedParamsStatement::EstimatedParamsStatement(const vector<EstimationParams> &estim_params_list_arg,
|
|
|
|
const SymbolTable &symbol_table_arg) :
|
|
|
|
estim_params_list(estim_params_list_arg),
|
|
|
|
symbol_table(symbol_table_arg)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2010-06-11 21:19:30 +02:00
|
|
|
void
|
|
|
|
EstimatedParamsStatement::checkPass(ModFileStructure &mod_file_struct)
|
|
|
|
{
|
|
|
|
for (vector<EstimationParams>::const_iterator it = estim_params_list.begin();
|
|
|
|
it != estim_params_list.end(); it++)
|
2010-06-18 15:09:47 +02:00
|
|
|
{
|
|
|
|
if (it->name == "dsge_prior_weight")
|
|
|
|
mod_file_struct.dsge_prior_weight_in_estimated_params = true;
|
|
|
|
|
2010-09-16 15:37:09 +02:00
|
|
|
// Handle case of degenerate beta prior
|
2010-06-18 15:09:47 +02:00
|
|
|
if (it->prior == "1") //BETA_PDF is associated with "1" in DynareBison.yy
|
2010-09-16 15:37:09 +02:00
|
|
|
try
|
2010-06-18 15:09:47 +02:00
|
|
|
{
|
2011-02-04 16:25:38 +01:00
|
|
|
if (it->mean->eval(eval_context_t()) == 0.5
|
|
|
|
&& it->std->eval(eval_context_t()) == 0.5)
|
2010-09-16 15:37:09 +02:00
|
|
|
{
|
|
|
|
cerr << "ERROR: The prior density is not defined for the beta distribution when the mean = standard deviation = 0.5." << endl;
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (ExprNode::EvalException &e)
|
|
|
|
{
|
|
|
|
// We don't have enough information to compute the numerical value, skip the test
|
2010-06-18 15:09:47 +02:00
|
|
|
}
|
|
|
|
}
|
2010-06-11 21:19:30 +02:00
|
|
|
}
|
|
|
|
|
2006-12-12 12:54:30 +01:00
|
|
|
void
|
2006-12-19 00:28:52 +01:00
|
|
|
EstimatedParamsStatement::writeOutput(ostream &output, const string &basename) const
|
2006-12-12 12:54:30 +01:00
|
|
|
{
|
2009-01-22 16:05:38 +01:00
|
|
|
output << "global estim_params_" << endl
|
|
|
|
<< "estim_params_.var_exo = [];" << endl
|
|
|
|
<< "estim_params_.var_endo = [];" << endl
|
|
|
|
<< "estim_params_.corrx = [];" << endl
|
|
|
|
<< "estim_params_.corrn = [];" << endl
|
2010-04-14 15:03:41 +02:00
|
|
|
<< "estim_params_.param_vals = [];" << endl;
|
2006-12-12 12:54:30 +01:00
|
|
|
|
|
|
|
vector<EstimationParams>::const_iterator it;
|
|
|
|
|
2009-12-16 18:13:23 +01:00
|
|
|
for (it = estim_params_list.begin(); it != estim_params_list.end(); it++)
|
2006-11-05 00:31:17 +01:00
|
|
|
{
|
2009-02-27 13:19:25 +01:00
|
|
|
int symb_id = symbol_table.getTypeSpecificID(it->name) + 1;
|
2009-01-22 16:05:38 +01:00
|
|
|
SymbolType symb_type = symbol_table.getType(it->name);
|
|
|
|
|
2009-12-16 18:13:23 +01:00
|
|
|
switch (it->type)
|
2006-11-05 00:31:17 +01:00
|
|
|
{
|
2006-12-12 12:54:30 +01:00
|
|
|
case 1:
|
2009-01-22 16:05:38 +01:00
|
|
|
if (symb_type == eExogenous)
|
2006-12-12 12:54:30 +01:00
|
|
|
output << "estim_params_.var_exo = [estim_params_.var_exo; ";
|
2009-01-22 16:05:38 +01:00
|
|
|
else if (symb_type == eEndogenous)
|
2006-12-12 12:54:30 +01:00
|
|
|
output << "estim_params_.var_endo = [estim_params_.var_endo; ";
|
2009-01-22 16:05:38 +01:00
|
|
|
output << symb_id;
|
2006-12-12 12:54:30 +01:00
|
|
|
break;
|
|
|
|
case 2:
|
2009-01-22 16:05:38 +01:00
|
|
|
output << "estim_params_.param_vals = [estim_params_.param_vals; "
|
|
|
|
<< symb_id;
|
2006-12-12 12:54:30 +01:00
|
|
|
break;
|
|
|
|
case 3:
|
2009-01-22 16:05:38 +01:00
|
|
|
if (symb_type == eExogenous)
|
2006-12-12 12:54:30 +01:00
|
|
|
output << "estim_params_.corrx = [estim_params_.corrx; ";
|
2009-01-22 16:05:38 +01:00
|
|
|
else if (symb_type == eEndogenous)
|
2006-12-12 12:54:30 +01:00
|
|
|
output << "estim_params_.corrn = [estim_params_.corrn; ";
|
2009-02-27 13:19:25 +01:00
|
|
|
output << symb_id << " " << symbol_table.getTypeSpecificID(it->name2)+1;
|
2006-12-12 12:54:30 +01:00
|
|
|
break;
|
2006-11-05 00:31:17 +01:00
|
|
|
}
|
2009-01-22 16:05:38 +01:00
|
|
|
output << ", ";
|
|
|
|
it->init_val->writeOutput(output);
|
|
|
|
output << ", ";
|
|
|
|
it->low_bound->writeOutput(output);
|
|
|
|
output << ", ";
|
|
|
|
it->up_bound->writeOutput(output);
|
|
|
|
output << ", "
|
|
|
|
<< it->prior << ", ";
|
|
|
|
it->mean->writeOutput(output);
|
|
|
|
output << ", ";
|
|
|
|
it->std->writeOutput(output);
|
|
|
|
output << ", ";
|
|
|
|
it->p3->writeOutput(output);
|
|
|
|
output << ", ";
|
|
|
|
it->p4->writeOutput(output);
|
|
|
|
output << ", ";
|
|
|
|
it->jscale->writeOutput(output);
|
|
|
|
output << " ];" << endl;
|
2006-11-05 00:31:17 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-12-12 12:54:30 +01:00
|
|
|
EstimatedParamsInitStatement::EstimatedParamsInitStatement(const vector<EstimationParams> &estim_params_list_arg,
|
|
|
|
const SymbolTable &symbol_table_arg) :
|
|
|
|
estim_params_list(estim_params_list_arg),
|
|
|
|
symbol_table(symbol_table_arg)
|
2006-11-05 00:31:17 +01:00
|
|
|
{
|
2006-12-12 12:54:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-12-19 00:28:52 +01:00
|
|
|
EstimatedParamsInitStatement::writeOutput(ostream &output, const string &basename) const
|
2006-12-12 12:54:30 +01:00
|
|
|
{
|
|
|
|
vector<EstimationParams>::const_iterator it;
|
|
|
|
|
2009-12-16 18:13:23 +01:00
|
|
|
for (it = estim_params_list.begin(); it != estim_params_list.end(); it++)
|
2006-11-05 00:31:17 +01:00
|
|
|
{
|
2009-02-27 13:19:25 +01:00
|
|
|
int symb_id = symbol_table.getTypeSpecificID(it->name) + 1;
|
2009-01-22 16:05:38 +01:00
|
|
|
SymbolType symb_type = symbol_table.getType(it->name);
|
|
|
|
|
2006-12-12 12:54:30 +01:00
|
|
|
if (it->type < 3)
|
2006-11-05 00:31:17 +01:00
|
|
|
{
|
2009-01-22 16:05:38 +01:00
|
|
|
if (symb_type == eExogenous)
|
2006-12-12 12:54:30 +01:00
|
|
|
{
|
2009-01-22 16:05:38 +01:00
|
|
|
output << "tmp1 = find(estim_params_.var_exo(:,1)==" << symb_id << ");" << endl;
|
|
|
|
output << "estim_params_.var_exo(tmp1,2) = ";
|
|
|
|
it->init_val->writeOutput(output);
|
|
|
|
output << ";" << endl;
|
2006-12-12 12:54:30 +01:00
|
|
|
}
|
2009-01-22 16:05:38 +01:00
|
|
|
else if (symb_type == eEndogenous)
|
2006-12-12 12:54:30 +01:00
|
|
|
{
|
2009-01-22 16:05:38 +01:00
|
|
|
output << "tmp1 = find(estim_params_.var_endo(:,1)==" << symb_id << ");" << endl;
|
|
|
|
output << "estim_params_.var_endo(tmp1,2) = ";
|
|
|
|
it->init_val->writeOutput(output);
|
|
|
|
output << ";" << endl;
|
2006-12-12 12:54:30 +01:00
|
|
|
}
|
2009-01-22 16:05:38 +01:00
|
|
|
else if (symb_type == eParameter)
|
2006-12-12 12:54:30 +01:00
|
|
|
{
|
2009-01-22 16:05:38 +01:00
|
|
|
output << "tmp1 = find(estim_params_.param_vals(:,1)==" << symb_id << ");" << endl;
|
|
|
|
output << "estim_params_.param_vals(tmp1,2) = ";
|
|
|
|
it->init_val->writeOutput(output);
|
|
|
|
output << ";" << endl;
|
2006-12-12 12:54:30 +01:00
|
|
|
}
|
2006-11-05 00:31:17 +01:00
|
|
|
}
|
2006-12-12 12:54:30 +01:00
|
|
|
else
|
2006-11-05 00:31:17 +01:00
|
|
|
{
|
2009-01-22 16:05:38 +01:00
|
|
|
if (symb_type == eExogenous)
|
2006-12-12 12:54:30 +01:00
|
|
|
{
|
2009-02-27 13:19:25 +01:00
|
|
|
output << "tmp1 = find((estim_params_.corrx(:,1)==" << symb_id << ")) & (estim_params_.corrx(:,2)==" << symbol_table.getTypeSpecificID(it->name2)+1 << ");" << endl;
|
2009-01-22 16:05:38 +01:00
|
|
|
output << "estim_params_.corrx(tmp1,3) = ";
|
|
|
|
it->init_val->writeOutput(output);
|
|
|
|
output << ";" << endl;
|
2006-12-12 12:54:30 +01:00
|
|
|
}
|
2009-01-22 16:05:38 +01:00
|
|
|
else if (symb_type == eEndogenous)
|
2006-12-12 12:54:30 +01:00
|
|
|
{
|
2009-02-27 13:19:25 +01:00
|
|
|
output << "tmp1 = find((estim_params_.corrn(:,1)==" << symb_id << ")) & (estim_params_.corrn(:,2)==" << symbol_table.getTypeSpecificID(it->name2)+1 << ";" << endl;
|
2009-01-22 16:05:38 +01:00
|
|
|
output << "estim_params_.corrn(tmp1,3) = ";
|
|
|
|
it->init_val->writeOutput(output);
|
|
|
|
output << ";" << endl;
|
2006-12-12 12:54:30 +01:00
|
|
|
}
|
2006-11-05 00:31:17 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-12-12 12:54:30 +01:00
|
|
|
EstimatedParamsBoundsStatement::EstimatedParamsBoundsStatement(const vector<EstimationParams> &estim_params_list_arg,
|
|
|
|
const SymbolTable &symbol_table_arg) :
|
|
|
|
estim_params_list(estim_params_list_arg),
|
|
|
|
symbol_table(symbol_table_arg)
|
2006-11-05 00:31:17 +01:00
|
|
|
{
|
2006-12-12 12:54:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-12-19 00:28:52 +01:00
|
|
|
EstimatedParamsBoundsStatement::writeOutput(ostream &output, const string &basename) const
|
2006-12-12 12:54:30 +01:00
|
|
|
{
|
|
|
|
vector<EstimationParams>::const_iterator it;
|
|
|
|
|
2009-12-16 18:13:23 +01:00
|
|
|
for (it = estim_params_list.begin(); it != estim_params_list.end(); it++)
|
2006-11-05 00:31:17 +01:00
|
|
|
{
|
2009-02-27 13:19:25 +01:00
|
|
|
int symb_id = symbol_table.getTypeSpecificID(it->name) + 1;
|
2009-01-22 16:05:38 +01:00
|
|
|
SymbolType symb_type = symbol_table.getType(it->name);
|
|
|
|
|
2006-12-12 12:54:30 +01:00
|
|
|
if (it->type < 3)
|
2006-11-05 00:31:17 +01:00
|
|
|
{
|
2009-01-22 16:05:38 +01:00
|
|
|
if (symb_type == eExogenous)
|
2006-12-12 12:54:30 +01:00
|
|
|
{
|
2009-01-22 16:05:38 +01:00
|
|
|
output << "tmp1 = find(estim_params_.var_exo(:,1)==" << symb_id << ");" << endl;
|
|
|
|
|
|
|
|
output << "estim_params_.var_exo(tmp1,3) = ";
|
|
|
|
it->low_bound->writeOutput(output);
|
|
|
|
output << ";" << endl;
|
|
|
|
|
|
|
|
output << "estim_params_.var_exo(tmp1,4) = ";
|
|
|
|
it->up_bound->writeOutput(output);
|
|
|
|
output << ";" << endl;
|
2006-12-12 12:54:30 +01:00
|
|
|
}
|
2009-01-22 16:05:38 +01:00
|
|
|
else if (symb_type == eEndogenous)
|
2006-12-12 12:54:30 +01:00
|
|
|
{
|
2009-01-22 16:05:38 +01:00
|
|
|
output << "tmp1 = find(estim_params_.var_endo(:,1)==" << symb_id << ");" << endl;
|
|
|
|
|
|
|
|
output << "estim_params_.var_endo(tmp1,3) = ";
|
|
|
|
it->low_bound->writeOutput(output);
|
|
|
|
output << ";" << endl;
|
|
|
|
|
|
|
|
output << "estim_params_.var_endo(tmp1,4) = ";
|
|
|
|
it->up_bound->writeOutput(output);
|
|
|
|
output << ";" << endl;
|
2006-12-12 12:54:30 +01:00
|
|
|
}
|
2009-01-22 16:05:38 +01:00
|
|
|
else if (symb_type == eParameter)
|
2006-12-12 12:54:30 +01:00
|
|
|
{
|
2009-01-22 16:05:38 +01:00
|
|
|
output << "tmp1 = find(estim_params_.param_vals(:,1)==" << symb_id << ");" << endl;
|
|
|
|
|
|
|
|
output << "estim_params_.param_vals(tmp1,3) = ";
|
|
|
|
it->low_bound->writeOutput(output);
|
|
|
|
output << ";" << endl;
|
|
|
|
|
|
|
|
output << "estim_params_.param_vals(tmp1,4) = ";
|
|
|
|
it->up_bound->writeOutput(output);
|
|
|
|
output << ";" << endl;
|
2006-12-12 12:54:30 +01:00
|
|
|
}
|
2006-11-05 00:31:17 +01:00
|
|
|
}
|
2006-12-12 12:54:30 +01:00
|
|
|
else
|
2006-11-05 00:31:17 +01:00
|
|
|
{
|
2009-01-22 16:05:38 +01:00
|
|
|
if (symb_type == eExogenous)
|
2006-12-12 12:54:30 +01:00
|
|
|
{
|
2009-02-27 13:19:25 +01:00
|
|
|
output << "tmp1 = find((estim_params_.corrx(:,1)==" << symb_id << ")) & (estim_params_.corrx(:,2)==" << symbol_table.getTypeSpecificID(it->name2)+1 << ");" << endl;
|
2009-01-22 16:05:38 +01:00
|
|
|
|
|
|
|
output << "estim_params_.corrx(tmp1,4) = ";
|
|
|
|
it->low_bound->writeOutput(output);
|
|
|
|
output << ";" << endl;
|
|
|
|
|
|
|
|
output << "estim_params_.corrx(tmp1,5) = ";
|
|
|
|
it->up_bound->writeOutput(output);
|
|
|
|
output << ";" << endl;
|
2006-12-12 12:54:30 +01:00
|
|
|
}
|
2009-01-22 16:05:38 +01:00
|
|
|
else if (symb_type == eEndogenous)
|
2006-12-12 12:54:30 +01:00
|
|
|
{
|
2009-02-27 13:19:25 +01:00
|
|
|
output << "tmp1 = find((estim_params_.corrn(:,1)==" << symb_id << ")) & (estim_params_.corrn(:,2)==" << symbol_table.getTypeSpecificID(it->name2)+1 << ";" << endl;
|
2009-01-22 16:05:38 +01:00
|
|
|
|
|
|
|
output << "estim_params_.corrn(tmp1,4) = ";
|
|
|
|
it->low_bound->writeOutput(output);
|
|
|
|
output << ";" << endl;
|
|
|
|
|
|
|
|
output << "estim_params_.corrn(tmp1,5) = ";
|
|
|
|
it->up_bound->writeOutput(output);
|
|
|
|
output << ";" << endl;
|
2006-12-12 12:54:30 +01:00
|
|
|
}
|
2006-11-05 00:31:17 +01:00
|
|
|
}
|
|
|
|
}
|
2006-12-12 12:54:30 +01:00
|
|
|
}
|
|
|
|
|
2010-09-16 19:00:48 +02:00
|
|
|
ObservationTrendsStatement::ObservationTrendsStatement(const trend_elements_t &trend_elements_arg,
|
2006-12-12 12:54:30 +01:00
|
|
|
const SymbolTable &symbol_table_arg) :
|
|
|
|
trend_elements(trend_elements_arg),
|
|
|
|
symbol_table(symbol_table_arg)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-12-19 00:28:52 +01:00
|
|
|
ObservationTrendsStatement::writeOutput(ostream &output, const string &basename) const
|
2006-12-12 12:54:30 +01:00
|
|
|
{
|
|
|
|
output << "options_.trend_coeff_ = {};" << endl;
|
|
|
|
|
2010-09-16 19:00:48 +02:00
|
|
|
trend_elements_t::const_iterator it;
|
2006-12-12 12:54:30 +01:00
|
|
|
|
2009-12-16 18:13:23 +01:00
|
|
|
for (it = trend_elements.begin(); it != trend_elements.end(); it++)
|
2006-11-05 00:31:17 +01:00
|
|
|
{
|
2008-10-17 12:20:19 +02:00
|
|
|
SymbolType type = symbol_table.getType(it->first);
|
2006-12-12 12:54:30 +01:00
|
|
|
if (type == eEndogenous)
|
2006-11-05 00:31:17 +01:00
|
|
|
{
|
2006-12-12 12:54:30 +01:00
|
|
|
output << "tmp1 = strmatch('" << it->first << "',options_.varobs,'exact');\n";
|
2007-03-09 18:27:46 +01:00
|
|
|
output << "options_.trend_coeffs{tmp1} = '";
|
|
|
|
it->second->writeOutput(output);
|
|
|
|
output << "';" << endl;
|
2006-11-05 00:31:17 +01:00
|
|
|
}
|
2006-12-12 12:54:30 +01:00
|
|
|
else
|
|
|
|
cout << "Error : Non-variable symbol used in TREND_COEFF: " << it->first << endl;
|
2006-11-05 00:31:17 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-04-07 15:14:40 +02:00
|
|
|
OsrParamsStatement::OsrParamsStatement(const SymbolList &symbol_list_arg) :
|
|
|
|
symbol_list(symbol_list_arg)
|
2006-11-05 00:31:17 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2011-03-03 16:30:53 +01:00
|
|
|
void
|
|
|
|
OsrParamsStatement::checkPass(ModFileStructure &mod_file_struct)
|
|
|
|
{
|
|
|
|
mod_file_struct.osr_params_present = true;
|
|
|
|
}
|
|
|
|
|
2006-12-12 12:54:30 +01:00
|
|
|
void
|
2006-12-19 00:28:52 +01:00
|
|
|
OsrParamsStatement::writeOutput(ostream &output, const string &basename) const
|
2006-11-05 00:31:17 +01:00
|
|
|
{
|
2008-04-07 15:14:40 +02:00
|
|
|
symbol_list.writeOutput("osr_params_", output);
|
2006-11-05 00:31:17 +01:00
|
|
|
}
|
|
|
|
|
2008-04-07 15:14:40 +02:00
|
|
|
OsrStatement::OsrStatement(const SymbolList &symbol_list_arg,
|
2006-12-12 12:54:30 +01:00
|
|
|
const OptionsList &options_list_arg) :
|
2008-04-07 15:14:40 +02:00
|
|
|
symbol_list(symbol_list_arg),
|
2006-12-12 12:54:30 +01:00
|
|
|
options_list(options_list_arg)
|
2006-11-05 00:31:17 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2006-12-15 12:44:58 +01:00
|
|
|
void
|
|
|
|
OsrStatement::checkPass(ModFileStructure &mod_file_struct)
|
|
|
|
{
|
2008-09-29 12:16:13 +02:00
|
|
|
mod_file_struct.osr_present = true;
|
2007-02-08 12:56:46 +01:00
|
|
|
|
|
|
|
// Fill in option_order of mod_file_struct
|
2010-09-16 19:00:48 +02:00
|
|
|
OptionsList::num_options_t::const_iterator it = options_list.num_options.find("order");
|
2007-02-08 12:56:46 +01:00
|
|
|
if (it != options_list.num_options.end())
|
2009-12-16 18:13:23 +01:00
|
|
|
mod_file_struct.order_option = max(mod_file_struct.order_option, atoi(it->second.c_str()));
|
2008-11-04 12:00:54 +01:00
|
|
|
|
2009-10-20 18:55:31 +02:00
|
|
|
// Fill in mod_file_struct.partial_information
|
|
|
|
it = options_list.num_options.find("partial_information");
|
|
|
|
if (it != options_list.num_options.end() && it->second == "1")
|
|
|
|
mod_file_struct.partial_information = true;
|
2009-12-09 12:50:58 +01:00
|
|
|
|
|
|
|
// Option k_order_solver (implicit when order >= 3)
|
|
|
|
it = options_list.num_options.find("k_order_solver");
|
|
|
|
if ((it != options_list.num_options.end() && it->second == "1")
|
|
|
|
|| mod_file_struct.order_option >= 3)
|
|
|
|
mod_file_struct.k_order_solver = true;
|
2006-12-15 12:44:58 +01:00
|
|
|
}
|
|
|
|
|
2006-12-12 12:54:30 +01:00
|
|
|
void
|
2006-12-19 00:28:52 +01:00
|
|
|
OsrStatement::writeOutput(ostream &output, const string &basename) const
|
2006-11-05 00:31:17 +01:00
|
|
|
{
|
2006-12-12 12:54:30 +01:00
|
|
|
options_list.writeOutput(output);
|
2008-04-07 15:14:40 +02:00
|
|
|
symbol_list.writeOutput("var_list_", output);
|
2006-12-12 12:54:30 +01:00
|
|
|
output << "osr(var_list_,osr_params_,obj_var_,optim_weights_);\n";
|
2006-11-05 00:31:17 +01:00
|
|
|
}
|
|
|
|
|
2010-09-16 19:00:48 +02:00
|
|
|
OptimWeightsStatement::OptimWeightsStatement(const var_weights_t &var_weights_arg,
|
|
|
|
const covar_weights_t &covar_weights_arg,
|
2006-12-12 12:54:30 +01:00
|
|
|
const SymbolTable &symbol_table_arg) :
|
|
|
|
var_weights(var_weights_arg),
|
|
|
|
covar_weights(covar_weights_arg),
|
|
|
|
symbol_table(symbol_table_arg)
|
2006-11-05 00:31:17 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2011-03-03 16:30:53 +01:00
|
|
|
void
|
|
|
|
OptimWeightsStatement::checkPass(ModFileStructure &mod_file_struct)
|
|
|
|
{
|
|
|
|
mod_file_struct.optim_weights_present = true;
|
|
|
|
}
|
|
|
|
|
2006-12-12 12:54:30 +01:00
|
|
|
void
|
2006-12-19 00:28:52 +01:00
|
|
|
OptimWeightsStatement::writeOutput(ostream &output, const string &basename) const
|
2006-11-05 00:31:17 +01:00
|
|
|
{
|
2008-06-16 18:33:28 +02:00
|
|
|
output << "%" << endl
|
|
|
|
<< "% OPTIM_WEIGHTS" << endl
|
|
|
|
<< "%" << endl
|
|
|
|
<< "optim_weights_ = sparse(M_.endo_nbr,M_.endo_nbr);" << endl
|
|
|
|
<< "obj_var_ = [];" << endl << endl;
|
2006-12-12 12:54:30 +01:00
|
|
|
|
2010-09-16 19:00:48 +02:00
|
|
|
for (var_weights_t::const_iterator it = var_weights.begin();
|
2009-12-16 18:13:23 +01:00
|
|
|
it != var_weights.end(); it++)
|
2006-11-05 00:31:17 +01:00
|
|
|
{
|
2006-12-12 12:54:30 +01:00
|
|
|
const string &name = it->first;
|
2010-09-16 19:18:45 +02:00
|
|
|
const expr_t value = it->second;
|
2009-02-27 13:19:25 +01:00
|
|
|
int id = symbol_table.getTypeSpecificID(name) + 1;
|
2007-03-09 18:27:46 +01:00
|
|
|
output << "optim_weights_(" << id << "," << id << ") = ";
|
|
|
|
value->writeOutput(output);
|
|
|
|
output << ";" << endl;
|
2006-12-12 12:54:30 +01:00
|
|
|
output << "obj_var_ = [obj_var_; " << id << "];\n";
|
2006-11-05 00:31:17 +01:00
|
|
|
}
|
2006-12-12 12:54:30 +01:00
|
|
|
|
2010-09-16 19:00:48 +02:00
|
|
|
for (covar_weights_t::const_iterator it = covar_weights.begin();
|
2009-12-16 18:13:23 +01:00
|
|
|
it != covar_weights.end(); it++)
|
2006-11-05 00:31:17 +01:00
|
|
|
{
|
2006-12-12 12:54:30 +01:00
|
|
|
const string &name1 = it->first.first;
|
|
|
|
const string &name2 = it->first.second;
|
2010-09-16 19:18:45 +02:00
|
|
|
const expr_t value = it->second;
|
2009-02-27 13:19:25 +01:00
|
|
|
int id1 = symbol_table.getTypeSpecificID(name1) + 1;
|
|
|
|
int id2 = symbol_table.getTypeSpecificID(name2) + 1;
|
2007-03-09 18:27:46 +01:00
|
|
|
output << "optim_weights_(" << id1 << "," << id2 << ") = ";
|
|
|
|
value->writeOutput(output);
|
|
|
|
output << ";" << endl;
|
2010-08-10 20:16:59 +02:00
|
|
|
output << "obj_var_ = [obj_var_; " << id1 << "; " << id2 << "];\n";
|
2006-11-05 00:31:17 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-04-07 15:14:40 +02:00
|
|
|
DynaSaveStatement::DynaSaveStatement(const SymbolList &symbol_list_arg,
|
2008-10-13 18:06:07 +02:00
|
|
|
const string &filename_arg) :
|
2008-04-07 15:14:40 +02:00
|
|
|
symbol_list(symbol_list_arg),
|
2008-10-13 18:06:07 +02:00
|
|
|
filename(filename_arg)
|
2006-11-05 00:31:17 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2006-12-12 12:54:30 +01:00
|
|
|
void
|
2006-12-19 00:28:52 +01:00
|
|
|
DynaSaveStatement::writeOutput(ostream &output, const string &basename) const
|
2006-11-05 00:31:17 +01:00
|
|
|
{
|
2008-04-07 15:14:40 +02:00
|
|
|
symbol_list.writeOutput("var_list_", output);
|
2008-10-13 18:06:07 +02:00
|
|
|
output << "dynasave('" << filename
|
|
|
|
<< "',var_list_);" << endl;
|
2006-11-05 00:31:17 +01:00
|
|
|
}
|
|
|
|
|
2008-04-07 15:14:40 +02:00
|
|
|
DynaTypeStatement::DynaTypeStatement(const SymbolList &symbol_list_arg,
|
2008-10-13 18:06:07 +02:00
|
|
|
const string &filename_arg) :
|
2008-04-07 15:14:40 +02:00
|
|
|
symbol_list(symbol_list_arg),
|
2008-10-13 18:06:07 +02:00
|
|
|
filename(filename_arg)
|
2006-11-05 00:31:17 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2006-12-12 12:54:30 +01:00
|
|
|
void
|
2006-12-19 00:28:52 +01:00
|
|
|
DynaTypeStatement::writeOutput(ostream &output, const string &basename) const
|
2006-11-05 00:31:17 +01:00
|
|
|
{
|
2008-04-07 15:14:40 +02:00
|
|
|
symbol_list.writeOutput("var_list_", output);
|
2008-10-13 18:06:07 +02:00
|
|
|
output << "dynatype('" << filename
|
|
|
|
<< "',var_list_);" << endl;
|
2006-11-05 00:31:17 +01:00
|
|
|
}
|
|
|
|
|
2010-09-16 19:00:48 +02:00
|
|
|
ModelComparisonStatement::ModelComparisonStatement(const filename_list_t &filename_list_arg,
|
2006-12-12 12:54:30 +01:00
|
|
|
const OptionsList &options_list_arg) :
|
|
|
|
filename_list(filename_list_arg),
|
|
|
|
options_list(options_list_arg)
|
2006-11-05 00:31:17 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2006-12-12 12:54:30 +01:00
|
|
|
void
|
2006-12-19 00:28:52 +01:00
|
|
|
ModelComparisonStatement::writeOutput(ostream &output, const string &basename) const
|
2006-12-12 12:54:30 +01:00
|
|
|
{
|
|
|
|
options_list.writeOutput(output);
|
|
|
|
|
2008-09-26 18:24:13 +02:00
|
|
|
output << "ModelNames_ = {};" << endl;
|
|
|
|
output << "ModelPriors_ = [];" << endl;
|
2006-12-12 12:54:30 +01:00
|
|
|
|
2010-09-16 19:00:48 +02:00
|
|
|
for (filename_list_t::const_iterator it = filename_list.begin();
|
2009-12-16 18:13:23 +01:00
|
|
|
it != filename_list.end(); it++)
|
2006-12-12 12:54:30 +01:00
|
|
|
{
|
2008-09-26 18:24:13 +02:00
|
|
|
output << "ModelNames_ = { ModelNames_{:} '" << (*it).first << "'};" << endl;
|
|
|
|
output << "ModelPriors_ = [ ModelPriors_ ; " << (*it).second << "];" << endl;
|
2006-12-12 12:54:30 +01:00
|
|
|
}
|
2008-09-26 18:24:13 +02:00
|
|
|
output << "model_comparison(ModelNames_,ModelPriors_,oo_,options_,M_.fname);" << endl;
|
2006-12-12 12:54:30 +01:00
|
|
|
}
|
2006-12-19 00:28:52 +01:00
|
|
|
|
2009-04-14 16:39:53 +02:00
|
|
|
PlannerObjectiveStatement::PlannerObjectiveStatement(StaticModel *model_tree_arg) :
|
2006-12-19 00:28:52 +01:00
|
|
|
model_tree(model_tree_arg)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
PlannerObjectiveStatement::~PlannerObjectiveStatement()
|
|
|
|
{
|
|
|
|
delete model_tree;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PlannerObjectiveStatement::checkPass(ModFileStructure &mod_file_struct)
|
|
|
|
{
|
2009-04-28 18:21:39 +02:00
|
|
|
assert(model_tree->equation_number() == 1);
|
2011-03-03 16:03:21 +01:00
|
|
|
mod_file_struct.planner_objective_present = true;
|
2006-12-19 00:28:52 +01:00
|
|
|
}
|
|
|
|
|
2011-03-21 18:40:57 +01:00
|
|
|
StaticModel *
|
|
|
|
PlannerObjectiveStatement::getPlannerObjective() const
|
|
|
|
{
|
|
|
|
return model_tree;
|
|
|
|
}
|
|
|
|
|
2006-12-19 00:28:52 +01:00
|
|
|
void
|
|
|
|
PlannerObjectiveStatement::computingPass()
|
|
|
|
{
|
2010-09-16 19:00:48 +02:00
|
|
|
model_tree->computingPass(eval_context_t(), false, true, false, false);
|
2006-12-19 00:28:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PlannerObjectiveStatement::writeOutput(ostream &output, const string &basename) const
|
|
|
|
{
|
2011-08-18 12:44:11 +02:00
|
|
|
model_tree->writeStaticFile(basename + "_objective", false, false, false);
|
2006-12-19 00:28:52 +01:00
|
|
|
}
|
2007-06-26 00:42:30 +02:00
|
|
|
|
|
|
|
BVARDensityStatement::BVARDensityStatement(int maxnlags_arg, const OptionsList &options_list_arg) :
|
|
|
|
maxnlags(maxnlags_arg),
|
|
|
|
options_list(options_list_arg)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2008-10-17 14:52:08 +02:00
|
|
|
void
|
|
|
|
BVARDensityStatement::checkPass(ModFileStructure &mod_file_struct)
|
|
|
|
{
|
2009-11-26 18:25:04 +01:00
|
|
|
mod_file_struct.bvar_present = true;
|
2008-10-17 14:52:08 +02:00
|
|
|
}
|
|
|
|
|
2007-06-26 00:42:30 +02:00
|
|
|
void
|
|
|
|
BVARDensityStatement::writeOutput(ostream &output, const string &basename) const
|
|
|
|
{
|
|
|
|
options_list.writeOutput(output);
|
|
|
|
output << "bvar_density(" << maxnlags << ");" << endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
BVARForecastStatement::BVARForecastStatement(int nlags_arg, const OptionsList &options_list_arg) :
|
|
|
|
nlags(nlags_arg),
|
|
|
|
options_list(options_list_arg)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2008-10-17 14:52:08 +02:00
|
|
|
void
|
|
|
|
BVARForecastStatement::checkPass(ModFileStructure &mod_file_struct)
|
|
|
|
{
|
2009-11-26 18:25:04 +01:00
|
|
|
mod_file_struct.bvar_present = true;
|
2008-10-17 14:52:08 +02:00
|
|
|
}
|
|
|
|
|
2007-06-26 00:42:30 +02:00
|
|
|
void
|
|
|
|
BVARForecastStatement::writeOutput(ostream &output, const string &basename) const
|
|
|
|
{
|
|
|
|
options_list.writeOutput(output);
|
|
|
|
output << "bvar_forecast(" << nlags << ");" << endl;
|
|
|
|
}
|
2009-04-20 15:58:15 +02:00
|
|
|
|
2009-07-26 19:07:07 +02:00
|
|
|
SBVARStatement::SBVARStatement(const OptionsList &options_list_arg) :
|
|
|
|
options_list(options_list_arg)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SBVARStatement::checkPass(ModFileStructure &mod_file_struct)
|
|
|
|
{
|
2009-11-26 18:25:04 +01:00
|
|
|
mod_file_struct.bvar_present = true;
|
2009-07-26 19:07:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SBVARStatement::writeOutput(ostream &output, const string &basename) const
|
|
|
|
{
|
|
|
|
options_list.writeOutput(output);
|
2011-05-31 10:39:41 +02:00
|
|
|
output << "sbvar(M_,options_);" << endl;
|
2009-07-26 19:07:07 +02:00
|
|
|
}
|
|
|
|
|
2011-05-11 19:02:39 +02:00
|
|
|
MSSBVAREstimationStatement::MSSBVAREstimationStatement(const OptionsList &options_list_arg) :
|
2009-07-26 19:07:07 +02:00
|
|
|
options_list(options_list_arg)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2011-05-11 19:02:39 +02:00
|
|
|
MSSBVAREstimationStatement::checkPass(ModFileStructure &mod_file_struct)
|
2009-07-26 19:07:07 +02:00
|
|
|
{
|
2009-11-26 18:25:04 +01:00
|
|
|
mod_file_struct.bvar_present = true;
|
2009-07-26 19:07:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2011-05-11 19:02:39 +02:00
|
|
|
MSSBVAREstimationStatement::writeOutput(ostream &output, const string &basename) const
|
2009-07-26 19:07:07 +02:00
|
|
|
{
|
2011-08-10 11:25:38 +02:00
|
|
|
output << "options_ = initialize_ms_sbvar_options(M_, options_);" << endl;
|
2009-07-26 19:07:07 +02:00
|
|
|
options_list.writeOutput(output);
|
2011-05-20 14:29:23 +02:00
|
|
|
output << "[options_, oo_] = ms_estimation(M_, options_, oo_);" << endl;
|
2011-05-11 19:02:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
MSSBVARSimulationStatement::MSSBVARSimulationStatement(const OptionsList &options_list_arg) :
|
|
|
|
options_list(options_list_arg)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
MSSBVARSimulationStatement::checkPass(ModFileStructure &mod_file_struct)
|
|
|
|
{
|
|
|
|
mod_file_struct.bvar_present = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
MSSBVARSimulationStatement::writeOutput(ostream &output, const string &basename) const
|
|
|
|
{
|
2011-08-10 11:25:38 +02:00
|
|
|
output << "options_ = initialize_ms_sbvar_options(M_, options_);" << endl;
|
2011-05-11 19:02:39 +02:00
|
|
|
options_list.writeOutput(output);
|
2011-09-14 20:27:51 +02:00
|
|
|
|
|
|
|
// Redeclare drop option if necessary
|
|
|
|
OptionsList::num_options_t::const_iterator mh_replic_it = options_list.num_options.find("ms.mh_replic");
|
2011-09-15 21:05:44 +02:00
|
|
|
OptionsList::num_options_t::const_iterator thinning_factor_it = options_list.num_options.find("ms.thinning_factor");
|
2011-09-14 20:27:51 +02:00
|
|
|
OptionsList::num_options_t::const_iterator drop_it = options_list.num_options.find("ms.drop");
|
2011-09-15 21:05:44 +02:00
|
|
|
if (mh_replic_it != options_list.num_options.end() || thinning_factor_it != options_list.num_options.end())
|
2011-09-14 20:27:51 +02:00
|
|
|
if (drop_it == options_list.num_options.end())
|
2011-09-15 21:05:44 +02:00
|
|
|
output << "options_.ms.drop = 0.1*options_.ms.mh_replic*options_.ms.thinning_factor;" << endl;
|
2011-09-14 20:27:51 +02:00
|
|
|
|
2011-05-20 14:29:23 +02:00
|
|
|
output << "[options_, oo_] = ms_simulation(M_, options_, oo_);" << endl;
|
2011-05-11 19:02:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
MSSBVARComputeMDDStatement::MSSBVARComputeMDDStatement(const OptionsList &options_list_arg) :
|
|
|
|
options_list(options_list_arg)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
MSSBVARComputeMDDStatement::checkPass(ModFileStructure &mod_file_struct)
|
|
|
|
{
|
|
|
|
mod_file_struct.bvar_present = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
MSSBVARComputeMDDStatement::writeOutput(ostream &output, const string &basename) const
|
|
|
|
{
|
2011-08-10 11:25:38 +02:00
|
|
|
output << "options_ = initialize_ms_sbvar_options(M_, options_);" << endl;
|
2011-05-11 19:02:39 +02:00
|
|
|
options_list.writeOutput(output);
|
2011-05-20 14:29:23 +02:00
|
|
|
output << "[options_, oo_] = ms_compute_mdd(M_, options_, oo_);" << endl;
|
2011-05-11 19:02:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
MSSBVARComputeProbabilitiesStatement::MSSBVARComputeProbabilitiesStatement(const OptionsList &options_list_arg) :
|
|
|
|
options_list(options_list_arg)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
MSSBVARComputeProbabilitiesStatement::checkPass(ModFileStructure &mod_file_struct)
|
|
|
|
{
|
|
|
|
mod_file_struct.bvar_present = true;
|
2011-10-24 13:58:59 +02:00
|
|
|
|
|
|
|
if (options_list.num_options.find("ms.real_time_smoothed_probabilities") != options_list.num_options.end())
|
|
|
|
if (options_list.num_options.find("ms.filtered_probabilities") != options_list.num_options.end())
|
|
|
|
{
|
|
|
|
cerr << "ERROR: You may only pass one of real_time_smoothed "
|
|
|
|
<< "and filtered_probabilities to ms_compute_probabilities." << endl;
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
2011-05-11 19:02:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
MSSBVARComputeProbabilitiesStatement::writeOutput(ostream &output, const string &basename) const
|
|
|
|
{
|
2011-08-10 11:25:38 +02:00
|
|
|
output << "options_ = initialize_ms_sbvar_options(M_, options_);" << endl;
|
2011-05-11 19:02:39 +02:00
|
|
|
options_list.writeOutput(output);
|
2011-05-20 14:29:23 +02:00
|
|
|
output << "[options_, oo_] = ms_compute_probabilities(M_, options_, oo_);" << endl;
|
2011-05-11 19:02:39 +02:00
|
|
|
}
|
|
|
|
|
2011-05-30 15:47:34 +02:00
|
|
|
MSSBVARIrfStatement::MSSBVARIrfStatement(const SymbolList &symbol_list_arg,
|
|
|
|
const OptionsList &options_list_arg) :
|
|
|
|
symbol_list(symbol_list_arg),
|
2011-05-11 19:02:39 +02:00
|
|
|
options_list(options_list_arg)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
MSSBVARIrfStatement::checkPass(ModFileStructure &mod_file_struct)
|
|
|
|
{
|
|
|
|
mod_file_struct.bvar_present = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
MSSBVARIrfStatement::writeOutput(ostream &output, const string &basename) const
|
|
|
|
{
|
2011-08-10 11:25:38 +02:00
|
|
|
output << "options_ = initialize_ms_sbvar_options(M_, options_);" << endl;
|
2011-05-30 15:47:34 +02:00
|
|
|
symbol_list.writeOutput("var_list_", output);
|
2011-05-11 19:02:39 +02:00
|
|
|
options_list.writeOutput(output);
|
2011-05-30 15:47:34 +02:00
|
|
|
output << "[options_, oo_] = ms_irf(var_list_,M_, options_, oo_);" << endl;
|
2011-05-11 19:02:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
MSSBVARForecastStatement::MSSBVARForecastStatement(const OptionsList &options_list_arg) :
|
|
|
|
options_list(options_list_arg)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
MSSBVARForecastStatement::checkPass(ModFileStructure &mod_file_struct)
|
|
|
|
{
|
|
|
|
mod_file_struct.bvar_present = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
MSSBVARForecastStatement::writeOutput(ostream &output, const string &basename) const
|
|
|
|
{
|
2011-08-10 11:25:38 +02:00
|
|
|
output << "options_ = initialize_ms_sbvar_options(M_, options_);" << endl;
|
2011-05-11 19:02:39 +02:00
|
|
|
options_list.writeOutput(output);
|
2011-05-20 14:29:23 +02:00
|
|
|
output << "[options_, oo_] = ms_forecast(M_, options_, oo_);" << endl;
|
2011-05-11 19:02:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
MSSBVARVarianceDecompositionStatement::MSSBVARVarianceDecompositionStatement(const OptionsList &options_list_arg) :
|
|
|
|
options_list(options_list_arg)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
MSSBVARVarianceDecompositionStatement::checkPass(ModFileStructure &mod_file_struct)
|
|
|
|
{
|
|
|
|
mod_file_struct.bvar_present = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
MSSBVARVarianceDecompositionStatement::writeOutput(ostream &output, const string &basename) const
|
|
|
|
{
|
2011-08-10 11:25:38 +02:00
|
|
|
output << "options_ = initialize_ms_sbvar_options(M_, options_);" << endl;
|
2011-05-11 19:02:39 +02:00
|
|
|
options_list.writeOutput(output);
|
2011-05-20 14:29:23 +02:00
|
|
|
output << "[options_, oo_] = ms_variance_decomposition(M_, options_, oo_);" << endl;
|
2009-07-26 19:07:07 +02:00
|
|
|
}
|
|
|
|
|
2011-04-20 12:13:30 +02:00
|
|
|
IdentificationStatement::IdentificationStatement(const OptionsList &options_list_arg)
|
2009-04-20 15:58:15 +02:00
|
|
|
{
|
2011-04-20 12:13:30 +02:00
|
|
|
options_list = options_list_arg;
|
|
|
|
if (options_list.num_options.find("max_dim_cova_group") != options_list.num_options.end())
|
|
|
|
if (atoi(options_list.num_options["max_dim_cova_group"].c_str()) == 0)
|
|
|
|
{
|
|
|
|
cerr << "ERROR: The max_dim_cova_group option to identification only accepts integers > 0." << endl;
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
2009-04-20 15:58:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
IdentificationStatement::checkPass(ModFileStructure &mod_file_struct)
|
|
|
|
{
|
|
|
|
mod_file_struct.identification_present = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
IdentificationStatement::writeOutput(ostream &output, const string &basename) const
|
|
|
|
{
|
2009-10-14 18:16:43 +02:00
|
|
|
options_list.writeOutput(output, "options_ident");
|
|
|
|
output << "dynare_identification(options_ident);" << endl;
|
2009-04-20 15:58:15 +02:00
|
|
|
}
|
2009-04-30 15:14:33 +02:00
|
|
|
|
|
|
|
WriteLatexDynamicModelStatement::WriteLatexDynamicModelStatement(const DynamicModel &dynamic_model_arg) :
|
|
|
|
dynamic_model(dynamic_model_arg)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
WriteLatexDynamicModelStatement::writeOutput(ostream &output, const string &basename) const
|
|
|
|
{
|
|
|
|
dynamic_model.writeLatexFile(basename);
|
|
|
|
}
|
|
|
|
|
|
|
|
WriteLatexStaticModelStatement::WriteLatexStaticModelStatement(const StaticModel &static_model_arg) :
|
|
|
|
static_model(static_model_arg)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
WriteLatexStaticModelStatement::writeOutput(ostream &output, const string &basename) const
|
|
|
|
{
|
|
|
|
static_model.writeLatexFile(basename);
|
|
|
|
}
|
2009-07-23 10:31:48 +02:00
|
|
|
|
|
|
|
ShockDecompositionStatement::ShockDecompositionStatement(const SymbolList &symbol_list_arg,
|
2009-12-16 18:13:23 +01:00
|
|
|
const OptionsList &options_list_arg) :
|
2009-07-23 10:31:48 +02:00
|
|
|
symbol_list(symbol_list_arg),
|
|
|
|
options_list(options_list_arg)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ShockDecompositionStatement::writeOutput(ostream &output, const string &basename) const
|
|
|
|
{
|
|
|
|
options_list.writeOutput(output);
|
|
|
|
symbol_list.writeOutput("var_list_", output);
|
|
|
|
output << "oo_ = shock_decomposition(M_,oo_,options_,var_list_);\n";
|
|
|
|
}
|
|
|
|
|
2009-10-16 19:23:57 +02:00
|
|
|
ConditionalForecastStatement::ConditionalForecastStatement(const OptionsList &options_list_arg) :
|
|
|
|
options_list(options_list_arg)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ConditionalForecastStatement::writeOutput(ostream &output, const string &basename) const
|
|
|
|
{
|
|
|
|
options_list.writeOutput(output, "options_cond_fcst_");
|
|
|
|
output << "imcforecast(constrained_paths_, constrained_vars_, options_cond_fcst_);" << endl;
|
|
|
|
}
|
2009-07-23 10:31:48 +02:00
|
|
|
|
2009-10-16 19:23:57 +02:00
|
|
|
PlotConditionalForecastStatement::PlotConditionalForecastStatement(int periods_arg, const SymbolList &symbol_list_arg) :
|
|
|
|
periods(periods_arg),
|
|
|
|
symbol_list(symbol_list_arg)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PlotConditionalForecastStatement::writeOutput(ostream &output, const string &basename) const
|
|
|
|
{
|
|
|
|
symbol_list.writeOutput("var_list_", output);
|
2009-10-22 16:42:12 +02:00
|
|
|
if (periods == -1)
|
|
|
|
output << "plot_icforecast(var_list_);" << endl;
|
|
|
|
else
|
|
|
|
output << "plot_icforecast(var_list_, " << periods << ");" << endl;
|
2009-10-16 19:23:57 +02:00
|
|
|
}
|
2009-12-04 22:32:19 +01:00
|
|
|
|
2011-10-10 11:45:55 +02:00
|
|
|
SvarIdentificationStatement::SvarIdentificationStatement(const svar_identification_restrictions_t &restrictions_arg,
|
2009-12-04 22:32:19 +01:00
|
|
|
const bool &upper_cholesky_present_arg,
|
|
|
|
const bool &lower_cholesky_present_arg,
|
2011-07-29 18:11:50 +02:00
|
|
|
const bool &constants_exclusion_present_arg,
|
2009-12-04 22:32:19 +01:00
|
|
|
const SymbolTable &symbol_table_arg) :
|
2011-10-10 11:45:55 +02:00
|
|
|
restrictions(restrictions_arg),
|
2009-12-04 22:32:19 +01:00
|
|
|
upper_cholesky_present(upper_cholesky_present_arg),
|
|
|
|
lower_cholesky_present(lower_cholesky_present_arg),
|
2011-07-29 18:11:50 +02:00
|
|
|
constants_exclusion_present(constants_exclusion_present_arg),
|
2009-12-04 22:32:19 +01:00
|
|
|
symbol_table(symbol_table_arg)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
SvarIdentificationStatement::getMaxLag() const
|
|
|
|
{
|
|
|
|
int max_lag = 0;
|
2011-10-10 11:45:55 +02:00
|
|
|
for (svar_identification_restrictions_t::const_iterator it = restrictions.begin(); it != restrictions.end(); it++)
|
|
|
|
if (it->lag > max_lag)
|
|
|
|
max_lag = it->lag;
|
2009-12-04 22:32:19 +01:00
|
|
|
|
|
|
|
return max_lag;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SvarIdentificationStatement::checkPass(ModFileStructure &mod_file_struct)
|
|
|
|
{
|
|
|
|
if (!mod_file_struct.svar_identification_present)
|
|
|
|
mod_file_struct.svar_identification_present = true;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
cerr << "ERROR: You may only have one svar_identification block in your .mod file." << endl;
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
2011-08-03 11:00:11 +02:00
|
|
|
|
|
|
|
if (upper_cholesky_present && lower_cholesky_present)
|
|
|
|
{
|
|
|
|
cerr << "ERROR: Within the svar_identification statement, you may only have one of "
|
|
|
|
<< "upper_cholesky and lower_cholesky." << endl;
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
2009-12-04 22:32:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SvarIdentificationStatement::writeOutput(ostream &output, const string &basename) const
|
|
|
|
{
|
|
|
|
if (upper_cholesky_present && lower_cholesky_present)
|
|
|
|
{
|
|
|
|
cerr << "SvarIdentificationStatement::writeOutput() Should not arrive here (1). Please report this to the Dynare Team." << endl;
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
|
|
|
output << "%" << endl
|
|
|
|
<< "% SVAR IDENTIFICATION" << endl
|
|
|
|
<< "%" << endl;
|
|
|
|
|
|
|
|
if (upper_cholesky_present)
|
|
|
|
output << "options_.ms.upper_cholesky=1;" << endl;
|
|
|
|
|
|
|
|
if (lower_cholesky_present)
|
|
|
|
output << "options_.ms.lower_cholesky=1;" << endl;
|
|
|
|
|
2011-07-29 18:11:50 +02:00
|
|
|
if (constants_exclusion_present)
|
|
|
|
output << "options_.ms.constants_exclusion=1;" << endl;
|
|
|
|
|
2009-12-04 22:32:19 +01:00
|
|
|
if (!upper_cholesky_present && !lower_cholesky_present)
|
|
|
|
{
|
|
|
|
int n = symbol_table.endo_nbr();
|
2010-03-10 08:32:51 +01:00
|
|
|
int m = 1; // this is the constant, not the shocks
|
2010-03-15 12:03:37 +01:00
|
|
|
int r = getMaxLag();
|
2009-12-04 22:32:19 +01:00
|
|
|
int k = r*n+m;
|
|
|
|
|
2009-12-16 18:13:23 +01:00
|
|
|
if (k < 1)
|
2011-02-04 16:25:38 +01:00
|
|
|
{
|
|
|
|
cerr << "ERROR: lag = " << r
|
|
|
|
<< ", number of endogenous variables = " << n
|
|
|
|
<< ", number of exogenous variables = " << m
|
|
|
|
<< ". If this is not a logical error in the specification"
|
|
|
|
<< " of the .mod file, please report it to the Dynare Team." << endl;
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
2009-12-16 18:13:23 +01:00
|
|
|
if (n < 1)
|
2009-12-04 22:32:19 +01:00
|
|
|
{
|
|
|
|
cerr << "ERROR: Number of endogenous variables = " << n << "< 1. If this is not a logical "
|
|
|
|
<< "error in the specification of the .mod file, please report it to the Dynare Team." << endl;
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
2011-08-02 10:49:50 +02:00
|
|
|
output << "options_.ms.Qi = cell(" << n << ",1);" << endl;
|
|
|
|
output << "options_.ms.Ri = cell(" << n << ",1);" << endl;
|
2009-12-04 22:32:19 +01:00
|
|
|
|
2011-10-10 11:45:55 +02:00
|
|
|
// vector<int> rows(n);
|
|
|
|
// fill(rows.begin(),rows.end(),1);
|
2011-07-12 14:30:07 +02:00
|
|
|
|
2011-10-10 11:45:55 +02:00
|
|
|
for (svar_identification_restrictions_t::const_iterator it = restrictions.begin(); it != restrictions.end(); it++)
|
2009-12-04 22:32:19 +01:00
|
|
|
{
|
2011-10-10 11:45:55 +02:00
|
|
|
if (it->lag == 0)
|
|
|
|
{
|
2011-10-13 13:34:28 +02:00
|
|
|
output << "options_.ms.Qi{" << it->equation << "}(" << it->restriction_nbr << ", " << it->variable + 1 << ") = ";
|
2011-10-10 11:45:55 +02:00
|
|
|
it->value->writeOutput(output);
|
|
|
|
output << ";" << endl;
|
|
|
|
}
|
|
|
|
else if (it->lag > 0)
|
|
|
|
{
|
2011-10-13 13:34:28 +02:00
|
|
|
int col = (it->lag-1)*n+it->variable+1;
|
2011-10-10 11:45:55 +02:00
|
|
|
if (col > k)
|
|
|
|
{
|
|
|
|
cerr << "ERROR: lag =" << it->lag << ", num endog vars = " << n << "current endog var index = " << it->variable << ". Index "
|
|
|
|
<< "out of bounds. If the above does not represent a logical error, please report this to the Dyanre Team." << endl;
|
|
|
|
}
|
|
|
|
output << "options_.ms.Ri{" << it->equation << "}(" << it->restriction_nbr << ", " << col << ") = ";
|
|
|
|
it->value->writeOutput(output);
|
|
|
|
output << ";" << endl;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
cerr << "SvarIdentificationStatement::writeOutput() Should not arrive here (3). Please report this to the Dynare Team." << endl;
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
|
|
|
// for (unsigned int h = 0; h < it->second.size(); h++)
|
|
|
|
// {
|
|
|
|
// int j = it->second.at(h) + 1;
|
|
|
|
// int i = it->first.second;
|
|
|
|
// int lag = it->first.first;
|
|
|
|
// if (j < 1 || j > n || (int) h+1 > n || i < 1)
|
|
|
|
// {
|
|
|
|
// cerr << "SvarIdentificationStatement::writeOutput() Should not arrive here (2). Please report this to the Dynare Team." << endl;
|
|
|
|
// exit(EXIT_FAILURE);
|
|
|
|
// }
|
|
|
|
// if (i > n)
|
|
|
|
// {
|
|
|
|
// cerr << "ERROR: equation number " << i << " is greater than the number of endogenous variables, " << n << "." << endl;
|
|
|
|
// exit(EXIT_FAILURE);
|
|
|
|
// }
|
|
|
|
|
|
|
|
// if (lag == 0)
|
|
|
|
// output << "options_.ms.Qi{" << i << "}(" << h+1 << ", " << j << ") = 1;" << endl;
|
|
|
|
// else if (lag > 0)
|
|
|
|
// {
|
|
|
|
// if ((lag-1)*n+j > k)
|
|
|
|
// {
|
|
|
|
// cerr << "ERROR: lag =" << lag << ", num endog vars = " << n << "current endog var index = " << j << ". Index "
|
|
|
|
// << "out of bounds. If the above does not represent a logical error, please report this to the Dyanre Team." << endl;
|
|
|
|
// }
|
|
|
|
// output << "options_.ms.Ri{" << i << "}(" << rows[i-1] << ", " << (lag-1)*n+j << ") = 1;" << endl;
|
|
|
|
// rows[i-1]++;
|
|
|
|
// }
|
|
|
|
// else
|
|
|
|
// {
|
|
|
|
// cerr << "SvarIdentificationStatement::writeOutput() Should not arrive here (3). Please report this to the Dynare Team." << endl;
|
|
|
|
// exit(EXIT_FAILURE);
|
|
|
|
// }
|
|
|
|
// }
|
2009-12-04 22:32:19 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-12-08 17:46:13 +01:00
|
|
|
|
|
|
|
MarkovSwitchingStatement::MarkovSwitchingStatement(const OptionsList &options_list_arg) :
|
|
|
|
options_list(options_list_arg)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
MarkovSwitchingStatement::writeOutput(ostream &output, const string &basename) const
|
|
|
|
{
|
2010-09-16 19:00:48 +02:00
|
|
|
OptionsList::num_options_t::const_iterator itChain, itState, itNOS, itDuration;
|
2009-12-08 17:46:13 +01:00
|
|
|
|
|
|
|
itChain = options_list.num_options.find("ms.chain");
|
|
|
|
if (itChain == options_list.num_options.end())
|
|
|
|
{
|
|
|
|
cerr << "MarkovSwitchingStatement::writeOutput() Should not arrive here (1). Please report this to the Dynare Team." << endl;
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
|
|
|
itDuration = options_list.num_options.find("ms.duration");
|
|
|
|
if (itDuration == options_list.num_options.end())
|
|
|
|
{
|
|
|
|
cerr << "MarkovSwitchingStatement::writeOutput() Should not arrive here (2). Please report this to the Dynare Team." << endl;
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
|
|
|
itState = options_list.num_options.find("ms.state");
|
|
|
|
itNOS = options_list.num_options.find("ms.number_of_states");
|
2009-12-16 18:13:23 +01:00
|
|
|
if (itState != options_list.num_options.end()
|
|
|
|
&& itNOS == options_list.num_options.end())
|
2009-12-08 17:46:13 +01:00
|
|
|
output << "options_.ms.ms_chain(" << itChain->second << ").state(" << itState->second << ").duration = " << itDuration->second << ";" << endl;
|
2009-12-16 18:13:23 +01:00
|
|
|
else if (itState == options_list.num_options.end()
|
|
|
|
&& itNOS != options_list.num_options.end())
|
|
|
|
for (int i = 0; i < atoi(itNOS->second.c_str()); i++)
|
2009-12-08 17:46:13 +01:00
|
|
|
output << "options_.ms.ms_chain(" << itChain->second << ").state(" << i+1 << ").duration = " << itDuration->second << ";" << endl;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
cerr << "MarkovSwitchingStatement::writeOutput() Should not arrive here (3). Please report this to the Dynare Team." << endl;
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
}
|
2009-12-09 01:38:53 +01:00
|
|
|
|
|
|
|
SvarStatement::SvarStatement(const OptionsList &options_list_arg) :
|
|
|
|
options_list(options_list_arg)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SvarStatement::writeOutput(ostream &output, const string &basename) const
|
|
|
|
{
|
2010-09-16 19:00:48 +02:00
|
|
|
OptionsList::num_options_t::const_iterator it0, it1, it2;
|
|
|
|
OptionsList::vec_int_options_t::const_iterator itv;
|
2009-12-09 01:38:53 +01:00
|
|
|
|
|
|
|
it0 = options_list.num_options.find("ms.chain");
|
|
|
|
if (it0 != options_list.num_options.end())
|
|
|
|
output << "options_.ms.ms_chain(" << it0->second << ")";
|
|
|
|
else
|
|
|
|
{
|
|
|
|
cerr << "SvarStatement::writeOutput() Should not arrive here (1). Please report this to the Dynare Team." << endl;
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
|
|
|
it0 = options_list.string_options.find("ms.coefficients");
|
|
|
|
it1 = options_list.string_options.find("ms.variances");
|
|
|
|
it2 = options_list.string_options.find("ms.constants");
|
2009-12-16 18:13:23 +01:00
|
|
|
if (it0 != options_list.string_options.end()
|
|
|
|
&& it1 == options_list.string_options.end()
|
|
|
|
&& it2 == options_list.string_options.end())
|
2009-12-09 01:38:53 +01:00
|
|
|
output << "." << it0->second;
|
2009-12-16 18:13:23 +01:00
|
|
|
else if (it0 == options_list.string_options.end()
|
|
|
|
&& it1 != options_list.string_options.end()
|
|
|
|
&& it2 == options_list.string_options.end())
|
2009-12-09 01:38:53 +01:00
|
|
|
output << "." << it1->second;
|
2009-12-16 18:13:23 +01:00
|
|
|
else if (it0 == options_list.string_options.end()
|
|
|
|
&& it1 == options_list.string_options.end()
|
|
|
|
&& it2 != options_list.string_options.end())
|
2009-12-09 01:38:53 +01:00
|
|
|
output << "." << it2->second;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
cerr << "SvarStatement::writeOutput() Should not arrive here (2). Please report this to the Dynare Team." << endl;
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
2009-12-10 23:49:50 +01:00
|
|
|
itv = options_list.vector_int_options.find("ms.equations");
|
|
|
|
output << ".equations = ";
|
|
|
|
if (itv != options_list.vector_int_options.end())
|
|
|
|
{
|
|
|
|
if (itv->second.size() > 1)
|
|
|
|
{
|
|
|
|
output << "[";
|
2009-12-16 18:13:23 +01:00
|
|
|
for (vector<int>::const_iterator viit = itv->second.begin();
|
|
|
|
viit != itv->second.end(); viit++)
|
2009-12-10 23:49:50 +01:00
|
|
|
output << *viit << ";";
|
|
|
|
output << "];" << endl;
|
|
|
|
}
|
|
|
|
else if (itv->second.size() == 1)
|
|
|
|
output << itv->second.front() << ";" << endl;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
cerr << "SvarStatement::writeOutput() Should not arrive here (3). Please report this to the Dynare Team." << endl;
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
}
|
2009-12-09 01:38:53 +01:00
|
|
|
else
|
2009-12-10 23:49:50 +01:00
|
|
|
output << "'ALL';" << endl;
|
2009-12-09 01:38:53 +01:00
|
|
|
}
|