estimation: clear subsamples substructure whenever a subsamples statement is encountered
parent
7e6bd80f17
commit
08bcf39fe7
|
@ -246,12 +246,12 @@ options_.timeless = 0;
|
||||||
|
|
||||||
% estimation
|
% estimation
|
||||||
estimation_info.empty_prior = struct(...
|
estimation_info.empty_prior = struct(...
|
||||||
'domain', {}, 'interval', {}, 'mean', {}, ...
|
'domain', [], 'interval', [], 'mean', [], ...
|
||||||
'median', {}, 'mode', {}, 'shape', {}, ...
|
'median', [], 'mode', [], 'shape', [], ...
|
||||||
'shift', {}, 'stdev', {}, 'truncate', {}, 'variance', {});
|
'shift', [], 'stdev', [], 'truncate', [], 'variance', []);
|
||||||
estimation_info.empty_options = struct(...
|
estimation_info.empty_options = struct(...
|
||||||
'bounds',{}, 'init', {}, 'jscale', {});
|
'bounds',[], 'init', [], 'jscale', []);
|
||||||
estimation_info.subsamples.range = struct('date1', {}, 'date2', {});
|
estimation_info.subsamples.range = struct('date1', [], 'date2', []);
|
||||||
estimation_info.parameter.prior = estimation_info.empty_prior;
|
estimation_info.parameter.prior = estimation_info.empty_prior;
|
||||||
estimation_info.parameter.subsample_prior = estimation_info.empty_prior;
|
estimation_info.parameter.subsample_prior = estimation_info.empty_prior;
|
||||||
estimation_info.parameter.options = estimation_info.empty_options;
|
estimation_info.parameter.options = estimation_info.empty_options;
|
||||||
|
|
|
@ -1632,10 +1632,12 @@ EstimationDataStatement::writeOutput(ostream &output, const string &basename) co
|
||||||
|
|
||||||
SubsamplesStatement::SubsamplesStatement(const string &name1_arg,
|
SubsamplesStatement::SubsamplesStatement(const string &name1_arg,
|
||||||
const string &name2_arg,
|
const string &name2_arg,
|
||||||
const subsample_declaration_map_t subsample_declaration_map_arg) :
|
const subsample_declaration_map_t subsample_declaration_map_arg,
|
||||||
|
const SymbolTable &symbol_table_arg) :
|
||||||
name1(name1_arg),
|
name1(name1_arg),
|
||||||
name2(name2_arg),
|
name2(name2_arg),
|
||||||
subsample_declaration_map(subsample_declaration_map_arg)
|
subsample_declaration_map(subsample_declaration_map_arg),
|
||||||
|
symbol_table(symbol_table_arg)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1664,6 +1666,40 @@ SubsamplesStatement::writeOutput(ostream &output, const string &basename) const
|
||||||
<< it->second.first << "';" << endl
|
<< it->second.first << "';" << endl
|
||||||
<< "estimation_info.subsamples(subsamples_indx).range(" << map_indx << ").date2 = '"
|
<< "estimation_info.subsamples(subsamples_indx).range(" << map_indx << ").date2 = '"
|
||||||
<< it->second.second << "';" << endl;
|
<< it->second.second << "';" << endl;
|
||||||
|
|
||||||
|
// Initialize associated subsample substructures in estimation_info
|
||||||
|
const SymbolType symb_type = symbol_table.getType(name1);
|
||||||
|
string lhs_field;
|
||||||
|
if (symb_type == eParameter)
|
||||||
|
lhs_field = "parameter";
|
||||||
|
else if (symb_type == eExogenous || symb_type == eExogenousDet)
|
||||||
|
lhs_field = "structural_innovation";
|
||||||
|
else
|
||||||
|
lhs_field = "measurement_error";
|
||||||
|
|
||||||
|
output << "eifind = get_new_or_existing_ei_index('" << lhs_field;
|
||||||
|
|
||||||
|
if (!name2.empty())
|
||||||
|
output << "_corr";
|
||||||
|
output << "_prior_index', '"
|
||||||
|
<< name1 << "', '";
|
||||||
|
if (!name2.empty())
|
||||||
|
output << name2;
|
||||||
|
output << "');" << endl;
|
||||||
|
|
||||||
|
lhs_field = "estimation_info." + lhs_field;
|
||||||
|
if (!name2.empty())
|
||||||
|
lhs_field += "_corr";
|
||||||
|
output << lhs_field << "_prior_index(eifind) = {'" << name1;
|
||||||
|
if (!name2.empty())
|
||||||
|
output << ":" << name2;
|
||||||
|
output << "'};" << endl;
|
||||||
|
|
||||||
|
output << lhs_field << "(eifind).subsample_prior = estimation_info.empty_prior;" << endl
|
||||||
|
<< lhs_field << "(eifind).subsample_prior(1:" << subsample_declaration_map.size()
|
||||||
|
<< ") = estimation_info.empty_prior;" << endl
|
||||||
|
<< lhs_field << "(eifind).range_index = estimation_info.subsamples(subsamples_indx).range_index;"
|
||||||
|
<< endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
SubsamplesEqualStatement::SubsamplesEqualStatement(const string &to_name1_arg,
|
SubsamplesEqualStatement::SubsamplesEqualStatement(const string &to_name1_arg,
|
||||||
|
|
|
@ -588,10 +588,12 @@ private:
|
||||||
const string name1;
|
const string name1;
|
||||||
const string name2;
|
const string name2;
|
||||||
const subsample_declaration_map_t subsample_declaration_map;
|
const subsample_declaration_map_t subsample_declaration_map;
|
||||||
|
const SymbolTable symbol_table;
|
||||||
public:
|
public:
|
||||||
SubsamplesStatement(const string &name1_arg,
|
SubsamplesStatement(const string &name1_arg,
|
||||||
const string &name2_arg,
|
const string &name2_arg,
|
||||||
const subsample_declaration_map_t subsample_declaration_map_arg);
|
const subsample_declaration_map_t subsample_declaration_map_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;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1242,7 +1242,7 @@ ParsingDriver::set_subsamples(string *name1, string *name2)
|
||||||
if (!name2->empty())
|
if (!name2->empty())
|
||||||
check_symbol_existence(*name2);
|
check_symbol_existence(*name2);
|
||||||
|
|
||||||
mod_file->addStatement(new SubsamplesStatement(*name1, *name2, subsample_declaration_map));
|
mod_file->addStatement(new SubsamplesStatement(*name1, *name2, subsample_declaration_map, mod_file->symbol_table));
|
||||||
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;
|
||||||
|
|
Loading…
Reference in New Issue