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
9c22fc1b
Commit
9c22fc1b
authored
Sep 19, 2011
by
Stéphane Adjemian
Browse files
Removed globals from DsgeLikelihood. Still broken.
Added texinfo header in DsgeLikelihood.
parent
9c0e559e
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
matlab/DsgeLikelihood.m
View file @
9c22fc1b
This diff is collapsed.
Click to expand it.
matlab/dynare_estimation_1.m
View file @
9c22fc1b
...
...
@@ -31,15 +31,17 @@ function dynare_estimation_1(var_list_,dname)
global
M_
options_
oo_
estim_params_
bayestopt_
if
~
options_
.
dsge_var
objective_function
=
str2func
(
'DsgeLikelihood'
);
else
objective_function
=
str2func
(
'DsgeVarLikelihood'
);
end
[
dataset_
,
xparam1
,
M_
,
options_
,
oo_
,
estim_params_
,
bayestopt_
,
fake
]
=
dynare_estimation_init
(
var_list_
,
dname
,
[],
M_
,
options_
,
oo_
,
estim_params_
,
bayestopt_
);
data
=
dataset_
.
data
;
rawdata
=
dataset_
.
rawdata
;
% Set various options.
options_
=
set_default_option
(
options_
,
'mh_nblck'
,
2
);
options_
=
set_default_option
(
options_
,
'nodiagnostic'
,
0
);
% Set number of observations
gend
=
options_
.
nobs
;
% Set the number of observed variables.
...
...
@@ -121,7 +123,7 @@ number_of_observations = gend*n_varobs;
[
data_index
,
junk
,
no_more_missing_observations
]
=
...
describe_missing_data
(
data
);
initial_estimation_checks
(
xparam1
,
gend
,
data
,
data_index
,
number_of_observations
,
no_more_missing_observations
);
oo_
=
initial_estimation_checks
(
xparam1
,
dataset_
,
M_
,
estim_params_
,
options_
,
bayestopt_
,
oo_
);
if
isequal
(
options_
.
mode_compute
,
0
)
&&
isempty
(
options_
.
mode_file
)
&&
options_
.
mh_posterior_mode_estimation
==
0
if
options_
.
smoother
==
1
...
...
matlab/initial_estimation_checks.m
View file @
9c22fc1b
function
initial_estimation_checks
(
xparam1
,
gend
,
data
,
data_index
,
number_of_observations
,
no_more_missing_observations
)
function
oo
=
initial_estimation_checks
(
xparam1
,
dataset
,
M
,
estim_params
,
options
,
bayestopt
,
oo
);
%
initial_estimation_checks(xparam1,gend,data,data_index,number_of_observations,no_more_missing_observations
% function initial_estimation_checks(xparam1,gend,data,data_index,number_of_observations,no_more_missing_observations)
% Checks data (complex values, ML evaluation, initial values, BK conditions,..)
%
%
% INPUTS
% xparam1: vector of parameters to be estimated
% gend: scalar specifying the number of observations
% data: matrix of data
%
%
% OUTPUTS
% none
%
%
% SPECIAL REQUIREMENTS
% none
...
...
@@ -30,66 +30,54 @@ function initial_estimation_checks(xparam1,gend,data,data_index,number_of_observ
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
global
dr1_test
bayestopt_
estim_params_
options_
oo_
M_
nv
=
size
(
data
,
1
);
if
nv
-
size
(
options_
.
varobs
,
1
)
disp
(
' '
)
disp
([
'Declared number of observed variables = '
int2str
(
size
(
options_
.
varobs
,
1
))])
disp
([
'Number of variables in the database = '
int2str
(
nv
)])
disp
(
' '
)
error
([
'Estimation can
''
t take place because the declared number of observed'
...
'variables doesn
''
t match the number of variables in the database.'
])
end
if
nv
>
M_
.
exo_nbr
+
estim_params_
.
nvn
error
([
'Estimation can
''
t take place because there are less shocks than'
...
'observed variables'
])
if
dataset
.
info
.
nvobs
>
M
.
exo_nbr
+
estim_params
.
nvn
error
([
'initial_estimation_checks:: Estimation can
''
t take place because there are less shocks than observed variables!'
])
end
if
options
_
.
dsge_var
if
options
.
dsge_var
[
fval
,
cost_flag
,
info
]
=
DsgeVarLikelihood
(
xparam1
,
gend
);
else
[
fval
,
cost_flag
,
ys
,
trend_coeff
,
info
]
=
DsgeLikelihood
(
xparam1
,
gend
,
data
,
data_index
,
number_of_observations
,
no_more_missing_observations
);
[
fval
,
cost_flag
,
ys
,
trend_coeff
,
info
]
=
DsgeLikelihood
(
xparam1
,
dataset_
,
options_
,
M_
,
estim_params_
,
bayestopt_
,
oo_
);
end
% when their is an analytical steadystate, check that the values
% returned by *_steadystate match with the static model
if
options
_
.
steadystate_flag
[
ys
,
check
]
=
feval
([
M
_
.
fname
'_steadystate'
],
...
oo
_
.
steady_state
,
...
[
oo
_
.
exo_steady_state
;
...
oo
_
.
exo_det_steady_state
]);
if
size
(
ys
,
1
)
<
M
_
.
endo_nbr
if
length
(
M
_
.
aux_vars
)
>
0
ys
=
add_auxiliary_variables_to_steadystate
(
ys
,
M
_
.
aux_vars
,
...
M
_
.
fname
,
...
oo
_
.
exo_steady_state
,
...
oo
_
.
exo_det_steady_state
,
...
M
_
.
params
,
...
options
_
.
bytecode
);
if
options
.
steadystate_flag
[
ys
,
check
]
=
feval
([
M
.
fname
'_steadystate'
],
...
oo
.
steady_state
,
...
[
oo
.
exo_steady_state
;
...
oo
.
exo_det_steady_state
]);
if
size
(
ys
,
1
)
<
M
.
endo_nbr
if
length
(
M
.
aux_vars
)
>
0
ys
=
add_auxiliary_variables_to_steadystate
(
ys
,
M
.
aux_vars
,
...
M
.
fname
,
...
oo
.
exo_steady_state
,
...
oo
.
exo_det_steady_state
,
...
M
.
params
,
...
options
.
bytecode
);
else
error
([
M
_
.
fname
'_steadystate.m doesn
''
t match the model'
]);
error
([
M
.
fname
'_steadystate.m doesn
''
t match the model'
]);
end
end
oo
_
.
steady_state
=
ys
;
% Check if the steady state obtained from the _steadystate file is a
oo
.
steady_state
=
ys
;
% Check if the steady state obtained from the _steadystate file is a
% steady state.
check1
=
0
;
if
isfield
(
options
_
,
'unit_root_vars'
)
&&
options
_
.
diffuse_filter
==
0
if
isempty
(
options
_
.
unit_root_vars
)
if
~
options
_
.
bytecode
check1
=
max
(
abs
(
feval
([
M
_
.
fname
'_static'
],
...
oo
_
.
steady_state
,
...
[
oo
_
.
exo_steady_state
;
...
oo
_
.
exo_det_steady_state
],
M
_
.
params
)))
>
options
_
.
dynatol
;
if
isfield
(
options
,
'unit_root_vars'
)
&&
options
.
diffuse_filter
==
0
if
isempty
(
options
.
unit_root_vars
)
if
~
options
.
bytecode
check1
=
max
(
abs
(
feval
([
M
.
fname
'_static'
],
...
oo
.
steady_state
,
...
[
oo
.
exo_steady_state
;
...
oo
.
exo_det_steady_state
],
M
.
params
)))
>
options
.
dynatol
;
else
[
info
,
res
]
=
bytecode
(
'static'
,
'evaluate'
,
oo
_
.
steady_state
,
...
[
oo
_
.
exo_steady_state
;
...
oo
_
.
exo_det_steady_state
],
M
_
.
params
);
check1
=
max
(
abs
(
res
))
>
options
_
.
dynatol
;
[
info
,
res
]
=
bytecode
(
'static'
,
'evaluate'
,
oo
.
steady_state
,
...
[
oo
.
exo_steady_state
;
...
oo
.
exo_det_steady_state
],
M
.
params
);
check1
=
max
(
abs
(
res
))
>
options
.
dynatol
;
end
if
check1
error
([
'The seadystate values returned by '
M
_
.
fname
...
error
([
'The seadystate values returned by '
M
.
fname
...
'_steadystate.m don
''
t solve the static model!'
])
end
end
...
...
@@ -98,10 +86,10 @@ end
if
info
(
1
)
>
0
disp
(
'Error in computing likelihood for initial parameter values'
)
print_info
(
info
,
options
_
.
noprint
)
print_info
(
info
,
options
.
noprint
)
end
if
any
(
abs
(
oo
_
.
steady_state
(
bayestopt
_
.
mfys
))
>
1e-9
)
&&
(
options
_
.
prefilter
==
1
)
if
any
(
abs
(
oo
.
steady_state
(
bayestopt
.
mfys
))
>
1e-9
)
&&
(
options
.
prefilter
==
1
)
disp
([
'You are trying to estimate a model with a non zero steady state for the observed endogenous'
])
disp
([
'variables using demeaned data!'
])
error
(
'You should change something in your mod file...'
)
...
...
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