Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Dóra Kocsis
dynare
Commits
7feb27fe
Commit
7feb27fe
authored
Mar 29, 2012
by
Houtan Bastani
Browse files
estimation: rewrite options output
parent
d54e4c4b
Changes
5
Hide whitespace changes
Inline
Side-by-side
matlab/global_initialization.m
View file @
7feb27fe
...
...
@@ -252,6 +252,10 @@ estimation_info.parameters.subsample_prior = struct(...
'shape'
,
{},
'mean'
,
{},
...
'mode'
,
{},
'stdev'
,
{},
'date1'
,
{},
...
'date2'
,
{},
'shift'
,
{},
'variance'
,
{});
estimation_info
.
parameters
.
options
=
struct
(
...
'init'
,
{},
'bounds'
,{},
'jscale'
,
{});
estimation_info
.
parameters
.
subsample_options
=
struct
(
...
'init'
,
{},
'bounds'
,{},
'jscale'
,
{});
estimation_info
.
structural_innovation
.
prior
=
struct
(
...
'shape'
,
{},
'mean'
,
{},
...
'mode'
,
{},
'stdev'
,
{},
'date1'
,
{},
...
...
...
@@ -260,6 +264,10 @@ estimation_info.structural_innovation.subsample_prior = struct(...
'shape'
,
{},
'mean'
,
{},
...
'mode'
,
{},
'stdev'
,
{},
'date1'
,
{},
...
'date2'
,
{},
'shift'
,
{},
'variance'
,
{});
estimation_info
.
structural_innovation
.
options
=
struct
(
...
'init'
,
{},
'bounds'
,{},
'jscale'
,
{});
estimation_info
.
structural_innovation
.
subsample_options
=
struct
(
...
'init'
,
{},
'bounds'
,{},
'jscale'
,
{});
estimation_info
.
structural_innovation_corr
.
prior
=
struct
(
...
'shape'
,
{},
'mean'
,
{},
...
'mode'
,
{},
'stdev'
,
{},
'date1'
,
{},
...
...
...
@@ -268,6 +276,10 @@ estimation_info.structural_innovation_corr.subsample_prior = struct(...
'shape'
,
{},
'mean'
,
{},
...
'mode'
,
{},
'stdev'
,
{},
'date1'
,
{},
...
'date2'
,
{},
'shift'
,
{},
'variance'
,
{});
estimation_info
.
structural_innovation_corr
.
options
=
struct
(
...
'init'
,
{},
'bounds'
,{},
'jscale'
,
{});
estimation_info
.
structural_innovation_corr
.
subsample_options
=
struct
(
...
'init'
,
{},
'bounds'
,{},
'jscale'
,
{});
estimation_info
.
measurement_error
.
prior
=
struct
(
...
'shape'
,
{},
'mean'
,
{},
...
'mode'
,
{},
'stdev'
,
{},
'date1'
,
{},
...
...
...
@@ -276,6 +288,10 @@ estimation_info.measurement_error.subsample_prior = struct(...
'shape'
,
{},
'mean'
,
{},
...
'mode'
,
{},
'stdev'
,
{},
'date1'
,
{},
...
'date2'
,
{},
'shift'
,
{},
'variance'
,
{});
estimation_info
.
measurement_error
.
options
=
struct
(
...
'init'
,
{},
'bounds'
,{},
'jscale'
,
{});
estimation_info
.
measurement_error
.
subsample_options
=
struct
(
...
'init'
,
{},
'bounds'
,{},
'jscale'
,
{});
estimation_info
.
measurement_error_corr
.
prior
=
struct
(
...
'name1'
,
{},
'name2'
,
{},
'shape'
,
{},
'mean'
,
{},
...
'mode'
,
{},
'stdev'
,
{},
'date1'
,
{},
...
...
...
@@ -284,26 +300,25 @@ estimation_info.measurement_error_corr.subsample_prior = struct(...
'name1'
,
{},
'name2'
,
{},
'shape'
,
{},
'mean'
,
{},
...
'mode'
,
{},
'stdev'
,
{},
'date1'
,
{},
...
'date2'
,
{},
'shift'
,
{},
'variance'
,
{});
estimation_info
.
measurement_error_corr
.
options
=
struct
(
...
'init'
,
{},
'bounds'
,{},
'jscale'
,
{});
estimation_info
.
measurement_error_corr
.
subsample_options
=
struct
(
...
'init'
,
{},
'bounds'
,{},
'jscale'
,
{});
estimation_info
.
subsamples_index
=
{};
estimation_info
.
subsamples
.
range_index
=
{};
estimation_info
.
parameter_prior_index
=
{};
estimation_info
.
parameter_options_index
=
{};
estimation_info
.
parameters
.
range_index
=
{};
estimation_info
.
measurement_error_prior_index
=
{};
estimation_info
.
measurement_error
.
range_index
=
{};
estimation_info
.
structural_innovation_prior_index
=
{};
estimation_info
.
structural_innovation
.
range_index
=
{};
estimation_info
.
measurement_error_corr_prior_index
=
{};
estimation_info
.
measurement_error_corr
.
range_index
=
{};
estimation_info
.
structural_innovation_corr_prior_index
=
{};
estimation_info
.
structural_innovation_corr
.
range_index
=
{};
estimation_info
.
parameters_options_index
=
{};
estimation_info
.
parameters
.
range_index
=
{};
estimation_info
.
measurement_error_options_index
=
{};
estimation_info
.
measurement_error
.
range_index
=
{};
estimation_info
.
structural_innovation_prior_index
=
{};
estimation_info
.
structural_innovation_options_index
=
{};
estimation_info
.
structural_innovation
.
range_index
=
{};
estimation_info
.
measurement_error_corr_prior_index
=
{};
estimation_info
.
measurement_error_corr_options_index
=
{};
estimation_info
.
measurement_error_corr
.
range_index
=
{};
estimation_info
.
structural_innovation_corr_prior_index
=
{};
estimation_info
.
structural_innovation_corr_options_index
=
{};
estimation_info
.
structural_innovation_corr
.
range_index
=
{};
options_
.
initial_period
=
dynDate
(
1
);
...
...
preprocessor/ComputingTasks.cc
View file @
7feb27fe
...
...
@@ -1882,9 +1882,9 @@ CorrPriorStatement::writeOutput(ostream &output, const string &basename) const
string
lhs_field
;
get_base_name
(
symbol_table
.
getType
(
name
),
lhs_field
);
output
<<
"eifind = get_new_or_existing_ei_index('"
<<
lhs_field
<<
"_prior_index', '"
output
<<
"eifind = get_new_or_existing_ei_index('"
<<
lhs_field
<<
"_
corr_
prior_index', '"
<<
name
<<
"', '"
<<
name1
<<
"');"
<<
endl
<<
"estimation_info."
<<
lhs_field
<<
"_prior_index(eifind) = {'"
<<
"estimation_info."
<<
lhs_field
<<
"_
corr_
prior_index(eifind) = {'"
<<
name
<<
"_"
<<
name1
<<
"'};"
<<
endl
;
lhs_field
=
"estimation_info."
+
lhs_field
+
"_corr(eifind)"
;
...
...
@@ -1903,8 +1903,7 @@ BasicOptionsStatement::BasicOptionsStatement(const string &name_arg,
const
OptionsList
&
options_list_arg
)
:
name
(
name_arg
),
subsample_name
(
subsample_name_arg
),
options_list
(
options_list_arg
),
first_statement_encountered
(
false
)
options_list
(
options_list_arg
)
{
}
...
...
@@ -1913,15 +1912,6 @@ BasicOptionsStatement::checkPass(ModFileStructure &mod_file_struct, WarningConso
{
}
void
BasicOptionsStatement
::
writeOptionsIndex
(
ostream
&
output
,
const
string
&
lhs_field
)
const
{
if
(
first_statement_encountered
)
output
<<
"options_indx = 1;"
<<
endl
;
else
output
<<
"options_indx = size(estimation_info"
<<
lhs_field
<<
"_index, 2) + 1;"
<<
endl
;
}
void
BasicOptionsStatement
::
get_base_name
(
const
SymbolType
symb_type
,
string
&
lhs_field
)
const
{
...
...
@@ -1944,32 +1934,22 @@ BasicOptionsStatement::writeCommonOutputHelper(ostream &output, const string &fi
{
OptionsList
::
num_options_t
::
const_iterator
itn
=
options_list
.
num_options
.
find
(
field
);
if
(
itn
!=
options_list
.
num_options
.
end
())
output
<<
"estimation_info"
<<
lhs_field
<<
"(options_indx)."
<<
field
<<
" = "
<<
itn
->
second
<<
";"
<<
endl
;
OptionsList
::
date_options_t
::
const_iterator
itd
=
options_list
.
date_options
.
find
(
field
);
if
(
itd
!=
options_list
.
date_options
.
end
())
output
<<
"estimation_info"
<<
lhs_field
<<
"(options_indx)."
<<
field
<<
" = '"
<<
itd
->
second
<<
"';"
<<
endl
;
}
void
BasicOptionsStatement
::
writeSubsampleName
(
ostream
&
output
)
const
{
if
(
!
subsample_name
.
empty
())
output
<<
":"
<<
subsample_name
;
output
<<
lhs_field
<<
"."
<<
field
<<
" = "
<<
itn
->
second
<<
";"
<<
endl
;
}
void
BasicOptionsStatement
::
write
SubsampleInfo
(
ostream
&
output
,
const
string
&
lhs_field
,
const
string
name1
,
const
string
name2
)
const
BasicOptionsStatement
::
write
OptionsOutput
(
ostream
&
output
,
string
&
lhs_field
,
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
;
lhs_field
+=
".options(1)"
;
else
{
output
<<
"subsamples_indx = get_existing_subsamples_indx('"
<<
name
<<
"','"
<<
name2
<<
"');"
<<
endl
<<
lhs_field
<<
".range_index = estimation_info.subsamples(subsamples_indx).range_index;"
<<
endl
<<
"eisind = get_subsamples_range_indx(subsamples_indx, '"
<<
subsample_name
<<
"');"
<<
endl
;
lhs_field
+=
".subsample_options(eisind)"
;
}
writeCommonOutput
(
output
,
lhs_field
);
}
OptionsStatement
::
OptionsStatement
(
const
string
&
name_arg
,
...
...
@@ -1979,28 +1959,14 @@ OptionsStatement::OptionsStatement(const string &name_arg,
{
}
void
OptionsStatement
::
checkPass
(
ModFileStructure
&
mod_file_struct
,
WarningConsolidation
&
warnings
)
{
BasicOptionsStatement
::
checkPass
(
mod_file_struct
,
warnings
);
if
(
!
mod_file_struct
.
options_statement_present
)
first_statement_encountered
=
true
;
mod_file_struct
.
options_statement_present
=
true
;
}
void
OptionsStatement
::
writeOutput
(
ostream
&
output
,
const
string
&
basename
)
const
{
string
lhs_field
=
".parameters.options"
;
writeOptionsIndex
(
output
,
lhs_field
);
output
<<
"estimation_info"
<<
lhs_field
<<
"_index(options_indx) = {'"
<<
name
;
writeSubsampleName
(
output
);
output
<<
"'};"
<<
endl
<<
"estimation_info"
<<
lhs_field
<<
"(options_indx).name = '"
<<
name
<<
"';"
<<
endl
;
writeCommonOutput
(
output
,
lhs_field
);
writeSubsampleInfo
(
output
,
lhs_field
,
name
,
""
);
string
lhs_field
=
"estimation_info.parameters(eifind)"
;
output
<<
"eifind = get_new_or_existing_ei_index('parameter_options_index', '"
<<
name
<<
"', '');"
<<
endl
<<
"estimation_info.parameter_options_index(eifind) = {'"
<<
name
<<
"'};"
<<
endl
;
writeOptionsOutput
(
output
,
lhs_field
,
""
);
}
StdOptionsStatement
::
StdOptionsStatement
(
const
string
&
name_arg
,
...
...
@@ -2012,30 +1978,17 @@ StdOptionsStatement::StdOptionsStatement(const string &name_arg,
{
}
void
StdOptionsStatement
::
checkPass
(
ModFileStructure
&
mod_file_struct
,
WarningConsolidation
&
warnings
)
{
BasicOptionsStatement
::
checkPass
(
mod_file_struct
,
warnings
);
if
(
!
mod_file_struct
.
std_options_statement_present
)
first_statement_encountered
=
true
;
mod_file_struct
.
std_options_statement_present
=
true
;
}
void
StdOptionsStatement
::
writeOutput
(
ostream
&
output
,
const
string
&
basename
)
const
{
string
lhs_field
;
get_base_name
(
symbol_table
.
getType
(
name
),
lhs_field
);
lhs_field
=
"."
+
lhs_field
+
".options"
;
writeOptionsIndex
(
output
,
lhs_field
);
output
<<
"estimation_info"
<<
lhs_field
<<
"_index(options_indx) = {'"
<<
name
;
writeSubsampleName
(
output
);
output
<<
"'};"
<<
endl
<<
"estimation_info"
<<
lhs_field
<<
"(options_indx).name = '"
<<
name
<<
"';"
<<
endl
;
output
<<
"eifind = get_new_or_existing_ei_index('"
<<
lhs_field
<<
"_options_index', '"
<<
name
<<
"', '');"
<<
endl
<<
"estimation_info."
<<
lhs_field
<<
"_options_index(eifind) = {'"
<<
name
<<
"'};"
<<
endl
;
writeCommonOutput
(
output
,
lhs_field
)
;
write
SubsampleInfo
(
output
,
lhs_field
,
name
,
""
);
lhs_field
=
"estimation_info."
+
lhs_field
+
"(eifind)"
;
write
OptionsOutput
(
output
,
lhs_field
,
""
);
}
CorrOptionsStatement
::
CorrOptionsStatement
(
const
string
&
name_arg1
,
const
string
&
name_arg2
,
...
...
@@ -2058,8 +2011,6 @@ CorrOptionsStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsol
<<
"types."
<<
endl
;
exit
(
EXIT_FAILURE
);
}
if
(
!
mod_file_struct
.
corr_options_statement_present
)
first_statement_encountered
=
true
;
}
void
...
...
@@ -2067,15 +2018,15 @@ CorrOptionsStatement::writeOutput(ostream &output, const string &basename) const
{
string
lhs_field
;
get_base_name
(
symbol_table
.
getType
(
name
),
lhs_field
);
lhs_field
=
"."
+
lhs_field
+
"_corr.options"
;
writeOptionsIndex
(
output
,
lhs_field
);
output
<<
"estimation_info"
<<
lhs_field
<<
"_index(options_indx) = {'"
<<
name
<<
"_"
<<
name1
;
writeSubsampleName
(
output
);
output
<<
"'};"
<<
endl
<<
"estimation_info"
<<
lhs_field
<<
"(options_indx).name1 = '"
<<
name
<<
"';"
<<
endl
<<
"estimation_info"
<<
lhs_field
<<
"(options_indx).name2 = '"
<<
name1
<<
"';"
<<
endl
;
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
;
writeCommonOutput
(
output
,
lhs_field
);
writeSubsampleInfo
(
output
,
lhs_field
,
name
,
name1
);
lhs_field
=
"estimation_info."
+
lhs_field
+
"_corr(eifind)"
;
writeOptionsOutput
(
output
,
lhs_field
,
name1
);
output
<<
lhs_field
<<
".name1 = '"
<<
name
<<
"';"
<<
endl
<<
lhs_field
<<
".name2 = '"
<<
name1
<<
"';"
<<
endl
;
}
preprocessor/ComputingTasks.hh
View file @
7feb27fe
...
...
@@ -684,24 +684,20 @@ protected:
const
string
name
;
const
string
subsample_name
;
const
OptionsList
options_list
;
bool
first_statement_encountered
;
BasicOptionsStatement
(
const
string
&
name_arg
,
const
string
&
subsample_name_arg
,
const
OptionsList
&
options_list_arg
);
void
get_base_name
(
const
SymbolType
symb_type
,
string
&
lhs_field
)
const
;
virtual
void
checkPass
(
ModFileStructure
&
mod_file_struct
,
WarningConsolidation
&
warnings
);
void
writeOptions
Index
(
ostream
&
output
,
const
string
&
lhs_field
)
const
;
void
writeOptions
Output
(
ostream
&
output
,
string
&
lhs_field
,
const
string
&
name2
)
const
;
void
writeCommonOutput
(
ostream
&
output
,
const
string
&
lhs_field
)
const
;
void
writeCommonOutputHelper
(
ostream
&
output
,
const
string
&
field
,
const
string
&
lhs_field
)
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
{
public:
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
writeOutput
(
ostream
&
output
,
const
string
&
basename
)
const
;
};
...
...
@@ -714,7 +710,6 @@ public:
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
writeOutput
(
ostream
&
output
,
const
string
&
basename
)
const
;
};
...
...
preprocessor/Statement.cc
View file @
7feb27fe
...
...
@@ -45,9 +45,6 @@ ModFileStructure::ModFileStructure() :
dsge_var_estimated
(
false
),
bayesian_irf_present
(
false
),
estimation_data_statement_present
(
false
),
options_statement_present
(
false
),
std_options_statement_present
(
false
),
corr_options_statement_present
(
false
),
last_markov_switching_chain
(
0
)
{
}
...
...
preprocessor/Statement.hh
View file @
7feb27fe
...
...
@@ -89,12 +89,6 @@ public:
bool
bayesian_irf_present
;
//! Whether there is a data statement present
bool
estimation_data_statement_present
;
//! Whether there is a options statement present
bool
options_statement_present
;
//! Whether there is a std options statement present
bool
std_options_statement_present
;
//! Whether there is a corr options statement present
bool
corr_options_statement_present
;
//! Last chain number for Markov Switching statement
int
last_markov_switching_chain
;
};
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment