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
bab490fc
Commit
bab490fc
authored
Jun 21, 2010
by
Houtan Bastani
Browse files
DSGE-VAR: support deprecated way of declaring dsge_prior_weight
parent
9b5df058
Changes
8
Hide whitespace changes
Inline
Side-by-side
preprocessor/DynareBison.yy
View file @
bab490fc
...
...
@@ -929,7 +929,6 @@ estimated_elem1 : STDERR symbol
}
| DSGE_PRIOR_WEIGHT
{
driver.declare_dsge_prior_weight();
driver.estim_params.type = 2;
driver.estim_params.name = "dsge_prior_weight";
}
...
...
preprocessor/ModFile.cc
View file @
bab490fc
...
...
@@ -153,13 +153,51 @@ ModFile::checkPass()
exit
(
EXIT_FAILURE
);
}
if
(
symbol_table
.
exists
(
"dsge_prior_weight"
))
{
if
(
symbol_table
.
getType
(
"dsge_prior_weight"
)
!=
eParameter
)
{
cerr
<<
"ERROR: dsge_prior_weight may only be used as a parameter."
<<
endl
;
exit
(
EXIT_FAILURE
);
}
else
cout
<<
"WARNING: When estimating a DSGE-Var, declaring dsge_prior_weight as a parameter is deprecated. "
<<
"The preferred method is to do this via the dsge_var option in the estimation statement."
<<
endl
;
if
(
mod_file_struct
.
dsge_var_estimated
||
!
mod_file_struct
.
dsge_var_calibrated
.
empty
())
{
cerr
<<
"ERROR: dsge_prior_weight can either be declared as a parameter (deprecated) or via the dsge_var option "
<<
"to the estimation statement (preferred), but not both."
<<
endl
;
exit
(
EXIT_FAILURE
);
}
if
(
!
mod_file_struct
.
dsge_prior_weight_initialized
&&
!
mod_file_struct
.
dsge_prior_weight_in_estimated_params
)
{
cerr
<<
"ERROR: If dsge_prior_weight is declared as a parameter, it must either be initialized or placed in the "
<<
"estimated_params block."
<<
endl
;
exit
(
EXIT_FAILURE
);
}
if
(
mod_file_struct
.
dsge_prior_weight_initialized
&&
mod_file_struct
.
dsge_prior_weight_in_estimated_params
)
{
cerr
<<
"ERROR: dsge_prior_weight cannot be both initalized and estimated."
<<
endl
;
exit
(
EXIT_FAILURE
);
}
}
if
(
mod_file_struct
.
dsge_prior_weight_in_estimated_params
)
if
(
!
mod_file_struct
.
dsge_var_estimated
)
if
(
!
mod_file_struct
.
dsge_var_estimated
&&
!
mod_file_struct
.
dsge_var_calibrated
.
empty
()
)
{
cerr
<<
"ERROR: If dsge_prior_weight is in the estimated_params
_
block, the prior weight cannot be calibrated "
cerr
<<
"ERROR: If dsge_prior_weight is in the estimated_params
block, the prior weight cannot be calibrated "
<<
"via the dsge_var option in the estimation statement."
<<
endl
;
exit
(
EXIT_FAILURE
);
}
else
if
(
!
mod_file_struct
.
dsge_var_estimated
&&
!
symbol_table
.
exists
(
"dsge_prior_weight"
))
{
cerr
<<
"ERROR: If dsge_prior_weight is in the estimated_params block, it must either be declared as a parameter "
<<
"(deprecated) or the dsge_var option must be passed to the estimation statement (preferred)."
<<
endl
;
exit
(
EXIT_FAILURE
);
}
}
void
...
...
@@ -183,12 +221,14 @@ ModFile::transformPass()
dynamic_model
.
substituteExoLag
();
}
if
(
!
mod_file_struct
.
dsge_var_calibrated
.
empty
())
if
(
mod_file_struct
.
dsge_var_estimated
||
!
mod_file_struct
.
dsge_var_calibrated
.
empty
())
try
{
addStatement
(
new
InitParamStatement
(
symbol_table
.
addSymbol
(
"dsge_prior_weight"
,
eParameter
),
expressions_tree
.
AddNumConstant
(
mod_file_struct
.
dsge_var_calibrated
),
symbol_table
));
int
sid
=
symbol_table
.
addSymbol
(
"dsge_prior_weight"
,
eParameter
);
if
(
!
mod_file_struct
.
dsge_var_calibrated
.
empty
())
addStatement
(
new
InitParamStatement
(
sid
,
expressions_tree
.
AddNumConstant
(
mod_file_struct
.
dsge_var_calibrated
),
symbol_table
));
}
catch
(
SymbolTable
::
AlreadyDeclaredException
&
e
)
{
...
...
@@ -215,21 +255,21 @@ ModFile::transformPass()
cout
<<
"Found "
<<
dynamic_model
.
equation_number
()
<<
" equation(s)."
<<
endl
;
if
(
!
mod_file_struct
.
dsge_var_calibrated
.
empty
()
||
mod_file_struct
.
dsge_var_estimated
)
if
(
symbol_table
.
exists
(
"dsge_prior_weight"
)
)
if
(
mod_file_struct
.
bayesian_irf_present
)
{
if
(
symbol_table
.
exo_nbr
()
!=
symbol_table
.
observedVariablesNbr
())
{
cerr
<<
"ERROR:
If bayesian_irf and dsge_var are
passed to the estimation
statement,
"
<<
"the number of shocks must equal the number of observed variables."
<<
endl
;
cerr
<<
"ERROR:
When estimating a DSGE-Var and the bayesian_irf option is
passed to the estimation "
<<
"
statement,
the number of shocks must equal the number of observed variables."
<<
endl
;
exit
(
EXIT_FAILURE
);
}
}
else
if
(
symbol_table
.
exo_nbr
()
<
symbol_table
.
observedVariablesNbr
())
{
cerr
<<
"ERROR:
If dsge_var is passed to t
he estimati
on statement
, the number of shocks "
<<
"
must be
greater than or equal to the number of observed variables."
<<
endl
;
cerr
<<
"ERROR:
W
he
n
estimati
ng a DSGE-Var
, the number of shocks
must be
"
<<
"greater than or equal to the number of observed variables."
<<
endl
;
exit
(
EXIT_FAILURE
);
}
}
...
...
preprocessor/NumericalInitialization.cc
View file @
bab490fc
/*
* Copyright (C) 2003-200
9
Dynare Team
* Copyright (C) 2003-20
1
0 Dynare Team
*
* This file is part of Dynare.
*
...
...
@@ -32,6 +32,13 @@ InitParamStatement::InitParamStatement(int symb_id_arg,
{
}
void
InitParamStatement
::
checkPass
(
ModFileStructure
&
mod_file_struct
)
{
if
(
symbol_table
.
getName
(
symb_id
)
==
"dsge_prior_weight"
)
mod_file_struct
.
dsge_prior_weight_initialized
=
true
;
}
void
InitParamStatement
::
writeOutput
(
ostream
&
output
,
const
string
&
basename
)
const
{
...
...
preprocessor/NumericalInitialization.hh
View file @
bab490fc
/*
* Copyright (C) 2003-200
9
Dynare Team
* Copyright (C) 2003-20
1
0 Dynare Team
*
* This file is part of Dynare.
*
...
...
@@ -39,6 +39,7 @@ private:
public:
InitParamStatement
(
int
symb_id_arg
,
const
NodeID
param_value_arg
,
const
SymbolTable
&
symbol_table_arg
);
virtual
void
checkPass
(
ModFileStructure
&
mod_file_struct
);
virtual
void
writeOutput
(
ostream
&
output
,
const
string
&
basename
)
const
;
//! Fill eval context with parameter value
void
fillEvalContext
(
eval_context_type
&
eval_context
)
const
;
...
...
preprocessor/ParsingDriver.cc
View file @
bab490fc
...
...
@@ -164,16 +164,6 @@ ParsingDriver::declare_parameter(string *name, string *tex_name)
delete
tex_name
;
}
void
ParsingDriver
::
declare_dsge_prior_weight
()
{
if
(
mod_file
->
symbol_table
.
exists
(
"dsge_prior_weight"
))
error
(
"If dsge_prior_weight appears in the estimated_params block, it cannot have been previosly declared."
);
string
*
dsge_prior_weight
=
new
string
(
"dsge_prior_weight"
);
declare_parameter
(
dsge_prior_weight
);
}
void
ParsingDriver
::
add_predetermined_variable
(
string
*
name
)
{
...
...
@@ -893,10 +883,12 @@ ParsingDriver::check()
void
ParsingDriver
::
add_estimated_params_element
()
{
check_symbol_existence
(
estim_params
.
name
);
if
(
estim_params
.
name2
.
size
()
>
0
)
check_symbol_existence
(
estim_params
.
name2
);
if
(
estim_params
.
name
!=
"dsge_prior_weight"
)
{
check_symbol_existence
(
estim_params
.
name
);
if
(
estim_params
.
name2
.
size
()
>
0
)
check_symbol_existence
(
estim_params
.
name2
);
}
estim_params_list
.
push_back
(
estim_params
);
estim_params
.
init
(
*
data_tree
);
}
...
...
preprocessor/ParsingDriver.hh
View file @
bab490fc
...
...
@@ -212,8 +212,6 @@ public:
void
declare_exogenous_det
(
string
*
name
,
string
*
tex_name
=
NULL
);
//! Declares a parameter
void
declare_parameter
(
string
*
name
,
string
*
tex_name
=
NULL
);
//! Declares dsge_prior_weight
void
declare_dsge_prior_weight
();
//! Adds a predetermined_variable
void
add_predetermined_variable
(
string
*
name
);
//! Declares and initializes a local parameter
...
...
preprocessor/Statement.hh
View file @
bab490fc
...
...
@@ -65,6 +65,8 @@ public:
bool
k_order_solver
;
//! Whether there is a calibrated measurement error
bool
calibrated_measurement_errors
;
//! Whether dsge_prior_weight was initialized as a parameter
bool
dsge_prior_weight_initialized
;
//! Whether dsge_prior_weight is in the estimated_params block
bool
dsge_prior_weight_in_estimated_params
;
//! Whether there is a dsge_var, with calibrated prior weight
...
...
preprocessor/SymbolTable.cc
View file @
bab490fc
...
...
@@ -201,6 +201,9 @@ SymbolTable::writeOutput(ostream &output) const throw (NotYetFrozenException)
{
output
<<
"M_.param_names = strvcat(M_.param_names, '"
<<
getName
(
param_ids
[
id
])
<<
"');"
<<
endl
<<
"M_.param_names_tex = strvcat(M_.param_names_tex, '"
<<
getTeXName
(
param_ids
[
id
])
<<
"');"
<<
endl
;
if
(
getName
(
param_ids
[
id
])
==
"dsge_prior_weight"
)
output
<<
"options_.dsge_var = 1;"
<<
endl
;
}
}
...
...
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