Merge branch 'master' of kirikou.dynare.org:/srv/d_kirikou/git/dynare
commit
2c04f5c825
|
@ -1954,6 +1954,12 @@ of the simulation is period @code{0}, then period @code{-1}, and so on.
|
|||
If your lagged variables are linked by identities, be careful to
|
||||
satisfy these identities when you set historical initial values.
|
||||
|
||||
Variables not initialized in the @code{histval} block are assumed to
|
||||
have a value of zero at period 0 and before. Note that this behavior
|
||||
differs from the case where there is no @code{histval} block, where all
|
||||
variables are initialized at their steady state value at period 0 and
|
||||
before.
|
||||
|
||||
@examplehead
|
||||
|
||||
@example
|
||||
|
@ -3803,7 +3809,7 @@ algorithm. For the time being, @code{mh_replic} should be larger than
|
|||
|
||||
@item sub_draws = @var{INTEGER}
|
||||
@anchor{sub_draws} number of draws from the Metropolis iterations that
|
||||
are used to compute posterior distirbution of various objects (smoothed
|
||||
are used to compute posterior distribution of various objects (smoothed
|
||||
variable, smoothed shocks, forecast, moments, IRF). @code{sub_draws} should be smaller than
|
||||
the total number of Metropolis draws available. Default:
|
||||
@code{min(1200,0.25*Total number of draws)}
|
||||
|
|
|
@ -28,7 +28,7 @@ function global_initialization()
|
|||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
global oo_ M_ options_ estim_params_ bayestopt_
|
||||
global oo_ M_ options_ estim_params_ bayestopt_ estimation_info
|
||||
|
||||
estim_params_ = [];
|
||||
bayestopt_ = [];
|
||||
|
@ -182,6 +182,35 @@ options_.ramsey_policy = 0;
|
|||
options_.timeless = 0;
|
||||
|
||||
% estimation
|
||||
estimation_info.prior = struct('name', {}, 'shape', {}, 'mean', {}, ...
|
||||
'mode', {}, 'stdev', {}, 'date1', {}, ...
|
||||
'date2', {}, 'shift', {}, 'variance', {});
|
||||
estimation_info.structural_innovation.prior = struct('name', {}, 'shape', {}, 'mean', {}, ...
|
||||
'mode', {}, 'stdev', {}, 'date1', {}, ...
|
||||
'date2', {}, 'shift', {}, 'variance', {});
|
||||
estimation_info.structural_innovation_corr.prior = struct('name', {}, 'shape', {}, 'mean', {}, ...
|
||||
'mode', {}, 'stdev', {}, 'date1', {}, ...
|
||||
'date2', {}, 'shift', {}, 'variance', {});
|
||||
estimation_info.measurement_error.prior = struct('name', {}, 'shape', {}, 'mean', {}, ...
|
||||
'mode', {}, 'stdev', {}, 'date1', {}, ...
|
||||
'date2', {}, 'shift', {}, 'variance', {});
|
||||
estimation_info.measurement_error_corr.prior = struct('name', {}, 'shape', {}, 'mean', {}, ...
|
||||
'mode', {}, 'stdev', {}, 'date1', {}, ...
|
||||
'date2', {}, 'shift', {}, 'variance', {});
|
||||
estimation_info.measurement_error.prior_index = {};
|
||||
estimation_info.structural_innovation.prior_index = {};
|
||||
estimation_info.measurement_error_corr.prior_index = {};
|
||||
estimation_info.structural_innovation_corr.prior_index = {};
|
||||
estimation_info.measurement_error.options_index = {};
|
||||
estimation_info.structural_innovation.options_index = {};
|
||||
estimation_info.measurement_error_corr.options_index = {};
|
||||
estimation_info.structural_innovation_corr.options_index = {};
|
||||
options_.initial_period = dynDate(1);
|
||||
options_.dataset.firstobs = options_.initial_period;
|
||||
options_.dataset.lastobs = NaN;
|
||||
options_.dataset.nobs = NaN;
|
||||
options_.dataset.xls_sheet = NaN;
|
||||
options_.dataset.xls_range = NaN;
|
||||
options_.Harvey_scale_factor = 10;
|
||||
options_.MaxNumberOfBytes = 1e6;
|
||||
options_.MaximumNumberOfMegaBytes = 111;
|
||||
|
|
|
@ -52,7 +52,7 @@ function ms_write_markov_file(fname, options)
|
|||
%//=====================================================//
|
||||
fprintf(fh,'//== Number of states for state_variable[%d] ==//\n', ...
|
||||
i_chain);
|
||||
n_states = length(options.ms.ms_chain(i_chain).state);
|
||||
n_states = length(options.ms.ms_chain(i_chain).regime);
|
||||
fprintf(fh,'%d\n\n',n_states);
|
||||
|
||||
%//== 03/15/06: DW TVBVAR code reads the data below and overwrite the prior data read somewhere else if any.
|
||||
|
@ -64,7 +64,7 @@ function ms_write_markov_file(fname, options)
|
|||
i_chain);
|
||||
Alpha = ones(n_states,n_states);
|
||||
for i_state = 1:n_states
|
||||
p = 1-1/options.ms.ms_chain(i_chain).state(i_state).duration;
|
||||
p = 1-1/options.ms.ms_chain(i_chain).regime(i_state).duration;
|
||||
Alpha(i_state,i_state) = p*(n_states-1)/(1-p);
|
||||
fprintf(fh,'%22.16f',Alpha(i_state,:));
|
||||
fprintf(fh,'\n');
|
||||
|
|
|
@ -31,7 +31,7 @@ function plot_ms_probabilities(computed_probabilities, options_)
|
|||
[T,num_grand_regimes] = size(computed_probabilities);
|
||||
num_chains = length(options_.ms.ms_chain);
|
||||
for i=1:num_chains
|
||||
chains(i).num_regimes = length(options_.ms.ms_chain(i).state);
|
||||
chains(i).num_regimes = length(options_.ms.ms_chain(i).regime);
|
||||
chains(i).probabilities = zeros([T,chains(i).num_regimes]);
|
||||
end
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
function y_=simult(ys, dr)
|
||||
% function y_=simult(ys, dr)
|
||||
function y_=simult(y0, dr)
|
||||
% function y_=simult(y0, dr)
|
||||
% Recursive Monte Carlo simulations
|
||||
%
|
||||
% INPUTS
|
||||
% ys: vector of variables in steady state
|
||||
% y0: vector of variables in initial period of the simulation
|
||||
% dr: structure of decisions rules for stochastic simulations
|
||||
%
|
||||
% OUTPUTS
|
||||
|
@ -54,7 +54,7 @@ for i=1:replic
|
|||
if ~isempty(M_.Sigma_e)
|
||||
oo_.exo_simul(:,i_exo_var) = randn(options_.periods,nxs)*chol_S;
|
||||
end
|
||||
y_ = simult_(ys,dr,oo_.exo_simul,order);
|
||||
y_ = simult_(y0,dr,oo_.exo_simul,order);
|
||||
% elimninating initial value
|
||||
y_ = y_(:,2:end);
|
||||
if replic > 1
|
||||
|
|
|
@ -130,7 +130,15 @@ if options_.periods > 0 && ~PI_PCL_solver
|
|||
options_ =options_old;
|
||||
return
|
||||
end
|
||||
oo_.endo_simul = simult(oo_.dr.ys,oo_.dr);
|
||||
% Note that the first column of oo_.endo_simul is preserved by the following
|
||||
% call to simult; this is important because stoch_simul can be followed by
|
||||
% forecast (see ticket #157)
|
||||
if size(oo_.endo_simul,2) == 0
|
||||
y0 = oo_.dr.ys;
|
||||
else
|
||||
y0 = oo_.endo_simul(:,1);
|
||||
end
|
||||
oo_.endo_simul = simult(y0,oo_.dr);
|
||||
dyn2vec;
|
||||
end
|
||||
|
||||
|
|
|
@ -82,7 +82,12 @@ elseif options_.periods ~= 0
|
|||
options_ =options_old;
|
||||
return
|
||||
end
|
||||
oo_.endo_simul = simult(repmat(oo_.dr.ys,1,M_.maximum_lag),oo_.dr);
|
||||
if size(oo_.endo_simul,2) < maximum_lag
|
||||
y0 = oo_.dr.ys;
|
||||
else
|
||||
y0 = oo_.endo_simul(:,1);
|
||||
end
|
||||
oo_.endo_simul = simult(y0,oo_.dr);
|
||||
dyn2vec;
|
||||
if options_.nomoments == 0
|
||||
disp_moments(oo_.endo_simul,var_list);
|
||||
|
|
|
@ -147,7 +147,8 @@ enum SymbolType
|
|||
eModelLocalVariable = 10, //!< Local variable whose scope is model (pound expression)
|
||||
eModFileLocalVariable = 11, //!< Local variable whose scope is mod file (model excluded)
|
||||
eExternalFunction = 12, //!< External (user-defined) function
|
||||
eTrend = 13 //!< Trend variable
|
||||
eTrend = 13, //!< Trend variable
|
||||
eStatementDeclaredVariable = 14 //!< Local variable assigned within a Statement (see subsample statement for example)
|
||||
};
|
||||
|
||||
enum ExpressionType
|
||||
|
|
|
@ -135,15 +135,6 @@ StochSimulStatement::checkPass(ModFileStructure &mod_file_struct)
|
|||
cerr << "ERROR: in 'stoch_simul', you cannot use option 'pruning' with 'k_order_solver' option or with 3rd order approximation" << endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -325,6 +316,30 @@ EstimationStatement::checkPass(ModFileStructure &mod_file_struct)
|
|||
cerr << "ERROR: An estimation statement cannot take more than one dsge_var option." << endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (options_list.string_options.find("datafile") == options_list.string_options.end() &&
|
||||
!mod_file_struct.estimation_data_statement_present)
|
||||
{
|
||||
cerr << "ERROR: The estimation statement requires a data file to be supplied "
|
||||
<< "either from the data statement or from the deprecated option datafile." << endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (options_list.string_options.find("datafile") != options_list.string_options.end())
|
||||
cerr << "WARNING: The datafile option of estimation has been deprecated. "
|
||||
<< "Use the data command instead." << endl;
|
||||
|
||||
if (options_list.string_options.find("xls_sheet") != options_list.string_options.end())
|
||||
cerr << "WARNING: The xls_sheet option of estimation has been deprecated. "
|
||||
<< "Use the data command instead." << endl;
|
||||
|
||||
if (options_list.string_options.find("xls_range") != options_list.string_options.end())
|
||||
cerr << "WARNING: The xls_range option of estimation has been deprecated. "
|
||||
<< "Use the data command instead." << endl;
|
||||
|
||||
if (options_list.num_options.find("first_obs") != options_list.num_options.end())
|
||||
cerr << "WARNING: The first_obs option of estimation has been deprecated. "
|
||||
<< "Use the data command instead." << endl;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1335,7 +1350,9 @@ MarkovSwitchingStatement::MarkovSwitchingStatement(const OptionsList &options_li
|
|||
void
|
||||
MarkovSwitchingStatement::writeOutput(ostream &output, const string &basename) const
|
||||
{
|
||||
OptionsList::num_options_t::const_iterator itChain, itState, itNOS, itDuration;
|
||||
bool isDurationAVec = true;
|
||||
string infStr("Inf");
|
||||
OptionsList::num_options_t::const_iterator itChain, itNOR, itDuration;
|
||||
|
||||
itChain = options_list.num_options.find("ms.chain");
|
||||
if (itChain == options_list.num_options.end())
|
||||
|
@ -1350,16 +1367,20 @@ MarkovSwitchingStatement::writeOutput(ostream &output, const string &basename) c
|
|||
cerr << "MarkovSwitchingStatement::writeOutput() Should not arrive here (2). Please report this to the Dynare Team." << endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
else if (atof(itDuration->second.c_str()) || infStr.compare(itDuration->second) == 0)
|
||||
isDurationAVec = false;
|
||||
output << "options_.ms.duration = " << itDuration->second << ";" << endl;
|
||||
|
||||
itState = options_list.num_options.find("ms.state");
|
||||
itNOS = options_list.num_options.find("ms.number_of_states");
|
||||
if (itState != options_list.num_options.end()
|
||||
&& itNOS == options_list.num_options.end())
|
||||
output << "options_.ms.ms_chain(" << itChain->second << ").state(" << itState->second << ").duration = " << itDuration->second << ";" << endl;
|
||||
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++)
|
||||
output << "options_.ms.ms_chain(" << itChain->second << ").state(" << i+1 << ").duration = " << itDuration->second << ";" << endl;
|
||||
itNOR = options_list.num_options.find("ms.number_of_regimes");
|
||||
if (itNOR != options_list.num_options.end())
|
||||
for (int i = 0; i < atoi(itNOR->second.c_str()); i++)
|
||||
{
|
||||
output << "options_.ms.ms_chain(" << itChain->second << ").regime("
|
||||
<< i+1 << ").duration = options_.ms.duration";
|
||||
if (isDurationAVec)
|
||||
output << "(" << i+1 << ")";
|
||||
output << ";" << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
cerr << "MarkovSwitchingStatement::writeOutput() Should not arrive here (3). Please report this to the Dynare Team." << endl;
|
||||
|
@ -1431,3 +1452,416 @@ SvarStatement::writeOutput(ostream &output, const string &basename) const
|
|||
else
|
||||
output << "'ALL';" << endl;
|
||||
}
|
||||
|
||||
SetTimeStatement::SetTimeStatement(const OptionsList &options_list_arg) :
|
||||
options_list(options_list_arg)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
SetTimeStatement::writeOutput(ostream &output, const string &basename) const
|
||||
{
|
||||
options_list.writeOutput(output);
|
||||
}
|
||||
|
||||
EstimationDataStatement::EstimationDataStatement(const OptionsList &options_list_arg) :
|
||||
options_list(options_list_arg)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
EstimationDataStatement::checkPass(ModFileStructure &mod_file_struct)
|
||||
{
|
||||
mod_file_struct.estimation_data_statement_present = true;
|
||||
|
||||
OptionsList::num_options_t::const_iterator it = options_list.num_options.find("nobs");
|
||||
if (it != options_list.num_options.end())
|
||||
if (atoi(it->second.c_str()) <= 0)
|
||||
{
|
||||
cerr << "ERROR: The nobs option of the data statement only accepts positive integers." << endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (options_list.string_options.find("file") == options_list.string_options.end())
|
||||
{
|
||||
cerr << "ERROR: The file option must be passed to the data statement." << endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
EstimationDataStatement::writeOutput(ostream &output, const string &basename) const
|
||||
{
|
||||
options_list.writeOutput(output, "options_.dataset");
|
||||
if (options_list.date_options.find("first_obs") == options_list.date_options.end())
|
||||
output << "options_.dataset.firstobs = options_.initial_period;" << endl;
|
||||
}
|
||||
|
||||
BasicPriorStatement::~BasicPriorStatement()
|
||||
{
|
||||
}
|
||||
|
||||
BasicPriorStatement::BasicPriorStatement(const string &name_arg,
|
||||
const expr_t &variance_arg,
|
||||
const OptionsList &options_list_arg) :
|
||||
name(name_arg),
|
||||
variance(variance_arg),
|
||||
options_list(options_list_arg),
|
||||
first_statement_encountered(false)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
BasicPriorStatement::checkPass(ModFileStructure &mod_file_struct)
|
||||
{
|
||||
if (options_list.num_options.find("shape") == options_list.num_options.end())
|
||||
{
|
||||
cerr << "ERROR: You must pass the shape option to the prior statement." << endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
if (options_list.num_options.find("date1") != options_list.num_options.end() ||
|
||||
options_list.num_options.find("date2") != options_list.num_options.end())
|
||||
if (options_list.num_options.find("date1") == options_list.num_options.end() ||
|
||||
options_list.num_options.find("date2") == options_list.num_options.end())
|
||||
{
|
||||
cerr << "ERROR: PriorStatement::checkPass(1). Should not arrive here. "
|
||||
<< "Please inform Dynare Team." << endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
BasicPriorStatement::get_base_name(const SymbolType symb_type, string &lhs_field) const
|
||||
{
|
||||
if (symb_type == eExogenous || symb_type == eExogenousDet)
|
||||
lhs_field = "structural_innovation";
|
||||
else
|
||||
lhs_field = "measurement_error";
|
||||
}
|
||||
|
||||
void
|
||||
BasicPriorStatement::writePriorIndex(ostream &output, const string &lhs_field) const
|
||||
{
|
||||
if (first_statement_encountered)
|
||||
output << "prior_indx = 1;" << endl;
|
||||
else
|
||||
output << "prior_indx = size(estimation_info" << lhs_field << "_index, 2) + 1;" << endl;
|
||||
}
|
||||
|
||||
void
|
||||
BasicPriorStatement::writeVarianceOption(ostream &output, const string &lhs_field) const
|
||||
{
|
||||
if (variance)
|
||||
{
|
||||
output << "estimation_info" << lhs_field << "(prior_indx).variance = ";
|
||||
variance->writeOutput(output);
|
||||
output << ";" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
BasicPriorStatement::writeOutputHelper(ostream &output, const string &field, const string &lhs_field) const
|
||||
{
|
||||
|
||||
OptionsList::num_options_t::const_iterator itn = options_list.num_options.find(field);
|
||||
if (itn != options_list.num_options.end())
|
||||
output << "estimation_info" << lhs_field << "(prior_indx)." << field
|
||||
<< " = " << itn->second << ";" << endl;
|
||||
|
||||
OptionsList::date_options_t::const_iterator itd = options_list.date_options.find(field);
|
||||
if (itd != options_list.date_options.end())
|
||||
output << "estimation_info" << lhs_field << "(prior_indx)." << field
|
||||
<< " = '" << itd->second << "';" << endl;
|
||||
}
|
||||
|
||||
PriorStatement::PriorStatement(const string &name_arg,
|
||||
const expr_t &variance_arg,
|
||||
const OptionsList &options_list_arg) :
|
||||
BasicPriorStatement(name_arg, variance_arg, options_list_arg)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
PriorStatement::checkPass(ModFileStructure &mod_file_struct)
|
||||
{
|
||||
BasicPriorStatement::checkPass(mod_file_struct);
|
||||
if (!mod_file_struct.prior_statement_present)
|
||||
first_statement_encountered = true;
|
||||
mod_file_struct.prior_statement_present = true;
|
||||
}
|
||||
|
||||
void
|
||||
PriorStatement::writeOutput(ostream &output, const string &basename) const
|
||||
{
|
||||
string lhs_field = ".prior";
|
||||
|
||||
BasicPriorStatement::writePriorIndex(output, lhs_field);
|
||||
output << "estimation_info" << lhs_field << "_index(prior_indx) = {'" << name << "'};" << endl
|
||||
<< "estimation_info" << lhs_field <<"(prior_indx).name = '" << name << "';" << endl;
|
||||
|
||||
writeOutputHelper(output, "mean", lhs_field);
|
||||
writeOutputHelper(output, "mode", lhs_field);
|
||||
writeOutputHelper(output, "stdev", lhs_field);
|
||||
writeOutputHelper(output, "shape", lhs_field);
|
||||
writeOutputHelper(output, "shift", lhs_field);
|
||||
writeOutputHelper(output, "date1", lhs_field);
|
||||
writeOutputHelper(output, "date2", lhs_field);
|
||||
writeOutputHelper(output, "domain", lhs_field);
|
||||
writeOutputHelper(output, "interval", lhs_field);
|
||||
BasicPriorStatement::writeVarianceOption(output, lhs_field);
|
||||
}
|
||||
|
||||
StdPriorStatement::StdPriorStatement(const string &name_arg,
|
||||
const expr_t &variance_arg,
|
||||
const OptionsList &options_list_arg,
|
||||
const SymbolTable &symbol_table_arg ) :
|
||||
BasicPriorStatement(name_arg, variance_arg, options_list_arg),
|
||||
symbol_table(symbol_table_arg)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
StdPriorStatement::checkPass(ModFileStructure &mod_file_struct)
|
||||
{
|
||||
BasicPriorStatement::checkPass(mod_file_struct);
|
||||
if (!mod_file_struct.std_prior_statement_present)
|
||||
first_statement_encountered = true;
|
||||
mod_file_struct.std_prior_statement_present = true;
|
||||
}
|
||||
|
||||
void
|
||||
StdPriorStatement::writeOutput(ostream &output, const string &basename) const
|
||||
{
|
||||
string lhs_field;
|
||||
get_base_name(symbol_table.getType(name), lhs_field);
|
||||
lhs_field = "." + lhs_field + ".prior";
|
||||
|
||||
BasicPriorStatement::writePriorIndex(output, lhs_field);
|
||||
output << "estimation_info" << lhs_field << "_index(prior_indx) = {'" << name << "'};" << endl;
|
||||
output << "estimation_info" << lhs_field << "(prior_indx).name = '" << name << "';" << endl;
|
||||
|
||||
writeOutputHelper(output, "mean", lhs_field);
|
||||
writeOutputHelper(output, "mode", lhs_field);
|
||||
writeOutputHelper(output, "stdev", lhs_field);
|
||||
writeOutputHelper(output, "shape", lhs_field);
|
||||
writeOutputHelper(output, "shift", lhs_field);
|
||||
writeOutputHelper(output, "domain", lhs_field);
|
||||
writeOutputHelper(output, "interval", lhs_field);
|
||||
BasicPriorStatement::writeVarianceOption(output, lhs_field);
|
||||
}
|
||||
|
||||
CorrPriorStatement::CorrPriorStatement(const string &name_arg1, const string &name_arg2,
|
||||
const expr_t &variance_arg,
|
||||
const OptionsList &options_list_arg,
|
||||
const SymbolTable &symbol_table_arg ) :
|
||||
BasicPriorStatement(name_arg1, variance_arg, options_list_arg),
|
||||
name1(name_arg2),
|
||||
symbol_table(symbol_table_arg)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
CorrPriorStatement::checkPass(ModFileStructure &mod_file_struct)
|
||||
{
|
||||
BasicPriorStatement::checkPass(mod_file_struct);
|
||||
if (symbol_table.getType(name) != symbol_table.getType(name1))
|
||||
{
|
||||
cerr << "ERROR: In the corr(A,B).prior statement, A and B must be of the same type. "
|
||||
<< "In your case, " << name << " and " << name1 << " are of different "
|
||||
<< "types." << endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
if (!mod_file_struct.corr_prior_statement_present)
|
||||
first_statement_encountered = true;
|
||||
mod_file_struct.corr_prior_statement_present = true;
|
||||
}
|
||||
|
||||
void
|
||||
CorrPriorStatement::writeOutput(ostream &output, const string &basename) const
|
||||
{
|
||||
string lhs_field;
|
||||
get_base_name(symbol_table.getType(name), lhs_field);
|
||||
lhs_field = "." + lhs_field + "_corr.prior";
|
||||
|
||||
BasicPriorStatement::writePriorIndex(output, lhs_field);
|
||||
output << "estimation_info" << lhs_field << "_index(prior_indx) = {'" << name << "_" << name1 << "'};" << endl;
|
||||
output << "estimation_info" << lhs_field << "(prior_indx).name1 = '" << name << "';" << endl;
|
||||
output << "estimation_info" << lhs_field << "(prior_indx).name2 = '" << name1 << "';" << endl;
|
||||
|
||||
writeOutputHelper(output, "mean", lhs_field);
|
||||
writeOutputHelper(output, "mode", lhs_field);
|
||||
writeOutputHelper(output, "stdev", lhs_field);
|
||||
writeOutputHelper(output, "shape", lhs_field);
|
||||
writeOutputHelper(output, "shift", lhs_field);
|
||||
writeOutputHelper(output, "domain", lhs_field);
|
||||
writeOutputHelper(output, "interval", lhs_field);
|
||||
BasicPriorStatement::writeVarianceOption(output, lhs_field);
|
||||
}
|
||||
|
||||
BasicOptionsStatement::~BasicOptionsStatement()
|
||||
{
|
||||
}
|
||||
|
||||
BasicOptionsStatement::BasicOptionsStatement(const string &name_arg,
|
||||
const OptionsList &options_list_arg) :
|
||||
name(name_arg),
|
||||
options_list(options_list_arg),
|
||||
first_statement_encountered(false)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
BasicOptionsStatement::checkPass(ModFileStructure &mod_file_struct)
|
||||
{
|
||||
if (options_list.num_options.find("date1") != options_list.num_options.end() ||
|
||||
options_list.num_options.find("date2") != options_list.num_options.end())
|
||||
if (options_list.num_options.find("date1") == options_list.num_options.end() ||
|
||||
options_list.num_options.find("date2") == options_list.num_options.end())
|
||||
{
|
||||
cerr << "ERROR: OptionsStatement::checkPass(1). Should not arrive here. "
|
||||
<< "Please inform Dynare Team." << endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
BasicOptionsStatement::writeOptionsIndex(ostream &output, const string &lhs_field) const
|
||||
{
|
||||
if (first_statement_encountered)
|
||||
output << "options_indx = 1;" << endl;
|
||||
else
|
||||
output << "options_indx = size(estimation_info" << lhs_field << "_index, 2) + 1;" << endl;
|
||||
}
|
||||
|
||||
void
|
||||
BasicOptionsStatement::get_base_name(const SymbolType symb_type, string &lhs_field) const
|
||||
{
|
||||
if (symb_type == eExogenous || symb_type == eExogenousDet)
|
||||
lhs_field = "structural_innovation";
|
||||
else
|
||||
lhs_field = "measurement_error";
|
||||
}
|
||||
|
||||
void
|
||||
BasicOptionsStatement::writeOutputHelper(ostream &output, const string &field, const string &lhs_field) const
|
||||
{
|
||||
OptionsList::num_options_t::const_iterator itn = options_list.num_options.find(field);
|
||||
if (itn != options_list.num_options.end())
|
||||
output << "estimation_info" << lhs_field << "(options_indx)." << field
|
||||
<< " = " << itn->second << ";" << endl;
|
||||
|
||||
OptionsList::date_options_t::const_iterator itd = options_list.date_options.find(field);
|
||||
if (itd != options_list.date_options.end())
|
||||
output << "estimation_info" << lhs_field << "(options_indx)." << field
|
||||
<< " = '" << itd->second << "';" << endl;
|
||||
}
|
||||
|
||||
OptionsStatement::OptionsStatement(const string &name_arg,
|
||||
const OptionsList &options_list_arg) :
|
||||
BasicOptionsStatement(name_arg, options_list_arg)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
OptionsStatement::checkPass(ModFileStructure &mod_file_struct)
|
||||
{
|
||||
BasicOptionsStatement::checkPass(mod_file_struct);
|
||||
if (!mod_file_struct.options_statement_present)
|
||||
first_statement_encountered = true;
|
||||
mod_file_struct.options_statement_present = true;
|
||||
}
|
||||
|
||||
void
|
||||
OptionsStatement::writeOutput(ostream &output, const string &basename) const
|
||||
{
|
||||
string lhs_field = ".options";
|
||||
|
||||
BasicOptionsStatement::writeOptionsIndex(output, lhs_field);
|
||||
output << "estimation_info" << lhs_field <<"_index(options_indx) = {'" << name << "'};" << endl
|
||||
<< "estimation_info" << lhs_field << "(options_indx).name = '" << name << "';" << endl;
|
||||
|
||||
writeOutputHelper(output, "init", lhs_field);
|
||||
writeOutputHelper(output, "bounds", lhs_field);
|
||||
writeOutputHelper(output, "jscale", lhs_field);
|
||||
writeOutputHelper(output, "date1", lhs_field);
|
||||
writeOutputHelper(output, "date2", lhs_field);
|
||||
}
|
||||
|
||||
StdOptionsStatement::StdOptionsStatement(const string &name_arg,
|
||||
const OptionsList &options_list_arg,
|
||||
const SymbolTable &symbol_table_arg ) :
|
||||
BasicOptionsStatement(name_arg, options_list_arg),
|
||||
symbol_table(symbol_table_arg)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
StdOptionsStatement::checkPass(ModFileStructure &mod_file_struct)
|
||||
{
|
||||
BasicOptionsStatement::checkPass(mod_file_struct);
|
||||
if (!mod_file_struct.std_options_statement_present)
|
||||
first_statement_encountered = true;
|
||||
mod_file_struct.std_options_statement_present = true;
|
||||
}
|
||||
|
||||
void
|
||||
StdOptionsStatement::writeOutput(ostream &output, const string &basename) const
|
||||
{
|
||||
string lhs_field;
|
||||
get_base_name(symbol_table.getType(name), lhs_field);
|
||||
lhs_field = "." + lhs_field + ".options";
|
||||
|
||||
BasicOptionsStatement::writeOptionsIndex(output, lhs_field);
|
||||
output << "estimation_info" << lhs_field << "_index(options_indx) = {'" << name << "'};" << endl;
|
||||
output << "estimation_info" << lhs_field << "(options_indx).name = '" << name << "';" << endl;
|
||||
|
||||
writeOutputHelper(output, "init", lhs_field);
|
||||
writeOutputHelper(output, "bounds", lhs_field);
|
||||
writeOutputHelper(output, "jscale", lhs_field);
|
||||
writeOutputHelper(output, "date1", lhs_field);
|
||||
writeOutputHelper(output, "date2", lhs_field);
|
||||
}
|
||||
|
||||
CorrOptionsStatement::CorrOptionsStatement(const string &name_arg1, const string &name_arg2,
|
||||
const OptionsList &options_list_arg,
|
||||
const SymbolTable &symbol_table_arg ) :
|
||||
BasicOptionsStatement(name_arg1, options_list_arg),
|
||||
name1(name_arg2),
|
||||
symbol_table(symbol_table_arg)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
CorrOptionsStatement::checkPass(ModFileStructure &mod_file_struct)
|
||||
{
|
||||
if (symbol_table.getType(name) != symbol_table.getType(name1))
|
||||
{
|
||||
cerr << "ERROR: In the corr(A,B).options statement, A and B must be of the same type. "
|
||||
<< "In your case, " << name << " and " << name1 << " are of different "
|
||||
<< "types." << endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
if (!mod_file_struct.corr_options_statement_present)
|
||||
first_statement_encountered = true;
|
||||
mod_file_struct.corr_prior_statement_present = true;
|
||||
}
|
||||
|
||||
void
|
||||
CorrOptionsStatement::writeOutput(ostream &output, const string &basename) const
|
||||
{
|
||||
string lhs_field;
|
||||
get_base_name(symbol_table.getType(name), lhs_field);
|
||||
lhs_field = "." + lhs_field + "_corr.options";
|
||||
|
||||
BasicOptionsStatement::writeOptionsIndex(output, lhs_field);
|
||||
output << "estimation_info" << lhs_field << "_index(options_indx) = {'" << name << "_" << name1 << "'};" << endl;
|
||||
lhs_field += ".";
|
||||
output << "estimation_info" << lhs_field << "(options_indx).name1 = '" << name << "';" << endl;
|
||||
output << "estimation_info" << lhs_field << "(options_indx).name2 = '" << name1 << "';" << endl;
|
||||
|
||||
writeOutputHelper(output, "init", lhs_field);
|
||||
writeOutputHelper(output, "bounds", lhs_field);
|
||||
writeOutputHelper(output, "jscale", lhs_field);
|
||||
writeOutputHelper(output, "date1", lhs_field);
|
||||
writeOutputHelper(output, "date2", lhs_field);
|
||||
}
|
||||
|
|
|
@ -556,4 +556,127 @@ public:
|
|||
virtual void writeOutput(ostream &output, const string &basename) const;
|
||||
};
|
||||
|
||||
class SetTimeStatement : public Statement
|
||||
{
|
||||
private:
|
||||
const OptionsList options_list;
|
||||
public:
|
||||
SetTimeStatement(const OptionsList &options_list_arg);
|
||||
virtual void writeOutput(ostream &output, const string &basename) const;
|
||||
};
|
||||
|
||||
class EstimationDataStatement : public Statement
|
||||
{
|
||||
private:
|
||||
const OptionsList options_list;
|
||||
public:
|
||||
EstimationDataStatement(const OptionsList &options_list_arg);
|
||||
virtual void checkPass(ModFileStructure &mod_file_struct);
|
||||
virtual void writeOutput(ostream &output, const string &basename) const;
|
||||
};
|
||||
|
||||
class BasicPriorStatement : public Statement
|
||||
{
|
||||
public:
|
||||
virtual ~BasicPriorStatement();
|
||||
protected:
|
||||
const string name;
|
||||
const expr_t variance;
|
||||
const OptionsList options_list;
|
||||
bool first_statement_encountered;
|
||||
BasicPriorStatement(const string &name_arg,
|
||||
const expr_t &variance_arg,
|
||||
const OptionsList &options_list_arg);
|
||||
virtual void checkPass(ModFileStructure &mod_file_struct);
|
||||
void get_base_name(const SymbolType symb_type, string &lhs_field) const;
|
||||
void writePriorIndex(ostream &output, const string &lhs_field) const;
|
||||
void writeVarianceOption(ostream &output, const string &lhs_field) const;
|
||||
void writeOutputHelper(ostream &output, const string &field, const string &lhs_field) const;
|
||||
};
|
||||
|
||||
class PriorStatement : public BasicPriorStatement
|
||||
{
|
||||
public:
|
||||
PriorStatement(const string &name_arg,
|
||||
const expr_t &variance_arg,
|
||||
const OptionsList &options_list_arg);
|
||||
virtual void checkPass(ModFileStructure &mod_file_struct);
|
||||
virtual void writeOutput(ostream &output, const string &basename) const;
|
||||
};
|
||||
|
||||
class StdPriorStatement : public BasicPriorStatement
|
||||
{
|
||||
private:
|
||||
const SymbolTable symbol_table;
|
||||
public:
|
||||
StdPriorStatement(const string &name_arg,
|
||||
const expr_t &variance_arg,
|
||||
const OptionsList &options_list_arg,
|
||||
const SymbolTable &symbol_table_arg);
|
||||
virtual void checkPass(ModFileStructure &mod_file_struct);
|
||||
virtual void writeOutput(ostream &output, const string &basename) const;
|
||||
};
|
||||
|
||||
class CorrPriorStatement : public BasicPriorStatement
|
||||
{
|
||||
private:
|
||||
const string name1;
|
||||
const SymbolTable symbol_table;
|
||||
public:
|
||||
CorrPriorStatement(const string &name_arg1,
|
||||
const string &name_arg2,
|
||||
const expr_t &variance_arg,
|
||||
const OptionsList &options_list_arg,
|
||||
const SymbolTable &symbol_table_arg);
|
||||
virtual void checkPass(ModFileStructure &mod_file_struct);
|
||||
virtual void writeOutput(ostream &output, const string &basename) const;
|
||||
};
|
||||
|
||||
class BasicOptionsStatement : public Statement
|
||||
{
|
||||
public:
|
||||
virtual ~BasicOptionsStatement();
|
||||
protected:
|
||||
const string name;
|
||||
const OptionsList options_list;
|
||||
bool first_statement_encountered;
|
||||
BasicOptionsStatement(const string &name_arg,
|
||||
const OptionsList &options_list_arg);
|
||||
void get_base_name(const SymbolType symb_type, string &lhs_field) const;
|
||||
virtual void checkPass(ModFileStructure &mod_file_struct);
|
||||
void writeOptionsIndex(ostream &output, const string &lhs_field) const;
|
||||
void writeOutputHelper(ostream &output, const string &field, const string &lhs_field) const;
|
||||
};
|
||||
|
||||
class OptionsStatement : public BasicOptionsStatement
|
||||
{
|
||||
public:
|
||||
OptionsStatement(const string &name_arg, const OptionsList &options_list_arg);
|
||||
virtual void checkPass(ModFileStructure &mod_file_struct);
|
||||
virtual void writeOutput(ostream &output, const string &basename) const;
|
||||
};
|
||||
|
||||
class StdOptionsStatement : public BasicOptionsStatement
|
||||
{
|
||||
private:
|
||||
const SymbolTable symbol_table;
|
||||
public:
|
||||
StdOptionsStatement(const string &name_arg, const OptionsList &options_list_arg,
|
||||
const SymbolTable &symbol_table_arg);
|
||||
virtual void checkPass(ModFileStructure &mod_file_struct);
|
||||
virtual void writeOutput(ostream &output, const string &basename) const;
|
||||
};
|
||||
|
||||
class CorrOptionsStatement : public BasicOptionsStatement
|
||||
{
|
||||
private:
|
||||
const string name1;
|
||||
const SymbolTable symbol_table;
|
||||
public:
|
||||
CorrOptionsStatement(const string &name_arg1, const string &name_arg2,
|
||||
const OptionsList &options_list_arg, const SymbolTable &symbol_table_arg);
|
||||
virtual void checkPass(ModFileStructure &mod_file_struct);
|
||||
virtual void writeOutput(ostream &output, const string &basename) const;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -94,17 +94,18 @@ class ParsingDriver;
|
|||
%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 DATAFILE DR_ALGO DROP DSAMPLE DYNASAVE DYNATYPE CALIBRATION
|
||||
%token DATAFILE FILE 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
|
||||
%token FILENAME FILTER_STEP_AHEAD FILTERED_VARS FIRST_OBS LAST_OBS SET_TIME
|
||||
%token <string_val> FLOAT_NUMBER
|
||||
%token FORECAST K_ORDER_SOLVER INSTRUMENTS
|
||||
%token GAMMA_PDF GRAPH CONDITIONAL_VARIANCE_DECOMPOSITION NOCHECK
|
||||
%token FORECAST K_ORDER_SOLVER INSTRUMENTS PRIOR SHIFT MEAN STDEV VARIANCE MODE INTERVAL SHAPE DOMAINN
|
||||
%token GAMMA_PDF GRAPH CONDITIONAL_VARIANCE_DECOMPOSITION NOCHECK STD
|
||||
%token HISTVAL HOMOTOPY_SETUP HOMOTOPY_MODE HOMOTOPY_STEPS HP_FILTER HP_NGRID
|
||||
%token IDENTIFICATION INF_CONSTANT INITVAL INITVAL_FILE
|
||||
%token IDENTIFICATION INF_CONSTANT INITVAL INITVAL_FILE BOUNDS JSCALE INIT
|
||||
%token <string_val> INT_NUMBER
|
||||
%token <string_val> DATE_NUMBER
|
||||
%token INV_GAMMA_PDF INV_GAMMA1_PDF INV_GAMMA2_PDF IRF IRF_SHOCKS
|
||||
%token KALMAN_ALGO KALMAN_TOL
|
||||
%token KALMAN_ALGO KALMAN_TOL SUBSAMPLES OPTIONS
|
||||
%token LABELS LAPLACE LIK_ALGO LIK_INIT LINEAR LOAD_IDENT_FILES LOAD_MH_FILE LOAD_PARAMS_AND_STEADY_STATE LOGLINEAR
|
||||
%token MARKOWITZ MARGINAL_DENSITY MAX MAXIT
|
||||
%token MFS MH_DROP MH_INIT_SCALE MH_JSCALE MH_MODE MH_NBLOCKS MH_REPLIC MH_RECOVER MIN MINIMAL_SOLVING_PERIODS
|
||||
|
@ -144,9 +145,9 @@ class ParsingDriver;
|
|||
/* end of GSA analysis*/
|
||||
%token FREQ INITIAL_YEAR INITIAL_SUBPERIOD FINAL_YEAR FINAL_SUBPERIOD DATA VLIST LOG_VAR PERCENT_VAR
|
||||
%token VLISTLOG VLISTPER
|
||||
%token RESTRICTION RESTRICTIONS RESTRICTION_FNAME CROSS_RESTRICTIONS NLAGS CONTEMP_REDUCED_FORM REAL_PSEUDO_FORECAST
|
||||
%token RESTRICTION RESTRICTION_FNAME CROSS_RESTRICTIONS NLAGS CONTEMP_REDUCED_FORM REAL_PSEUDO_FORECAST
|
||||
%token NONE DUMMY_OBS NSTATES INDXSCALESSTATES NO_BAYESIAN_PRIOR SPECIFICATION SIMS_ZHA
|
||||
%token <string_val> ALPHA BETA ABAND NINV CMS NCMS CNUM
|
||||
%token <string_val> ALPHA BETA ABAND NINV CMS NCMS CNUM GAMMA INV_GAMMA INV_GAMMA1 INV_GAMMA2 NORMAL UNIFORM
|
||||
%token GSIG2_LMDM Q_DIAG FLAT_PRIOR NCSK NSTD
|
||||
%token INDXPARR INDXOVR INDXAP APBAND INDXIMF IMFBAND INDXFORE FOREBAND INDXGFOREHAT INDXGIMFHAT
|
||||
%token INDXESTIMA INDXGDLS EQ_MS FILTER_COVARIANCE FILTER_DECOMPOSITION
|
||||
|
@ -155,7 +156,7 @@ class ParsingDriver;
|
|||
%token SBVAR TREND_VAR DEFLATOR GROWTH_FACTOR MS_IRF MS_VARIANCE_DECOMPOSITION
|
||||
%token MS_ESTIMATION MS_SIMULATION MS_COMPUTE_MDD MS_COMPUTE_PROBABILITIES MS_FORECAST
|
||||
%token SVAR_IDENTIFICATION EQUATION EXCLUSION LAG UPPER_CHOLESKY LOWER_CHOLESKY MONTHLY QUARTERLY
|
||||
%token MARKOV_SWITCHING CHAIN STATE DURATION NUMBER_OF_STATES
|
||||
%token MARKOV_SWITCHING CHAIN DURATION NUMBER_OF_REGIMES
|
||||
%token SVAR COEFF COEFFICIENTS VARIANCES CONSTANTS EQUATIONS
|
||||
%token EXTERNAL_FUNCTION EXT_FUNC_NAME EXT_FUNC_NARGS FIRST_DERIV_PROVIDED SECOND_DERIV_PROVIDED
|
||||
%token SELECTED_VARIABLES_ONLY COVA_COMPUTE SIMULATION_FILE_TAG FILE_TAG
|
||||
|
@ -173,10 +174,10 @@ class ParsingDriver;
|
|||
|
||||
%type <node_val> expression expression_or_empty
|
||||
%type <node_val> equation hand_side
|
||||
%type <string_val> non_negative_number signed_number signed_integer
|
||||
%type <string_val> filename symbol
|
||||
%type <string_val> vec_value_1 vec_value
|
||||
%type <string_val> range prior
|
||||
%type <string_val> non_negative_number signed_number signed_integer date_number
|
||||
%type <string_val> filename symbol prior_distribution
|
||||
%type <string_val> vec_value_1 vec_value signed_inf signed_number_w_inf
|
||||
%type <string_val> range prior_pdf_string vec_value_w_inf vec_value_1_w_inf
|
||||
%type <symbol_type_val> change_type_arg
|
||||
%type <vector_string_val> change_type_var_list
|
||||
%type <vector_int_val> vec_int_elem vec_int_1 vec_int vec_int_number
|
||||
|
@ -213,6 +214,12 @@ statement : parameters
|
|||
| estimated_params
|
||||
| estimated_params_bounds
|
||||
| estimated_params_init
|
||||
| set_time
|
||||
| data
|
||||
| prior
|
||||
| subsamples
|
||||
| subsamples_eq
|
||||
| options
|
||||
| varobs
|
||||
| observation_trends
|
||||
| unit_root_vars
|
||||
|
@ -733,9 +740,8 @@ ms_options_list : ms_options_list COMMA ms_options
|
|||
;
|
||||
|
||||
ms_options : o_chain
|
||||
| o_state
|
||||
| o_duration
|
||||
| o_number_of_states
|
||||
| o_number_of_regimes
|
||||
;
|
||||
|
||||
svar : SVAR '(' svar_options_list ')' ';'
|
||||
|
@ -963,6 +969,10 @@ non_negative_number : INT_NUMBER
|
|||
| FLOAT_NUMBER
|
||||
;
|
||||
|
||||
date_number : DATE_NUMBER
|
||||
| INT_NUMBER
|
||||
;
|
||||
|
||||
signed_number : PLUS non_negative_number
|
||||
{ $$ = $2; }
|
||||
| MINUS non_negative_number
|
||||
|
@ -970,6 +980,18 @@ signed_number : PLUS non_negative_number
|
|||
| non_negative_number
|
||||
;
|
||||
|
||||
signed_inf : PLUS INF_CONSTANT
|
||||
{ $$ = new string ("Inf"); }
|
||||
| MINUS INF_CONSTANT
|
||||
{ $$ = new string ("-Inf"); }
|
||||
| INF_CONSTANT
|
||||
{ $$ = new string ("Inf"); }
|
||||
;
|
||||
|
||||
signed_number_w_inf : signed_inf
|
||||
| signed_number
|
||||
;
|
||||
|
||||
estimated_params : ESTIMATED_PARAMS ';' estimated_list END ';' { driver.estimated_params(); };
|
||||
|
||||
estimated_list : estimated_list estimated_elem
|
||||
|
@ -1007,18 +1029,18 @@ estimated_elem1 : STDERR symbol
|
|||
}
|
||||
;
|
||||
|
||||
estimated_elem2 : prior COMMA estimated_elem3
|
||||
estimated_elem2 : prior_pdf_string COMMA estimated_elem3
|
||||
{
|
||||
driver.estim_params.prior = *$1;
|
||||
delete $1;
|
||||
}
|
||||
| expression_or_empty COMMA prior COMMA estimated_elem3
|
||||
| expression_or_empty COMMA prior_pdf_string COMMA estimated_elem3
|
||||
{
|
||||
driver.estim_params.init_val = $1;
|
||||
driver.estim_params.prior = *$3;
|
||||
delete $3;
|
||||
}
|
||||
| expression_or_empty COMMA expression_or_empty COMMA expression_or_empty COMMA prior COMMA estimated_elem3
|
||||
| expression_or_empty COMMA expression_or_empty COMMA expression_or_empty COMMA prior_pdf_string COMMA estimated_elem3
|
||||
{
|
||||
driver.estim_params.init_val = $1;
|
||||
driver.estim_params.low_bound = $3;
|
||||
|
@ -1137,7 +1159,23 @@ estimated_bounds_elem : STDERR symbol COMMA expression COMMA expression ';'
|
|||
}
|
||||
;
|
||||
|
||||
prior : BETA_PDF
|
||||
prior_distribution : BETA
|
||||
{ $$ = new string("1"); }
|
||||
| GAMMA
|
||||
{ $$ = new string("2"); }
|
||||
| NORMAL
|
||||
{ $$ = new string("3"); }
|
||||
| INV_GAMMA
|
||||
{ $$ = new string("4"); }
|
||||
| INV_GAMMA1
|
||||
{ $$ = new string("4"); }
|
||||
| UNIFORM
|
||||
{ $$ = new string("5"); }
|
||||
| INV_GAMMA2
|
||||
{ $$ = new string("6"); }
|
||||
;
|
||||
|
||||
prior_pdf_string : BETA_PDF
|
||||
{ $$ = new string("1"); }
|
||||
| GAMMA_PDF
|
||||
{ $$ = new string("2"); }
|
||||
|
@ -1153,6 +1191,87 @@ prior : BETA_PDF
|
|||
{ $$ = new string("6"); }
|
||||
;
|
||||
|
||||
set_time : SET_TIME '(' date_number ')' ';'
|
||||
{ driver.set_time($3); }
|
||||
;
|
||||
|
||||
data : DATA '(' data_options_list ')'';'
|
||||
{ driver.estimation_data(); }
|
||||
;
|
||||
|
||||
data_options_list : data_options_list COMMA data_options
|
||||
| data_options
|
||||
;
|
||||
|
||||
data_options : o_file
|
||||
| o_new_estimation_data_first_obs
|
||||
| o_last_obs
|
||||
| o_new_estimation_data_nobs
|
||||
| o_xls_sheet
|
||||
| o_xls_range
|
||||
;
|
||||
|
||||
subsamples : symbol '.' SUBSAMPLES '(' subsamples_name_list ')' ';'
|
||||
{ driver.set_subsamples($1); }
|
||||
;
|
||||
|
||||
subsamples_eq : symbol '.' SUBSAMPLES EQUAL symbol '.' SUBSAMPLES ';'
|
||||
{ driver.copy_subsamples($1, $5); }
|
||||
;
|
||||
|
||||
subsamples_name_list : subsamples_name_list COMMA o_subsample_name
|
||||
| o_subsample_name
|
||||
;
|
||||
|
||||
prior : symbol '.' PRIOR '(' prior_options_list ')' ';'
|
||||
{ driver.set_prior($1); }
|
||||
| symbol '.' symbol '.' PRIOR '(' prior_options_list ')' ';'
|
||||
{
|
||||
driver.add_subsample_range(new string (*$1), $3);
|
||||
driver.set_prior($1);
|
||||
}
|
||||
| STD '(' symbol ')' '.' PRIOR '(' prior_options_list ')' ';'
|
||||
{ driver.set_std_prior($3); }
|
||||
| CORR '(' symbol COMMA symbol')' '.' PRIOR '(' prior_options_list ')' ';'
|
||||
{ driver.set_corr_prior($3, $5); }
|
||||
;
|
||||
|
||||
prior_options_list : prior_options_list COMMA prior_options
|
||||
| prior_options
|
||||
;
|
||||
|
||||
prior_options : o_shift
|
||||
| o_mean
|
||||
| o_stdev
|
||||
| o_variance
|
||||
| o_mode
|
||||
| o_interval
|
||||
| o_shape
|
||||
| o_domain
|
||||
;
|
||||
|
||||
options : symbol '.' OPTIONS '(' options_options_list ')' ';'
|
||||
{ driver.set_options($1); }
|
||||
| symbol '.' symbol '.' OPTIONS '(' options_options_list ')' ';'
|
||||
{
|
||||
driver.add_subsample_range(new string (*$1), $3);
|
||||
driver.set_options($1);
|
||||
}
|
||||
| STD '(' symbol ')' '.' OPTIONS '(' options_options_list ')' ';'
|
||||
{ driver.set_std_options($3); }
|
||||
| CORR '(' symbol COMMA symbol')' '.' OPTIONS '(' options_options_list ')' ';'
|
||||
{ driver.set_corr_options($3, $5); }
|
||||
;
|
||||
|
||||
options_options_list : options_options_list COMMA options_options
|
||||
| options_options
|
||||
;
|
||||
|
||||
options_options : o_jscale
|
||||
| o_init
|
||||
| o_bounds
|
||||
;
|
||||
|
||||
estimation : ESTIMATION ';'
|
||||
{ driver.run_estimation(); }
|
||||
| ESTIMATION '(' estimation_options_list ')' ';'
|
||||
|
@ -1852,6 +1971,7 @@ o_mfs : MFS EQUAL INT_NUMBER { driver.mfs($3); };
|
|||
o_simul : SIMUL; // Do nothing, only here for backward compatibility
|
||||
o_simul_seed : SIMUL_SEED EQUAL INT_NUMBER { driver.error("'simul_seed' option is no longer supported; use 'set_dynare_seed' command instead"); } ;
|
||||
o_qz_criterium : QZ_CRITERIUM EQUAL non_negative_number { driver.option_num("qz_criterium", $3); };
|
||||
o_file : FILE EQUAL filename { driver.option_str("file", $3); };
|
||||
o_datafile : DATAFILE EQUAL filename { driver.option_str("datafile", $3); };
|
||||
o_nobs : NOBS EQUAL vec_int
|
||||
{ driver.option_vec_int("nobs", $3); }
|
||||
|
@ -1864,6 +1984,24 @@ o_conditional_variance_decomposition : CONDITIONAL_VARIANCE_DECOMPOSITION EQUAL
|
|||
{ driver.option_vec_int("conditional_variance_decomposition", $3); }
|
||||
;
|
||||
o_first_obs : FIRST_OBS EQUAL INT_NUMBER { driver.option_num("first_obs", $3); };
|
||||
o_new_estimation_data_first_obs : FIRST_OBS EQUAL date_number
|
||||
{ driver.option_date("first_obs", $3); }
|
||||
;
|
||||
o_last_obs : LAST_OBS EQUAL date_number
|
||||
{ driver.option_date("last_obs", $3); }
|
||||
;
|
||||
o_shift : SHIFT EQUAL signed_number { driver.option_num("shift", $3); };
|
||||
o_shape : SHAPE EQUAL prior_distribution { driver.option_num("shape", $3); };
|
||||
o_mode : MODE EQUAL signed_number { driver.option_num("mode", $3); };
|
||||
o_mean : MEAN EQUAL signed_number { driver.option_num("mean", $3); };
|
||||
o_stdev : STDEV EQUAL non_negative_number { driver.option_num("stdev", $3); };
|
||||
o_jscale : JSCALE EQUAL non_negative_number { driver.option_num("jscale", $3); };
|
||||
o_init : INIT EQUAL signed_number { driver.option_num("init", $3); };
|
||||
o_bounds : BOUNDS EQUAL vec_value_w_inf { driver.option_num("bounds", $3); };
|
||||
o_domain : DOMAINN EQUAL vec_value { driver.option_num("domain", $3); };
|
||||
o_interval : INTERVAL EQUAL vec_value { driver.option_num("interval", $3); };
|
||||
o_variance : VARIANCE EQUAL expression { driver.add_expression_to_prior_statement($3); }
|
||||
o_new_estimation_data_nobs : NOBS EQUAL INT_NUMBER { driver.option_num("nobs", $3); };
|
||||
o_prefilter : PREFILTER EQUAL INT_NUMBER { driver.option_num("prefilter", $3); };
|
||||
o_presample : PRESAMPLE EQUAL INT_NUMBER { driver.option_num("presample", $3); };
|
||||
o_lik_algo : LIK_ALGO EQUAL INT_NUMBER { driver.option_num("lik_algo", $3); };
|
||||
|
@ -1873,6 +2011,12 @@ o_nograph : NOGRAPH
|
|||
| GRAPH
|
||||
{ driver.option_num("nograph", "0"); }
|
||||
;
|
||||
o_subsample_name : symbol EQUAL date_number ':' date_number
|
||||
{
|
||||
driver.declare_statement_local_variable(new string (*$1));
|
||||
driver.set_subsample_name_equal_to_date_range($1, $3, $5);
|
||||
}
|
||||
;
|
||||
o_conf_sig : CONF_SIG EQUAL non_negative_number { driver.option_num("conf_sig", $3); };
|
||||
o_mh_replic : MH_REPLIC EQUAL INT_NUMBER { driver.option_num("mh_replic", $3); };
|
||||
o_mh_drop : MH_DROP EQUAL non_negative_number { driver.option_num("mh_drop", $3); };
|
||||
|
@ -2075,13 +2219,12 @@ o_cnum : CNUM EQUAL INT_NUMBER {driver.option_num("ms.cnum",$3); };
|
|||
o_k_order_solver : K_ORDER_SOLVER {driver.option_num("k_order_solver","1"); };
|
||||
o_pruning : PRUNING { driver.option_num("pruning", "1"); };
|
||||
o_chain : CHAIN EQUAL INT_NUMBER { driver.option_num("ms.chain",$3); };
|
||||
o_state : STATE EQUAL INT_NUMBER { driver.option_num("ms.state",$3); };
|
||||
o_duration : DURATION EQUAL non_negative_number
|
||||
{ driver.option_num("ms.duration",$3); }
|
||||
| DURATION EQUAL INF_CONSTANT
|
||||
{ driver.option_num("ms.duration","Inf"); }
|
||||
| DURATION EQUAL vec_value_w_inf
|
||||
{ driver.option_num("ms.duration",$3); }
|
||||
;
|
||||
o_number_of_states : NUMBER_OF_STATES EQUAL INT_NUMBER { driver.option_num("ms.number_of_states",$3); };
|
||||
o_number_of_regimes : NUMBER_OF_REGIMES EQUAL INT_NUMBER { driver.option_num("ms.number_of_regimes",$3); };
|
||||
o_coefficients : COEFFICIENTS { driver.option_str("ms.coefficients","svar_coefficients"); };
|
||||
o_variances : VARIANCES { driver.option_str("ms.variances","svar_variances"); };
|
||||
o_equations : EQUATIONS EQUAL vec_int
|
||||
|
@ -2219,8 +2362,8 @@ vec_int : vec_int_1 ']'
|
|||
{ $$ = $1; }
|
||||
;
|
||||
|
||||
vec_value_1 : '[' signed_number
|
||||
{ $2->insert(0, "["); $$ = $2;}
|
||||
vec_value_1 : '[' signed_number { $2->insert(0,"["); $$ = $2; }
|
||||
| '[' COMMA signed_number { $3->insert(0,"["); $$ = $3; }
|
||||
| vec_value_1 signed_number
|
||||
{
|
||||
$1->append(" ");
|
||||
|
@ -2228,9 +2371,31 @@ vec_value_1 : '[' signed_number
|
|||
delete $2;
|
||||
$$ = $1;
|
||||
}
|
||||
| vec_value_1 COMMA signed_number
|
||||
{
|
||||
$1->append(" ");
|
||||
$1->append(*$3);
|
||||
delete $3;
|
||||
$$ = $1;
|
||||
}
|
||||
;
|
||||
|
||||
vec_value : vec_value_1 ']' { $1->append("]"); $$ = $1; }
|
||||
| vec_value_1 COMMA ']' { $1->append("]"); $$ = $1; }
|
||||
;
|
||||
|
||||
vec_value_1_w_inf : '[' signed_number_w_inf
|
||||
{ $2->insert(0, "["); $$ = $2;}
|
||||
| vec_value_1_w_inf signed_number_w_inf
|
||||
{
|
||||
$1->append(" ");
|
||||
$1->append(*$2);
|
||||
delete $2;
|
||||
$$ = $1;
|
||||
}
|
||||
;
|
||||
|
||||
vec_value : vec_value_1 ']' { $1->append("]"); $$ = $1; };
|
||||
vec_value_w_inf : vec_value_1_w_inf ']' { $1->append("]"); $$ = $1; };
|
||||
|
||||
symbol : NAME
|
||||
| ALPHA
|
||||
|
@ -2240,6 +2405,12 @@ symbol : NAME
|
|||
| CMS
|
||||
| NCMS
|
||||
| CNUM
|
||||
| GAMMA
|
||||
| INV_GAMMA
|
||||
| INV_GAMMA1
|
||||
| INV_GAMMA2
|
||||
| NORMAL
|
||||
| UNIFORM
|
||||
;
|
||||
%%
|
||||
|
||||
|
|
|
@ -108,6 +108,8 @@ string eofbuff;
|
|||
<INITIAL>periods {BEGIN DYNARE_STATEMENT; return token::PERIODS;}
|
||||
<INITIAL>model_info {BEGIN DYNARE_STATEMENT; return token::MODEL_INFO;}
|
||||
<INITIAL>estimation {BEGIN DYNARE_STATEMENT; return token::ESTIMATION;}
|
||||
<INITIAL>set_time {BEGIN DYNARE_STATEMENT; return token::SET_TIME;}
|
||||
<INITIAL>data {BEGIN DYNARE_STATEMENT; return token::DATA;}
|
||||
<INITIAL>varobs {BEGIN DYNARE_STATEMENT; return token::VAROBS;}
|
||||
<INITIAL>unit_root_vars {BEGIN DYNARE_STATEMENT; return token::UNIT_ROOT_VARS;}
|
||||
<INITIAL>rplot {BEGIN DYNARE_STATEMENT; return token::RPLOT;}
|
||||
|
@ -187,10 +189,29 @@ string eofbuff;
|
|||
/* End of a Dynare block */
|
||||
<DYNARE_BLOCK>end {BEGIN INITIAL; return token::END;}
|
||||
|
||||
<DYNARE_STATEMENT>subsamples {return token::SUBSAMPLES;}
|
||||
<DYNARE_STATEMENT>options {return token::OPTIONS;}
|
||||
<DYNARE_STATEMENT>prior {return token::PRIOR;}
|
||||
<INITIAL>std {BEGIN DYNARE_STATEMENT; return token::STD;}
|
||||
<INITIAL>corr {BEGIN DYNARE_STATEMENT; return token::CORR;}
|
||||
|
||||
/* Inside of a Dynare statement */
|
||||
<DYNARE_STATEMENT>file {return token::FILE;}
|
||||
<DYNARE_STATEMENT>datafile {return token::DATAFILE;}
|
||||
<DYNARE_STATEMENT>nobs {return token::NOBS;}
|
||||
<DYNARE_STATEMENT>last_obs {return token::LAST_OBS;}
|
||||
<DYNARE_STATEMENT>first_obs {return token::FIRST_OBS;}
|
||||
<DYNARE_STATEMENT>mean {return token::MEAN;}
|
||||
<DYNARE_STATEMENT>stdev {return token::STDEV;}
|
||||
<DYNARE_STATEMENT>domain {return token::DOMAINN;}
|
||||
<DYNARE_STATEMENT>variance {return token::VARIANCE;}
|
||||
<DYNARE_STATEMENT>mode {return token::MODE;}
|
||||
<DYNARE_STATEMENT>interval {return token::INTERVAL;}
|
||||
<DYNARE_STATEMENT>shape {return token::SHAPE;}
|
||||
<DYNARE_STATEMENT>shift {return token::SHIFT;}
|
||||
<DYNARE_STATEMENT>bounds {return token::BOUNDS;}
|
||||
<DYNARE_STATEMENT>init {return token::INIT;}
|
||||
<DYNARE_STATEMENT>jscale {return token::JSCALE;}
|
||||
<DYNARE_STATEMENT>prefilter {return token::PREFILTER;}
|
||||
<DYNARE_STATEMENT>presample {return token::PRESAMPLE;}
|
||||
<DYNARE_STATEMENT>lik_algo {return token::LIK_ALGO;}
|
||||
|
@ -249,7 +270,6 @@ string eofbuff;
|
|||
<DYNARE_STATEMENT>nargs {return token::EXT_FUNC_NARGS;}
|
||||
<DYNARE_STATEMENT>first_deriv_provided {return token::FIRST_DERIV_PROVIDED;}
|
||||
<DYNARE_STATEMENT>second_deriv_provided {return token::SECOND_DERIV_PROVIDED;}
|
||||
|
||||
<DYNARE_STATEMENT>freq {return token::FREQ;}
|
||||
<DYNARE_STATEMENT>monthly {return token::MONTHLY; }
|
||||
<DYNARE_STATEMENT>quarterly {return token::QUARTERLY; }
|
||||
|
@ -277,6 +297,30 @@ string eofbuff;
|
|||
yylval->string_val = new string(yytext);
|
||||
return token::BETA;
|
||||
}
|
||||
<DYNARE_STATEMENT>gamma {
|
||||
yylval->string_val = new string(yytext);
|
||||
return token::GAMMA;
|
||||
}
|
||||
<DYNARE_STATEMENT>inv_gamma {
|
||||
yylval->string_val = new string(yytext);
|
||||
return token::INV_GAMMA;
|
||||
}
|
||||
<DYNARE_STATEMENT>inv_gamma1 {
|
||||
yylval->string_val = new string(yytext);
|
||||
return token::INV_GAMMA1;
|
||||
}
|
||||
<DYNARE_STATEMENT>inv_gamma2 {
|
||||
yylval->string_val = new string(yytext);
|
||||
return token::INV_GAMMA2;
|
||||
}
|
||||
<DYNARE_STATEMENT>normal {
|
||||
yylval->string_val = new string(yytext);
|
||||
return token::NORMAL;
|
||||
}
|
||||
<DYNARE_STATEMENT>uniform {
|
||||
yylval->string_val = new string(yytext);
|
||||
return token::UNIFORM;
|
||||
}
|
||||
<DYNARE_STATEMENT>gsig2_lmdm {return token::GSIG2_LMDM;}
|
||||
<DYNARE_STATEMENT>specification {return token::SPECIFICATION;}
|
||||
<DYNARE_STATEMENT>sims_zha {return token::SIMS_ZHA;}
|
||||
|
@ -427,7 +471,6 @@ string eofbuff;
|
|||
<DYNARE_BLOCK># {return Dynare::parser::token_type (yytext[0]);}
|
||||
|
||||
<DYNARE_BLOCK>autocorr {return token::AUTOCORR;}
|
||||
<DYNARE_BLOCK>restrictions {return token::RESTRICTIONS;}
|
||||
<DYNARE_BLOCK>restriction {return token::RESTRICTION;}
|
||||
|
||||
/* Inside Dynare statement */
|
||||
|
@ -461,8 +504,7 @@ string eofbuff;
|
|||
<DYNARE_STATEMENT,DYNARE_BLOCK>upper_cholesky {return token::UPPER_CHOLESKY;}
|
||||
<DYNARE_STATEMENT,DYNARE_BLOCK>lower_cholesky {return token::LOWER_CHOLESKY;}
|
||||
<DYNARE_STATEMENT>chain {return token::CHAIN;}
|
||||
<DYNARE_STATEMENT>state {return token::STATE;}
|
||||
<DYNARE_STATEMENT>number_of_states {return token::NUMBER_OF_STATES;}
|
||||
<DYNARE_STATEMENT>number_of_regimes {return token::NUMBER_OF_REGIMES;}
|
||||
<DYNARE_STATEMENT>duration {return token::DURATION;}
|
||||
<DYNARE_STATEMENT>coefficients {return token::COEFFICIENTS;}
|
||||
<DYNARE_STATEMENT>variances {return token::VARIANCES;}
|
||||
|
@ -591,6 +633,11 @@ string eofbuff;
|
|||
return token::INT_NUMBER;
|
||||
}
|
||||
|
||||
<DYNARE_STATEMENT,DYNARE_BLOCK>([1-2][0-9]{3}[Mm](([1-9])|(1[0-2])))|([1-2][0-9]{3}[Qq][1-4])|([1-2][0-9]{3}[Ww](([1-9]{1})|([1-5][0-9]))) {
|
||||
yylval->string_val = new string(yytext);
|
||||
return token::DATE_NUMBER;
|
||||
}
|
||||
|
||||
<DYNARE_STATEMENT,DYNARE_BLOCK>\'[^\']+\' {
|
||||
yylval->string_val = new string(yytext + 1);
|
||||
yylval->string_val->resize(yylval->string_val->length() - 1);
|
||||
|
|
|
@ -496,6 +496,7 @@ VariableNode::prepareForDerivation()
|
|||
non_null_derivatives = datatree.local_variables_table[symb_id]->non_null_derivatives;
|
||||
break;
|
||||
case eModFileLocalVariable:
|
||||
case eStatementDeclaredVariable:
|
||||
// Such a variable is never derived
|
||||
break;
|
||||
case eExternalFunction:
|
||||
|
@ -523,6 +524,9 @@ VariableNode::computeDerivative(int deriv_id)
|
|||
case eModFileLocalVariable:
|
||||
cerr << "ModFileLocalVariable is not derivable" << endl;
|
||||
exit(EXIT_FAILURE);
|
||||
case eStatementDeclaredVariable:
|
||||
cerr << "eStatementDeclaredVariable is not derivable" << endl;
|
||||
exit(EXIT_FAILURE);
|
||||
case eExternalFunction:
|
||||
cerr << "Impossible case!" << endl;
|
||||
exit(EXIT_FAILURE);
|
||||
|
@ -735,6 +739,7 @@ VariableNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
|
|||
|
||||
case eExternalFunction:
|
||||
case eTrend:
|
||||
case eStatementDeclaredVariable:
|
||||
cerr << "Impossible case" << endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
@ -917,6 +922,9 @@ VariableNode::getChainRuleDerivative(int deriv_id, const map<int, expr_t> &recur
|
|||
case eModFileLocalVariable:
|
||||
cerr << "ModFileLocalVariable is not derivable" << endl;
|
||||
exit(EXIT_FAILURE);
|
||||
case eStatementDeclaredVariable:
|
||||
cerr << "eStatementDeclaredVariable is not derivable" << endl;
|
||||
exit(EXIT_FAILURE);
|
||||
case eExternalFunction:
|
||||
cerr << "Impossible case!" << endl;
|
||||
exit(EXIT_FAILURE);
|
||||
|
|
|
@ -449,7 +449,7 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all, bool console,
|
|||
}
|
||||
|
||||
mOutputFile << "tic;" << endl
|
||||
<< "global M_ oo_ options_ ys0_ ex0_" << endl
|
||||
<< "global M_ oo_ options_ ys0_ ex0_ estimation_info" << endl
|
||||
<< "options_ = [];" << endl
|
||||
<< "M_.fname = '" << basename << "';" << endl
|
||||
<< "%" << endl
|
||||
|
|
|
@ -46,6 +46,15 @@ ParsingDriver::check_symbol_existence(const string &name)
|
|||
error("Unknown symbol: " + name);
|
||||
}
|
||||
|
||||
void
|
||||
ParsingDriver::check_symbol_is_parameter(string *name)
|
||||
{
|
||||
check_symbol_existence(*name);
|
||||
int symb_id = mod_file->symbol_table.getID(*name);
|
||||
if (mod_file->symbol_table.getType(symb_id) != eParameter)
|
||||
error(*name + " is not a parameter");
|
||||
}
|
||||
|
||||
void
|
||||
ParsingDriver::set_current_data_tree(DataTree *data_tree_arg)
|
||||
{
|
||||
|
@ -166,6 +175,16 @@ ParsingDriver::declare_parameter(string *name, string *tex_name)
|
|||
delete tex_name;
|
||||
}
|
||||
|
||||
void
|
||||
ParsingDriver::declare_statement_local_variable(string *name)
|
||||
{
|
||||
if (mod_file->symbol_table.exists(*name))
|
||||
error("Symbol " + *name + " cannot be assigned within a statement " +
|
||||
"while being assigned elsewhere in the modfile");
|
||||
declare_symbol(name, eStatementDeclaredVariable, NULL);
|
||||
delete name;
|
||||
}
|
||||
|
||||
void
|
||||
ParsingDriver::declare_optimal_policy_discount_factor_parameter(expr_t exprnode)
|
||||
{
|
||||
|
@ -372,13 +391,9 @@ ParsingDriver::dsample(string *arg1, string *arg2)
|
|||
void
|
||||
ParsingDriver::init_param(string *name, expr_t rhs)
|
||||
{
|
||||
check_symbol_existence(*name);
|
||||
check_symbol_is_parameter(name);
|
||||
int symb_id = mod_file->symbol_table.getID(*name);
|
||||
if (mod_file->symbol_table.getType(symb_id) != eParameter)
|
||||
error(*name + " is not a parameter");
|
||||
|
||||
mod_file->addStatement(new InitParamStatement(symb_id, rhs, mod_file->symbol_table));
|
||||
|
||||
delete name;
|
||||
}
|
||||
|
||||
|
@ -1056,6 +1071,23 @@ ParsingDriver::option_str(const string &name_option, const string &opt)
|
|||
options_list.string_options[name_option] = opt;
|
||||
}
|
||||
|
||||
void
|
||||
ParsingDriver::option_date(const string &name_option, string *opt)
|
||||
{
|
||||
option_date(name_option, *opt);
|
||||
delete opt;
|
||||
}
|
||||
|
||||
void
|
||||
ParsingDriver::option_date(const string &name_option, const string &opt)
|
||||
{
|
||||
if (options_list.date_options.find(name_option)
|
||||
!= options_list.date_options.end())
|
||||
error("option " + name_option + " declared twice");
|
||||
|
||||
options_list.date_options[name_option] = opt;
|
||||
}
|
||||
|
||||
void
|
||||
ParsingDriver::option_symbol_list(const string &name_option)
|
||||
{
|
||||
|
@ -1184,6 +1216,172 @@ ParsingDriver::set_unit_root_vars()
|
|||
symbol_list.clear();
|
||||
}
|
||||
|
||||
void
|
||||
ParsingDriver::set_time(string *arg)
|
||||
{
|
||||
string arg1 = *arg;
|
||||
for (size_t i=0; i<arg1.length(); i++)
|
||||
arg1[i]= toupper(arg1[i]);
|
||||
option_date("initial_period", arg1);
|
||||
mod_file->addStatement(new SetTimeStatement(options_list));
|
||||
options_list.clear();
|
||||
}
|
||||
|
||||
void
|
||||
ParsingDriver::estimation_data()
|
||||
{
|
||||
mod_file->addStatement(new EstimationDataStatement(options_list));
|
||||
options_list.clear();
|
||||
}
|
||||
|
||||
void
|
||||
ParsingDriver::copy_subsamples(string *to_parameter, string *from_parameter)
|
||||
{
|
||||
check_symbol_is_parameter(to_parameter);
|
||||
check_symbol_is_parameter(from_parameter);
|
||||
if (subsample_declarations.find(*to_parameter) != subsample_declarations.end())
|
||||
error("Parameter " + *to_parameter + " has more than one subsample statement." +
|
||||
"You may only have one subsample statement per parameter.");
|
||||
if (subsample_declarations.find(*from_parameter) == subsample_declarations.end())
|
||||
error("Parameter " + *from_parameter + " does not have an associated subsample statement.");
|
||||
subsample_declarations[*to_parameter] = subsample_declarations[*from_parameter];
|
||||
delete to_parameter;
|
||||
delete from_parameter;
|
||||
}
|
||||
|
||||
void
|
||||
ParsingDriver::set_subsamples(string *name)
|
||||
{
|
||||
check_symbol_is_parameter(name);
|
||||
if (subsample_declarations.find(*name) != subsample_declarations.end())
|
||||
error("Parameter " + *name + " has more than one subsample statement." +
|
||||
"You may only have one subsample statement per parameter.");
|
||||
subsample_declarations[*name] = subsample_declaration_map;
|
||||
subsample_declaration_map.clear();
|
||||
delete name;
|
||||
}
|
||||
|
||||
void
|
||||
ParsingDriver::check_symbol_is_statement_variable(string *name)
|
||||
{
|
||||
check_symbol_existence(*name);
|
||||
int symb_id = mod_file->symbol_table.getID(*name);
|
||||
if (mod_file->symbol_table.getType(symb_id) != eStatementDeclaredVariable)
|
||||
error(*name + " is not a variable assigned in a statement");
|
||||
}
|
||||
|
||||
void
|
||||
ParsingDriver::set_subsample_name_equal_to_date_range(string *name, string *date1, string *date2)
|
||||
{
|
||||
check_symbol_is_statement_variable(name);
|
||||
if (subsample_declaration_map.find(*name) != subsample_declaration_map.end())
|
||||
error("Symbol " + *name + " may only be assigned once in a SUBSAMPLE statement");
|
||||
subsample_declaration_map[*name] = make_pair(*date1, *date2);
|
||||
delete name;
|
||||
delete date1;
|
||||
delete date2;
|
||||
}
|
||||
|
||||
void
|
||||
ParsingDriver::add_subsample_range(string *parameter, string *subsample_name)
|
||||
{
|
||||
check_symbol_is_parameter(parameter);
|
||||
check_symbol_is_statement_variable(subsample_name);
|
||||
subsample_declarations_t::const_iterator it = subsample_declarations.find(*parameter);
|
||||
if (it == subsample_declarations.end())
|
||||
error("A subsample statement has not been issued for " + *parameter);
|
||||
subsample_declaration_map_t tmp_map = it->second;
|
||||
if (tmp_map.find(*subsample_name) == tmp_map.end())
|
||||
error("The subsample name " + *subsample_name + " was not previously declared in a subsample statement.");
|
||||
option_date("date1", tmp_map[*subsample_name].first);
|
||||
option_date("date2", tmp_map[*subsample_name].second);
|
||||
delete parameter;
|
||||
delete subsample_name;
|
||||
}
|
||||
|
||||
void
|
||||
ParsingDriver::set_prior(string *name)
|
||||
{
|
||||
check_symbol_is_parameter(name);
|
||||
mod_file->addStatement(new PriorStatement(*name, prior_variance, options_list));
|
||||
options_list.clear();
|
||||
prior_variance = NULL;
|
||||
delete name;
|
||||
}
|
||||
|
||||
void
|
||||
ParsingDriver::add_expression_to_prior_statement(expr_t variance)
|
||||
{
|
||||
prior_variance = variance;
|
||||
}
|
||||
|
||||
void
|
||||
ParsingDriver::set_options(string *name)
|
||||
{
|
||||
check_symbol_is_parameter(name);
|
||||
mod_file->addStatement(new OptionsStatement(*name, options_list));
|
||||
options_list.clear();
|
||||
delete name;
|
||||
}
|
||||
|
||||
void
|
||||
ParsingDriver::check_symbol_is_endogenous_or_exogenous(string *name)
|
||||
{
|
||||
check_symbol_existence(*name);
|
||||
int symb_id = mod_file->symbol_table.getID(*name);
|
||||
switch(mod_file->symbol_table.getType(symb_id))
|
||||
{
|
||||
case eEndogenous:
|
||||
case eExogenous:
|
||||
case eExogenousDet:
|
||||
break;
|
||||
default:
|
||||
error(*name + " is neither endogenous or exogenous.");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ParsingDriver::set_std_prior(string *name)
|
||||
{
|
||||
check_symbol_is_endogenous_or_exogenous(name);
|
||||
mod_file->addStatement(new StdPriorStatement(*name, prior_variance, options_list, mod_file->symbol_table));
|
||||
options_list.clear();
|
||||
prior_variance = NULL;
|
||||
delete name;
|
||||
}
|
||||
|
||||
void
|
||||
ParsingDriver::set_std_options(string *name)
|
||||
{
|
||||
check_symbol_is_endogenous_or_exogenous(name);
|
||||
// mod_file->addStatement(new StdOptionsStatement(*name, options_list, mod_file->symbol_table));
|
||||
options_list.clear();
|
||||
delete name;
|
||||
}
|
||||
|
||||
void
|
||||
ParsingDriver::set_corr_prior(string *name1, string *name2)
|
||||
{
|
||||
check_symbol_is_endogenous_or_exogenous(name1);
|
||||
check_symbol_is_endogenous_or_exogenous(name2);
|
||||
mod_file->addStatement(new CorrPriorStatement(*name1, *name2, prior_variance, options_list, mod_file->symbol_table));
|
||||
options_list.clear();
|
||||
prior_variance = NULL;
|
||||
delete name1;
|
||||
delete name2;
|
||||
}
|
||||
|
||||
void
|
||||
ParsingDriver::set_corr_options(string *name1, string *name2)
|
||||
{
|
||||
check_symbol_is_endogenous_or_exogenous(name1);
|
||||
check_symbol_is_endogenous_or_exogenous(name2);
|
||||
// mod_file->addStatement(new CorrOptionsStatement(*name1, *name2, options_list, mod_file->symbol_table));
|
||||
options_list.clear();
|
||||
delete name1;
|
||||
delete name2;
|
||||
}
|
||||
|
||||
void
|
||||
ParsingDriver::run_estimation()
|
||||
{
|
||||
|
@ -1540,7 +1738,7 @@ ParsingDriver::svar()
|
|||
void
|
||||
ParsingDriver::markov_switching()
|
||||
{
|
||||
OptionsList::num_options_t::const_iterator it0, it1;
|
||||
OptionsList::num_options_t::const_iterator it0;
|
||||
|
||||
it0 = options_list.num_options.find("ms.chain");
|
||||
if (it0 == options_list.num_options.end())
|
||||
|
@ -1548,31 +1746,15 @@ ParsingDriver::markov_switching()
|
|||
else if (atoi(it0->second.c_str()) <= 0)
|
||||
error("The value passed to the chain option must be greater than zero.");
|
||||
|
||||
it0 = options_list.num_options.find("ms.state");
|
||||
it1 = options_list.num_options.find("ms.number_of_states");
|
||||
if ((it0 == options_list.num_options.end())
|
||||
&& (it1 == options_list.num_options.end()))
|
||||
error("Either a state option or a number_of_states option must be passed to the markov_switching statement.");
|
||||
it0 = options_list.num_options.find("ms.number_of_regimes");
|
||||
if (it0 == options_list.num_options.end())
|
||||
error("A number_of_regimes option must be passed to the markov_switching statement.");
|
||||
else if (atoi(it0->second.c_str()) <= 0)
|
||||
error("The value passed to the number_of_regimes option must be greater than zero.");
|
||||
|
||||
if ((it0 != options_list.num_options.end())
|
||||
&& (it1 != options_list.num_options.end()))
|
||||
error("You cannot pass both a state option and a number_of_states option to the markov_switching statement.");
|
||||
|
||||
if (it0 != options_list.num_options.end())
|
||||
if (atoi(it0->second.c_str()) <= 0)
|
||||
error("The value passed to the state option must be greater than zero.");
|
||||
|
||||
if (it1 != options_list.num_options.end())
|
||||
if (atoi(it1->second.c_str()) <= 0)
|
||||
error("The value passed to the number_of_states option must be greater than zero.");
|
||||
|
||||
string infStr("Inf");
|
||||
it0 = options_list.num_options.find("ms.duration");
|
||||
if (it0 == options_list.num_options.end())
|
||||
error("A duration option must be passed to the markov_switching statement.");
|
||||
else if (infStr.compare(it0->second) != 0)
|
||||
if (atof(it0->second.c_str()) <= 0.0)
|
||||
error("The value passed to the duration option must be greater than zero.");
|
||||
|
||||
mod_file->addStatement(new MarkovSwitchingStatement(options_list));
|
||||
options_list.clear();
|
||||
|
|
|
@ -81,6 +81,15 @@ private:
|
|||
//! Checks that a given symbol exists, and stops with an error message if it doesn't
|
||||
void check_symbol_existence(const string &name);
|
||||
|
||||
//! Checks that a given symbol exists and is a parameter, and stops with an error message if it isn't
|
||||
void check_symbol_is_parameter(string *name);
|
||||
|
||||
//! Checks that a given symbol was assigned within a Statement
|
||||
void check_symbol_is_statement_variable(string *name);
|
||||
|
||||
//! Checks that a given symbol exists and is a endogenous or exogenous, and stops with an error message if it isn't
|
||||
void check_symbol_is_endogenous_or_exogenous(string *name);
|
||||
|
||||
//! Helper to add a symbol declaration
|
||||
void declare_symbol(const string *name, SymbolType type, const string *tex_name);
|
||||
|
||||
|
@ -178,6 +187,14 @@ private:
|
|||
vector<int> declared_trend_vars;
|
||||
//! Temporary storage for declaring nonstationary variables
|
||||
vector<int> declared_nonstationary_vars;
|
||||
//! Temporary storage for a variance declared in the prior statement
|
||||
expr_t prior_variance;
|
||||
//! Temporary storage for declaring subsamples: map<statement_local_var, <date1, date2 >
|
||||
typedef map<string, pair<string, string> > subsample_declaration_map_t;
|
||||
subsample_declaration_map_t subsample_declaration_map;
|
||||
//! Temporary storage for subsample statement: map<parameter, subsample_declaration_map >
|
||||
typedef map<string, subsample_declaration_map_t > subsample_declarations_t;
|
||||
subsample_declarations_t subsample_declarations;
|
||||
//! reset the values for temporary storage
|
||||
void reset_current_external_function_options();
|
||||
//! Adds a model lagged variable to ModelTree and VariableTable
|
||||
|
@ -231,6 +248,16 @@ public:
|
|||
void declare_exogenous_det(string *name, string *tex_name = NULL);
|
||||
//! Declares a parameter
|
||||
void declare_parameter(string *name, string *tex_name = NULL);
|
||||
//! Declares a statement local variable
|
||||
void declare_statement_local_variable(string *name);
|
||||
//! Completes a subsample statement
|
||||
void set_subsamples(string *name);
|
||||
//! Declares a subsample, assigning the value to name
|
||||
void set_subsample_name_equal_to_date_range(string *name, string *date1, string *date2);
|
||||
//! Adds a subsample range to the list of options for the prior statement
|
||||
void add_subsample_range(string *parameter, string *subsample_name);
|
||||
//! Copies the set of subsamples from_parameter to_parameter
|
||||
void copy_subsamples(string *to_parameter, string *from_parameter);
|
||||
//! Declares declare_optimal_policy_discount_factor as a parameter and initializes it to exprnode
|
||||
void declare_optimal_policy_discount_factor_parameter(expr_t exprnode);
|
||||
//! Adds a predetermined_variable
|
||||
|
@ -319,6 +346,10 @@ public:
|
|||
void option_str(const string &name_option, string *opt);
|
||||
//! Sets an option to a string value
|
||||
void option_str(const string &name_option, const string &opt);
|
||||
//! Sets an option to a date value
|
||||
void option_date(const string &name_option, string *opt);
|
||||
//! Sets an option to a date value
|
||||
void option_date(const string &name_option, const string &opt);
|
||||
//! Sets an option to a list of symbols (used in conjunction with add_in_symbol_list())
|
||||
void option_symbol_list(const string &name_option);
|
||||
//! Sets an option to a vector of integers
|
||||
|
@ -351,6 +382,24 @@ public:
|
|||
void external_function_option(const string &name_option, const string &opt);
|
||||
//! Add a line in an estimated params block
|
||||
void add_estimated_params_element();
|
||||
//! Sets the frequency of the data
|
||||
void set_time(string *arg);
|
||||
//! Estimation Data
|
||||
void estimation_data();
|
||||
//! Sets the prior for a parameter
|
||||
void set_prior(string *arg);
|
||||
//! Adds the variance option to its temporary holding place
|
||||
void add_expression_to_prior_statement(expr_t variance);
|
||||
//! Sets the options for a parameter
|
||||
void set_options(string *arg);
|
||||
//! Sets the prior for estimated std dev
|
||||
void set_std_prior(string *arg);
|
||||
//! Sets the options for estimated std dev
|
||||
void set_std_options(string *arg);
|
||||
//! Sets the prior for estimated correlation
|
||||
void set_corr_prior(string *arg1, string *arg2);
|
||||
//! Sets the options for estimated correlation
|
||||
void set_corr_options(string *arg1, string *arg2);
|
||||
//! Runs estimation process
|
||||
void run_estimation();
|
||||
//! Runs dynare_sensitivy()
|
||||
|
|
|
@ -88,6 +88,10 @@ OptionsList::writeOutput(ostream &output) const
|
|||
it != string_options.end(); it++)
|
||||
output << "options_." << it->first << " = '" << it->second << "';" << endl;
|
||||
|
||||
for (date_options_t::const_iterator it = date_options.begin();
|
||||
it != date_options.end(); it++)
|
||||
output << "options_." << it->first << " = dynDate('" << it->second << "');" << endl;
|
||||
|
||||
for (symbol_list_options_t::const_iterator it = symbol_list_options.begin();
|
||||
it != symbol_list_options.end(); it++)
|
||||
it->second.writeOutput("options_." + it->first, output);
|
||||
|
@ -127,6 +131,10 @@ OptionsList::writeOutput(ostream &output, const string &option_group) const
|
|||
it != string_options.end(); it++)
|
||||
output << option_group << "." << it->first << " = '" << it->second << "';" << endl;
|
||||
|
||||
for (date_options_t::const_iterator it = date_options.begin();
|
||||
it != date_options.end(); it++)
|
||||
output << option_group << "." << it->first << " = dynDate('" << it->second << "');" << endl;
|
||||
|
||||
for (symbol_list_options_t::const_iterator it = symbol_list_options.begin();
|
||||
it != symbol_list_options.end(); it++)
|
||||
it->second.writeOutput(option_group + "." + it->first, output);
|
||||
|
@ -154,6 +162,7 @@ OptionsList::clear()
|
|||
num_options.clear();
|
||||
paired_num_options.clear();
|
||||
string_options.clear();
|
||||
date_options.clear();
|
||||
symbol_list_options.clear();
|
||||
vector_int_options.clear();
|
||||
}
|
||||
|
|
|
@ -86,6 +86,20 @@ public:
|
|||
bool dsge_var_estimated;
|
||||
//! Whether there is a bayesian_irf option passed to the estimation statement
|
||||
bool bayesian_irf_present;
|
||||
//! Whether there is a data statement present
|
||||
bool estimation_data_statement_present;
|
||||
//! Whether there is a prior statement present
|
||||
bool prior_statement_present;
|
||||
//! Whether there is a std prior statement present
|
||||
bool std_prior_statement_present;
|
||||
//! Whether there is a corr prior statement present
|
||||
bool corr_prior_statement_present;
|
||||
//! Whether there is a options statement present
|
||||
bool options_statement_present;
|
||||
//! Whether there is a std options statement present
|
||||
bool std_options_statement_present;
|
||||
//! Whether there is a corr options statement present
|
||||
bool corr_options_statement_present;
|
||||
};
|
||||
|
||||
class Statement
|
||||
|
@ -118,11 +132,13 @@ public:
|
|||
typedef map<string, string> num_options_t;
|
||||
typedef map<string, pair<string, string> > paired_num_options_t;
|
||||
typedef map<string, string> string_options_t;
|
||||
typedef map<string, string> date_options_t;
|
||||
typedef map<string, SymbolList> symbol_list_options_t;
|
||||
typedef map<string, vector<int> > vec_int_options_t;
|
||||
num_options_t num_options;
|
||||
paired_num_options_t paired_num_options;
|
||||
string_options_t string_options;
|
||||
date_options_t date_options;
|
||||
symbol_list_options_t symbol_list_options;
|
||||
vec_int_options_t vector_int_options;
|
||||
void writeOutput(ostream &output) const;
|
||||
|
|
|
@ -6,7 +6,7 @@ svar_identification;
|
|||
lower_cholesky;
|
||||
end;
|
||||
|
||||
markov_switching(chain=1,number_of_states=2,duration=2.5);
|
||||
markov_switching(chain=1,number_of_regimes=2,duration=2.5);
|
||||
|
||||
svar(variances, chain=1);
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ svar_identification;
|
|||
lower_cholesky;
|
||||
end;
|
||||
|
||||
markov_switching(chain=1,number_of_states=2,duration=2.5);
|
||||
markov_switching(chain=1,number_of_regimes=2,duration=2.5);
|
||||
|
||||
svar(variances, chain=1);
|
||||
|
||||
|
|
Loading…
Reference in New Issue