Merge remote-tracking branch 'houtanb/master'
commit
3be6b610c8
|
@ -38,9 +38,9 @@ global estimation_info
|
|||
if isempty(name2) % parameter or std() statement
|
||||
subsamples_indx = find(strcmp(name1, estimation_info.subsamples_index) == 1);
|
||||
else % corr statement
|
||||
subsamples_indx = find(strcmp([name1 '_' name2], estimation_info.subsamples_index) == 1);
|
||||
subsamples_indx = find(strcmp([name1 ':' name2], estimation_info.subsamples_index) == 1);
|
||||
if isempty(subsamples_indx)
|
||||
subsamples_indx = find(strcmp([name2 '_' name1], estimation_info.subsamples_index) == 1);
|
||||
subsamples_indx = find(strcmp([name2 ':' name1], estimation_info.subsamples_index) == 1);
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -44,9 +44,9 @@ end
|
|||
if isempty(name2) % parameter or std() statement
|
||||
indx = eval(['find(strcmp(name1, estimation_info.' substructure_name ') == 1)']);
|
||||
else % corr statement
|
||||
indx = eval(['find(strcmp([''' name1 '_' name2 '''], estimation_info.' substructure_name ') == 1)']);
|
||||
indx = eval(['find(strcmp([''' name1 ':' name2 '''], estimation_info.' substructure_name ') == 1)']);
|
||||
if isempty(indx)
|
||||
indx = eval(['find(strcmp([''' name2 '_' name1 '''], estimation_info.' substructure_name ') == 1)']);
|
||||
indx = eval(['find(strcmp([''' name2 ':' name1 '''], estimation_info.' substructure_name ') == 1)']);
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -247,65 +247,65 @@ options_.timeless = 0;
|
|||
% estimation
|
||||
estimation_info.subsamples.range = struct('date1', {}, 'date2', {});
|
||||
estimation_info.parameters.prior = struct(...
|
||||
'shape', {}, 'mean', {}, ...
|
||||
'mode', {}, 'stdev', {}, 'date1', {}, ...
|
||||
'date2', {}, 'shift', {}, 'variance', {});
|
||||
'domain', {}, 'interval', {}, 'mean', {}, ...
|
||||
'median', {}, 'mode', {}, 'shape', {}, ...
|
||||
'shift', {}, 'stdev', {}, 'truncate', {}, 'variance', {});
|
||||
estimation_info.parameters.subsample_prior = struct(...
|
||||
'shape', {}, 'mean', {}, ...
|
||||
'mode', {}, 'stdev', {}, 'date1', {}, ...
|
||||
'date2', {}, 'shift', {}, 'variance', {});
|
||||
'domain', {}, 'interval', {}, 'mean', {}, ...
|
||||
'median', {}, 'mode', {}, 'shape', {}, ...
|
||||
'shift', {}, 'stdev', {}, 'truncate', {}, 'variance', {});
|
||||
estimation_info.parameters.options = struct(...
|
||||
'init', {}, 'bounds',{}, 'jscale', {});
|
||||
'bounds',{}, 'init', {}, 'jscale', {});
|
||||
estimation_info.parameters.subsample_options = struct(...
|
||||
'init', {}, 'bounds',{}, 'jscale', {});
|
||||
'bounds',{}, 'init', {}, 'jscale', {});
|
||||
estimation_info.structural_innovation.prior = struct(...
|
||||
'shape', {}, 'mean', {}, ...
|
||||
'mode', {}, 'stdev', {}, 'date1', {}, ...
|
||||
'date2', {}, 'shift', {}, 'variance', {});
|
||||
'domain', {}, 'interval', {}, 'mean', {}, ...
|
||||
'median', {}, 'mode', {}, 'shape', {}, ...
|
||||
'shift', {}, 'stdev', {}, 'truncate', {}, 'variance', {});
|
||||
estimation_info.structural_innovation.subsample_prior = struct(...
|
||||
'shape', {}, 'mean', {}, ...
|
||||
'mode', {}, 'stdev', {}, 'date1', {}, ...
|
||||
'date2', {}, 'shift', {}, 'variance', {});
|
||||
'domain', {}, 'interval', {}, 'mean', {}, ...
|
||||
'median', {}, 'mode', {}, 'shape', {}, ...
|
||||
'shift', {}, 'stdev', {}, 'truncate', {}, 'variance', {});
|
||||
estimation_info.structural_innovation.options = struct(...
|
||||
'init', {}, 'bounds',{}, 'jscale', {});
|
||||
'bounds',{}, 'init', {}, 'jscale', {});
|
||||
estimation_info.structural_innovation.subsample_options = struct(...
|
||||
'init', {}, 'bounds',{}, 'jscale', {});
|
||||
'bounds',{}, 'init', {}, 'jscale', {});
|
||||
estimation_info.structural_innovation_corr.prior = struct(...
|
||||
'shape', {}, 'mean', {}, ...
|
||||
'mode', {}, 'stdev', {}, 'date1', {}, ...
|
||||
'date2', {}, 'shift', {}, 'variance', {});
|
||||
'domain', {}, 'interval', {}, 'mean', {}, ...
|
||||
'median', {}, 'mode', {}, 'shape', {}, ...
|
||||
'shift', {}, 'stdev', {}, 'truncate', {}, 'variance', {});
|
||||
estimation_info.structural_innovation_corr.subsample_prior = struct(...
|
||||
'shape', {}, 'mean', {}, ...
|
||||
'mode', {}, 'stdev', {}, 'date1', {}, ...
|
||||
'date2', {}, 'shift', {}, 'variance', {});
|
||||
'domain', {}, 'interval', {}, 'mean', {}, ...
|
||||
'median', {}, 'mode', {}, 'shape', {}, ...
|
||||
'shift', {}, 'stdev', {}, 'truncate', {}, 'variance', {});
|
||||
estimation_info.structural_innovation_corr.options = struct(...
|
||||
'init', {}, 'bounds',{}, 'jscale', {});
|
||||
'bounds',{}, 'init', {}, 'jscale', {});
|
||||
estimation_info.structural_innovation_corr.subsample_options = struct(...
|
||||
'init', {}, 'bounds',{}, 'jscale', {});
|
||||
'bounds',{}, 'init', {}, 'jscale', {});
|
||||
estimation_info.measurement_error.prior = struct(...
|
||||
'shape', {}, 'mean', {}, ...
|
||||
'mode', {}, 'stdev', {}, 'date1', {}, ...
|
||||
'date2', {}, 'shift', {}, 'variance', {});
|
||||
'domain', {}, 'interval', {}, 'mean', {}, ...
|
||||
'median', {}, 'mode', {}, 'shape', {}, ...
|
||||
'shift', {}, 'stdev', {}, 'truncate', {}, 'variance', {});
|
||||
estimation_info.measurement_error.subsample_prior = struct(...
|
||||
'shape', {}, 'mean', {}, ...
|
||||
'mode', {}, 'stdev', {}, 'date1', {}, ...
|
||||
'date2', {}, 'shift', {}, 'variance', {});
|
||||
'domain', {}, 'interval', {}, 'mean', {}, ...
|
||||
'median', {}, 'mode', {}, 'shape', {}, ...
|
||||
'shift', {}, 'stdev', {}, 'truncate', {}, 'variance', {});
|
||||
estimation_info.measurement_error.options = struct(...
|
||||
'init', {}, 'bounds',{}, 'jscale', {});
|
||||
'bounds',{}, 'init', {}, 'jscale', {});
|
||||
estimation_info.measurement_error.subsample_options = struct(...
|
||||
'init', {}, 'bounds',{}, 'jscale', {});
|
||||
'bounds',{}, 'init', {}, 'jscale', {});
|
||||
estimation_info.measurement_error_corr.prior = struct(...
|
||||
'name1', {}, 'name2', {}, 'shape', {}, 'mean', {}, ...
|
||||
'mode', {}, 'stdev', {}, 'date1', {}, ...
|
||||
'date2', {}, 'shift', {}, 'variance', {});
|
||||
'domain', {}, 'interval', {}, 'mean', {}, ...
|
||||
'median', {}, 'mode', {}, 'shape', {}, ...
|
||||
'shift', {}, 'stdev', {}, 'truncate', {}, 'variance', {});
|
||||
estimation_info.measurement_error_corr.subsample_prior = struct(...
|
||||
'name1', {}, 'name2', {},'shape', {}, 'mean', {}, ...
|
||||
'mode', {}, 'stdev', {}, 'date1', {}, ...
|
||||
'date2', {}, 'shift', {}, 'variance', {});
|
||||
'domain', {}, 'interval', {}, 'mean', {}, ...
|
||||
'median', {}, 'mode', {}, 'shape', {}, ...
|
||||
'shift', {}, 'stdev', {}, 'truncate', {}, 'variance', {});
|
||||
estimation_info.measurement_error_corr.options = struct(...
|
||||
'init', {}, 'bounds',{}, 'jscale', {});
|
||||
'bounds',{}, 'init', {}, 'jscale', {});
|
||||
estimation_info.measurement_error_corr.subsample_options = struct(...
|
||||
'init', {}, 'bounds',{}, 'jscale', {});
|
||||
'bounds',{}, 'init', {}, 'jscale', {});
|
||||
estimation_info.subsamples_index = {};
|
||||
estimation_info.subsamples.range_index = {};
|
||||
estimation_info.parameter_prior_index = {};
|
||||
|
|
|
@ -1651,7 +1651,7 @@ SubsamplesStatement::writeOutput(ostream &output, const string &basename) const
|
|||
<< name1 << "','" << name2 << "');" << endl
|
||||
<< "estimation_info.subsamples_index(subsamples_indx) = {'" << name1;
|
||||
if (!name2.empty())
|
||||
output << "_" << name2;
|
||||
output << ":" << name2;
|
||||
output << "'};" << endl
|
||||
<< "estimation_info.subsamples(subsamples_indx).range = {};" << endl;
|
||||
|
||||
|
@ -1677,11 +1677,6 @@ SubsamplesEqualStatement::SubsamplesEqualStatement(const string &to_name1_arg,
|
|||
{
|
||||
}
|
||||
|
||||
void
|
||||
SubsamplesEqualStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
SubsamplesEqualStatement::writeOutput(ostream &output, const string &basename) const
|
||||
{
|
||||
|
@ -1689,7 +1684,7 @@ SubsamplesEqualStatement::writeOutput(ostream &output, const string &basename) c
|
|||
<< to_name1 << "','" << to_name2 << "');" << endl
|
||||
<< "estimation_info.subsamples_index(subsamples_to_indx) = {'" << to_name1;
|
||||
if (!to_name2.empty())
|
||||
output << "_" << to_name2;
|
||||
output << ":" << to_name2;
|
||||
output << "'};" << endl
|
||||
<< "subsamples_from_indx = get_existing_subsamples_indx('" << from_name1 << "','" << from_name2 << "');"
|
||||
<< endl
|
||||
|
@ -1764,33 +1759,37 @@ BasicPriorStatement::get_base_name(const SymbolType symb_type, string &lhs_field
|
|||
void
|
||||
BasicPriorStatement::writeCommonOutput(ostream &output, const string &lhs_field) const
|
||||
{
|
||||
writeCommonOutputHelper(output, "domain", lhs_field);
|
||||
writeCommonOutputHelper(output, "interval", lhs_field);
|
||||
writeCommonOutputHelper(output, "mean", lhs_field);
|
||||
writeCommonOutputHelper(output, "median", lhs_field);
|
||||
writeCommonOutputHelper(output, "mode", lhs_field);
|
||||
|
||||
assert(prior_shape != eNoShape);
|
||||
output << lhs_field << ".shape = " << prior_shape << ";" << endl;
|
||||
|
||||
if (variance)
|
||||
{
|
||||
output << lhs_field << ".variance = ";
|
||||
variance->writeOutput(output);
|
||||
output << ";" << endl;
|
||||
}
|
||||
|
||||
writeCommonOutputHelper(output, "mean", lhs_field);
|
||||
writeCommonOutputHelper(output, "mode", lhs_field);
|
||||
writeCommonOutputHelper(output, "stdev", lhs_field);
|
||||
writeCommonOutputHelper(output, "shape", lhs_field);
|
||||
writeCommonOutputHelper(output, "shift", lhs_field);
|
||||
writeCommonOutputHelper(output, "domain", lhs_field);
|
||||
writeCommonOutputHelper(output, "median", lhs_field);
|
||||
writeCommonOutputHelper(output, "stdev", lhs_field);
|
||||
writeCommonOutputHelper(output, "truncate", lhs_field);
|
||||
writeCommonOutputHelper(output, "interval", lhs_field);
|
||||
|
||||
output << lhs_field << ".variance = ";
|
||||
if (variance)
|
||||
variance->writeOutput(output);
|
||||
else
|
||||
output << "[]";
|
||||
output << ";" << endl;
|
||||
}
|
||||
|
||||
void
|
||||
BasicPriorStatement::writeCommonOutputHelper(ostream &output, const string &field, const string &lhs_field) const
|
||||
{
|
||||
OptionsList::num_options_t::const_iterator itn = options_list.num_options.find(field);
|
||||
output << lhs_field << "." << field << " = ";
|
||||
if (itn != options_list.num_options.end())
|
||||
output << lhs_field << "." << field << " = " << itn->second << ";" << endl;
|
||||
output << itn->second;
|
||||
else
|
||||
output << "[]";
|
||||
output << ";" << endl;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1885,13 +1884,114 @@ CorrPriorStatement::writeOutput(ostream &output, const string &basename) const
|
|||
output << "eifind = get_new_or_existing_ei_index('" << lhs_field << "_corr_prior_index', '"
|
||||
<< name << "', '" << name1 << "');" << endl
|
||||
<< "estimation_info." << lhs_field << "_corr_prior_index(eifind) = {'"
|
||||
<< name << "_" << name1 << "'};" << endl;
|
||||
<< name << ":" << name1 << "'};" << endl;
|
||||
|
||||
lhs_field = "estimation_info." + lhs_field + "_corr(eifind)";
|
||||
writePriorOutput(output, lhs_field);
|
||||
}
|
||||
|
||||
output << lhs_field << ".name1 = '" << name << "';" << endl
|
||||
<< lhs_field << ".name2 = '" << name1 << "';" << endl;
|
||||
PriorEqualStatement::PriorEqualStatement(const string &to_declaration_type_arg,
|
||||
const string &to_name1_arg,
|
||||
const string &to_name2_arg,
|
||||
const string &to_subsample_name_arg,
|
||||
const string &from_declaration_type_arg,
|
||||
const string &from_name1_arg,
|
||||
const string &from_name2_arg,
|
||||
const string &from_subsample_name_arg,
|
||||
const SymbolTable &symbol_table_arg) :
|
||||
to_declaration_type(to_declaration_type_arg),
|
||||
to_name1(to_name1_arg),
|
||||
to_name2(to_name2_arg),
|
||||
to_subsample_name(to_subsample_name_arg),
|
||||
from_declaration_type(from_declaration_type_arg),
|
||||
from_name1(from_name1_arg),
|
||||
from_name2(from_name2_arg),
|
||||
from_subsample_name(from_subsample_name_arg),
|
||||
symbol_table(symbol_table_arg)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
PriorEqualStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings)
|
||||
{
|
||||
if ((to_declaration_type != "par" && to_declaration_type != "std" && to_declaration_type != "corr") ||
|
||||
(from_declaration_type != "par" && from_declaration_type != "std" && from_declaration_type != "corr"))
|
||||
{
|
||||
cerr << "Internal Dynare Error" << endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
PriorEqualStatement::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
|
||||
PriorEqualStatement::writeOutput(ostream &output, const string &basename) const
|
||||
{
|
||||
string lhs_field, rhs_field;
|
||||
|
||||
if (to_declaration_type == "par")
|
||||
lhs_field = "parameter";
|
||||
else
|
||||
get_base_name(symbol_table.getType(to_name1), lhs_field);
|
||||
|
||||
if (from_declaration_type == "par")
|
||||
rhs_field = "parameter";
|
||||
else
|
||||
get_base_name(symbol_table.getType(from_name1), rhs_field);
|
||||
|
||||
|
||||
if (to_declaration_type == "corr")
|
||||
lhs_field += "_corr";
|
||||
|
||||
if (from_declaration_type == "corr")
|
||||
rhs_field += "_corr";
|
||||
|
||||
output << "ei_to_ind = get_new_or_existing_ei_index('" << lhs_field << "_prior_index', '"
|
||||
<< to_name1 << "', '" << to_name2<< "');" << endl
|
||||
<< "ei_from_ind = get_new_or_existing_ei_index('" << rhs_field << "_prior_index', '"
|
||||
<< from_name1 << "', '" << from_name2<< "');" << endl
|
||||
<< "estimation_info." << lhs_field << "_prior_index(ei_to_ind) = {'" << to_name1;
|
||||
|
||||
if (to_declaration_type == "corr")
|
||||
output << ":" << to_name2;
|
||||
output << "'};" << endl;
|
||||
|
||||
if (to_declaration_type == "par")
|
||||
lhs_field = "parameters";
|
||||
|
||||
if (from_declaration_type == "par")
|
||||
rhs_field = "parameters";
|
||||
|
||||
lhs_field = "estimation_info." + lhs_field + "(ei_to_ind)";
|
||||
rhs_field = "estimation_info." + rhs_field + "(ei_from_ind)";
|
||||
|
||||
if (to_subsample_name.empty())
|
||||
lhs_field += ".prior";
|
||||
else
|
||||
{
|
||||
output << "subsamples_to_indx = get_existing_subsamples_indx('" << to_name1 << "','" << to_name2 << "');" << endl
|
||||
<< lhs_field << ".range_index = estimation_info.subsamples(subsamples_to_indx).range_index;" << endl
|
||||
<< "ei_to_ss_ind = get_subsamples_range_indx(subsamples_to_indx, '" << to_subsample_name << "');" << endl;
|
||||
lhs_field += ".subsample_prior(ei_to_ss_ind)";
|
||||
}
|
||||
|
||||
if (from_subsample_name.empty())
|
||||
rhs_field += ".prior";
|
||||
else
|
||||
{
|
||||
output << "subsamples_from_indx = get_existing_subsamples_indx('" << from_name1 << "','" << from_name2 << "');" << endl
|
||||
<< "ei_from_ss_ind = get_subsamples_range_indx(subsamples_from_indx, '" << from_subsample_name << "');" << endl;
|
||||
rhs_field += ".subsample_prior(ei_from_ss_ind)";
|
||||
}
|
||||
|
||||
output << lhs_field << " = " << rhs_field << ";" << endl;
|
||||
}
|
||||
|
||||
BasicOptionsStatement::~BasicOptionsStatement()
|
||||
|
@ -1924,8 +2024,8 @@ BasicOptionsStatement::get_base_name(const SymbolType symb_type, string &lhs_fie
|
|||
void
|
||||
BasicOptionsStatement::writeCommonOutput(ostream &output, const string &lhs_field) const
|
||||
{
|
||||
writeCommonOutputHelper(output, "init", lhs_field);
|
||||
writeCommonOutputHelper(output, "bounds", lhs_field);
|
||||
writeCommonOutputHelper(output, "init", lhs_field);
|
||||
writeCommonOutputHelper(output, "jscale", lhs_field);
|
||||
}
|
||||
|
||||
|
@ -1933,8 +2033,12 @@ void
|
|||
BasicOptionsStatement::writeCommonOutputHelper(ostream &output, const string &field, const string &lhs_field) const
|
||||
{
|
||||
OptionsList::num_options_t::const_iterator itn = options_list.num_options.find(field);
|
||||
output << lhs_field << "." << field << " = ";
|
||||
if (itn != options_list.num_options.end())
|
||||
output << lhs_field << "." << field << " = " << itn->second << ";" << endl;
|
||||
output << itn->second;
|
||||
else
|
||||
output << "[]";
|
||||
output << ";" << endl;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -2022,11 +2126,112 @@ CorrOptionsStatement::writeOutput(ostream &output, const string &basename) const
|
|||
output << "eifind = get_new_or_existing_ei_index('" << lhs_field << "_corr_options_index', '"
|
||||
<< name << "', '" << name1 << "');" << endl
|
||||
<< "estimation_info." << lhs_field << "_corr_options_index(eifind) = {'"
|
||||
<< name << "_" << name1 << "'};" << endl;
|
||||
<< name << ":" << name1 << "'};" << endl;
|
||||
|
||||
lhs_field = "estimation_info." + lhs_field + "_corr(eifind)";
|
||||
writeOptionsOutput(output, lhs_field, name1);
|
||||
|
||||
output << lhs_field << ".name1 = '" << name << "';" << endl
|
||||
<< lhs_field << ".name2 = '" << name1 << "';" << endl;
|
||||
}
|
||||
|
||||
OptionsEqualStatement::OptionsEqualStatement(const string &to_declaration_type_arg,
|
||||
const string &to_name1_arg,
|
||||
const string &to_name2_arg,
|
||||
const string &to_subsample_name_arg,
|
||||
const string &from_declaration_type_arg,
|
||||
const string &from_name1_arg,
|
||||
const string &from_name2_arg,
|
||||
const string &from_subsample_name_arg,
|
||||
const SymbolTable &symbol_table_arg) :
|
||||
to_declaration_type(to_declaration_type_arg),
|
||||
to_name1(to_name1_arg),
|
||||
to_name2(to_name2_arg),
|
||||
to_subsample_name(to_subsample_name_arg),
|
||||
from_declaration_type(from_declaration_type_arg),
|
||||
from_name1(from_name1_arg),
|
||||
from_name2(from_name2_arg),
|
||||
from_subsample_name(from_subsample_name_arg),
|
||||
symbol_table(symbol_table_arg)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
OptionsEqualStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings)
|
||||
{
|
||||
if ((to_declaration_type != "par" && to_declaration_type != "std" && to_declaration_type != "corr") ||
|
||||
(from_declaration_type != "par" && from_declaration_type != "std" && from_declaration_type != "corr"))
|
||||
{
|
||||
cerr << "Internal Dynare Error" << endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
OptionsEqualStatement::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
|
||||
OptionsEqualStatement::writeOutput(ostream &output, const string &basename) const
|
||||
{
|
||||
string lhs_field, rhs_field;
|
||||
|
||||
if (to_declaration_type == "par")
|
||||
lhs_field = "parameter";
|
||||
else
|
||||
get_base_name(symbol_table.getType(to_name1), lhs_field);
|
||||
|
||||
if (from_declaration_type == "par")
|
||||
rhs_field = "parameter";
|
||||
else
|
||||
get_base_name(symbol_table.getType(from_name1), rhs_field);
|
||||
|
||||
|
||||
if (to_declaration_type == "corr")
|
||||
lhs_field += "_corr";
|
||||
|
||||
if (from_declaration_type == "corr")
|
||||
rhs_field += "_corr";
|
||||
|
||||
output << "ei_to_ind = get_new_or_existing_ei_index('" << lhs_field << "_options_index', '"
|
||||
<< to_name1 << "', '" << to_name2<< "');" << endl
|
||||
<< "ei_from_ind = get_new_or_existing_ei_index('" << rhs_field << "_options_index', '"
|
||||
<< from_name1 << "', '" << from_name2<< "');" << endl
|
||||
<< "estimation_info." << lhs_field << "_options_index(ei_to_ind) = {'" << to_name1;
|
||||
|
||||
if (to_declaration_type == "corr")
|
||||
output << ":" << to_name2;
|
||||
output << "'};" << endl;
|
||||
|
||||
if (to_declaration_type == "par")
|
||||
lhs_field = "parameters";
|
||||
|
||||
if (from_declaration_type == "par")
|
||||
rhs_field = "parameters";
|
||||
|
||||
lhs_field = "estimation_info." + lhs_field + "(ei_to_ind)";
|
||||
rhs_field = "estimation_info." + rhs_field + "(ei_from_ind)";
|
||||
|
||||
if (to_subsample_name.empty())
|
||||
lhs_field += ".options";
|
||||
else
|
||||
{
|
||||
output << "subsamples_to_indx = get_existing_subsamples_indx('" << to_name1 << "','" << to_name2 << "');" << endl
|
||||
<< lhs_field << ".range_index = estimation_info.subsamples(subsamples_to_indx).range_index;" << endl
|
||||
<< "ei_to_ss_ind = get_subsamples_range_indx(subsamples_to_indx, '" << to_subsample_name << "');" << endl;
|
||||
lhs_field += ".subsample_options(ei_to_ss_ind)";
|
||||
}
|
||||
|
||||
if (from_subsample_name.empty())
|
||||
rhs_field += ".options";
|
||||
else
|
||||
{
|
||||
output << "subsamples_from_indx = get_existing_subsamples_indx('" << from_name1 << "','" << from_name2 << "');" << endl
|
||||
<< "ei_from_ss_ind = get_subsamples_range_indx(subsamples_from_indx, '" << from_subsample_name << "');" << endl;
|
||||
rhs_field += ".subsample_options(ei_from_ss_ind)";
|
||||
}
|
||||
|
||||
output << lhs_field << " = " << rhs_field << ";" << endl;
|
||||
}
|
||||
|
|
|
@ -608,7 +608,6 @@ public:
|
|||
const string &to_name2_arg,
|
||||
const string &from_name1_arg,
|
||||
const string &from_name2_arg);
|
||||
virtual void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings);
|
||||
virtual void writeOutput(ostream &output, const string &basename) const;
|
||||
};
|
||||
|
||||
|
@ -676,6 +675,33 @@ public:
|
|||
virtual void writeOutput(ostream &output, const string &basename) const;
|
||||
};
|
||||
|
||||
class PriorEqualStatement : public Statement
|
||||
{
|
||||
private:
|
||||
const string to_declaration_type;
|
||||
const string to_name1;
|
||||
const string to_name2;
|
||||
const string to_subsample_name;
|
||||
const string from_declaration_type;
|
||||
const string from_name1;
|
||||
const string from_name2;
|
||||
const string from_subsample_name;
|
||||
const SymbolTable symbol_table;
|
||||
public:
|
||||
PriorEqualStatement(const string &to_declaration_type_arg,
|
||||
const string &to_name1_arg,
|
||||
const string &to_name2_arg,
|
||||
const string &to_subsample_name_arg,
|
||||
const string &from_declaration_type_arg,
|
||||
const string &from_name1_arg,
|
||||
const string &from_name2_arg,
|
||||
const string &from_subsample_name_arg,
|
||||
const SymbolTable &symbol_table_arg);
|
||||
void get_base_name(const SymbolType symb_type, string &lhs_field) const;
|
||||
virtual void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings);
|
||||
virtual void writeOutput(ostream &output, const string &basename) const;
|
||||
};
|
||||
|
||||
class BasicOptionsStatement : public Statement
|
||||
{
|
||||
public:
|
||||
|
@ -727,4 +753,31 @@ public:
|
|||
virtual void writeOutput(ostream &output, const string &basename) const;
|
||||
};
|
||||
|
||||
class OptionsEqualStatement : public Statement
|
||||
{
|
||||
private:
|
||||
const string to_declaration_type;
|
||||
const string to_name1;
|
||||
const string to_name2;
|
||||
const string to_subsample_name;
|
||||
const string from_declaration_type;
|
||||
const string from_name1;
|
||||
const string from_name2;
|
||||
const string from_subsample_name;
|
||||
const SymbolTable symbol_table;
|
||||
public:
|
||||
OptionsEqualStatement(const string &to_declaration_type_arg,
|
||||
const string &to_name1_arg,
|
||||
const string &to_name2_arg,
|
||||
const string &to_subsample_name_arg,
|
||||
const string &from_declaration_type_arg,
|
||||
const string &from_name1_arg,
|
||||
const string &from_name2_arg,
|
||||
const string &from_subsample_name_arg,
|
||||
const SymbolTable &symbol_table_arg);
|
||||
void get_base_name(const SymbolType symb_type, string &lhs_field) const;
|
||||
virtual void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings);
|
||||
virtual void writeOutput(ostream &output, const string &basename) const;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -182,7 +182,7 @@ class ParsingDriver;
|
|||
%type <string_val> vec_value_1 vec_value signed_inf signed_number_w_inf
|
||||
%type <string_val> range vec_value_w_inf vec_value_1_w_inf
|
||||
%type <symbol_type_val> change_type_arg
|
||||
%type <vector_string_val> change_type_var_list subsamples_eq_opt
|
||||
%type <vector_string_val> change_type_var_list subsamples_eq_opt prior_eq_opt options_eq_opt
|
||||
%type <vector_int_val> vec_int_elem vec_int_1 vec_int vec_int_number
|
||||
%type <prior_distributions_val> prior_pdf prior_distribution
|
||||
%%
|
||||
|
@ -220,9 +220,11 @@ statement : parameters
|
|||
| set_time
|
||||
| data
|
||||
| prior
|
||||
| prior_eq
|
||||
| subsamples
|
||||
| subsamples_eq
|
||||
| options
|
||||
| options_eq
|
||||
| varobs
|
||||
| observation_trends
|
||||
| unit_root_vars
|
||||
|
@ -1279,6 +1281,65 @@ prior_options : o_shift
|
|||
| o_domain
|
||||
;
|
||||
|
||||
prior_eq : prior_eq_opt EQUAL prior_eq_opt ';'
|
||||
{
|
||||
driver.copy_prior($1->at(0), $1->at(1), $1->at(2), $1->at(3),
|
||||
$3->at(0), $3->at(1), $3->at(2), $3->at(3));
|
||||
delete $1;
|
||||
delete $3;
|
||||
}
|
||||
;
|
||||
|
||||
prior_eq_opt : symbol '.' PRIOR
|
||||
{
|
||||
$$ = new vector<string *>();
|
||||
$$->push_back(new string ("par"));
|
||||
$$->push_back($1);
|
||||
$$->push_back(new string (""));
|
||||
$$->push_back(new string (""));
|
||||
}
|
||||
| symbol '.' symbol '.' PRIOR
|
||||
{
|
||||
$$ = new vector<string *>();
|
||||
$$->push_back(new string ("par"));
|
||||
$$->push_back($1);
|
||||
$$->push_back(new string (""));
|
||||
$$->push_back($3);
|
||||
}
|
||||
| STD '(' symbol ')' '.' PRIOR
|
||||
{
|
||||
$$ = new vector<string *>();
|
||||
$$->push_back(new string ("std"));
|
||||
$$->push_back($3);
|
||||
$$->push_back(new string (""));
|
||||
$$->push_back(new string (""));
|
||||
}
|
||||
| STD '(' symbol ')' '.' symbol '.' PRIOR
|
||||
{
|
||||
$$ = new vector<string *>();
|
||||
$$->push_back(new string ("std"));
|
||||
$$->push_back($3);
|
||||
$$->push_back(new string (""));
|
||||
$$->push_back($6);
|
||||
}
|
||||
| CORR '(' symbol COMMA symbol ')' '.' PRIOR
|
||||
{
|
||||
$$ = new vector<string *>();
|
||||
$$->push_back(new string ("corr"));
|
||||
$$->push_back($3);
|
||||
$$->push_back($5);
|
||||
$$->push_back(new string (""));
|
||||
}
|
||||
| CORR '(' symbol COMMA symbol ')' '.' symbol '.' PRIOR
|
||||
{
|
||||
$$ = new vector<string *>();
|
||||
$$->push_back(new string ("corr"));
|
||||
$$->push_back($3);
|
||||
$$->push_back($5);
|
||||
$$->push_back($8);
|
||||
}
|
||||
;
|
||||
|
||||
options : symbol '.' OPTIONS '(' options_options_list ')' ';'
|
||||
{ driver.set_options($1, new string ("")); }
|
||||
| symbol '.' symbol '.' OPTIONS '(' options_options_list ')' ';'
|
||||
|
@ -1302,6 +1363,65 @@ options_options : o_jscale
|
|||
| o_bounds
|
||||
;
|
||||
|
||||
options_eq : options_eq_opt EQUAL options_eq_opt ';'
|
||||
{
|
||||
driver.copy_options($1->at(0), $1->at(1), $1->at(2), $1->at(3),
|
||||
$3->at(0), $3->at(1), $3->at(2), $3->at(3));
|
||||
delete $1;
|
||||
delete $3;
|
||||
}
|
||||
;
|
||||
|
||||
options_eq_opt : symbol '.' OPTIONS
|
||||
{
|
||||
$$ = new vector<string *>();
|
||||
$$->push_back(new string ("par"));
|
||||
$$->push_back($1);
|
||||
$$->push_back(new string (""));
|
||||
$$->push_back(new string (""));
|
||||
}
|
||||
| symbol '.' symbol '.' OPTIONS
|
||||
{
|
||||
$$ = new vector<string *>();
|
||||
$$->push_back(new string ("par"));
|
||||
$$->push_back($1);
|
||||
$$->push_back(new string (""));
|
||||
$$->push_back($3);
|
||||
}
|
||||
| STD '(' symbol ')' '.' OPTIONS
|
||||
{
|
||||
$$ = new vector<string *>();
|
||||
$$->push_back(new string ("std"));
|
||||
$$->push_back($3);
|
||||
$$->push_back(new string (""));
|
||||
$$->push_back(new string (""));
|
||||
}
|
||||
| STD '(' symbol ')' '.' symbol '.' OPTIONS
|
||||
{
|
||||
$$ = new vector<string *>();
|
||||
$$->push_back(new string ("std"));
|
||||
$$->push_back($3);
|
||||
$$->push_back(new string (""));
|
||||
$$->push_back($6);
|
||||
}
|
||||
| CORR '(' symbol COMMA symbol ')' '.' OPTIONS
|
||||
{
|
||||
$$ = new vector<string *>();
|
||||
$$->push_back(new string ("corr"));
|
||||
$$->push_back($3);
|
||||
$$->push_back($5);
|
||||
$$->push_back(new string (""));
|
||||
}
|
||||
| CORR '(' symbol COMMA symbol ')' '.' symbol '.' OPTIONS
|
||||
{
|
||||
$$ = new vector<string *>();
|
||||
$$->push_back(new string ("corr"));
|
||||
$$->push_back($3);
|
||||
$$->push_back($5);
|
||||
$$->push_back($8);
|
||||
}
|
||||
;
|
||||
|
||||
estimation : ESTIMATION ';'
|
||||
{ driver.run_estimation(); }
|
||||
| ESTIMATION '(' estimation_options_list ')' ';'
|
||||
|
|
|
@ -1357,6 +1357,32 @@ ParsingDriver::set_prior_variance(expr_t variance)
|
|||
prior_variance = variance;
|
||||
}
|
||||
|
||||
void
|
||||
ParsingDriver::copy_prior(string *to_declaration_type, string *to_name1, string *to_name2, string *to_subsample_name,
|
||||
string *from_declaration_type, string *from_name1, string *from_name2, string *from_subsample_name)
|
||||
{
|
||||
check_symbol_existence(*to_name1);
|
||||
check_symbol_existence(*from_name1);
|
||||
|
||||
if (!to_name2->empty())
|
||||
check_symbol_existence(*to_name2);
|
||||
|
||||
if (!from_name2->empty())
|
||||
check_symbol_existence(*from_name2);
|
||||
|
||||
mod_file->addStatement(new PriorEqualStatement(*to_declaration_type, *to_name1, *to_name2, *to_subsample_name,
|
||||
*from_declaration_type, *from_name1, *from_name2, *from_subsample_name,
|
||||
mod_file->symbol_table));
|
||||
delete to_declaration_type;
|
||||
delete to_name1;
|
||||
delete to_name2;
|
||||
delete to_subsample_name;
|
||||
delete from_declaration_type;
|
||||
delete from_name1;
|
||||
delete from_name2;
|
||||
delete from_subsample_name;
|
||||
}
|
||||
|
||||
void
|
||||
ParsingDriver::set_options(string *name, string *subsample_name)
|
||||
{
|
||||
|
@ -1368,6 +1394,32 @@ ParsingDriver::set_options(string *name, string *subsample_name)
|
|||
delete subsample_name;
|
||||
}
|
||||
|
||||
void
|
||||
ParsingDriver::copy_options(string *to_declaration_type, string *to_name1, string *to_name2, string *to_subsample_name,
|
||||
string *from_declaration_type, string *from_name1, string *from_name2, string *from_subsample_name)
|
||||
{
|
||||
check_symbol_existence(*to_name1);
|
||||
check_symbol_existence(*from_name1);
|
||||
|
||||
if (!to_name2->empty())
|
||||
check_symbol_existence(*to_name2);
|
||||
|
||||
if (!from_name2->empty())
|
||||
check_symbol_existence(*from_name2);
|
||||
|
||||
mod_file->addStatement(new OptionsEqualStatement(*to_declaration_type, *to_name1, *to_name2, *to_subsample_name,
|
||||
*from_declaration_type, *from_name1, *from_name2, *from_subsample_name,
|
||||
mod_file->symbol_table));
|
||||
delete to_declaration_type;
|
||||
delete to_name1;
|
||||
delete to_name2;
|
||||
delete to_subsample_name;
|
||||
delete from_declaration_type;
|
||||
delete from_name1;
|
||||
delete from_name2;
|
||||
delete from_subsample_name;
|
||||
}
|
||||
|
||||
void
|
||||
ParsingDriver::check_symbol_is_endogenous_or_exogenous(string *name)
|
||||
{
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2003-2011 Dynare Team
|
||||
* Copyright (C) 2003-2012 Dynare Team
|
||||
*
|
||||
* This file is part of Dynare.
|
||||
*
|
||||
|
@ -392,8 +392,14 @@ public:
|
|||
void set_prior(string *arg1, string *arg2);
|
||||
//! Adds the variance option to its temporary holding place
|
||||
void set_prior_variance(expr_t variance=NULL);
|
||||
//! Copies the prior from_name to_name
|
||||
void copy_prior(string *to_declaration_type, string *to_name1, string *to_name2, string *to_subsample_name,
|
||||
string *from_declaration_type, string *from_name1, string *from_name2, string *from_subsample_name);
|
||||
//! Sets the options for a parameter
|
||||
void set_options(string *arg1, string *arg2);
|
||||
//! Copies the options from_name to_name
|
||||
void copy_options(string *to_declaration_type, string *to_name1, string *to_name2, string *to_subsample_name,
|
||||
string *from_declaration_type, string *from_name1, string *from_name2, string *from_subsample_name);
|
||||
//! Sets the prior for estimated std dev
|
||||
void set_std_prior(string *arg1, string *arg2);
|
||||
//! Sets the options for estimated std dev
|
||||
|
|
Loading…
Reference in New Issue