Commit 8b8f919a authored by Sébastien Villemot's avatar Sébastien Villemot
Browse files

Merge branch 'smoother2histval' into 'master'

Improvements for smoother2histval

See merge request Dynare/dynare!1886
parents 0e793fae 3fb41e07
...@@ -4956,7 +4956,8 @@ block decomposition of the model (see :opt:`block`). ...@@ -4956,7 +4956,8 @@ block decomposition of the model (see :opt:`block`).
computed on the variables listed after the ``estimation`` computed on the variables listed after the ``estimation``
command. Alternatively, one can choose to compute these quantities command. Alternatively, one can choose to compute these quantities
on all endogenous or on all observed variables (see on all endogenous or on all observed variables (see
``consider_all_endogenous`` and ``consider_only_observed`` options ``consider_all_endogenous``, ``consider_all_endogenous_and_auxiliary``,
and ``consider_only_observed`` options
below). If no variable is listed after the estimation command, below). If no variable is listed after the estimation command,
then Dynare will interactively ask which variable set to use. then Dynare will interactively ask which variable set to use.
...@@ -6756,6 +6757,14 @@ block decomposition of the model (see :opt:`block`). ...@@ -6756,6 +6757,14 @@ block decomposition of the model (see :opt:`block`).
endogenous variables. This is equivalent to manually listing endogenous variables. This is equivalent to manually listing
all the endogenous variables after the ``estimation`` command. all the endogenous variables after the ``estimation`` command.
.. option:: consider_all_endogenous_and_auxiliary
Compute the posterior moments, smoothed variables, k-step ahead
filtered variables and forecasts (when requested) on all the
endogenous variables and the auxiliary variables introduced by the
preprocessor. This option is useful when e.g. running ``smoother2histval``
on the results of the Kalman smoother.
.. option:: consider_only_observed .. option:: consider_only_observed
Compute the posterior moments, smoothed variables, k-step ahead Compute the posterior moments, smoothed variables, k-step ahead
......
...@@ -59,10 +59,12 @@ if options_.dsge_var && options_.bayesian_irf ...@@ -59,10 +59,12 @@ if options_.dsge_var && options_.bayesian_irf
end end
if ~isempty(varlist) && ~isempty(options_.endo_vars_for_moment_computations_in_estimation) if ~isempty(varlist) && ~isempty(options_.endo_vars_for_moment_computations_in_estimation)
error('You cannot use the consider_all_endogenous or consider_all_observed options when listing variables after the estimation command') error('You cannot use the consider_all_endogenous, consider_all_endogenous_and_auxiliary or consider_all_observed options when listing variables after the estimation command')
elseif isempty(varlist) && ~isempty(options_.endo_vars_for_moment_computations_in_estimation) elseif isempty(varlist) && ~isempty(options_.endo_vars_for_moment_computations_in_estimation)
if strcmp(options_.endo_vars_for_moment_computations_in_estimation,'all_endogenous_variables') if strcmp(options_.endo_vars_for_moment_computations_in_estimation,'all_endogenous_variables')
varlist = M_.endo_names(1:M_.orig_endo_nbr); varlist = M_.endo_names(1:M_.orig_endo_nbr);
elseif strcmp(options_.endo_vars_for_moment_computations_in_estimation,'all_endogenous_and_auxiliary_variables')
varlist = M_.endo_names;
elseif strcmp(options_.endo_vars_for_moment_computations_in_estimation,'only_observed_variables') elseif strcmp(options_.endo_vars_for_moment_computations_in_estimation,'only_observed_variables')
varlist = options_.varobs; varlist = options_.varobs;
else else
...@@ -119,6 +121,7 @@ elseif isempty(varlist) && isempty(options_.endo_vars_for_moment_computations_in ...@@ -119,6 +121,7 @@ elseif isempty(varlist) && isempty(options_.endo_vars_for_moment_computations_in
disp(' [1] Consider all the endogenous variables.') disp(' [1] Consider all the endogenous variables.')
disp(' [2] Consider all the observed endogenous variables.') disp(' [2] Consider all the observed endogenous variables.')
disp(' [3] Stop Dynare and change the mod file.') disp(' [3] Stop Dynare and change the mod file.')
disp(' [4] Consider all the endogenous and auxiliary variables.')
skipline() skipline()
choice = input('options [default is 1] = '); choice = input('options [default is 1] = ');
if isempty(choice) if isempty(choice)
...@@ -130,9 +133,11 @@ elseif isempty(varlist) && isempty(options_.endo_vars_for_moment_computations_in ...@@ -130,9 +133,11 @@ elseif isempty(varlist) && isempty(options_.endo_vars_for_moment_computations_in
varlist = options_.varobs; varlist = options_.varobs;
elseif choice==3 elseif choice==3
varlist = cell(0); varlist = cell(0);
elseif choice==4
varlist = M_.endo_names;
else else
skipline() skipline()
disp('YOU HAVE TO ANSWER 1, 2 or 3!') disp('YOU HAVE TO ANSWER 1, 2, 3 or 4!')
skipline() skipline()
end end
end end
......
...@@ -78,6 +78,11 @@ end ...@@ -78,6 +78,11 @@ end
if post_metropolis if post_metropolis
tmp = fieldnames(smoothedvars.Mean); tmp = fieldnames(smoothedvars.Mean);
if length(tmp)~=M_.endo_nbr
warning(['You are using smoother2histval although smoothed values have not'...
'been computed for all endogenous and auxiliary variables.'...
'The value of these variables will be set to 0.'])
end
tmpexo = fieldnames(smoothedshocks.Mean); tmpexo = fieldnames(smoothedshocks.Mean);
else else
tmp = fieldnames(smoothedvars); tmp = fieldnames(smoothedvars);
......
Subproject commit e1f7d8c73556398a774ab55c8dc578c79ebb6c3b Subproject commit 5da01faa743f8ca27055bc8389c54ec4ba9f5c41
...@@ -82,6 +82,6 @@ varobs gp_obs gy_obs; ...@@ -82,6 +82,6 @@ varobs gp_obs gy_obs;
options_.solve_tolf = 1e-12; options_.solve_tolf = 1e-12;
estimation(order=1,datafile=fsdat_simul,mh_replic=1500,mh_nblocks=1,mh_jscale=0.8,smoother,consider_all_endogenous); estimation(order=1,datafile=fsdat_simul,mh_replic=1500,mh_nblocks=1,mh_jscale=0.8,smoother,consider_all_endogenous_and_auxiliary);
smoother2histval(period = 5, outfile = 'fs2000_histval.mat'); smoother2histval(period = 5, outfile = 'fs2000_histval.mat');
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment