estimation: rewrite subsamples statement as an actual statement
parent
90e2de65f7
commit
46a655fbd5
|
@ -0,0 +1,49 @@
|
||||||
|
function subsamples_indx = get_existing_subsamples_indx(name1, name2)
|
||||||
|
% function subsamples_indx = get_existing_subsamples_indx(name1, name2)
|
||||||
|
%
|
||||||
|
% Returns the existing estimation_info.subsamples_index index
|
||||||
|
% for the name1 & name2 pair
|
||||||
|
%
|
||||||
|
% INPUTS
|
||||||
|
% name1 [string] the variable for which the subsample index is
|
||||||
|
% desired
|
||||||
|
% name2 [string] used only in case of corr(name1,name2).subsamples()
|
||||||
|
%
|
||||||
|
% OUTPUTS
|
||||||
|
% subsamples_indx [integer] existing index in the estimation_info.subsamples
|
||||||
|
% structure associated with the name pair
|
||||||
|
%
|
||||||
|
% SPECIAL REQUIREMENTS
|
||||||
|
% none
|
||||||
|
|
||||||
|
% Copyright (C) 2012 Dynare Team
|
||||||
|
%
|
||||||
|
% This file is part of Dynare.
|
||||||
|
%
|
||||||
|
% Dynare is free software: you can redistribute it and/or modify
|
||||||
|
% it under the terms of the GNU General Public License as published by
|
||||||
|
% the Free Software Foundation, either version 3 of the License, or
|
||||||
|
% (at your option) any later version.
|
||||||
|
%
|
||||||
|
% Dynare is distributed in the hope that it will be useful,
|
||||||
|
% but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
% GNU General Public License for more details.
|
||||||
|
%
|
||||||
|
% You should have received a copy of the GNU General Public License
|
||||||
|
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
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);
|
||||||
|
if isempty(subsamples_indx)
|
||||||
|
subsamples_indx = find(strcmp([name2 '_' name1], estimation_info.subsamples_index) == 1);
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if size(subsamples_indx,2) ~= 1
|
||||||
|
error(['Error: Index not found for ' name1 ' ' name2]);
|
||||||
|
end
|
|
@ -0,0 +1,57 @@
|
||||||
|
function subsamples_indx = get_new_or_existing_subsamples_indx(name1, name2)
|
||||||
|
% function subsamples_indx = get_new_or_existing_subsamples_indx(name1, name2)
|
||||||
|
%
|
||||||
|
% Returns the new estimation_info.subsamples_index index
|
||||||
|
% for the name1 & name2 pair
|
||||||
|
%
|
||||||
|
% INPUTS
|
||||||
|
% name1 [string] the variable for which the subsample was declared
|
||||||
|
% name2 [string] used only in case of corr(name1,name2).subsamples()
|
||||||
|
%
|
||||||
|
% OUTPUTS
|
||||||
|
% subsamples_indx [integer] new index in the estimation_info.subsamples
|
||||||
|
% structure associated with the name pair
|
||||||
|
%
|
||||||
|
% SPECIAL REQUIREMENTS
|
||||||
|
% none
|
||||||
|
|
||||||
|
% Copyright (C) 2012 Dynare Team
|
||||||
|
%
|
||||||
|
% This file is part of Dynare.
|
||||||
|
%
|
||||||
|
% Dynare is free software: you can redistribute it and/or modify
|
||||||
|
% it under the terms of the GNU General Public License as published by
|
||||||
|
% the Free Software Foundation, either version 3 of the License, or
|
||||||
|
% (at your option) any later version.
|
||||||
|
%
|
||||||
|
% Dynare is distributed in the hope that it will be useful,
|
||||||
|
% but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
% GNU General Public License for more details.
|
||||||
|
%
|
||||||
|
% You should have received a copy of the GNU General Public License
|
||||||
|
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
global estimation_info
|
||||||
|
|
||||||
|
if isempty(estimation_info.subsamples_index)
|
||||||
|
subsamples_indx = 1;
|
||||||
|
return;
|
||||||
|
end
|
||||||
|
|
||||||
|
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);
|
||||||
|
if isempty(subsamples_indx)
|
||||||
|
subsamples_indx = find(strcmp([name2 '_' name1], estimation_info.subsamples_index) == 1);
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if isempty(subsamples_indx)
|
||||||
|
subsamples_indx = size(estimation_info.subsamples_index, 2) + 1;
|
||||||
|
end
|
||||||
|
|
||||||
|
if size(subsamples_indx,2) > 1
|
||||||
|
error(['Error: ' name1 ' ' name2 'found more than once in estimation_info.subsamples_index']);
|
||||||
|
end
|
|
@ -0,0 +1,43 @@
|
||||||
|
function range_indx = get_subsamples_range_indx(subsamples_indx, range_label)
|
||||||
|
% function range_indx = get_subsamples_range_indx(subsamples_indx, range_label)
|
||||||
|
%
|
||||||
|
% Returns the existing estimation_info.subsamples.range_index index
|
||||||
|
% for the range_label
|
||||||
|
%
|
||||||
|
% INPUTS
|
||||||
|
% subsamples_indx [integer] index in estimation_info.subsamples
|
||||||
|
% range_label [string] label for range
|
||||||
|
%
|
||||||
|
% OUTPUTS
|
||||||
|
% range_indx [integer] existing index in the
|
||||||
|
% estimation_info.subsamples.range_index
|
||||||
|
% structure associated with the range_label
|
||||||
|
%
|
||||||
|
% SPECIAL REQUIREMENTS
|
||||||
|
% none
|
||||||
|
|
||||||
|
% Copyright (C) 2012 Dynare Team
|
||||||
|
%
|
||||||
|
% This file is part of Dynare.
|
||||||
|
%
|
||||||
|
% Dynare is free software: you can redistribute it and/or modify
|
||||||
|
% it under the terms of the GNU General Public License as published by
|
||||||
|
% the Free Software Foundation, either version 3 of the License, or
|
||||||
|
% (at your option) any later version.
|
||||||
|
%
|
||||||
|
% Dynare is distributed in the hope that it will be useful,
|
||||||
|
% but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
% GNU General Public License for more details.
|
||||||
|
%
|
||||||
|
% You should have received a copy of the GNU General Public License
|
||||||
|
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
global estimation_info
|
||||||
|
|
||||||
|
range_indx = find(strcmp(range_label, estimation_info.subsamples(subsamples_indx).range_index) == 1);
|
||||||
|
|
||||||
|
if size(subsamples_indx,2) ~= 1
|
||||||
|
error(['Error: Index not found in estimation_info.subsamples(' ...
|
||||||
|
name1 ').range_index for label' range_label]);
|
||||||
|
end
|
|
@ -243,6 +243,7 @@ options_.ramsey_policy = 0;
|
||||||
options_.timeless = 0;
|
options_.timeless = 0;
|
||||||
|
|
||||||
% estimation
|
% estimation
|
||||||
|
estimation_info.subsamples.range = struct('date1', {}, 'date2', {});
|
||||||
estimation_info.parameters.prior = struct('name', {}, 'shape', {}, 'mean', {}, ...
|
estimation_info.parameters.prior = struct('name', {}, 'shape', {}, 'mean', {}, ...
|
||||||
'mode', {}, 'stdev', {}, 'date1', {}, ...
|
'mode', {}, 'stdev', {}, 'date1', {}, ...
|
||||||
'date2', {}, 'shift', {}, 'variance', {});
|
'date2', {}, 'shift', {}, 'variance', {});
|
||||||
|
@ -258,6 +259,8 @@ estimation_info.measurement_error.prior = struct('name', {}, 'shape', {}, 'mean'
|
||||||
estimation_info.measurement_error_corr.prior = struct('name', {}, 'shape', {}, 'mean', {}, ...
|
estimation_info.measurement_error_corr.prior = struct('name', {}, 'shape', {}, 'mean', {}, ...
|
||||||
'mode', {}, 'stdev', {}, 'date1', {}, ...
|
'mode', {}, 'stdev', {}, 'date1', {}, ...
|
||||||
'date2', {}, 'shift', {}, 'variance', {});
|
'date2', {}, 'shift', {}, 'variance', {});
|
||||||
|
estimation_info.subsamples_index = {};
|
||||||
|
estimation_info.subsamples.range_index = {};
|
||||||
estimation_info.parameters.prior_index = {};
|
estimation_info.parameters.prior_index = {};
|
||||||
estimation_info.measurement_error.prior_index = {};
|
estimation_info.measurement_error.prior_index = {};
|
||||||
estimation_info.structural_innovation.prior_index = {};
|
estimation_info.structural_innovation.prior_index = {};
|
||||||
|
|
|
@ -1630,15 +1630,82 @@ EstimationDataStatement::writeOutput(ostream &output, const string &basename) co
|
||||||
output << "options_.dataset.firstobs = options_.initial_period;" << endl;
|
output << "options_.dataset.firstobs = options_.initial_period;" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SubsamplesStatement::SubsamplesStatement(const string &name1_arg,
|
||||||
|
const string &name2_arg,
|
||||||
|
const subsample_declaration_map_t subsample_declaration_map_arg) :
|
||||||
|
name1(name1_arg),
|
||||||
|
name2(name2_arg),
|
||||||
|
subsample_declaration_map(subsample_declaration_map_arg)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
SubsamplesStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
SubsamplesStatement::writeOutput(ostream &output, const string &basename) const
|
||||||
|
{
|
||||||
|
output << "subsamples_indx = get_new_or_existing_subsamples_indx('" << name1 << "','" << name2 << "');" << endl
|
||||||
|
<< "estimation_info.subsamples_index(subsamples_indx) = {'" << name1;
|
||||||
|
if (!name2.empty())
|
||||||
|
output << "_" << name2;
|
||||||
|
output << "'};" << endl
|
||||||
|
<< "estimation_info.subsamples(subsamples_indx).range = {};" << endl;
|
||||||
|
|
||||||
|
int map_indx = 1;
|
||||||
|
for (subsample_declaration_map_t::const_iterator it = subsample_declaration_map.begin();
|
||||||
|
it != subsample_declaration_map.end(); it++, map_indx++)
|
||||||
|
output << "estimation_info.subsamples(subsamples_indx).range_index(" << map_indx << ") = {'"
|
||||||
|
<< it->first << "'};" << endl
|
||||||
|
<< "estimation_info.subsamples(subsamples_indx).range(" << map_indx << ").date1 = '"
|
||||||
|
<< it->second.first << "';" << endl
|
||||||
|
<< "estimation_info.subsamples(subsamples_indx).range(" << map_indx << ").date2 = '"
|
||||||
|
<< it->second.second << "';" << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
SubsamplesEqualStatement::SubsamplesEqualStatement(const string &to_name1_arg,
|
||||||
|
const string &to_name2_arg,
|
||||||
|
const string &from_name1_arg,
|
||||||
|
const string &from_name2_arg) :
|
||||||
|
to_name1(to_name1_arg),
|
||||||
|
to_name2(to_name2_arg),
|
||||||
|
from_name1(from_name1_arg),
|
||||||
|
from_name2(from_name2_arg)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
SubsamplesEqualStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
SubsamplesEqualStatement::writeOutput(ostream &output, const string &basename) const
|
||||||
|
{
|
||||||
|
output << "subsamples_to_indx = get_new_or_existing_subsamples_indx('" << to_name1 << "','" << to_name2 << "');" << endl
|
||||||
|
<< "estimation_info.subsamples_index(subsamples_to_indx) = {'" << to_name1;
|
||||||
|
if (!to_name2.empty())
|
||||||
|
output << "_" << to_name2;
|
||||||
|
output << "'};" << endl
|
||||||
|
<< "subsamples_from_indx = get_existing_subsamples_indx('" << from_name1 << "','" << from_name2 << "');"
|
||||||
|
<< endl
|
||||||
|
<< "estimation_info.subsamples(subsamples_to_indx) = estimation_info.subsamples(subsamples_from_indx);"
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
|
||||||
BasicPriorStatement::~BasicPriorStatement()
|
BasicPriorStatement::~BasicPriorStatement()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
BasicPriorStatement::BasicPriorStatement(const string &name_arg,
|
BasicPriorStatement::BasicPriorStatement(const string &name_arg,
|
||||||
|
const string &subsample_name_arg,
|
||||||
const PriorDistributions &prior_shape_arg,
|
const PriorDistributions &prior_shape_arg,
|
||||||
const expr_t &variance_arg,
|
const expr_t &variance_arg,
|
||||||
const OptionsList &options_list_arg) :
|
const OptionsList &options_list_arg) :
|
||||||
name(name_arg),
|
name(name_arg),
|
||||||
|
subsample_name(subsample_name_arg),
|
||||||
prior_shape(prior_shape_arg),
|
prior_shape(prior_shape_arg),
|
||||||
variance(variance_arg),
|
variance(variance_arg),
|
||||||
options_list(options_list_arg),
|
options_list(options_list_arg),
|
||||||
|
@ -1655,11 +1722,6 @@ BasicPriorStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsoli
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
assert((options_list.num_options.find("date1") != options_list.num_options.end() &&
|
|
||||||
options_list.num_options.find("date2") != options_list.num_options.end()) ||
|
|
||||||
(options_list.num_options.find("date1") == options_list.num_options.end() &&
|
|
||||||
options_list.num_options.find("date2") == options_list.num_options.end()));
|
|
||||||
|
|
||||||
OptionsList::num_options_t::const_iterator it_num = options_list.num_options.find("domain");
|
OptionsList::num_options_t::const_iterator it_num = options_list.num_options.find("domain");
|
||||||
if (it_num != options_list.num_options.end())
|
if (it_num != options_list.num_options.end())
|
||||||
{
|
{
|
||||||
|
@ -1701,8 +1763,6 @@ BasicPriorStatement::writeCommonOutput(ostream &output, const string &lhs_field)
|
||||||
writeCommonOutputHelper(output, "stdev", lhs_field);
|
writeCommonOutputHelper(output, "stdev", lhs_field);
|
||||||
writeCommonOutputHelper(output, "shape", lhs_field);
|
writeCommonOutputHelper(output, "shape", lhs_field);
|
||||||
writeCommonOutputHelper(output, "shift", lhs_field);
|
writeCommonOutputHelper(output, "shift", lhs_field);
|
||||||
writeCommonOutputHelper(output, "date1", lhs_field);
|
|
||||||
writeCommonOutputHelper(output, "date2", lhs_field);
|
|
||||||
writeCommonOutputHelper(output, "domain", lhs_field);
|
writeCommonOutputHelper(output, "domain", lhs_field);
|
||||||
writeCommonOutputHelper(output, "median", lhs_field);
|
writeCommonOutputHelper(output, "median", lhs_field);
|
||||||
writeCommonOutputHelper(output, "truncate", lhs_field);
|
writeCommonOutputHelper(output, "truncate", lhs_field);
|
||||||
|
@ -1745,16 +1805,28 @@ BasicPriorStatement::writeVarianceOption(ostream &output, const string &lhs_fiel
|
||||||
void
|
void
|
||||||
BasicPriorStatement::writeSubsampleName(ostream &output) const
|
BasicPriorStatement::writeSubsampleName(ostream &output) const
|
||||||
{
|
{
|
||||||
OptionsList::date_options_t::const_iterator itd = options_list.date_options.find("subsample_name");
|
if (!subsample_name.empty())
|
||||||
if (itd != options_list.date_options.end())
|
output << ":" << subsample_name;
|
||||||
output << ":" << itd->second;
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
BasicPriorStatement::writeSubsampleInfo(ostream &output, const string &lhs_field, const string name1, const string name2) const
|
||||||
|
{
|
||||||
|
if (subsample_name.empty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
output << "subsamples_indx = get_existing_subsamples_indx('" << name1 << "', '" << name2 << "');" << endl;
|
||||||
|
output << "range_indx = get_subsamples_range_indx(subsamples_indx, '" << subsample_name << "');" << endl;
|
||||||
|
output << "estimation_info" << lhs_field << "(prior_indx).date1 = estimation_info.subsamples(subsamples_indx).range(range_indx).date1;" << endl;
|
||||||
|
output << "estimation_info" << lhs_field << "(prior_indx).date2 = estimation_info.subsamples(subsamples_indx).range(range_indx).date2;" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
PriorStatement::PriorStatement(const string &name_arg,
|
PriorStatement::PriorStatement(const string &name_arg,
|
||||||
|
const string &subsample_name_arg,
|
||||||
const PriorDistributions &prior_shape_arg,
|
const PriorDistributions &prior_shape_arg,
|
||||||
const expr_t &variance_arg,
|
const expr_t &variance_arg,
|
||||||
const OptionsList &options_list_arg) :
|
const OptionsList &options_list_arg) :
|
||||||
BasicPriorStatement(name_arg, prior_shape_arg, variance_arg, options_list_arg)
|
BasicPriorStatement(name_arg, subsample_name_arg, prior_shape_arg, variance_arg, options_list_arg)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1779,14 +1851,16 @@ PriorStatement::writeOutput(ostream &output, const string &basename) const
|
||||||
<< "estimation_info" << lhs_field <<"(prior_indx).name = '" << name << "';" << endl;
|
<< "estimation_info" << lhs_field <<"(prior_indx).name = '" << name << "';" << endl;
|
||||||
|
|
||||||
writeCommonOutput(output, lhs_field);
|
writeCommonOutput(output, lhs_field);
|
||||||
|
writeSubsampleInfo(output, lhs_field, name, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
StdPriorStatement::StdPriorStatement(const string &name_arg,
|
StdPriorStatement::StdPriorStatement(const string &name_arg,
|
||||||
|
const string &subsample_name_arg,
|
||||||
const PriorDistributions &prior_shape_arg,
|
const PriorDistributions &prior_shape_arg,
|
||||||
const expr_t &variance_arg,
|
const expr_t &variance_arg,
|
||||||
const OptionsList &options_list_arg,
|
const OptionsList &options_list_arg,
|
||||||
const SymbolTable &symbol_table_arg ) :
|
const SymbolTable &symbol_table_arg ) :
|
||||||
BasicPriorStatement(name_arg, prior_shape_arg, variance_arg, options_list_arg),
|
BasicPriorStatement(name_arg, subsample_name_arg, prior_shape_arg, variance_arg, options_list_arg),
|
||||||
symbol_table(symbol_table_arg)
|
symbol_table(symbol_table_arg)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -1814,14 +1888,16 @@ StdPriorStatement::writeOutput(ostream &output, const string &basename) const
|
||||||
<< "estimation_info" << lhs_field << "(prior_indx).name = '" << name << "';" << endl;
|
<< "estimation_info" << lhs_field << "(prior_indx).name = '" << name << "';" << endl;
|
||||||
|
|
||||||
writeCommonOutput(output, lhs_field);
|
writeCommonOutput(output, lhs_field);
|
||||||
|
writeSubsampleInfo(output, lhs_field, name, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
CorrPriorStatement::CorrPriorStatement(const string &name_arg1, const string &name_arg2,
|
CorrPriorStatement::CorrPriorStatement(const string &name_arg1, const string &name_arg2,
|
||||||
|
const string &subsample_name_arg,
|
||||||
const PriorDistributions &prior_shape_arg,
|
const PriorDistributions &prior_shape_arg,
|
||||||
const expr_t &variance_arg,
|
const expr_t &variance_arg,
|
||||||
const OptionsList &options_list_arg,
|
const OptionsList &options_list_arg,
|
||||||
const SymbolTable &symbol_table_arg ) :
|
const SymbolTable &symbol_table_arg ) :
|
||||||
BasicPriorStatement(name_arg1, prior_shape_arg, variance_arg, options_list_arg),
|
BasicPriorStatement(name_arg1, subsample_name_arg, prior_shape_arg, variance_arg, options_list_arg),
|
||||||
name1(name_arg2),
|
name1(name_arg2),
|
||||||
symbol_table(symbol_table_arg)
|
symbol_table(symbol_table_arg)
|
||||||
{
|
{
|
||||||
|
@ -1858,6 +1934,7 @@ CorrPriorStatement::writeOutput(ostream &output, const string &basename) const
|
||||||
<< "estimation_info" << lhs_field << "(prior_indx).name2 = '" << name1 << "';" << endl;
|
<< "estimation_info" << lhs_field << "(prior_indx).name2 = '" << name1 << "';" << endl;
|
||||||
|
|
||||||
writeCommonOutput(output, lhs_field);
|
writeCommonOutput(output, lhs_field);
|
||||||
|
writeSubsampleInfo(output, lhs_field, name, name1);
|
||||||
}
|
}
|
||||||
|
|
||||||
BasicOptionsStatement::~BasicOptionsStatement()
|
BasicOptionsStatement::~BasicOptionsStatement()
|
||||||
|
@ -1865,8 +1942,10 @@ BasicOptionsStatement::~BasicOptionsStatement()
|
||||||
}
|
}
|
||||||
|
|
||||||
BasicOptionsStatement::BasicOptionsStatement(const string &name_arg,
|
BasicOptionsStatement::BasicOptionsStatement(const string &name_arg,
|
||||||
const OptionsList &options_list_arg) :
|
const string &subsample_name_arg,
|
||||||
|
const OptionsList &options_list_arg) :
|
||||||
name(name_arg),
|
name(name_arg),
|
||||||
|
subsample_name(subsample_name_arg),
|
||||||
options_list(options_list_arg),
|
options_list(options_list_arg),
|
||||||
first_statement_encountered(false)
|
first_statement_encountered(false)
|
||||||
{
|
{
|
||||||
|
@ -1875,10 +1954,6 @@ BasicOptionsStatement::BasicOptionsStatement(const string &name_arg,
|
||||||
void
|
void
|
||||||
BasicOptionsStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings)
|
BasicOptionsStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings)
|
||||||
{
|
{
|
||||||
assert((options_list.num_options.find("date1") != options_list.num_options.end() &&
|
|
||||||
options_list.num_options.find("date2") != options_list.num_options.end()) ||
|
|
||||||
(options_list.num_options.find("date1") == options_list.num_options.end() &&
|
|
||||||
options_list.num_options.find("date2") == options_list.num_options.end()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -1905,8 +1980,6 @@ BasicOptionsStatement::writeCommonOutput(ostream &output, const string &lhs_fiel
|
||||||
writeCommonOutputHelper(output, "init", lhs_field);
|
writeCommonOutputHelper(output, "init", lhs_field);
|
||||||
writeCommonOutputHelper(output, "bounds", lhs_field);
|
writeCommonOutputHelper(output, "bounds", lhs_field);
|
||||||
writeCommonOutputHelper(output, "jscale", lhs_field);
|
writeCommonOutputHelper(output, "jscale", lhs_field);
|
||||||
writeCommonOutputHelper(output, "date1", lhs_field);
|
|
||||||
writeCommonOutputHelper(output, "date2", lhs_field);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -1926,14 +1999,26 @@ BasicOptionsStatement::writeCommonOutputHelper(ostream &output, const string &fi
|
||||||
void
|
void
|
||||||
BasicOptionsStatement::writeSubsampleName(ostream &output) const
|
BasicOptionsStatement::writeSubsampleName(ostream &output) const
|
||||||
{
|
{
|
||||||
OptionsList::date_options_t::const_iterator itd = options_list.date_options.find("subsample_name");
|
if (!subsample_name.empty())
|
||||||
if (itd != options_list.date_options.end())
|
output << ":" << subsample_name;
|
||||||
output << ":" << itd->second;
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
BasicOptionsStatement::writeSubsampleInfo(ostream &output, const string &lhs_field, const string name1, const string name2) const
|
||||||
|
{
|
||||||
|
if (subsample_name.empty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
output << "subsamples_indx = get_existing_subsamples_indx('" << name1 << "', '" << name2 << "');" << endl;
|
||||||
|
output << "range_indx = get_subsamples_range_indx(subsamples_indx, '" << subsample_name << "');" << endl;
|
||||||
|
output << "estimation_info" << lhs_field << "(options_indx).date1 = estimation_info.subsamples(subsamples_indx).range(range_indx).date1;" << endl;
|
||||||
|
output << "estimation_info" << lhs_field << "(options_indx).date2 = estimation_info.subsamples(subsamples_indx).range(range_indx).date2;" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
OptionsStatement::OptionsStatement(const string &name_arg,
|
OptionsStatement::OptionsStatement(const string &name_arg,
|
||||||
|
const string &subsample_name_arg,
|
||||||
const OptionsList &options_list_arg) :
|
const OptionsList &options_list_arg) :
|
||||||
BasicOptionsStatement(name_arg, options_list_arg)
|
BasicOptionsStatement(name_arg, subsample_name_arg, options_list_arg)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1958,12 +2043,14 @@ OptionsStatement::writeOutput(ostream &output, const string &basename) const
|
||||||
<< "estimation_info" << lhs_field << "(options_indx).name = '" << name << "';" << endl;
|
<< "estimation_info" << lhs_field << "(options_indx).name = '" << name << "';" << endl;
|
||||||
|
|
||||||
writeCommonOutput(output, lhs_field);
|
writeCommonOutput(output, lhs_field);
|
||||||
|
writeSubsampleInfo(output, lhs_field, name, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
StdOptionsStatement::StdOptionsStatement(const string &name_arg,
|
StdOptionsStatement::StdOptionsStatement(const string &name_arg,
|
||||||
|
const string &subsample_name_arg,
|
||||||
const OptionsList &options_list_arg,
|
const OptionsList &options_list_arg,
|
||||||
const SymbolTable &symbol_table_arg ) :
|
const SymbolTable &symbol_table_arg ) :
|
||||||
BasicOptionsStatement(name_arg, options_list_arg),
|
BasicOptionsStatement(name_arg, subsample_name_arg, options_list_arg),
|
||||||
symbol_table(symbol_table_arg)
|
symbol_table(symbol_table_arg)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -1991,12 +2078,14 @@ StdOptionsStatement::writeOutput(ostream &output, const string &basename) const
|
||||||
<< "estimation_info" << lhs_field << "(options_indx).name = '" << name << "';" << endl;
|
<< "estimation_info" << lhs_field << "(options_indx).name = '" << name << "';" << endl;
|
||||||
|
|
||||||
writeCommonOutput(output, lhs_field);
|
writeCommonOutput(output, lhs_field);
|
||||||
|
writeSubsampleInfo(output, lhs_field, name, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
CorrOptionsStatement::CorrOptionsStatement(const string &name_arg1, const string &name_arg2,
|
CorrOptionsStatement::CorrOptionsStatement(const string &name_arg1, const string &name_arg2,
|
||||||
|
const string &subsample_name_arg,
|
||||||
const OptionsList &options_list_arg,
|
const OptionsList &options_list_arg,
|
||||||
const SymbolTable &symbol_table_arg ) :
|
const SymbolTable &symbol_table_arg ) :
|
||||||
BasicOptionsStatement(name_arg1, options_list_arg),
|
BasicOptionsStatement(name_arg1, subsample_name_arg, options_list_arg),
|
||||||
name1(name_arg2),
|
name1(name_arg2),
|
||||||
symbol_table(symbol_table_arg)
|
symbol_table(symbol_table_arg)
|
||||||
{
|
{
|
||||||
|
@ -2032,4 +2121,5 @@ CorrOptionsStatement::writeOutput(ostream &output, const string &basename) const
|
||||||
<< "estimation_info" << lhs_field << "(options_indx).name2 = '" << name1 << "';" << endl;
|
<< "estimation_info" << lhs_field << "(options_indx).name2 = '" << name1 << "';" << endl;
|
||||||
|
|
||||||
writeCommonOutput(output, lhs_field);
|
writeCommonOutput(output, lhs_field);
|
||||||
|
writeSubsampleInfo(output, lhs_field, name, name1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -579,17 +579,52 @@ public:
|
||||||
virtual void writeOutput(ostream &output, const string &basename) const;
|
virtual void writeOutput(ostream &output, const string &basename) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class SubsamplesStatement : public Statement
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
//! Storage for declaring subsamples: map<subsample_name, <date1, date2 >
|
||||||
|
typedef map<string, pair<string, string> > subsample_declaration_map_t;
|
||||||
|
private:
|
||||||
|
const string name1;
|
||||||
|
const string name2;
|
||||||
|
const subsample_declaration_map_t subsample_declaration_map;
|
||||||
|
public:
|
||||||
|
SubsamplesStatement(const string &name1_arg,
|
||||||
|
const string &name2_arg,
|
||||||
|
const subsample_declaration_map_t subsample_declaration_map_arg);
|
||||||
|
virtual void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings);
|
||||||
|
virtual void writeOutput(ostream &output, const string &basename) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
class SubsamplesEqualStatement : public Statement
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
const string to_name1;
|
||||||
|
const string to_name2;
|
||||||
|
const string from_name1;
|
||||||
|
const string from_name2;
|
||||||
|
public:
|
||||||
|
SubsamplesEqualStatement(const string &to_name1_arg,
|
||||||
|
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;
|
||||||
|
};
|
||||||
|
|
||||||
class BasicPriorStatement : public Statement
|
class BasicPriorStatement : public Statement
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~BasicPriorStatement();
|
virtual ~BasicPriorStatement();
|
||||||
protected:
|
protected:
|
||||||
const string name;
|
const string name;
|
||||||
|
const string subsample_name;
|
||||||
const PriorDistributions prior_shape;
|
const PriorDistributions prior_shape;
|
||||||
const expr_t variance;
|
const expr_t variance;
|
||||||
const OptionsList options_list;
|
const OptionsList options_list;
|
||||||
bool first_statement_encountered;
|
bool first_statement_encountered;
|
||||||
BasicPriorStatement(const string &name_arg,
|
BasicPriorStatement(const string &name_arg,
|
||||||
|
const string &subsample_name_arg,
|
||||||
const PriorDistributions &prior_shape_arg,
|
const PriorDistributions &prior_shape_arg,
|
||||||
const expr_t &variance_arg,
|
const expr_t &variance_arg,
|
||||||
const OptionsList &options_list_arg);
|
const OptionsList &options_list_arg);
|
||||||
|
@ -601,12 +636,14 @@ protected:
|
||||||
void writeCommonOutputHelper(ostream &output, const string &field, const string &lhs_field) const;
|
void writeCommonOutputHelper(ostream &output, const string &field, const string &lhs_field) const;
|
||||||
void writeShape(ostream &output, const string &lhs_field) const;
|
void writeShape(ostream &output, const string &lhs_field) const;
|
||||||
void writeSubsampleName(ostream &output) const;
|
void writeSubsampleName(ostream &output) const;
|
||||||
|
void writeSubsampleInfo(ostream &output, const string &lhs_field, const string name1, const string name2) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class PriorStatement : public BasicPriorStatement
|
class PriorStatement : public BasicPriorStatement
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PriorStatement(const string &name_arg,
|
PriorStatement(const string &name_arg,
|
||||||
|
const string &subsample_name_arg,
|
||||||
const PriorDistributions &prior_shape_arg,
|
const PriorDistributions &prior_shape_arg,
|
||||||
const expr_t &variance_arg,
|
const expr_t &variance_arg,
|
||||||
const OptionsList &options_list_arg);
|
const OptionsList &options_list_arg);
|
||||||
|
@ -620,6 +657,7 @@ private:
|
||||||
const SymbolTable symbol_table;
|
const SymbolTable symbol_table;
|
||||||
public:
|
public:
|
||||||
StdPriorStatement(const string &name_arg,
|
StdPriorStatement(const string &name_arg,
|
||||||
|
const string &subsample_name_arg,
|
||||||
const PriorDistributions &prior_shape_arg,
|
const PriorDistributions &prior_shape_arg,
|
||||||
const expr_t &variance_arg,
|
const expr_t &variance_arg,
|
||||||
const OptionsList &options_list_arg,
|
const OptionsList &options_list_arg,
|
||||||
|
@ -636,6 +674,7 @@ private:
|
||||||
public:
|
public:
|
||||||
CorrPriorStatement(const string &name_arg1,
|
CorrPriorStatement(const string &name_arg1,
|
||||||
const string &name_arg2,
|
const string &name_arg2,
|
||||||
|
const string &subsample_name_arg,
|
||||||
const PriorDistributions &prior_shape_arg,
|
const PriorDistributions &prior_shape_arg,
|
||||||
const expr_t &variance_arg,
|
const expr_t &variance_arg,
|
||||||
const OptionsList &options_list_arg,
|
const OptionsList &options_list_arg,
|
||||||
|
@ -650,22 +689,25 @@ public:
|
||||||
virtual ~BasicOptionsStatement();
|
virtual ~BasicOptionsStatement();
|
||||||
protected:
|
protected:
|
||||||
const string name;
|
const string name;
|
||||||
|
const string subsample_name;
|
||||||
const OptionsList options_list;
|
const OptionsList options_list;
|
||||||
bool first_statement_encountered;
|
bool first_statement_encountered;
|
||||||
BasicOptionsStatement(const string &name_arg,
|
BasicOptionsStatement(const string &name_arg,
|
||||||
const OptionsList &options_list_arg);
|
const string &subsample_name_arg,
|
||||||
|
const OptionsList &options_list_arg);
|
||||||
void get_base_name(const SymbolType symb_type, string &lhs_field) const;
|
void get_base_name(const SymbolType symb_type, string &lhs_field) const;
|
||||||
virtual void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings);
|
virtual void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings);
|
||||||
void writeOptionsIndex(ostream &output, const string &lhs_field) const;
|
void writeOptionsIndex(ostream &output, const string &lhs_field) const;
|
||||||
void writeCommonOutput(ostream &output, const string &lhs_field) const;
|
void writeCommonOutput(ostream &output, const string &lhs_field) const;
|
||||||
void writeCommonOutputHelper(ostream &output, const string &field, const string &lhs_field) const;
|
void writeCommonOutputHelper(ostream &output, const string &field, const string &lhs_field) const;
|
||||||
void writeSubsampleName(ostream &output) const;
|
void writeSubsampleName(ostream &output) const;
|
||||||
|
void writeSubsampleInfo(ostream &output, const string &lhs_field, const string name1, const string name2) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class OptionsStatement : public BasicOptionsStatement
|
class OptionsStatement : public BasicOptionsStatement
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
OptionsStatement(const string &name_arg, const OptionsList &options_list_arg);
|
OptionsStatement(const string &name_arg, const string &subsample_name_arg, const OptionsList &options_list_arg);
|
||||||
virtual void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings);
|
virtual void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings);
|
||||||
virtual void writeOutput(ostream &output, const string &basename) const;
|
virtual void writeOutput(ostream &output, const string &basename) const;
|
||||||
};
|
};
|
||||||
|
@ -675,8 +717,10 @@ class StdOptionsStatement : public BasicOptionsStatement
|
||||||
private:
|
private:
|
||||||
const SymbolTable symbol_table;
|
const SymbolTable symbol_table;
|
||||||
public:
|
public:
|
||||||
StdOptionsStatement(const string &name_arg, const OptionsList &options_list_arg,
|
StdOptionsStatement(const string &name_arg,
|
||||||
const SymbolTable &symbol_table_arg);
|
const string &subsample_name_arg,
|
||||||
|
const OptionsList &options_list_arg,
|
||||||
|
const SymbolTable &symbol_table_arg);
|
||||||
virtual void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings);
|
virtual void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings);
|
||||||
virtual void writeOutput(ostream &output, const string &basename) const;
|
virtual void writeOutput(ostream &output, const string &basename) const;
|
||||||
};
|
};
|
||||||
|
@ -688,7 +732,9 @@ private:
|
||||||
const SymbolTable symbol_table;
|
const SymbolTable symbol_table;
|
||||||
public:
|
public:
|
||||||
CorrOptionsStatement(const string &name_arg1, const string &name_arg2,
|
CorrOptionsStatement(const string &name_arg1, const string &name_arg2,
|
||||||
const OptionsList &options_list_arg, const SymbolTable &symbol_table_arg);
|
const string &subsample_name_arg,
|
||||||
|
const OptionsList &options_list_arg,
|
||||||
|
const SymbolTable &symbol_table_arg);
|
||||||
virtual void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings);
|
virtual void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings);
|
||||||
virtual void writeOutput(ostream &output, const string &basename) const;
|
virtual void writeOutput(ostream &output, const string &basename) const;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1250,26 +1250,17 @@ subsamples_name_list : subsamples_name_list COMMA o_subsample_name
|
||||||
;
|
;
|
||||||
|
|
||||||
prior : symbol '.' PRIOR { driver.set_prior_variance(); driver.prior_shape = eNoShape; } '(' prior_options_list ')' ';'
|
prior : symbol '.' PRIOR { driver.set_prior_variance(); driver.prior_shape = eNoShape; } '(' prior_options_list ')' ';'
|
||||||
{ driver.set_prior($1); }
|
{ driver.set_prior($1, new string ("")); }
|
||||||
| symbol '.' symbol '.' PRIOR { driver.set_prior_variance(); driver.prior_shape = eNoShape; } '(' prior_options_list ')' ';'
|
| symbol '.' symbol '.' PRIOR { driver.set_prior_variance(); driver.prior_shape = eNoShape; } '(' prior_options_list ')' ';'
|
||||||
{
|
{ driver.set_prior($1, $3); }
|
||||||
driver.add_subsample_range(new string (*$1), new string (""), $3);
|
|
||||||
driver.set_prior($1);
|
|
||||||
}
|
|
||||||
| STD '(' symbol ')' '.' PRIOR { driver.set_prior_variance(); driver.prior_shape = eNoShape; } '(' prior_options_list ')' ';'
|
| STD '(' symbol ')' '.' PRIOR { driver.set_prior_variance(); driver.prior_shape = eNoShape; } '(' prior_options_list ')' ';'
|
||||||
{ driver.set_std_prior($3); }
|
{ driver.set_std_prior($3, new string ("")); }
|
||||||
| STD '(' symbol ')' '.' symbol '.' PRIOR { driver.set_prior_variance(); driver.prior_shape = eNoShape; } '(' prior_options_list ')' ';'
|
| STD '(' symbol ')' '.' symbol '.' PRIOR { driver.set_prior_variance(); driver.prior_shape = eNoShape; } '(' prior_options_list ')' ';'
|
||||||
{
|
{ driver.set_std_prior($3, $6); }
|
||||||
driver.add_subsample_range(new string (*$3), new string (""), $6);
|
|
||||||
driver.set_std_prior($3);
|
|
||||||
}
|
|
||||||
| CORR '(' symbol COMMA symbol ')' '.' PRIOR { driver.set_prior_variance(); driver.prior_shape = eNoShape; } '(' prior_options_list ')' ';'
|
| CORR '(' symbol COMMA symbol ')' '.' PRIOR { driver.set_prior_variance(); driver.prior_shape = eNoShape; } '(' prior_options_list ')' ';'
|
||||||
{ driver.set_corr_prior($3, $5); }
|
{ driver.set_corr_prior($3, $5, new string ("")); }
|
||||||
| CORR '(' symbol COMMA symbol ')' '.' symbol '.' PRIOR { driver.set_prior_variance(); driver.prior_shape = eNoShape; } '(' prior_options_list ')' ';'
|
| CORR '(' symbol COMMA symbol ')' '.' symbol '.' PRIOR { driver.set_prior_variance(); driver.prior_shape = eNoShape; } '(' prior_options_list ')' ';'
|
||||||
{
|
{ driver.set_corr_prior($3, $5, $8); }
|
||||||
driver.add_subsample_range(new string (*$3), new string (*$5), $8);
|
|
||||||
driver.set_corr_prior($3, $5);
|
|
||||||
}
|
|
||||||
;
|
;
|
||||||
|
|
||||||
prior_options_list : prior_options_list COMMA prior_options
|
prior_options_list : prior_options_list COMMA prior_options
|
||||||
|
@ -1289,26 +1280,17 @@ prior_options : o_shift
|
||||||
;
|
;
|
||||||
|
|
||||||
options : symbol '.' OPTIONS '(' options_options_list ')' ';'
|
options : symbol '.' OPTIONS '(' options_options_list ')' ';'
|
||||||
{ driver.set_options($1); }
|
{ driver.set_options($1, new string ("")); }
|
||||||
| symbol '.' symbol '.' OPTIONS '(' options_options_list ')' ';'
|
| symbol '.' symbol '.' OPTIONS '(' options_options_list ')' ';'
|
||||||
{
|
{ driver.set_options($1, $3); }
|
||||||
driver.add_subsample_range(new string (*$1), new string (""), $3);
|
|
||||||
driver.set_options($1);
|
|
||||||
}
|
|
||||||
| STD '(' symbol ')' '.' OPTIONS '(' options_options_list ')' ';'
|
| STD '(' symbol ')' '.' OPTIONS '(' options_options_list ')' ';'
|
||||||
{ driver.set_std_options($3); }
|
{ driver.set_std_options($3, new string ("")); }
|
||||||
| STD '(' symbol ')' '.' symbol '.' OPTIONS '(' options_options_list ')' ';'
|
| STD '(' symbol ')' '.' symbol '.' OPTIONS '(' options_options_list ')' ';'
|
||||||
{
|
{ driver.set_std_options($3, $6); }
|
||||||
driver.add_subsample_range(new string (*$3), new string (""), $6);
|
|
||||||
driver.set_std_options($3);
|
|
||||||
}
|
|
||||||
| CORR '(' symbol COMMA symbol ')' '.' OPTIONS '(' options_options_list ')' ';'
|
| CORR '(' symbol COMMA symbol ')' '.' OPTIONS '(' options_options_list ')' ';'
|
||||||
{ driver.set_corr_options($3, $5); }
|
{ driver.set_corr_options($3, $5, new string ("")); }
|
||||||
| CORR '(' symbol COMMA symbol ')' '.' symbol '.' OPTIONS '(' options_options_list ')' ';'
|
| CORR '(' symbol COMMA symbol ')' '.' symbol '.' OPTIONS '(' options_options_list ')' ';'
|
||||||
{
|
{ driver.set_corr_options($3, $5, $8); }
|
||||||
driver.add_subsample_range(new string (*$3), new string (*$5), $8);
|
|
||||||
driver.set_corr_options($3, $5);
|
|
||||||
}
|
|
||||||
;
|
;
|
||||||
|
|
||||||
options_options_list : options_options_list COMMA options_options
|
options_options_list : options_options_list COMMA options_options
|
||||||
|
@ -2073,10 +2055,7 @@ o_nograph : NOGRAPH
|
||||||
{ driver.option_num("nograph", "0"); }
|
{ driver.option_num("nograph", "0"); }
|
||||||
;
|
;
|
||||||
o_subsample_name : symbol EQUAL date_number ':' date_number
|
o_subsample_name : symbol EQUAL date_number ':' date_number
|
||||||
{
|
{ driver.set_subsample_name_equal_to_date_range($1, $3, $5); }
|
||||||
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_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_replic : MH_REPLIC EQUAL INT_NUMBER { driver.option_num("mh_replic", $3); };
|
||||||
|
|
|
@ -1242,15 +1242,7 @@ ParsingDriver::set_subsamples(string *name1, string *name2)
|
||||||
if (!name2->empty())
|
if (!name2->empty())
|
||||||
check_symbol_existence(*name2);
|
check_symbol_existence(*name2);
|
||||||
|
|
||||||
if (subsample_declarations.find(make_pair(*name1,*name2)) != subsample_declarations.end())
|
mod_file->addStatement(new SubsamplesStatement(*name1, *name2, subsample_declaration_map));
|
||||||
{
|
|
||||||
string err = *name1;
|
|
||||||
if (!name2->empty())
|
|
||||||
err.append(",").append(*name2);
|
|
||||||
error(err + " has more than one subsample statement." +
|
|
||||||
"You may only have one subsample statement per variable.");
|
|
||||||
}
|
|
||||||
|
|
||||||
subsample_declarations[make_pair(*name1, *name2)] = subsample_declaration_map;
|
subsample_declarations[make_pair(*name1, *name2)] = subsample_declaration_map;
|
||||||
subsample_declaration_map.clear();
|
subsample_declaration_map.clear();
|
||||||
delete name1;
|
delete name1;
|
||||||
|
@ -1267,14 +1259,6 @@ ParsingDriver::copy_subsamples(string *to_name1, string *to_name2, string *from_
|
||||||
if (!from_name2->empty())
|
if (!from_name2->empty())
|
||||||
check_symbol_existence(*from_name2);
|
check_symbol_existence(*from_name2);
|
||||||
|
|
||||||
if (subsample_declarations.find(make_pair(*to_name1,*to_name2)) != subsample_declarations.end())
|
|
||||||
{
|
|
||||||
string err = *to_name1;
|
|
||||||
if (!to_name2->empty())
|
|
||||||
err.append(",").append(*to_name2);
|
|
||||||
error(err + " has more than one subsample statement." +
|
|
||||||
"You may only have one subsample statement per symbol (or pair thereof).");
|
|
||||||
}
|
|
||||||
if (subsample_declarations.find(make_pair(*from_name1,*from_name2)) == subsample_declarations.end())
|
if (subsample_declarations.find(make_pair(*from_name1,*from_name2)) == subsample_declarations.end())
|
||||||
{
|
{
|
||||||
string err = *from_name1;
|
string err = *from_name1;
|
||||||
|
@ -1283,6 +1267,8 @@ ParsingDriver::copy_subsamples(string *to_name1, string *to_name2, string *from_
|
||||||
error(err + " does not have an associated subsample statement.");
|
error(err + " does not have an associated subsample statement.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mod_file->addStatement(new SubsamplesEqualStatement(*to_name1, *to_name2, *from_name1, *from_name2));
|
||||||
|
|
||||||
subsample_declarations[make_pair(*to_name1, *to_name2)] =
|
subsample_declarations[make_pair(*to_name1, *to_name2)] =
|
||||||
subsample_declarations[make_pair(*from_name1, *from_name2)];
|
subsample_declarations[make_pair(*from_name1, *from_name2)];
|
||||||
|
|
||||||
|
@ -1304,7 +1290,6 @@ ParsingDriver::check_symbol_is_statement_variable(string *name)
|
||||||
void
|
void
|
||||||
ParsingDriver::set_subsample_name_equal_to_date_range(string *name, string *date1, string *date2)
|
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())
|
if (subsample_declaration_map.find(*name) != subsample_declaration_map.end())
|
||||||
error("Symbol " + *name + " may only be assigned once in a SUBSAMPLE statement");
|
error("Symbol " + *name + " may only be assigned once in a SUBSAMPLE statement");
|
||||||
subsample_declaration_map[*name] = make_pair(*date1, *date2);
|
subsample_declaration_map[*name] = make_pair(*date1, *date2);
|
||||||
|
@ -1314,44 +1299,56 @@ ParsingDriver::set_subsample_name_equal_to_date_range(string *name, string *date
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ParsingDriver::add_subsample_range(string *name1, string *name2, string *subsample_name)
|
ParsingDriver::check_subsample_declaration_exists(string *name1, string *subsample_name)
|
||||||
{
|
{
|
||||||
|
if (subsample_name->empty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
string *str_empty = new string ("");
|
||||||
|
check_subsample_declaration_exists(name1, str_empty, subsample_name);
|
||||||
|
delete str_empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ParsingDriver::check_subsample_declaration_exists(string *name1, string *name2, string *subsample_name)
|
||||||
|
{
|
||||||
|
if (subsample_name->empty())
|
||||||
|
return;
|
||||||
|
|
||||||
check_symbol_existence(*name1);
|
check_symbol_existence(*name1);
|
||||||
if (!name2->empty())
|
if (!name2->empty())
|
||||||
check_symbol_existence(*name2);
|
check_symbol_existence(*name2);
|
||||||
check_symbol_is_statement_variable(subsample_name);
|
|
||||||
|
|
||||||
subsample_declarations_t::const_iterator it = subsample_declarations.find(make_pair(*name1, *name2));
|
subsample_declarations_t::const_iterator it = subsample_declarations.find(make_pair(*name1, *name2));
|
||||||
if (it == subsample_declarations.end())
|
if (it == subsample_declarations.end())
|
||||||
{
|
{
|
||||||
string err = *name1;
|
it = subsample_declarations.find(make_pair(*name2, *name1));
|
||||||
if (!name2->empty())
|
if (it== subsample_declarations.end())
|
||||||
err.append(",").append(*name2);
|
{
|
||||||
error("A subsample statement has not been issued for " + err);
|
string err = *name1;
|
||||||
|
if (!name2->empty())
|
||||||
|
err.append(",").append(*name2);
|
||||||
|
error("A subsample statement has not been issued for " + err);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
subsample_declaration_map_t tmp_map = it->second;
|
SubsamplesStatement::subsample_declaration_map_t tmp_map = it->second;
|
||||||
if (tmp_map.find(*subsample_name) == tmp_map.end())
|
if (tmp_map.find(*subsample_name) == tmp_map.end())
|
||||||
error("The subsample name " + *subsample_name + " was not previously declared in a subsample statement.");
|
error("The subsample name " + *subsample_name + " was not previously declared in a subsample statement.");
|
||||||
|
|
||||||
option_date("subsample_name", *subsample_name);
|
|
||||||
option_date("date1", tmp_map[*subsample_name].first);
|
|
||||||
option_date("date2", tmp_map[*subsample_name].second);
|
|
||||||
|
|
||||||
delete name1;
|
|
||||||
delete name2;
|
|
||||||
delete subsample_name;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ParsingDriver::set_prior(string *name)
|
ParsingDriver::set_prior(string *name, string *subsample_name)
|
||||||
{
|
{
|
||||||
check_symbol_is_parameter(name);
|
check_symbol_is_parameter(name);
|
||||||
mod_file->addStatement(new PriorStatement(*name, prior_shape, prior_variance, options_list));
|
check_subsample_declaration_exists(name, subsample_name);
|
||||||
|
mod_file->addStatement(new PriorStatement(*name, *subsample_name, prior_shape, prior_variance, options_list));
|
||||||
options_list.clear();
|
options_list.clear();
|
||||||
set_prior_variance();
|
set_prior_variance();
|
||||||
prior_shape = eNoShape;
|
prior_shape = eNoShape;
|
||||||
delete name;
|
delete name;
|
||||||
|
delete subsample_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -1361,12 +1358,14 @@ ParsingDriver::set_prior_variance(expr_t variance)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ParsingDriver::set_options(string *name)
|
ParsingDriver::set_options(string *name, string *subsample_name)
|
||||||
{
|
{
|
||||||
check_symbol_is_parameter(name);
|
check_symbol_is_parameter(name);
|
||||||
mod_file->addStatement(new OptionsStatement(*name, options_list));
|
check_subsample_declaration_exists(name, subsample_name);
|
||||||
|
mod_file->addStatement(new OptionsStatement(*name, *subsample_name, options_list));
|
||||||
options_list.clear();
|
options_list.clear();
|
||||||
delete name;
|
delete name;
|
||||||
|
delete subsample_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -1386,49 +1385,57 @@ ParsingDriver::check_symbol_is_endogenous_or_exogenous(string *name)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ParsingDriver::set_std_prior(string *name)
|
ParsingDriver::set_std_prior(string *name, string *subsample_name)
|
||||||
{
|
{
|
||||||
check_symbol_is_endogenous_or_exogenous(name);
|
check_symbol_is_endogenous_or_exogenous(name);
|
||||||
mod_file->addStatement(new StdPriorStatement(*name, prior_shape, prior_variance,
|
check_subsample_declaration_exists(name, subsample_name);
|
||||||
|
mod_file->addStatement(new StdPriorStatement(*name, *subsample_name, prior_shape, prior_variance,
|
||||||
options_list, mod_file->symbol_table));
|
options_list, mod_file->symbol_table));
|
||||||
options_list.clear();
|
options_list.clear();
|
||||||
set_prior_variance();
|
set_prior_variance();
|
||||||
prior_shape = eNoShape;
|
prior_shape = eNoShape;
|
||||||
delete name;
|
delete name;
|
||||||
|
delete subsample_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ParsingDriver::set_std_options(string *name)
|
ParsingDriver::set_std_options(string *name, string *subsample_name)
|
||||||
{
|
{
|
||||||
check_symbol_is_endogenous_or_exogenous(name);
|
check_symbol_is_endogenous_or_exogenous(name);
|
||||||
mod_file->addStatement(new StdOptionsStatement(*name, options_list, mod_file->symbol_table));
|
check_subsample_declaration_exists(name, subsample_name);
|
||||||
|
mod_file->addStatement(new StdOptionsStatement(*name, *subsample_name, options_list, mod_file->symbol_table));
|
||||||
options_list.clear();
|
options_list.clear();
|
||||||
delete name;
|
delete name;
|
||||||
|
delete subsample_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ParsingDriver::set_corr_prior(string *name1, string *name2)
|
ParsingDriver::set_corr_prior(string *name1, string *name2, string *subsample_name)
|
||||||
{
|
{
|
||||||
check_symbol_is_endogenous_or_exogenous(name1);
|
check_symbol_is_endogenous_or_exogenous(name1);
|
||||||
check_symbol_is_endogenous_or_exogenous(name2);
|
check_symbol_is_endogenous_or_exogenous(name2);
|
||||||
mod_file->addStatement(new CorrPriorStatement(*name1, *name2, prior_shape, prior_variance,
|
check_subsample_declaration_exists(name1, name2, subsample_name);
|
||||||
|
mod_file->addStatement(new CorrPriorStatement(*name1, *name2, *subsample_name, prior_shape, prior_variance,
|
||||||
options_list, mod_file->symbol_table));
|
options_list, mod_file->symbol_table));
|
||||||
options_list.clear();
|
options_list.clear();
|
||||||
set_prior_variance();
|
set_prior_variance();
|
||||||
prior_shape = eNoShape;
|
prior_shape = eNoShape;
|
||||||
delete name1;
|
delete name1;
|
||||||
delete name2;
|
delete name2;
|
||||||
|
delete subsample_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ParsingDriver::set_corr_options(string *name1, string *name2)
|
ParsingDriver::set_corr_options(string *name1, string *name2, string *subsample_name)
|
||||||
{
|
{
|
||||||
check_symbol_is_endogenous_or_exogenous(name1);
|
check_symbol_is_endogenous_or_exogenous(name1);
|
||||||
check_symbol_is_endogenous_or_exogenous(name2);
|
check_symbol_is_endogenous_or_exogenous(name2);
|
||||||
mod_file->addStatement(new CorrOptionsStatement(*name1, *name2, options_list, mod_file->symbol_table));
|
check_subsample_declaration_exists(name1, name2, subsample_name);
|
||||||
|
mod_file->addStatement(new CorrOptionsStatement(*name1, *name2, *subsample_name, options_list, mod_file->symbol_table));
|
||||||
options_list.clear();
|
options_list.clear();
|
||||||
delete name1;
|
delete name1;
|
||||||
delete name2;
|
delete name2;
|
||||||
|
delete subsample_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -189,11 +189,9 @@ private:
|
||||||
vector<int> declared_nonstationary_vars;
|
vector<int> declared_nonstationary_vars;
|
||||||
//! Temporary storage for a variance declared in the prior statement
|
//! Temporary storage for a variance declared in the prior statement
|
||||||
expr_t prior_variance;
|
expr_t prior_variance;
|
||||||
//! Temporary storage for declaring subsamples: map<statement_local_var, <date1, date2 >
|
SubsamplesStatement::subsample_declaration_map_t subsample_declaration_map;
|
||||||
typedef map<string, pair<string, string> > subsample_declaration_map_t;
|
|
||||||
subsample_declaration_map_t subsample_declaration_map;
|
|
||||||
//! Temporary storage for subsample statement: map<pair<var_name1, var_name2>>, subsample_declaration_map >
|
//! Temporary storage for subsample statement: map<pair<var_name1, var_name2>>, subsample_declaration_map >
|
||||||
typedef map<pair<string, string >, subsample_declaration_map_t > subsample_declarations_t;
|
typedef map<pair<string, string >, SubsamplesStatement::subsample_declaration_map_t > subsample_declarations_t;
|
||||||
subsample_declarations_t subsample_declarations;
|
subsample_declarations_t subsample_declarations;
|
||||||
//! reset the values for temporary storage
|
//! reset the values for temporary storage
|
||||||
void reset_current_external_function_options();
|
void reset_current_external_function_options();
|
||||||
|
@ -257,8 +255,9 @@ public:
|
||||||
void set_subsamples(string *name1, string *name2);
|
void set_subsamples(string *name1, string *name2);
|
||||||
//! Declares a subsample, assigning the value to name
|
//! Declares a subsample, assigning the value to name
|
||||||
void set_subsample_name_equal_to_date_range(string *name, string *date1, string *date2);
|
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
|
//! Checks that a subsample statement (and given name) were provided for the pair name1 & name2
|
||||||
void add_subsample_range(string *name1, string *name2, string *subsample_name);
|
void check_subsample_declaration_exists(string *name1, string *subsample_name);
|
||||||
|
void check_subsample_declaration_exists(string *name1, string *name2, string *subsample_name);
|
||||||
//! Copies the set of subsamples from_name to_name
|
//! Copies the set of subsamples from_name to_name
|
||||||
void copy_subsamples(string *to_name1, string *to_name2, string *from_name1, string *from_name2);
|
void copy_subsamples(string *to_name1, string *to_name2, string *from_name1, string *from_name2);
|
||||||
//! Declares declare_optimal_policy_discount_factor as a parameter and initializes it to exprnode
|
//! Declares declare_optimal_policy_discount_factor as a parameter and initializes it to exprnode
|
||||||
|
@ -390,19 +389,19 @@ public:
|
||||||
//! Estimation Data
|
//! Estimation Data
|
||||||
void estimation_data();
|
void estimation_data();
|
||||||
//! Sets the prior for a parameter
|
//! Sets the prior for a parameter
|
||||||
void set_prior(string *arg);
|
void set_prior(string *arg1, string *arg2);
|
||||||
//! Adds the variance option to its temporary holding place
|
//! Adds the variance option to its temporary holding place
|
||||||
void set_prior_variance(expr_t variance=NULL);
|
void set_prior_variance(expr_t variance=NULL);
|
||||||
//! Sets the options for a parameter
|
//! Sets the options for a parameter
|
||||||
void set_options(string *arg);
|
void set_options(string *arg1, string *arg2);
|
||||||
//! Sets the prior for estimated std dev
|
//! Sets the prior for estimated std dev
|
||||||
void set_std_prior(string *arg);
|
void set_std_prior(string *arg1, string *arg2);
|
||||||
//! Sets the options for estimated std dev
|
//! Sets the options for estimated std dev
|
||||||
void set_std_options(string *arg);
|
void set_std_options(string *arg1, string *arg2);
|
||||||
//! Sets the prior for estimated correlation
|
//! Sets the prior for estimated correlation
|
||||||
void set_corr_prior(string *arg1, string *arg2);
|
void set_corr_prior(string *arg1, string *arg2, string *arg3);
|
||||||
//! Sets the options for estimated correlation
|
//! Sets the options for estimated correlation
|
||||||
void set_corr_options(string *arg1, string *arg2);
|
void set_corr_options(string *arg1, string *arg2, string *arg3);
|
||||||
//! Runs estimation process
|
//! Runs estimation process
|
||||||
void run_estimation();
|
void run_estimation();
|
||||||
//! Runs dynare_sensitivy()
|
//! Runs dynare_sensitivy()
|
||||||
|
|
Loading…
Reference in New Issue