Merge branch 'preparations_irf_matching' of git.dynare.org:wmutschl/dynare

Ref. !2181
kalman-mex
Sébastien Villemot 2023-09-20 10:17:14 +02:00
commit 6f5e346bf6
No known key found for this signature in database
GPG Key ID: 2CECE9350ECEBE4A
74 changed files with 1838 additions and 1992 deletions

View File

@ -8840,11 +8840,11 @@ observed variables.
Relative numerical efficiency (RNE) under the assumption
of iid draws.
``nse_x``
``nse_taper_x``
Numerical standard error (NSE) when using an x% taper.
``rne_x``
``rne_taper_x``
Relative numerical efficiency (RNE) when using an x% taper.
@ -8875,6 +8875,13 @@ observed variables.
autocorrelation in draws. In this case, the estimates using a
higher tapering are usually more reliable.
.. matvar:: oo_.convergence.raftery_lewis
Variable set by the convergence diagnostics of the ``estimation``
command when used with ``raftery_lewis_diagnostics`` option (see
:opt:`raftery_lewis_diagnostics`). Contains the results of the test in individual fields.
.. command:: unit_root_vars VARIABLE_NAME...;
|br| This command is deprecated. Use ``estimation`` option

File diff suppressed because it is too large Load Diff

View File

@ -20,7 +20,7 @@
*/
/*
* Copyright © 2021 Dynare Team
* Copyright © 2021-2023 Dynare Team
*
* This file is part of Dynare.
*
@ -147,13 +147,13 @@ end;
varobs yhat;
% Run prior function to get prior slope of the PC based on independent priors
hh=figure('Name','Slope of the Phillips Curve');
hh_fig=figure('Name','Slope of the Phillips Curve');
prior_function(function='Gali_2015_PC_slope');
PC_slope_vec=cell2mat(oo_.prior_function_results(:,1));
optimal_bandwidth = mh_optimal_bandwidth(PC_slope_vec,length(PC_slope_vec),0,'gaussian');
[density(:,1),density(:,2)] = kernel_density_estimate(PC_slope_vec,512,length(PC_slope_vec),optimal_bandwidth,'gaussian');
figure(hh)
figure(hh_fig)
subplot(3,1,1)
plot(density(:,1),density(:,2));
title('Prior')
@ -165,7 +165,7 @@ posterior_function(function='Gali_2015_PC_slope');
PC_slope_vec=cell2mat(oo_.posterior_function_results(:,1));
optimal_bandwidth = mh_optimal_bandwidth(PC_slope_vec,length(PC_slope_vec),0,'gaussian');
[density(:,1),density(:,2)] = kernel_density_estimate(PC_slope_vec,512,length(PC_slope_vec),optimal_bandwidth,'gaussian');
figure(hh)
figure(hh_fig)
subplot(3,1,2)
plot(density(:,1),density(:,2));
title('Updated Prior')
@ -178,7 +178,7 @@ posterior_function(function='Gali_2015_PC_slope');
PC_slope_vec=cell2mat(oo_.posterior_function_results(:,1));
optimal_bandwidth = mh_optimal_bandwidth(PC_slope_vec,length(PC_slope_vec),0,'gaussian');
[density(:,1),density(:,2)] = kernel_density_estimate(PC_slope_vec,512,length(PC_slope_vec),optimal_bandwidth,'gaussian');
figure(hh)
figure(hh_fig)
subplot(3,1,3)
plot(density(:,1),density(:,2));
title('Posterior')

View File

@ -1,185 +0,0 @@
function check_plot(fun,xparam,SE_vec,options_,M_,estim_params_,Bounds,bayestopt_,varargin)
%function check_plot(fun,xparam,SE_vec,options_,M_,estim_params_,Bounds,bayestopt_,varargin)
% Checks the estimated local minimum of the moment's distance objective
% Copyright © 2020-2021 Dynare Team
%
% This file is part of Dynare.
%
% Dynare is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% Dynare is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
TeX = options_.TeX;
if ~isempty(SE_vec)
[ s_min, k ] = min(SE_vec);
end
fval = feval(fun,xparam,varargin{:});
if ~isempty(SE_vec)
skipline()
disp('LOCAL MINIMUM CHECK')
skipline()
fprintf('Fval obtained by the minimization routine: %f', fval);
skipline()
if s_min<eps
fprintf('Most negative variance %f for parameter %d (%s = %f)', s_min, k , bayestopt_.name{k}, xparam(k))
end
end
[nbplt,nr,nc,lr,lc,nstar] = pltorg(length(xparam));
if ~exist([M_.dname filesep 'graphs'],'dir')
mkdir(M_.dname,'graphs');
end
if TeX && any(strcmp('eps',cellstr(options_.graph_format)))
fidTeX = fopen([M_.dname, '/graphs/', M_.fname '_MoMCheckPlots.tex'],'w');
fprintf(fidTeX,'%% TeX eps-loader file generated by mom.check_plot.m (Dynare).\n');
fprintf(fidTeX,['%% ' datestr(now,0) '\n']);
fprintf(fidTeX,' \n');
end
ll = options_.mode_check.neighbourhood_size;
if isinf(ll)
options_.mode_check.symmetric_plots = false;
end
mcheck = struct('cross',struct(),'emin',struct());
for plt = 1:nbplt
if TeX
NAMES = [];
TeXNAMES = [];
end
hh = dyn_figure(options_.nodisplay,'Name','Minimum check plots');
for k=1:min(nstar,length(xparam)-(plt-1)*nstar)
subplot(nr,nc,k)
kk = (plt-1)*nstar+k;
[name,texname] = get_the_name(kk,TeX,M_,estim_params_,options_);
xx = xparam;
if xparam(kk)~=0 || ~isinf(Bounds.lb(kk)) || ~isinf(Bounds.lb(kk))
l1 = max(Bounds.lb(kk),(1-sign(xparam(kk))*ll)*xparam(kk)); m1 = 0; %lower bound
l2 = min(Bounds.ub(kk),(1+sign(xparam(kk))*ll)*xparam(kk)); %upper bound
else
%size info for 0 parameter is missing, use prior standard
%deviation
upper_bound=Bounds.lb(kk);
if isinf(upper_bound)
upper_bound=-1e-6*options_.huge_number;
end
lower_bound=Bounds.ub(kk);
if isinf(lower_bound)
lower_bound=-1e-6*options_.huge_number;
end
l1 = max(lower_bound,-bayestopt_.p2(kk)); m1 = 0; %lower bound
l2 = min(upper_bound,bayestopt_.p2(kk)); %upper bound
end
binding_lower_bound=0;
binding_upper_bound=0;
if isequal(xparam(kk),Bounds.lb(kk))
binding_lower_bound=1;
bound_value=Bounds.lb(kk);
elseif isequal(xparam(kk),Bounds.ub(kk))
binding_upper_bound=1;
bound_value=Bounds.ub(kk);
end
if options_.mode_check.symmetric_plots && ~binding_lower_bound && ~binding_upper_bound
if l2<(1+ll)*xparam(kk) %test whether upper bound is too small due to prior binding
l1 = xparam(kk) - (l2-xparam(kk)); %adjust lower bound to become closer
m1 = 1;
end
if ~m1 && (l1>(1-ll)*xparam(kk)) && (xparam(kk)+(xparam(kk)-l1)<Bounds.ub(kk)) % if lower bound was truncated and using difference from lower bound does not violate upper bound
l2 = xparam(kk) + (xparam(kk)-l1); %set upper bound to same distance as lower bound
end
end
z1 = l1:((xparam(kk)-l1)/(options_.mode_check.number_of_points/2)):xparam(kk);
z2 = xparam(kk):((l2-xparam(kk))/(options_.mode_check.number_of_points/2)):l2;
z = union(z1,z2);
if options_.mom.penalized_estimator
y = zeros(length(z),2);
dy=(xx-bayestopt_.p1)'/diag(bayestopt_.p2.^2)*(xx-bayestopt_.p1);
else
y = zeros(length(z),1);
end
for i=1:length(z)
xx(kk) = z(i);
[fval, info, exit_flag] = feval(fun,xx,varargin{:});
if exit_flag
y(i,1) = fval;
else
y(i,1) = NaN;
if options_.debug
fprintf('mom.check_plot:: could not solve model for parameter %s at value %4.3f, error code: %u\n',name,z(i),info(1))
end
end
if options_.mom.penalized_estimator
prior=(xx-bayestopt_.p1)'/diag(bayestopt_.p2.^2)*(xx-bayestopt_.p1);
y(i,2) = (y(i,1)+prior-dy);
end
end
mcheck.cross = setfield(mcheck.cross, name, [transpose(z), y]);
mcheck.emin = setfield(mcheck.emin, name, xparam(kk));
fighandle=plot(z,y);
hold on
yl=get(gca,'ylim');
plot( [xparam(kk) xparam(kk)], yl, 'c', 'LineWidth', 1)
NaN_index = find(isnan(y(:,1)));
zNaN = z(NaN_index);
yNaN = yl(1)*ones(size(NaN_index));
plot(zNaN,yNaN,'o','MarkerEdgeColor','r','MarkerFaceColor','r','MarkerSize',6);
if TeX
title(texname,'interpreter','latex')
else
title(name,'interpreter','none')
end
axis tight
if binding_lower_bound || binding_upper_bound
xl=get(gca,'xlim');
plot( [bound_value bound_value], yl, 'r--', 'LineWidth', 1)
xlim([xl(1)-0.5*binding_lower_bound*(xl(2)-xl(1)) xl(2)+0.5*binding_upper_bound*(xl(2)-xl(1))])
end
hold off
drawnow
end
if options_.mom.penalized_estimator
if isoctave
axes('outerposition',[0.3 0.93 0.42 0.07],'box','on'),
else
axes('position',[0.3 0.01 0.42 0.05],'box','on'),
end
line_color=get(fighandle,'color');
plot([0.48 0.68],[0.5 0.5],'color',line_color{2})
hold on, plot([0.04 0.24],[0.5 0.5],'color',line_color{1})
set(gca,'xlim',[0 1],'ylim',[0 1],'xtick',[],'ytick',[])
text(0.25,0.5,'log-post')
text(0.69,0.5,'log-lik kernel')
end
dyn_saveas(hh,[M_.dname, '/graphs/', M_.fname '_MoMCheckPlots' int2str(plt) ],options_.nodisplay,options_.graph_format);
if TeX && any(strcmp('eps',cellstr(options_.graph_format)))
% TeX eps loader file
fprintf(fidTeX,'\\begin{figure}[H]\n');
fprintf(fidTeX,'\\centering \n');
fprintf(fidTeX,'\\includegraphics[width=%2.2f\\textwidth]{%s_MoMCheckPlots%s}\n',options_.figures.textwidth*min(k/nc,1),[M_.dname, '/graphs/',M_.fname],int2str(plt));
fprintf(fidTeX,'\\caption{Method of Moments check plots.}');
fprintf(fidTeX,'\\label{Fig:MoMCheckPlots:%s}\n',int2str(plt));
fprintf(fidTeX,'\\end{figure}\n');
fprintf(fidTeX,' \n');
end
end
if TeX && any(strcmp('eps',cellstr(options_.graph_format)))
fclose(fidTeX);
end
save([M_.dname filesep 'graphs' filesep M_.fname '_MoMCheckPlots_data.mat'],'mcheck');

View File

@ -29,6 +29,7 @@ function options_mom_ = default_option_mom_values(options_mom_, options_, dname,
% o user_has_matlab_license
% o user_has_octave_forge_package
% -------------------------------------------------------------------------
% Copyright © 2023 Dynare Team
%
% This file is part of Dynare.

View File

@ -560,12 +560,16 @@ if strcmp(options_mom_.mom.mom_method,'GMM') || strcmp(options_mom_.mom.mom_meth
end
[~, ~, ~,~,~, oo_] = feval(objective_function, xparam1, Bounds, oo_, estim_params_, M_, options_mom_); % compute model moments and oo_.mom.model_moments_params_derivs
options_mom_.mom.compute_derivs = false; % reset to not compute derivatives in objective function during optimization
SE = mom.standard_errors(xparam1, objective_function, Bounds, oo_, estim_params_, M_, options_mom_, Woptflag);
% mode check plots
if options_mom_.mode_check.status
mom.check_plot(objective_function,xparam1,SE,options_mom_,M_,estim_params_,Bounds,bayestopt_,...
Bounds, oo_, estim_params_, M_, options_mom_);
end
[stdh,hessian_xparam1] = mom.standard_errors(xparam1, objective_function, Bounds, oo_, estim_params_, M_, options_mom_, Woptflag);
end
% -------------------------------------------------------------------------
% checks for mode and hessian at the mode
% -------------------------------------------------------------------------
if options_mom_.mode_check.status
mode_check(objective_function, xparam1, hessian_xparam1, options_mom_, M_, estim_params_, bayestopt_, Bounds, true,...
Bounds, oo_, estim_params_, M_, options_mom_, bayestopt_);
end
@ -574,7 +578,7 @@ end
% -------------------------------------------------------------------------
if strcmp(options_mom_.mom.mom_method,'SMM') || strcmp(options_mom_.mom.mom_method,'GMM')
% Store results in output structure
oo_.mom = display_estimation_results_table(xparam1,SE,M_,options_mom_,estim_params_,bayestopt_,oo_.mom,prior_dist_names,options_mom_.mom.mom_method,lower(options_mom_.mom.mom_method));
oo_.mom = display_estimation_results_table(xparam1,stdh,M_,options_mom_,estim_params_,bayestopt_,oo_.mom,prior_dist_names,options_mom_.mom.mom_method,lower(options_mom_.mom.mom_method));
% J test
oo_ = mom.Jtest(xparam1, objective_function, Woptflag, oo_, options_mom_, bayestopt_, Bounds, estim_params_, M_, dataset_.nobs);
% display comparison of model moments and data moments

View File

@ -42,7 +42,7 @@ function [alphahat,etahat,epsilonhat,ahat0,SteadyState,trend_coeff,aKK,T0,R0,P,P
% - alphahat0 [double] (m*1) array, smoothed endogenous variables in period 0 (a_{0|T}) (decision-rule order)
% - state_uncertainty0 [double] (K,K,1) array, storing the uncertainty in period 0
% Copyright © 2021 Dynare Team
% Copyright © 2021-2023 Dynare Team
%
% This file is part of Dynare.
%
@ -401,7 +401,7 @@ if (~is_changed || occbin_smoother_debug) && nargin==12
if M_.Sigma_e(j,j)
j1=j1+1;
if mod(j1,9)==1
hfig = dyn_figure(options_.nodisplay,'name','Occbin smoothed shocks');
hh_fig = dyn_figure(options_.nodisplay,'name','Occbin smoothed shocks');
ifig=ifig+1;
isub=0;
end
@ -427,7 +427,7 @@ if (~is_changed || occbin_smoother_debug) && nargin==12
if mod(j1,9)~=0 && j==M_.exo_nbr
annotation('textbox', [0.1,0,0.35,0.05],'String', 'Linear','Color','Blue','horizontalalignment','center','interpreter','none');
annotation('textbox', [0.55,0,0.35,0.05],'String', 'Piecewise','Color','Red','horizontalalignment','center','interpreter','none');
dyn_saveas(hfig,[GraphDirectoryName filesep M_.fname,'_smoothedshocks_occbin',int2str(ifig)],options_.nodisplay,options_.graph_format);
dyn_saveas(hh_fig,[GraphDirectoryName filesep M_.fname,'_smoothedshocks_occbin',int2str(ifig)],options_.nodisplay,options_.graph_format);
end
end
end

View File

@ -65,13 +65,13 @@ opts_simul.piecewise_only = 1;
filtered_errs=zeros(sample_length,n_obs);
if options_.occbin.likelihood.waitbar
hh = dyn_waitbar(0,'IVF_core: Filtering the shocks');
set(hh,'Name','IVF_core: Filtering the shocks.');
hh_fig = dyn_waitbar(0,'IVF_core: Filtering the shocks');
set(hh_fig,'Name','IVF_core: Filtering the shocks.');
end
for this_period=1:sample_length
if options_.occbin.likelihood.waitbar
dyn_waitbar(this_period/sample_length, hh, sprintf('Period %u of %u', this_period,sample_length));
dyn_waitbar(this_period/sample_length, hh_fig, sprintf('Period %u of %u', this_period,sample_length));
end
current_obs = obs(this_period,:);
init_val_old = init_val;
@ -89,7 +89,7 @@ for this_period=1:sample_length
filtered_errs=NaN;
error_code(1) = 304;
error_code(4) = 1000;
if options_.occbin.likelihood.waitbar; dyn_waitbar_close(hh); end
if options_.occbin.likelihood.waitbar; dyn_waitbar_close(hh_fig); end
return
end
filtered_errs(this_period,inan)=err_vals_out';
@ -103,7 +103,7 @@ for this_period=1:sample_length
error_code(1) = 306;
error_code(4) = max(abs(err_vals_out))/1000;
filtered_errs=NaN;
if options_.occbin.likelihood.waitbar; dyn_waitbar_close(hh); end
if options_.occbin.likelihood.waitbar; dyn_waitbar_close(hh_fig); end
return
end
if max(abs(resids(this_period,:)))>0.001
@ -112,12 +112,12 @@ for this_period=1:sample_length
filtered_errs=NaN;
error_code(1) = 303;
error_code(4) = max(abs(resids(this_period,:)))*100;
if options_.occbin.likelihood.waitbar; dyn_waitbar_close(hh); end
if options_.occbin.likelihood.waitbar; dyn_waitbar_close(hh_fig); end
return
end
end
if options_.occbin.likelihood.waitbar
dyn_waitbar_close(hh);
dyn_waitbar_close(hh_fig);
end
end

View File

@ -8,7 +8,7 @@ function graph(M_, options_, options_occbin_, oo_, var_list)
% - oo_ [structure] Matlab's structure containing the results
% - var_list [char] list of the variables to plot
% Copyright © 2021 Dynare Team
% Copyright © 2021-2023 Dynare Team
%
% This file is part of Dynare.
%
@ -79,7 +79,7 @@ end
[nbplt,nr,nc,lr,lc,nstar] = pltorg(number_of_plots_to_draw_endo+number_of_plots_to_draw_exo);
for fig = 1:nbplt
hh = dyn_figure(options_.nodisplay,'Name',['Occbin simulated paths, figure ' int2str(fig)]);
hh_fig = dyn_figure(options_.nodisplay,'Name',['Occbin simulated paths, figure ' int2str(fig)]);
for plt = 1:nstar
if fig==nbplt && ~lr==0
subplot(lr,lc,plt);
@ -121,7 +121,7 @@ for fig = 1:nbplt
break
end
end
dyn_saveas(hh,[M_.dname, '/graphs/' M_.fname '_occbin_' int2str(fig)],options_.nodisplay,options_.graph_format);
dyn_saveas(hh_fig,[M_.dname, '/graphs/' M_.fname '_occbin_' int2str(fig)],options_.nodisplay,options_.graph_format);
if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format)))
fprintf(fidTeX,'\\begin{figure}[H]\n');
fprintf(fidTeX,'\\centering \n');

View File

@ -114,13 +114,13 @@ else
end
if opts_simul_.waitbar
hh = dyn_waitbar(0,'Occbin: Solving the model');
set(hh,'Name','Occbin: Solving the model.');
hh_fig = dyn_waitbar(0,'Occbin: Solving the model');
set(hh_fig,'Name','Occbin: Solving the model.');
end
for shock_period = 1:n_shocks_periods
if opts_simul_.waitbar
dyn_waitbar(shock_period/n_shocks_periods, hh, sprintf('Period %u of %u', shock_period,n_shocks_periods));
dyn_waitbar(shock_period/n_shocks_periods, hh_fig, sprintf('Period %u of %u', shock_period,n_shocks_periods));
end
regime_change_this_iteration=true;
@ -312,7 +312,7 @@ for shock_period = 1:n_shocks_periods
if periodic_solution
disp_verbose(['Max error:' num2str(merr) '.'],opts_simul_.debug)
else
if opts_simul_.waitbar; dyn_waitbar_close(hh); end
if opts_simul_.waitbar; dyn_waitbar_close(hh_fig); end
error_flag = 310;
return
end
@ -324,7 +324,7 @@ for shock_period = 1:n_shocks_periods
disp_verbose('Did not converge -- increase maxit.',opts_simul_.debug)
error_flag = 311;
end
if opts_simul_.waitbar; dyn_waitbar_close(hh); end
if opts_simul_.waitbar; dyn_waitbar_close(hh_fig); end
return
end
else
@ -333,7 +333,7 @@ for shock_period = 1:n_shocks_periods
end
if any(error_code_period)
disp_verbose('Increase nperiods.',opts_simul_.debug)
if opts_simul_.waitbar; dyn_waitbar_close(hh); end
if opts_simul_.waitbar; dyn_waitbar_close(hh_fig); end
error_flag = 312;
return
end
@ -363,5 +363,5 @@ if ~opts_simul_.piecewise_only
end
if opts_simul_.waitbar
dyn_waitbar_close(hh);
dyn_waitbar_close(hh_fig);
end

View File

@ -124,13 +124,13 @@ else
end
if opts_simul_.waitbar
hh = dyn_waitbar(0,'Occbin: Solving the model');
set(hh,'Name','Occbin: Solving the model.');
hh_fig = dyn_waitbar(0,'Occbin: Solving the model');
set(hh_fig,'Name','Occbin: Solving the model.');
end
for shock_period = 1:n_shocks_periods
if opts_simul_.waitbar
dyn_waitbar(shock_period/n_shocks_periods, hh, sprintf('Period %u of %u', shock_period,n_shocks_periods));
dyn_waitbar(shock_period/n_shocks_periods, hh_fig, sprintf('Period %u of %u', shock_period,n_shocks_periods));
end
regime_change_this_iteration=true;
nperiods_endogenously_increased = false;
@ -348,7 +348,7 @@ for shock_period = 1:n_shocks_periods
disp_verbose(['Max error:' num2str(min_err) '.'],opts_simul_.debug)
else
error_flag = 310;
if opts_simul_.waitbar; dyn_waitbar_close(hh); end
if opts_simul_.waitbar; dyn_waitbar_close(hh_fig); end
return;
end
else
@ -359,7 +359,7 @@ for shock_period = 1:n_shocks_periods
disp_verbose('Did not converge -- increase maxit.',opts_simul_.debug)
error_flag = 311;
end
if opts_simul_.waitbar; dyn_waitbar_close(hh); end
if opts_simul_.waitbar; dyn_waitbar_close(hh_fig); end
return;
end
else
@ -371,7 +371,7 @@ for shock_period = 1:n_shocks_periods
if any(error_code_period)
disp_verbose('Increase nperiods.',opts_simul_.debug)
error_flag = 312;
if opts_simul_.waitbar; dyn_waitbar_close(hh); end
if opts_simul_.waitbar; dyn_waitbar_close(hh_fig); end
return;
end
@ -396,5 +396,5 @@ if ~opts_simul_.piecewise_only
end
if opts_simul_.waitbar
dyn_waitbar_close(hh);
dyn_waitbar_close(hh_fig);
end

View File

@ -1,5 +1,5 @@
function CutSample(M_, options_, estim_params_)
% function CutSample(M_, options_, estim_params_)
function CutSample(M_, options_, dispString)
% function CutSample(M_, options_, dispString)
% Takes a subset from metropolis draws by storing the required information
% like the first MH-file to be loaded and the first line in that file to be
% loaded into the record structure saved on harddisk into the
@ -8,7 +8,7 @@ function CutSample(M_, options_, estim_params_)
% INPUTS
% M_ [structure] Dynare model structure
% options_ [structure] Dynare options structure
% estim_params_ [structure] Parameter structure
% dispString [string] String to be displayed in the command window
%
% OUTPUTS
% none
@ -33,8 +33,6 @@ function CutSample(M_, options_, estim_params_)
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
dispString = 'Estimation::mcmc';
% Get the path to the metropolis files.
MetropolisFolder = CheckPath('metropolis',M_.dname);

View File

@ -33,7 +33,7 @@ function DSMH_sampler(TargetFun,xparam1,mh_bounds,dataset_,dataset_info,options_
% Then the comments write here can be used for all the other pairs of
% parallel functions and also for management functions.
% Copyright © 2006-2022 Dynare Team
% Copyright © 2006-2023 Dynare Team
%
% This file is part of Dynare.
%
@ -125,7 +125,7 @@ if TeX
NAMES = [];
TeXNAMES = [];
end
hh = dyn_figure(options_.nodisplay,'Name','Parameters Densities');
hh_fig = dyn_figure(options_.nodisplay,'Name','Parameters Densities');
for k=1:npar %min(nstar,npar-(plt-1)*nstar)
subplot(ceil(sqrt(npar)),floor(sqrt(npar)),k)
%kk = (plt-1)*nstar+k;
@ -144,7 +144,7 @@ for k=1:npar %min(nstar,npar-(plt-1)*nstar)
axis tight
drawnow
end
dyn_saveas(hh,[ M_.fname '_param_density' int2str(plt) ],options_.nodisplay,options_.graph_format);
dyn_saveas(hh_fig,[ M_.fname '_param_density' int2str(plt) ],options_.nodisplay,options_.graph_format);
if TeX && any(strcmp('eps',cellstr(options_.graph_format)))
% TeX eps loader file
fprintf(fidTeX,'\\begin{figure}[H]\n');

View File

@ -1,8 +1,10 @@
function Draws = GetAllPosteriorDraws(column, FirstMhFile, FirstLine, TotalNumberOfMhFile, NumberOfDraws, nblcks, blck)
% function Draws = GetAllPosteriorDraws(column, FirstMhFile, FirstLine, TotalNumberOfMhFile, NumberOfDraws, nblcks, blck)
function Draws = GetAllPosteriorDraws(dname, fname, column, FirstMhFile, FirstLine, TotalNumberOfMhFile, NumberOfDraws, nblcks, blck)
% function Draws = GetAllPosteriorDraws(dname, fname, column, FirstMhFile, FirstLine, TotalNumberOfMhFile, NumberOfDraws, nblcks, blck)
% Gets all posterior draws
%
% INPUTS
% dname: name of directory with results
% fname: name of mod file
% column: column of desired parameter in draw matrix
% FirstMhFile: first mh file
% FirstLine: first line
@ -34,20 +36,18 @@ function Draws = GetAllPosteriorDraws(column, FirstMhFile, FirstLine, TotalNumbe
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
global M_
iline = FirstLine;
linee = 1;
DirectoryName = CheckPath('metropolis',M_.dname);
DirectoryName = CheckPath('metropolis',dname);
if nblcks>1 && nargin<7
if nblcks>1 && nargin<9
Draws = zeros(NumberOfDraws*nblcks,1);
iline0=iline;
if column>0
for blck = 1:nblcks
iline=iline0;
for file = FirstMhFile:TotalNumberOfMhFile
load([DirectoryName '/' M_.fname '_mh' int2str(file) '_blck' int2str(blck)],'x2')
load([DirectoryName '/' fname '_mh' int2str(file) '_blck' int2str(blck)],'x2')
NumberOfLines = size(x2(iline:end,:),1);
Draws(linee:linee+NumberOfLines-1) = x2(iline:end,column);
linee = linee+NumberOfLines;
@ -58,7 +58,7 @@ if nblcks>1 && nargin<7
for blck = 1:nblcks
iline=iline0;
for file = FirstMhFile:TotalNumberOfMhFile
load([DirectoryName '/' M_.fname '_mh' int2str(file) '_blck' int2str(blck)],'logpo2')
load([DirectoryName '/' fname '_mh' int2str(file) '_blck' int2str(blck)],'logpo2')
NumberOfLines = size(logpo2(iline:end),1);
Draws(linee:linee+NumberOfLines-1) = logpo2(iline:end);
linee = linee+NumberOfLines;
@ -72,7 +72,7 @@ else
end
if column>0
for file = FirstMhFile:TotalNumberOfMhFile
load([DirectoryName '/' M_.fname '_mh' int2str(file) '_blck' int2str(blck)],'x2')
load([DirectoryName '/' fname '_mh' int2str(file) '_blck' int2str(blck)],'x2')
NumberOfLines = size(x2(iline:end,:),1);
Draws(linee:linee+NumberOfLines-1) = x2(iline:end,column);
linee = linee+NumberOfLines;
@ -80,7 +80,7 @@ else
end
else
for file = FirstMhFile:TotalNumberOfMhFile
load([DirectoryName '/' M_.fname '_mh' int2str(file) '_blck' int2str(blck)],'logpo2')
load([DirectoryName '/' fname '_mh' int2str(file) '_blck' int2str(blck)],'logpo2')
NumberOfLines = size(logpo2(iline:end,:),1);
Draws(linee:linee+NumberOfLines-1) = logpo2(iline:end);
linee = linee+NumberOfLines;

View File

@ -46,7 +46,7 @@ ncn = estim_params_.ncn;
np = estim_params_.np ;
MetropolisFolder = CheckPath('metropolis',M_.dname);
OutputFolder = CheckPath('Output',M_.dname);
latexFolder = CheckPath('latex',M_.dname);
FileName = M_.fname;
record=load_last_mh_history_file(MetropolisFolder,FileName);
@ -86,7 +86,7 @@ end
if np
type = 'parameters';
if TeX
fid = TeXBegin(OutputFolder, M_.fname, 1, type);
fid = TeXBegin(latexFolder, M_.fname, 1, type);
end
skipline()
disp(type)
@ -94,7 +94,7 @@ if np
ip = nvx+nvn+ncx+ncn+1;
for i=1:np
if options_.mh_replic || (options_.load_mh_file && ~options_.load_results_after_load_mh)
Draws = GetAllPosteriorDraws(ip, FirstMhFile, FirstLine, TotalNumberOfMhFiles, NumberOfDraws, mh_nblck);
Draws = GetAllPosteriorDraws(M_.dname, M_.fname, ip, FirstMhFile, FirstLine, TotalNumberOfMhFiles, NumberOfDraws, mh_nblck);
[post_mean, post_median, post_var, hpd_interval, post_deciles, density] = posterior_moments(Draws, 1, options_.mh_conf_sig);
name = bayestopt_.name{ip};
oo_ = Filloo(oo_, name, type, post_mean, hpd_interval, post_median, post_var, post_deciles, density);
@ -103,7 +103,7 @@ if np
name = bayestopt_.name{ip};
[post_mean, hpd_interval, post_var] = Extractoo(oo_, name, type);
catch
Draws = GetAllPosteriorDraws(ip, FirstMhFile, FirstLine, TotalNumberOfMhFiles, NumberOfDraws, mh_nblck);
Draws = GetAllPosteriorDraws(M_.dname, M_.fname, ip, FirstMhFile, FirstLine, TotalNumberOfMhFiles, NumberOfDraws, mh_nblck);
[post_mean, post_median, post_var, hpd_interval, post_deciles, density] = posterior_moments(Draws, 1, options_.mh_conf_sig);
name = bayestopt_.name{ip};
oo_ = Filloo(oo_, name, type, post_mean, hpd_interval, post_median, post_var, post_deciles, density);
@ -129,7 +129,7 @@ end
if nvx
type = 'shocks_std';
if TeX
fid = TeXBegin(OutputFolder, FileName,2, 'standard deviation of structural shocks');
fid = TeXBegin(latexFolder, FileName,2, 'standard deviation of structural shocks');
end
ip = 1;
skipline()
@ -137,7 +137,7 @@ if nvx
disp(tit2)
for i=1:nvx
if options_.mh_replic || (options_.load_mh_file && ~options_.load_results_after_load_mh)
Draws = GetAllPosteriorDraws(ip, FirstMhFile, FirstLine, TotalNumberOfMhFiles, NumberOfDraws, mh_nblck);
Draws = GetAllPosteriorDraws(M_.dname, M_.fname, ip, FirstMhFile, FirstLine, TotalNumberOfMhFiles, NumberOfDraws, mh_nblck);
[post_mean, post_median, post_var, hpd_interval, post_deciles, density] = posterior_moments(Draws, 1, options_.mh_conf_sig);
k = estim_params_.var_exo(i,1);
name = M_.exo_names{k};
@ -149,7 +149,7 @@ if nvx
name = M_.exo_names{k};
[post_mean, hpd_interval, post_var] = Extractoo(oo_, name, type);
catch
Draws = GetAllPosteriorDraws(ip, FirstMhFile, FirstLine, TotalNumberOfMhFiles, NumberOfDraws, mh_nblck);
Draws = GetAllPosteriorDraws(M_.dname, M_.fname, ip, FirstMhFile, FirstLine, TotalNumberOfMhFiles, NumberOfDraws, mh_nblck);
[post_mean, post_median, post_var, hpd_interval, post_deciles, density] = ...
posterior_moments(Draws, 1, options_.mh_conf_sig);
k = estim_params_.var_exo(i,1);
@ -173,7 +173,7 @@ end
if nvn
type = 'measurement_errors_std';
if TeX
fid = TeXBegin(OutputFolder, FileName, 3, 'standard deviation of measurement errors');
fid = TeXBegin(latexFolder, FileName, 3, 'standard deviation of measurement errors');
end
skipline()
disp('standard deviation of measurement errors')
@ -181,7 +181,7 @@ if nvn
ip = nvx+1;
for i=1:nvn
if options_.mh_replic || (options_.load_mh_file && ~options_.load_results_after_load_mh)
Draws = GetAllPosteriorDraws(ip, FirstMhFile, FirstLine, TotalNumberOfMhFiles, NumberOfDraws, mh_nblck);
Draws = GetAllPosteriorDraws(M_.dname, M_.fname, ip, FirstMhFile, FirstLine, TotalNumberOfMhFiles, NumberOfDraws, mh_nblck);
[post_mean, post_median, post_var, hpd_interval, post_deciles, density] = posterior_moments(Draws, 1, options_.mh_conf_sig);
name = options_.varobs{estim_params_.nvn_observable_correspondence(i,1)};
oo_ = Filloo(oo_, name, type, post_mean, hpd_interval, post_median, post_var, post_deciles, density);
@ -190,7 +190,7 @@ if nvn
name = options_.varobs{estim_params_.nvn_observable_correspondence(i,1)};
[post_mean,hpd_interval,post_var] = Extractoo(oo_,name,type);
catch
Draws = GetAllPosteriorDraws(ip,FirstMhFile,FirstLine,TotalNumberOfMhFiles,NumberOfDraws, mh_nblck);
Draws = GetAllPosteriorDraws(M_.dname, M_.fname, ip,FirstMhFile,FirstLine,TotalNumberOfMhFiles,NumberOfDraws, mh_nblck);
[post_mean, post_median, post_var, hpd_interval, post_deciles, density] = posterior_moments(Draws,1,options_.mh_conf_sig);
name = options_.varobs{estim_params_.nvn_observable_correspondence(i,1)};
oo_ = Filloo(oo_,name,type,post_mean,hpd_interval,post_median,post_var,post_deciles,density);
@ -212,7 +212,7 @@ end
if ncx
type = 'shocks_corr';
if TeX
fid = TeXBegin(OutputFolder,FileName,4,'correlation of structural shocks');
fid = TeXBegin(latexFolder,FileName,4,'correlation of structural shocks');
end
skipline()
disp('correlation of shocks')
@ -220,7 +220,7 @@ if ncx
ip = nvx+nvn+1;
for i=1:ncx
if options_.mh_replic || (options_.load_mh_file && ~options_.load_results_after_load_mh)
Draws = GetAllPosteriorDraws(ip, FirstMhFile, FirstLine, TotalNumberOfMhFiles, NumberOfDraws, mh_nblck);
Draws = GetAllPosteriorDraws(M_.dname, M_.fname, ip, FirstMhFile, FirstLine, TotalNumberOfMhFiles, NumberOfDraws, mh_nblck);
[post_mean, post_median, post_var, hpd_interval, post_deciles, density] = posterior_moments(Draws,1,options_.mh_conf_sig);
k1 = estim_params_.corrx(i,1);
k2 = estim_params_.corrx(i,2);
@ -237,7 +237,7 @@ if ncx
NAME = sprintf('%s_%s', M_.exo_names{k1}, M_.exo_names{k2});
[post_mean,hpd_interval,post_var] = Extractoo(oo_, NAME, type);
catch
Draws = GetAllPosteriorDraws(ip, FirstMhFile, FirstLine, TotalNumberOfMhFiles, NumberOfDraws, mh_nblck);
Draws = GetAllPosteriorDraws(M_.dname, M_.fname, ip, FirstMhFile, FirstLine, TotalNumberOfMhFiles, NumberOfDraws, mh_nblck);
[post_mean, post_median, post_var, hpd_interval, post_deciles, density] = posterior_moments(Draws, 1, options_.mh_conf_sig);
k1 = estim_params_.corrx(i,1);
k2 = estim_params_.corrx(i,2);
@ -262,7 +262,7 @@ end
if ncn
type = 'measurement_errors_corr';
if TeX
fid = TeXBegin(OutputFolder, FileName, 5, 'correlation of measurement errors');
fid = TeXBegin(latexFolder, FileName, 5, 'correlation of measurement errors');
end
skipline()
disp('correlation of measurement errors')
@ -270,7 +270,7 @@ if ncn
ip = nvx+nvn+ncx+1;
for i=1:ncn
if options_.mh_replic || (options_.load_mh_file && ~options_.load_results_after_load_mh)
Draws = GetAllPosteriorDraws(ip,FirstMhFile,FirstLine,TotalNumberOfMhFiles,NumberOfDraws, mh_nblck);
Draws = GetAllPosteriorDraws(M_.dname, M_.fname, ip,FirstMhFile,FirstLine,TotalNumberOfMhFiles,NumberOfDraws, mh_nblck);
[post_mean, post_median, post_var, hpd_interval, post_deciles, density] = posterior_moments(Draws, 1, options_.mh_conf_sig);
k1 = estim_params_.corrn(i,1);
k2 = estim_params_.corrn(i,2);
@ -285,7 +285,7 @@ if ncn
NAME = sprintf('%s_%s', M_.endo_names{k1}, M_.endo_names{k2});
[post_mean,hpd_interval,post_var] = Extractoo(oo_, NAME, type);
catch
Draws = GetAllPosteriorDraws(ip, FirstMhFile, FirstLine, TotalNumberOfMhFiles, NumberOfDraws, mh_nblck);
Draws = GetAllPosteriorDraws(M_.dname, M_.fname, ip, FirstMhFile, FirstLine, TotalNumberOfMhFiles, NumberOfDraws, mh_nblck);
[post_mean, post_median, post_var, hpd_interval, post_deciles, density] = posterior_moments(Draws, 1, options_.mh_conf_sig);
k1 = estim_params_.corrn(i,1);
k2 = estim_params_.corrn(i,2);

View File

@ -33,7 +33,7 @@ function Herbst_Schorfheide_sampler(TargetFun,xparam1,mh_bounds,dataset_,dataset
% Then the comments write here can be used for all the other pairs of
% parallel functions and also for management functions.
% Copyright © 2006-2022 Dynare Team
% Copyright © 2006-2023 Dynare Team
%
% This file is part of Dynare.
%
@ -152,7 +152,7 @@ if TeX
NAMES = [];
TeXNAMES = [];
end
hh = dyn_figure(options_.nodisplay,'Name','Parameters Densities');
hh_fig = dyn_figure(options_.nodisplay,'Name','Parameters Densities');
for k=1:npar %min(nstar,npar-(plt-1)*nstar)
subplot(ceil(sqrt(npar)),floor(sqrt(npar)),k)
%kk = (plt-1)*nstar+k;
@ -171,7 +171,7 @@ for k=1:npar %min(nstar,npar-(plt-1)*nstar)
axis tight
drawnow
end
dyn_saveas(hh,[ M_.fname '_param_density' int2str(plt) ],options_.nodisplay,options_.graph_format);
dyn_saveas(hh_fig,[ M_.fname '_param_density' int2str(plt) ],options_.nodisplay,options_.graph_format);
if TeX && any(strcmp('eps',cellstr(options_.graph_format)))
% TeX eps loader file
fprintf(fidTeX,'\\begin{figure}[H]\n');

View File

@ -1,6 +1,6 @@
function MakeAllFigures(NumberOfPlots,Caption,FigureProperties,Info)
% Copyright © 2005-2017 Dynare Team
% Copyright © 2005-2023 Dynare Team
%
% This file is part of Dynare.
%
@ -97,45 +97,45 @@ for plt = 1:NumberOfPlots
subplot(nr,nc,plt)
hold on
for curve = 1:NumberOfCurves
hh = plot(x{curve},y{curve});
hh_fig = plot(x{curve},y{curve});
if strcmpi(PltType{curve},'PriorDensity')
set(hh,'Color',[0.7 0.7 0.7],'LineStyle','-','LineWidth',2)
set(hh_fig,'Color',[0.7 0.7 0.7],'LineStyle','-','LineWidth',2)
%
%
elseif strcmpi(PltType{curve},'DensityEstimate')
set(hh,'Color','k','LineStyle','-','LineWidth',2)
set(hh_fig,'Color','k','LineStyle','-','LineWidth',2)
%
%
elseif strcmpi(PltType{curve},'ModeEstimate')
set(hh,'Color','g','LineStyle','--','LineWidth',2)
set(hh_fig,'Color','g','LineStyle','--','LineWidth',2)
%
%
elseif strcmpi(PltType{curve},'SmoothVariable')
set(hh,'Color','k','LineStyle','-','LineWidth',2)
set(hh_fig,'Color','k','LineStyle','-','LineWidth',2)
%
%
elseif strcmpi(PltType{curve},'Deciles')
set(hh,'Color','g','LineStyle','-','LineWidth',1)
set(hh_fig,'Color','g','LineStyle','-','LineWidth',1)
%
%
elseif strcmpi(PltType{curve},'Forecasts')
set(hh,'Color','','LineStyle','-','LineWidth',2)
set(hh_fig,'Color','','LineStyle','-','LineWidth',2)
%
%
elseif strcmpi(PltType{curve},'ForecastsHPD')
set(hh,'Color','k','LineStyle','-','LineWidth',1)
set(hh_fig,'Color','k','LineStyle','-','LineWidth',1)
%
%
elseif strcmpi(PltType{curve},'ForecastsDeciles')
set(hh,'Color','g','LineStyle','-','LineWidth',1)
set(hh_fig,'Color','g','LineStyle','-','LineWidth',1)
%
%
elseif strcmpi(PltType{curve},'DiagnosticWithin')
set(hh,'Color','b','LineStyle','-','LineWidth',2)
set(hh_fig,'Color','b','LineStyle','-','LineWidth',2)
%
%
elseif strcmpi(PltType{curve},'DiagnosticPooled')
set(hh,'Color','r','LineStyle','-','LineWidth',2)
set(hh_fig,'Color','r','LineStyle','-','LineWidth',2)
%
%
end

View File

@ -4,19 +4,19 @@ function oo_ = PlotPosteriorDistributions(estim_params_, M_, options_, bayestopt
% plots posterior distributions
%
% INPUTS
% estim_params_ [structure]
% M_ [structure]
% options_ [structure]
% bayestopt_ [structure]
% oo_ [structure]
% estim_params_ [structure] information on estimated paramters
% M_ [structure] information on model
% options_ [structure] information on options
% bayestopt_ [structure] information on priors
% oo_ [structure] results
%
% OUTPUTS
% oo_ [structure]
% oo_ [structure] updated results
%
% SPECIAL REQUIREMENTS
% none
% Copyright © 2005-2018 Dynare Team
% Copyright © 2005-2023 Dynare Team
%
% This file is part of Dynare.
%
@ -32,8 +32,8 @@ function oo_ = PlotPosteriorDistributions(estim_params_, M_, options_, bayestopt
%
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
OutputDirectoryName = CheckPath('Output',M_.dname);
latexDirectoryName = CheckPath('latex',M_.dname);
graphDirectoryName = CheckPath('graphs',M_.dname);
TeX = options_.TeX;
nblck = options_.mh_nblck;
@ -50,7 +50,7 @@ nn = sqrt(MaxNumberOfPlotPerFigure);
figurename = 'Priors and posteriors';
if TeX && any(strcmp('eps',cellstr(options_.graph_format)))
fidTeX = fopen([OutputDirectoryName '/' M_.fname '_PriorsAndPosteriors.tex'],'w');
fidTeX = fopen([latexDirectoryName filesep M_.fname '_PriorsAndPosteriors.tex'],'w');
fprintf(fidTeX,'%% TeX eps-loader file generated by PlotPosteriorDistributions.m (Dynare).\n');
fprintf(fidTeX,['%% ' datestr(now,0) '\n']);
fprintf(fidTeX,' \n');
@ -63,7 +63,7 @@ for i=1:npar
subplotnum = subplotnum+1;
if subplotnum == 1
figunumber = figunumber+1;
hfig=dyn_figure(options_.nodisplay, 'Name', figurename);
hh_fig=dyn_figure(options_.nodisplay, 'Name', figurename);
end
[nam,texnam] = get_the_name(i, TeX, M_, estim_params_, options_);
[x2, f2, abscissa, dens, binf2, bsup2] = draw_prior_density(i, bayestopt_);
@ -128,8 +128,8 @@ for i=1:npar
borneinf = min(binf1, binf2);
bornesup = max(bsup1, bsup2);
subplot(nn, nn, subplotnum)
hh = plot(x2, f2, '-k', 'linewidth', 2);
set(hh, 'color', [0.7 0.7 0.7]);
hh_plt = plot(x2, f2, '-k', 'linewidth', 2);
set(hh_plt, 'color', [0.7 0.7 0.7]);
hold on;
plot(x1, f1, '-k', 'linewidth', 2);
if ~options_.mh_posterior_mode_estimation
@ -145,12 +145,12 @@ for i=1:npar
hold off
drawnow
if subplotnum == MaxNumberOfPlotPerFigure || i == npar
dyn_saveas(hfig,[OutputDirectoryName '/' M_.fname '_PriorsAndPosteriors' int2str(figunumber)], options_.nodisplay, options_.graph_format);
dyn_saveas(hh_fig,[graphDirectoryName filesep M_.fname '_PriorsAndPosteriors' int2str(figunumber)], options_.nodisplay, options_.graph_format);
if TeX && any(strcmp('eps', cellstr(options_.graph_format)))
fprintf(fidTeX, '\\begin{figure}[H]\n');
fprintf(fidTeX, '\\centering\n');
fprintf(fidTeX, '\\includegraphics[width=%2.2f\\textwidth]{%s/%s_PriorsAndPosteriors%s}\n', ...
options_.figures.textwidth*min(subplotnum/nn,1), OutputDirectoryName, M_.fname, int2str(figunumber));
options_.figures.textwidth*min(subplotnum/nn,1), graphDirectoryName, M_.fname, int2str(figunumber));
fprintf(fidTeX,'\\caption{Priors and posteriors.}');
fprintf(fidTeX,'\\label{Fig:PriorsAndPosteriors:%s}\n', int2str(figunumber));
fprintf(fidTeX,'\\end{figure}\n');

View File

@ -1,9 +1,10 @@
function PosteriorIRF(type)
function PosteriorIRF(type,dispString)
% Builds posterior IRFs after the MH algorithm.
%
% INPUTS
% o type [char] string specifying the joint density of the
% deep parameters ('prior','posterior').
% o dispString [char] string to display in the console.
%
% OUTPUTS
% None (oo_ and plots).
@ -36,8 +37,6 @@ function PosteriorIRF(type)
global options_ estim_params_ oo_ M_ bayestopt_ dataset_ dataset_info
dispString = 'Estimation::mcmc';
% Set the number of periods
if isempty(options_.irf) || ~options_.irf
options_.irf = 40;

View File

@ -30,7 +30,7 @@ function myoutput=PosteriorIRF_core2(myinputs,fpar,npar,whoiam,ThisMatlab)
% SPECIAL REQUIREMENTS.
% None.
%
% Copyright © 2006-2018 Dynare Team
% Copyright © 2006-2023 Dynare Team
%
% This file is part of Dynare.
%
@ -103,12 +103,12 @@ for i=fpar:npar
if max(abs(MeanIRF(:,j,i))) >= options_.impulse_responses.plot_threshold
subplotnum = subplotnum+1;
if subplotnum == 1 && options_.relative_irf
hh = dyn_figure(options_.nodisplay,'Name',['Relative response to orthogonalized shock to ' tit{i}]);
hh_fig = dyn_figure(options_.nodisplay,'Name',['Relative response to orthogonalized shock to ' tit{i}]);
elseif subplotnum == 1 && ~options_.relative_irf
hh = dyn_figure(options_.nodisplay,'Name',['Orthogonalized shock to ' tit{i}]);
hh_fig = dyn_figure(options_.nodisplay,'Name',['Orthogonalized shock to ' tit{i}]);
end
set(0,'CurrentFigure',hh)
set(0,'CurrentFigure',hh_fig)
subplot(nn,nn,subplotnum);
if ~MAX_nirfs_dsgevar
if ~isnan(min(HPDIRF(:,1,j,i)))
@ -155,7 +155,7 @@ for i=fpar:npar
if subplotnum == MaxNumberOfPlotPerFigure || (j == nvar && subplotnum> 0)
figunumber = figunumber+1;
dyn_saveas(hh,[DirectoryName '/' M_.fname '_Bayesian_IRF_' tit{i} '_' int2str(figunumber)],options_.nodisplay,options_.graph_format);
dyn_saveas(hh_fig,[DirectoryName '/' M_.fname '_Bayesian_IRF_' tit{i} '_' int2str(figunumber)],options_.nodisplay,options_.graph_format);
if RemoteFlag==1
OutputFileName = [OutputFileName; {[DirectoryName,filesep], [M_.fname '_Bayesian_IRF_' deblank(tit(i,:)) '_' int2str(figunumber) '.*']}];
end

View File

@ -19,7 +19,7 @@ function [oo_] = UnivariateSpectralDensity(M_,oo_,options_,var_list)
% Adapted from th_autocovariances.m.
% Copyright © 2006-2020 Dynare Team
% Copyright © 2006-2023 Dynare Team
%
% This file is part of Dynare.
%
@ -155,12 +155,12 @@ if ~options_.nograph
end
for i= 1:nvar
hh = dyn_figure(options_.nodisplay,'Name',['Spectral Density of ' M_.endo_names{ivar(i)} '.']);
hh_fig = dyn_figure(options_.nodisplay,'Name',['Spectral Density of ' M_.endo_names{ivar(i)} '.']);
plot(freqs,f(i,:),'-k','linewidth',2)
xlabel('0 \leq \omega \leq \pi')
ylabel('f(\omega)')
box on
axis tight
dyn_saveas(hh,[M_.dname ,filesep,'graphs', filesep, 'SpectralDensity_' M_.endo_names{ivar(i)}],options_.nodisplay,options_.graph_format)
dyn_saveas(hh_fig,[M_.dname ,filesep,'graphs', filesep, 'SpectralDensity_' M_.endo_names{ivar(i)}],options_.nodisplay,options_.graph_format)
end
end

View File

@ -20,7 +20,7 @@ function Scale = calibrate_mh_scale_parameter(ObjectiveFunction, CovarianceMatri
% Copyright © 2020-2021 Dynare Team
% Copyright © 2020-2023 Dynare Team
%
% This file is part of Dynare.
%
@ -38,8 +38,8 @@ function Scale = calibrate_mh_scale_parameter(ObjectiveFunction, CovarianceMatri
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
% Fire up the wait bar
hh = dyn_waitbar(0,'Tuning of the scale parameter...');
set(hh,'Name','Tuning of the scale parameter.');
hh_fig = dyn_waitbar(0,'Tuning of the scale parameter...');
set(hh_fig,'Name','Tuning of the scale parameter.');
% Intilialize various counters.
j = 1; jj = 1; isux = 0; jsux = 0; i = 0;
@ -100,7 +100,7 @@ while j<=options.maxiter
prtfrc = j/options.maxiter;
% Update the waitbar
if ~mod(j, 10)
dyn_waitbar(prtfrc, hh, sprintf('Acceptance ratio [during last %u]: %f [%f]', options.stepsize, isux/j, jsux/jj));
dyn_waitbar(prtfrc, hh_fig, sprintf('Acceptance ratio [during last %u]: %f [%f]', options.stepsize, isux/j, jsux/jj));
end
% Adjust the value of the scale parameter.
if ~mod(j, options.stepsize)
@ -135,4 +135,4 @@ while j<=options.maxiter
jj = jj + 1;
end
dyn_waitbar_close(hh);
dyn_waitbar_close(hh_fig);

View File

@ -1,5 +1,5 @@
function [posterior_sampler_options, options_, bayestopt_] = check_posterior_sampler_options(posterior_sampler_options, fname, dname, options_, bounds, bayestopt_)
% function [posterior_sampler_options, options_, bayestopt_] = check_posterior_sampler_options(posterior_sampler_options, fname, dname, options_, bounds, bayestopt_)
function [posterior_sampler_options, options_, bayestopt_] = check_posterior_sampler_options(posterior_sampler_options, fname, dname, options_, bounds, bayestopt_,outputFolderName)
% function [posterior_sampler_options, options_, bayestopt_] = check_posterior_sampler_options(posterior_sampler_options, fname, dname, options_, bounds, bayestopt_,outputFolderName)
% initialization of posterior samplers
%
% INPUTS
@ -14,6 +14,7 @@ function [posterior_sampler_options, options_, bayestopt_] = check_posterior_sam
% posterior_sampler_options: checked posterior sampler options
% options_: structure storing the options
% bayestopt_: structure storing information about priors
% outputFolderName: string of folder to store mat files
%
% SPECIAL REQUIREMENTS
% none
@ -35,6 +36,9 @@ function [posterior_sampler_options, options_, bayestopt_] = check_posterior_sam
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
if nargin < 7
outputFolderName = 'Output';
end
init=0;
if isempty(posterior_sampler_options)
@ -392,7 +396,7 @@ if ~strcmp(posterior_sampler_options.posterior_sampling_method,'slice')
end
if options_.load_mh_file && posterior_sampler_options.use_mh_covariance_matrix
[~, invhess] = compute_mh_covariance_matrix(bayestopt_,fname,dname);
[~, invhess] = compute_mh_covariance_matrix(bayestopt_,fname,dname,outputFolderName);
posterior_sampler_options.invhess = invhess;
end

View File

@ -1,5 +1,5 @@
function [posterior_mean,posterior_covariance,posterior_mode,posterior_kernel_at_the_mode] = compute_mh_covariance_matrix(bayestopt_,fname,dname)
% function [posterior_mean,posterior_covariance,posterior_mode,posterior_kernel_at_the_mode] = compute_mh_covariance_matrix(bayestopt_,fname,dname)
function [posterior_mean,posterior_covariance,posterior_mode,posterior_kernel_at_the_mode] = compute_mh_covariance_matrix(bayestopt_,fname,dname,outputFolderName)
% function [posterior_mean,posterior_covariance,posterior_mode,posterior_kernel_at_the_mode] = compute_mh_covariance_matrix(bayestopt_,fname,dname,outputFolderName)
% Estimation of the posterior covariance matrix, posterior mean, posterior mode and evaluation of the posterior kernel at the
% estimated mode, using the draws from a metropolis-hastings. The estimated posterior mode and covariance matrix are saved in
% a file <fname>_mh_mode.mat.
@ -8,6 +8,7 @@ function [posterior_mean,posterior_covariance,posterior_mode,posterior_kernel_at
% o bayestopt_ [struct] characterizing priors
% o fname [string] name of model
% o dname [string] name of directory with metropolis folder
% o outputFolderName [string] name of directory to store results
%
% OUTPUTS
% o posterior_mean [double] (n*1) vector, posterior expectation of the parameters.
@ -34,6 +35,9 @@ function [posterior_mean,posterior_covariance,posterior_mode,posterior_kernel_at
%
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
if nargin < 4
outputFolderName = 'Output';
end
MetropolisFolder = CheckPath('metropolis',dname);
BaseName = [MetropolisFolder filesep fname];
@ -70,4 +74,4 @@ hh = inv(posterior_covariance);
fval = posterior_kernel_at_the_mode;
parameter_names = bayestopt_.name;
save([dname filesep 'Output' filesep fname '_mh_mode.mat'],'xparam1','hh','fval','parameter_names');
save([dname filesep outputFolderName filesep fname '_mh_mode.mat'],'xparam1','hh','fval','parameter_names');

View File

@ -33,8 +33,8 @@ function oo_ = mcmc_diagnostics(options_, estim_params_, M_, oo_)
%
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
OutputFolder = CheckPath('Output',M_.dname);
graphFolder = CheckPath('graphs',M_.dname);
latexFolder = CheckPath('latex',M_.dname);
MetropolisFolder = CheckPath('metropolis',M_.dname);
ModelName = M_.fname;
@ -79,7 +79,7 @@ for jj = 1:npar
par_name_temp = get_the_name(jj, options_.TeX, M_, estim_params_, options_);
param_name = vertcat(param_name, par_name_temp);
end
Draws = GetAllPosteriorDraws(jj, FirstMhFile, FirstLine, TotalNumberOfMhFiles, NumberOfDraws, nblck);
Draws = GetAllPosteriorDraws(M_.dname, M_.fname, jj, FirstMhFile, FirstLine, TotalNumberOfMhFiles, NumberOfDraws, nblck);
Draws = reshape(Draws, [NumberOfDraws nblck]);
Nc = min(1000, NumberOfDraws/2);
for ll = 1:nblck
@ -191,11 +191,11 @@ if nblck == 1 % Brooks and Gelman tests need more than one block
Raftery_Lewis_q=options_.convergence.rafterylewis.qrs(1);
Raftery_Lewis_r=options_.convergence.rafterylewis.qrs(2);
Raftery_Lewis_s=options_.convergence.rafterylewis.qrs(3);
oo_.Raftery_Lewis = raftery_lewis(x2,Raftery_Lewis_q,Raftery_Lewis_r,Raftery_Lewis_s);
oo_.Raftery_Lewis.parameter_names=param_name;
oo_.convergence.raftery_lewis = raftery_lewis(x2,Raftery_Lewis_q,Raftery_Lewis_r,Raftery_Lewis_s);
oo_.convergence.raftery_lewis.parameter_names=param_name;
my_title=sprintf('Raftery/Lewis (1992) Convergence Diagnostics, based on quantile q=%4.3f with precision r=%4.3f with probability s=%4.3f.',Raftery_Lewis_q,Raftery_Lewis_r,Raftery_Lewis_s);
headers = {'Variables'; 'M (burn-in)'; 'N (req. draws)'; 'N+M (total draws)'; 'k (thinning)'};
raftery_data_mat=[oo_.Raftery_Lewis.M_burn,oo_.Raftery_Lewis.N_prec,oo_.Raftery_Lewis.N_total,oo_.Raftery_Lewis.k_thin];
raftery_data_mat=[oo_.convergence.raftery_lewis.M_burn,oo_.convergence.raftery_lewis.N_prec,oo_.convergence.raftery_lewis.N_total,oo_.convergence.raftery_lewis.k_thin];
raftery_data_mat=[raftery_data_mat;max(raftery_data_mat)];
labels_Raftery_Lewis = vertcat(param_name, 'Maximum');
lh = cellofchararraymaxlength(labels_Raftery_Lewis)+2;
@ -228,7 +228,7 @@ if NumberOfDraws < Origin
end
if TeX && any(strcmp('eps',cellstr(options_.graph_format)))
fidTeX = fopen([OutputFolder '/' ModelName '_UnivariateDiagnostics.tex'],'w');
fidTeX = fopen([latexFolder '/' ModelName '_UnivariateDiagnostics.tex'],'w');
fprintf(fidTeX,'%% TeX eps-loader file generated by mcmc_diagnostics.m (Dynare).\n');
fprintf(fidTeX,['%% ' datestr(now,0) '\n']);
fprintf(fidTeX,' \n');
@ -277,7 +277,7 @@ clear pmet temp moyenne CSUP CINF csup cinf n linea iter tmp;
pages = floor(npar/npardisp); % changed from 3 to npardisp
k = 0;
for i = 1:pages
h=dyn_figure(options_.nodisplay,'Name','MCMC univariate convergence diagnostic (Brooks and Gelman,1998)');
hh_fig = dyn_figure(options_.nodisplay,'Name','MCMC univariate convergence diagnostic (Brooks and Gelman,1998)');
boxplot = 1;
for j = 1:npardisp % Loop over parameters %npardisp instead of 3
k = k+1;
@ -311,11 +311,11 @@ for i = 1:pages
boxplot = boxplot + 1;
end
end
dyn_saveas(h,[OutputFolder '/' ModelName '_udiag' int2str(i)],options_.nodisplay,options_.graph_format);
dyn_saveas(hh_fig,[graphFolder '/' ModelName '_udiag' int2str(i)],options_.nodisplay,options_.graph_format);
if TeX && any(strcmp('eps',cellstr(options_.graph_format)))
fprintf(fidTeX,'\\begin{figure}[H]\n');
fprintf(fidTeX,'\\centering \n');
fprintf(fidTeX,'\\includegraphics[width=%2.2f\\textwidth]{%s_udiag%s}\n',options_.figures.textwidth*min((boxplot-1)/3,1),[OutputFolder '/' ModelName],int2str(i));
fprintf(fidTeX,'\\includegraphics[width=%2.2f\\textwidth]{%s_udiag%s}\n',options_.figures.textwidth*min((boxplot-1)/3,1),[graphFolder '/' ModelName],int2str(i));
fprintf(fidTeX,'\\caption{Univariate convergence diagnostics for the Metropolis-Hastings.\n');
fprintf(fidTeX,'The first, second and third columns are respectively the criteria based on\n');
fprintf(fidTeX,'the eighty percent interval, the second and third moments.}');
@ -333,7 +333,7 @@ if reste
nr = npardisp;
nc = 3;
end
h = dyn_figure(options_.nodisplay,'Name','MCMC univariate convergence diagnostic (Brooks and Gelman, 1998)');
hh_fig = dyn_figure(options_.nodisplay,'Name','MCMC univariate convergence diagnostic (Brooks and Gelman, 1998)');
boxplot = 1;
for j = 1:reste
k = k+1;
@ -375,11 +375,11 @@ if reste
boxplot = boxplot + 1;
end
end
dyn_saveas(h,[ OutputFolder '/' ModelName '_udiag' int2str(pages+1)],options_.nodisplay,options_.graph_format);
dyn_saveas(hh_fig,[ graphFolder '/' ModelName '_udiag' int2str(pages+1)],options_.nodisplay,options_.graph_format);
if TeX && any(strcmp('eps',cellstr(options_.graph_format)))
fprintf(fidTeX,'\\begin{figure}[H]\n');
fprintf(fidTeX,'\\centering \n');
fprintf(fidTeX,'\\includegraphics[width=%2.2f\\textwidth]{%s_udiag%s}\n',options_.figures.textwidth*min((boxplot-1)/nc,1),[OutputFolder '/' ModelName],int2str(pages+1));
fprintf(fidTeX,'\\includegraphics[width=%2.2f\\textwidth]{%s_udiag%s}\n',options_.figures.textwidth*min((boxplot-1)/nc,1),[graphFolder '/' ModelName],int2str(pages+1));
if reste == 2
fprintf(fidTeX,'\\caption{Univariate convergence diagnostics for the Metropolis-Hastings.\n');
fprintf(fidTeX,'The first, second and third columns are respectively the criteria based on\n');
@ -401,7 +401,7 @@ clear UDIAG;
% Multivariate diagnostic.
%
if TeX && any(strcmp('eps',cellstr(options_.graph_format)))
fidTeX = fopen([OutputFolder '/' ModelName '_MultivariateDiagnostics.tex'],'w');
fidTeX = fopen([latexFolder '/' ModelName '_MultivariateDiagnostics.tex'],'w');
fprintf(fidTeX,'%% TeX eps-loader file generated by mcmc_diagnostics.m (Dynare).\n');
fprintf(fidTeX,['%% ' datestr(now,0) '\n']);
fprintf(fidTeX,' \n');
@ -445,7 +445,7 @@ for iter = Origin:StepSize:NumberOfDraws
end
MDIAG(:,[2 4 6],:) = MDIAG(:,[2 4 6],:)/nblck;
h = dyn_figure(options_.nodisplay,'Name','Multivariate convergence diagnostic');
hh_fig = dyn_figure(options_.nodisplay,'Name','Multivariate convergence diagnostic');
boxplot = 1;
for crit = 1:3
if crit == 1
@ -470,12 +470,12 @@ for crit = 1:3
title(namnam,'Interpreter','none');
boxplot = boxplot + 1;
end
dyn_saveas(h,[ OutputFolder '/' ModelName '_mdiag'],options_.nodisplay,options_.graph_format);
dyn_saveas(hh_fig,[ graphFolder '/' ModelName '_mdiag'],options_.nodisplay,options_.graph_format);
if TeX && any(strcmp('eps',cellstr(options_.graph_format)))
fprintf(fidTeX,'\\begin{figure}[H]\n');
fprintf(fidTeX,'\\centering \n');
fprintf(fidTeX,'\\includegraphics[width=0.8\\textwidth]{%s_mdiag}\n',[OutputFolder '/' ModelName]);
fprintf(fidTeX,'\\includegraphics[width=0.8\\textwidth]{%s_mdiag}\n',[graphFolder '/' ModelName]);
fprintf(fidTeX,'\\caption{Multivariate convergence diagnostics for the Metropolis-Hastings.\n');
fprintf(fidTeX,'The first, second and third rows are respectively the criteria based on\n');
fprintf(fidTeX,'the eighty percent interval, the second and third moments. The different \n');

View File

@ -20,7 +20,7 @@ function oo_=display_estimation_results_table(xparam1,stdh,M_,options_,estim_par
% SPECIAL REQUIREMENTS
% None.
% Copyright © 2014-2018 Dynare Team
% Copyright © 2014-2023 Dynare Team
%
% This file is part of Dynare.
%
@ -177,11 +177,11 @@ if any(xparam1(1:nvx+nvn)<0)
warning(sprintf('Some estimated standard deviations are negative.\n Dynare internally works with variances so that the sign does not matter.\n Nevertheless, it is recommended to impose either prior restrictions (Bayesian Estimation)\n or a lower bound (ML) to assure positive values.'))
end
OutputDirectoryName = CheckPath('Output',M_.dname);
latexDirectoryName = CheckPath('latex',M_.dname);
if any(bayestopt_.pshape > 0) && options_.TeX %% Bayesian estimation (posterior mode) Latex output
if np
filename = [OutputDirectoryName '/' M_.fname '_Posterior_Mode_1.tex'];
filename = [latexDirectoryName '/' M_.fname '_Posterior_Mode_1.tex'];
fidTeX = fopen(filename,'w');
TeXBegin_Bayesian(fidTeX,1,'parameters')
ip = nvx+nvn+ncx+ncn+1;
@ -198,7 +198,7 @@ if any(bayestopt_.pshape > 0) && options_.TeX %% Bayesian estimation (posterior
TeXEnd(fidTeX)
end
if nvx
TeXfile = [OutputDirectoryName '/' M_.fname '_Posterior_Mode_2.tex'];
TeXfile = [latexDirectoryName '/' M_.fname '_Posterior_Mode_2.tex'];
fidTeX = fopen(TeXfile,'w');
TeXBegin_Bayesian(fidTeX,2,'standard deviation of structural shocks')
ip = 1;
@ -216,7 +216,7 @@ if any(bayestopt_.pshape > 0) && options_.TeX %% Bayesian estimation (posterior
TeXEnd(fidTeX)
end
if nvn
TeXfile = [OutputDirectoryName '/' M_.fname '_Posterior_Mode_3.tex'];
TeXfile = [latexDirectoryName '/' M_.fname '_Posterior_Mode_3.tex'];
fidTeX = fopen(TeXfile,'w');
TeXBegin_Bayesian(fidTeX,3,'standard deviation of measurement errors')
ip = nvx+1;
@ -234,7 +234,7 @@ if any(bayestopt_.pshape > 0) && options_.TeX %% Bayesian estimation (posterior
TeXEnd(fidTeX)
end
if ncx
TeXfile = [OutputDirectoryName '/' M_.fname '_Posterior_Mode_4.tex'];
TeXfile = [latexDirectoryName '/' M_.fname '_Posterior_Mode_4.tex'];
fidTeX = fopen(TeXfile,'w');
TeXBegin_Bayesian(fidTeX,4,'correlation of structural shocks')
ip = nvx+nvn+1;
@ -253,7 +253,7 @@ if any(bayestopt_.pshape > 0) && options_.TeX %% Bayesian estimation (posterior
TeXEnd(fidTeX)
end
if ncn
TeXfile = [OutputDirectoryName '/' M_.fname '_Posterior_Mode_5.tex'];
TeXfile = [latexDirectoryName '/' M_.fname '_Posterior_Mode_5.tex'];
fidTeX = fopen(TeXfile,'w');
TeXBegin_Bayesian(fidTeX,5,'correlation of measurement errors')
ip = nvx+nvn+ncx+1;
@ -273,7 +273,7 @@ if any(bayestopt_.pshape > 0) && options_.TeX %% Bayesian estimation (posterior
end
elseif all(bayestopt_.pshape == 0) && options_.TeX %% MLE and GMM Latex output
if np
filename = [OutputDirectoryName '/' M_.fname '_' LaTeXtitle '_Mode_1.tex'];
filename = [latexDirectoryName '/' M_.fname '_' LaTeXtitle '_Mode_1.tex'];
fidTeX = fopen(filename, 'w');
TeXBegin_ML(fidTeX, 1, 'parameters', table_title, LaTeXtitle)
ip = nvx+nvn+ncx+ncn+1;
@ -288,7 +288,7 @@ elseif all(bayestopt_.pshape == 0) && options_.TeX %% MLE and GMM Latex output
TeXEnd(fidTeX)
end
if nvx
filename = [OutputDirectoryName '/' M_.fname '_' LaTeXtitle '_Mode_2.tex'];
filename = [latexDirectoryName '/' M_.fname '_' LaTeXtitle '_Mode_2.tex'];
fidTeX = fopen(filename, 'w');
TeXBegin_ML(fidTeX, 2, 'standard deviation of structural shocks', table_title, LaTeXtitle)
ip = 1;
@ -304,7 +304,7 @@ elseif all(bayestopt_.pshape == 0) && options_.TeX %% MLE and GMM Latex output
TeXEnd(fidTeX)
end
if nvn
filename = [OutputDirectoryName '/' M_.fname '_' LaTeXtitle '_Mode_3.tex'];
filename = [latexDirectoryName '/' M_.fname '_' LaTeXtitle '_Mode_3.tex'];
fidTeX = fopen(filename, 'w');
TeXBegin_ML(fidTeX, 3, 'standard deviation of measurement errors', table_title, LaTeXtitle)
ip = nvx+1;
@ -320,7 +320,7 @@ elseif all(bayestopt_.pshape == 0) && options_.TeX %% MLE and GMM Latex output
TeXEnd(fidTeX)
end
if ncx
filename = [OutputDirectoryName '/' M_.fname '_' LaTeXtitle '_Mode_4.tex'];
filename = [latexDirectoryName '/' M_.fname '_' LaTeXtitle '_Mode_4.tex'];
fidTeX = fopen(filename, 'w');
TeXBegin_ML(fidTeX, 4, 'correlation of structural shocks', table_title,LaTeXtitle)
ip = nvx+nvn+1;
@ -337,7 +337,7 @@ elseif all(bayestopt_.pshape == 0) && options_.TeX %% MLE and GMM Latex output
TeXEnd(fidTeX)
end
if ncn
filename = [OutputDirectoryName '/' M_.fname '_' LaTeXtitle '_Mode_5.tex'];
filename = [latexDirectoryName '/' M_.fname '_' LaTeXtitle '_Mode_5.tex'];
fidTeX = fopen(filename, 'w');
TeXBegin_ML(fidTeX, 5, 'correlation of measurement errors', table_title, LaTeXtitle)
ip = nvx+nvn+ncx+1;

View File

@ -12,7 +12,7 @@ function oo_recursive_=dynare_estimation(var_list,dname)
% SPECIAL REQUIREMENTS
% none
% Copyright © 2003-2021 Dynare Team
% Copyright © 2003-2023 Dynare Team
%
% This file is part of Dynare.
%
@ -164,7 +164,7 @@ if nnobs > 1 && horizon > 0
for i = 1:length(var_list)
if mod(i,nstar) == 1
plot_index=plot_index+1;
hfig = dyn_figure(options_.nodisplay,'Name',['Out of sample forecasts (',num2str(plot_index),')']);
hh_fig = dyn_figure(options_.nodisplay,'Name',['Out of sample forecasts (',num2str(plot_index),')']);
m = 1;
end
subplot(nr,nc,m)
@ -221,7 +221,7 @@ if nnobs > 1 && horizon > 0
xlim([nobs(1)-offsetx nobs(end)+horizon])
m = m + 1;
if mod(i+1,nstar) == 1 || i==length(var_list)
dyn_saveas(hfig,[M_.dname,filesep,'graphs',filesep M_.fname '_RecursiveForecasts_' int2str(plot_index)],options_.nodisplay,options_.graph_format);
dyn_saveas(hh_fig,[M_.dname,filesep,'graphs',filesep M_.fname '_RecursiveForecasts_' int2str(plot_index)],options_.nodisplay,options_.graph_format);
end
end
end

View File

@ -309,7 +309,8 @@ end
if options_.mode_check.status && ~options_.mh_posterior_mode_estimation
ana_deriv_old = options_.analytic_derivation;
options_.analytic_derivation = 0;
mode_check(objective_function,xparam1,hh,dataset_,dataset_info,options_,M_,estim_params_,bayestopt_,bounds,oo_);
mode_check(objective_function,xparam1,hh,options_,M_,estim_params_,bayestopt_,bounds,false,...
dataset_, dataset_info, options_, M_, estim_params_, bayestopt_, bounds,oo_);
options_.analytic_derivation = ana_deriv_old;
end
@ -411,12 +412,12 @@ if (any(bayestopt_.pshape >0 ) && options_.mh_replic) || ...
if options_.mh_replic
ana_deriv_old = options_.analytic_derivation;
options_.analytic_derivation = 0;
posterior_sampler(objective_function,posterior_sampler_options.proposal_distribution,xparam1,posterior_sampler_options,bounds,dataset_,dataset_info,options_,M_,estim_params_,bayestopt_,oo_);
posterior_sampler(objective_function,posterior_sampler_options.proposal_distribution,xparam1,posterior_sampler_options,bounds,dataset_,dataset_info,options_,M_,estim_params_,bayestopt_,oo_,dispString);
options_.analytic_derivation = ana_deriv_old;
end
end
%% Here I discard first mh_drop percent of the draws:
CutSample(M_, options_, estim_params_);
CutSample(M_, options_, dispString);
if options_.mh_posterior_mode_estimation
[~,~,posterior_mode,~] = compute_mh_covariance_matrix(bayestopt_,M_.fname,M_.dname);
oo_=fill_mh_mode(posterior_mode',NaN(length(posterior_mode),1),M_,options_,estim_params_,bayestopt_,oo_,'posterior');
@ -475,7 +476,7 @@ if (any(bayestopt_.pshape >0 ) && options_.mh_replic) || ...
if error_flag
error('%s: I cannot compute the posterior IRFs!',dispString)
end
PosteriorIRF('posterior');
PosteriorIRF('posterior',dispString);
end
if options_.moments_varendo
if error_flag
@ -507,7 +508,7 @@ if (any(bayestopt_.pshape >0 ) && options_.mh_replic) || ...
error('%s: I cannot compute the posterior statistics!',dispString)
end
if options_.order==1 && ~options_.particle.status
prior_posterior_statistics('posterior',dataset_,dataset_info); %get smoothed and filtered objects and forecasts
prior_posterior_statistics('posterior',dataset_,dataset_info,dispString); %get smoothed and filtered objects and forecasts
else
error('%s: Particle Smoothers are not yet implemented.',dispString)
end

View File

@ -410,9 +410,9 @@ if options_gsa.rmse
end
end
prior_posterior_statistics('gsa',dataset_, dataset_info);
prior_posterior_statistics('gsa',dataset_, dataset_info,'gsa::mcmc');
if options_.bayesian_irf
PosteriorIRF('gsa');
PosteriorIRF('gsa','gsa::mcmc');
end
options_gsa.load_rmse=0;
% else

View File

@ -15,7 +15,7 @@ function dyntable(options_, title, headers, labels, values, label_width, val_wid
% OUTPUTS
% none
% Copyright © 2002-2022 Dynare Team
% Copyright © 2002-2023 Dynare Team
%
% This file is part of Dynare.
%
@ -73,11 +73,11 @@ if nargin==9
end
if length(headers) > 0
hh = sprintf(label_format_leftbound , headers{1});
hh_tbl = sprintf(label_format_leftbound , headers{1});
for i=2:length(headers)
hh = [hh sprintf(header_string_format, headers{i})];
hh_tbl = [hh_tbl sprintf(header_string_format, headers{i})];
end
disp(hh)
disp(hh_tbl)
end
for i=1:size(values,1)

View File

@ -19,7 +19,7 @@ function [ts, DynareResults] = extended_path(initialconditions, samplesize, exog
%
% SPECIAL REQUIREMENTS
% Copyright © 2009-2020 Dynare Team
% Copyright © 2009-2023 Dynare Team
%
% This file is part of Dynare.
%
@ -46,8 +46,8 @@ endogenous_variables_paths = NaN(DynareModel.endo_nbr,samplesize+1);
endogenous_variables_paths(:,1) = initialconditions;
% Set waitbar (graphic or text mode)
hh = dyn_waitbar(0,'Please wait. Extended Path simulations...');
set(hh,'Name','EP simulations.');
hh_fig = dyn_waitbar(0,'Please wait. Extended Path simulations...');
set(hh_fig,'Name','EP simulations.');
% Initialize while-loop index.
t = 1;
@ -55,7 +55,7 @@ t = 1;
% Main loop.
while (t <= samplesize)
if ~mod(t,10)
dyn_waitbar(t/samplesize,hh,'Please wait. Extended Path simulations...');
dyn_waitbar(t/samplesize,hh_fig,'Please wait. Extended Path simulations...');
end
% Set period index.
t = t+1;
@ -83,7 +83,7 @@ while (t <= samplesize)
end % (while) loop over t
% Close waitbar.
dyn_waitbar_close(hh);
dyn_waitbar_close(hh_fig);
% Set the initial period.
if isdates(DynareOptions.initial_period)

View File

@ -52,7 +52,7 @@ n_draws=options_.sampling_draws;
if strcmpi(type,'posterior')
% Get informations about the _posterior_draws files.
% discard first mh_drop percent of the draws:
CutSample(M_, options_, estim_params_);
CutSample(M_, options_, 'prior_posterior_function');
% initialize metropolis draws
options_.sub_draws = n_draws; % set draws for sampling; changed value is not returned to base workspace
[error_flag, ~, options_] = metropolis_draw(1, options_, estim_params_, M_);

View File

@ -8,7 +8,7 @@ function forecast_graphs(var_list,M_, oo_,options_)
% o oo_ outputs structure
% o options_ options structure
% Copyright © 2008-2018 Dynare Team
% Copyright © 2008-2023 Dynare Team
%
% This file is part of Dynare.
%
@ -61,11 +61,11 @@ end
m = 1;
n_fig = 1;
hh = dyn_figure(options_.nodisplay, 'Name', 'Forecasts (I)');
hh_fig = dyn_figure(options_.nodisplay, 'Name', 'Forecasts (I)');
for j= 1:nvar
if m > nc*nr
dyn_saveas(hh,[ dname '/graphs/forcst' int2str(n_fig)], options_.nodisplay, options_.graph_format);
dyn_saveas(hh_fig,[ dname '/graphs/forcst' int2str(n_fig)], options_.nodisplay, options_.graph_format);
if options_.TeX && any(strcmp('eps', cellstr(options_.graph_format)))
fprintf(fidTeX,'\\begin{figure}[H]\n');
fprintf(fidTeX,'\\centering \n');
@ -76,7 +76,7 @@ for j= 1:nvar
fprintf(fidTeX,' \n');
end
n_fig =n_fig+1;
eval(['hh=dyn_figure(options_.nodisplay,''Name'',''Forecasts (' int2str(n_fig) ')'');']);
eval(['hh_fig=dyn_figure(options_.nodisplay,''Name'',''Forecasts (' int2str(n_fig) ')'');']);
m = 1;
end
subplot(nr, nc, m);
@ -99,7 +99,7 @@ for j= 1:nvar
end
if m > 1
dyn_saveas(hh,[dname '/graphs/forcst' int2str(n_fig)],options_.nodisplay,options_.graph_format);
dyn_saveas(hh_fig,[dname '/graphs/forcst' int2str(n_fig)],options_.nodisplay,options_.graph_format);
if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format)))
fprintf(fidTeX,'\\begin{figure}[H]\n');
fprintf(fidTeX,'\\centering \n');
@ -124,10 +124,10 @@ if isfield(oo_.forecast,'HPDinf_ME')
m = 1;
n_fig = 1;
hh=dyn_figure(options_.nodisplay,'Name','Forecasts including ME (I)');
hh_fig=dyn_figure(options_.nodisplay,'Name','Forecasts including ME (I)');
for j= 1:length(var_names)
if m > nc*nr
dyn_saveas(hh,[ dname '/graphs/forcst_ME' int2str(n_fig)],options_.nodisplay,options_.graph_format);
dyn_saveas(hh_fig,[ dname '/graphs/forcst_ME' int2str(n_fig)],options_.nodisplay,options_.graph_format);
if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format)))
fprintf(fidTeX,'\\begin{figure}[H]\n');
fprintf(fidTeX,'\\centering \n');
@ -138,7 +138,7 @@ if isfield(oo_.forecast,'HPDinf_ME')
fprintf(fidTeX,' \n');
end
n_fig =n_fig+1;
eval(['hh=dyn_figure(options_.nodisplay,''Name'',''Forecasts (' int2str(n_fig) ')'');']);
eval(['hh_fig=dyn_figure(options_.nodisplay,''Name'',''Forecasts (' int2str(n_fig) ')'');']);
m = 1;
end
subplot(nr,nc,m);
@ -162,7 +162,7 @@ if isfield(oo_.forecast,'HPDinf_ME')
end
if m > 1
dyn_saveas(hh,[dname '/graphs/forcst_ME' int2str(n_fig)],options_.nodisplay,options_.graph_format);
dyn_saveas(hh_fig,[dname '/graphs/forcst_ME' int2str(n_fig)],options_.nodisplay,options_.graph_format);
if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format)))
fprintf(fidTeX,'\\begin{figure}[H]\n');
fprintf(fidTeX,'\\centering \n');

View File

@ -391,7 +391,7 @@ else
end
if mod(i,9)==1
ifig=ifig+1;
hh=dyn_figure(options_.nodisplay,'name',[temp_name,' ',int2str(ifig)]);
hh_fig=dyn_figure(options_.nodisplay,'name',[temp_name,' ',int2str(ifig)]);
end
subplot(3,3,i-9*(ifig-1))
h=cumplot(lnprior(ixx(1:nfilt0(i),i)));
@ -407,18 +407,18 @@ else
annotation('textbox', [0.55,0,0.35,0.05],'String', 'Log-prior for WORSE R2', 'Color','Red','horizontalalignment','center');
end
if options_.opt_gsa.ppost
dyn_saveas(hh,[OutDir filesep fname_ '_rmse_post_lnprior',int2str(ifig)],options_.nodisplay,options_.graph_format);
dyn_saveas(hh_fig,[OutDir filesep fname_ '_rmse_post_lnprior',int2str(ifig)],options_.nodisplay,options_.graph_format);
if options_.TeX
create_TeX_loader(options_,[OutDir '/' fname_ '_rmse_post_lnprior',int2str(ifig)],ifig,[temp_name,' ',int2str(ifig)],'rmse_post_lnprior',options_.figures.textwidth*min((i-9*(ifig-1))/3,1))
end
else
if options_.opt_gsa.pprior
dyn_saveas(hh,[OutDir filesep fname_ '_rmse_prior_lnprior',int2str(ifig) ],options_.nodisplay,options_.graph_format);
dyn_saveas(hh_fig,[OutDir filesep fname_ '_rmse_prior_lnprior',int2str(ifig) ],options_.nodisplay,options_.graph_format);
if options_.TeX
create_TeX_loader(options_,[OutDir '/' fname_ '_rmse_prior_lnprior',int2str(ifig)],ifig,[temp_name,' ',int2str(ifig)],'rmse_prior_lnprior',options_.figures.textwidth*min((i-9*(ifig-1))/3,1))
end
else
dyn_saveas(hh,[OutDir filesep fname_ '_rmse_mc_lnprior',int2str(ifig) ],options_.nodisplay,options_.graph_format);
dyn_saveas(hh_fig,[OutDir filesep fname_ '_rmse_mc_lnprior',int2str(ifig) ],options_.nodisplay,options_.graph_format);
if options_.TeX
create_TeX_loader(options_,[OutDir '/' fname_ '_rmse_mc_lnprior',int2str(ifig)],ifig,[temp_name,' ',int2str(ifig)],'rmse_mc_lnprior',options_.figures.textwidth*min((i-9*(ifig-1))/3,1))
end
@ -439,7 +439,7 @@ else
end
if mod(i,9)==1
ifig=ifig+1;
hh = dyn_figure(options_.nodisplay,'Name',[temp_name,' ',int2str(ifig)]);
hh_fig = dyn_figure(options_.nodisplay,'Name',[temp_name,' ',int2str(ifig)]);
end
subplot(3,3,i-9*(ifig-1))
h=cumplot(likelihood(ixx(1:nfilt0(i),i)));
@ -458,18 +458,18 @@ else
annotation('textbox', [0.55,0,0.35,0.05],'String', 'Log-likelihood for WORSE R2', 'Color','Red','horizontalalignment','center');
end
if options_.opt_gsa.ppost
dyn_saveas(hh,[OutDir filesep fname_ '_rmse_post_lnlik',int2str(ifig) ],options_.nodisplay,options_.graph_format);
dyn_saveas(hh_fig,[OutDir filesep fname_ '_rmse_post_lnlik',int2str(ifig) ],options_.nodisplay,options_.graph_format);
if options_.TeX
create_TeX_loader(options_,[OutDir filesep fname_ '_rmse_post_lnprior',int2str(ifig)],ifig,[temp_name,' ',int2str(ifig)],'rmse_post_lnprior',options_.figures.textwidth*min((i-9*(ifig-1))/3,1));
end
else
if options_.opt_gsa.pprior
dyn_saveas(hh,[OutDir filesep fname_ '_rmse_prior_lnlik',int2str(ifig)],options_.nodisplay,options_.graph_format);
dyn_saveas(hh_fig,[OutDir filesep fname_ '_rmse_prior_lnlik',int2str(ifig)],options_.nodisplay,options_.graph_format);
if options_.TeX
create_TeX_loader(options_,[OutDir filesep fname_ '_rmse_prior_lnlik',int2str(ifig)],ifig,[temp_name,' ',int2str(ifig)],'rmse_prior_lnlik',options_.figures.textwidth*min((i-9*(ifig-1))/3,1));
end
else
dyn_saveas(hh,[OutDir filesep fname_ '_rmse_mc_lnlik',int2str(ifig) ],options_.nodisplay,options_.graph_format);
dyn_saveas(hh_fig,[OutDir filesep fname_ '_rmse_mc_lnlik',int2str(ifig) ],options_.nodisplay,options_.graph_format);
if options_.TeX
create_TeX_loader(options_,[OutDir filesep fname_ '_rmse_mc_lnlik',int2str(ifig) ],ifig,[temp_name,' ',int2str(ifig)],'rmse_mc_lnlik',options_.figures.textwidth*min((i-9*(ifig-1))/3,1));
end
@ -490,7 +490,7 @@ else
end
if mod(i,9)==1
ifig=ifig+1;
hh = dyn_figure(options_.nodisplay,'Name',[temp_name,' ',int2str(ifig)]);
hh_fig = dyn_figure(options_.nodisplay,'Name',[temp_name,' ',int2str(ifig)]);
end
subplot(3,3,i-9*(ifig-1))
h=cumplot(logpo2(ixx(1:nfilt0(i),i)));
@ -509,18 +509,18 @@ else
annotation('textbox', [0.55,0,0.35,0.05],'String', 'Log-posterior for WORSE R2', 'Color','Red','horizontalalignment','center');
end
if options_.opt_gsa.ppost
dyn_saveas(hh,[OutDir filesep fname_ '_rmse_post_lnpost',int2str(ifig) ],options_.nodisplay,options_.graph_format);
dyn_saveas(hh_fig,[OutDir filesep fname_ '_rmse_post_lnpost',int2str(ifig) ],options_.nodisplay,options_.graph_format);
if options_.TeX
create_TeX_loader(options_,[OutDir filesep fname_ '_rmse_post_lnpost',int2str(ifig) ],ifig,[temp_name,' ',int2str(ifig)],'rmse_post_lnpost',options_.figures.textwidth*min((i-9*(ifig-1))/3,1));
end
else
if options_.opt_gsa.pprior
dyn_saveas(hh,[OutDir filesep fname_ '_rmse_prior_lnpost',int2str(ifig)],options_.nodisplay,options_.graph_format);
dyn_saveas(hh_fig,[OutDir filesep fname_ '_rmse_prior_lnpost',int2str(ifig)],options_.nodisplay,options_.graph_format);
if options_.TeX
create_TeX_loader(options_,[OutDir filesep fname_ '_rmse_prior_lnpost',int2str(ifig)],ifig,[temp_name,' ',int2str(ifig)],'rmse_prior_lnpost',options_.figures.textwidth*min((i-9*(ifig-1))/3,1));
end
else
dyn_saveas(hh,[OutDir filesep fname_ '_rmse_mc_lnpost',int2str(ifig)],options_.nodisplay,options_.graph_format);
dyn_saveas(hh_fig,[OutDir filesep fname_ '_rmse_mc_lnpost',int2str(ifig)],options_.nodisplay,options_.graph_format);
if options_.TeX
create_TeX_loader(options_,[OutDir filesep fname_ '_rmse_mc_lnpost',int2str(ifig)],ifig,[temp_name,' ',int2str(ifig)],'rmse_mc_lnpost',options_.figures.textwidth*min((i-9*(ifig-1))/3,1));
end
@ -746,7 +746,7 @@ else
for iy = 1:length(vvarvecm)
ipar = find(any(squeeze(PPV(iy,:,:))<alpha));
for ix=1:ceil(length(ipar)/5)
hh = dyn_figure(options_.nodisplay,'name',[temp_name,' observed variable ', vvarvecm{iy}]);
hh_fig = dyn_figure(options_.nodisplay,'name',[temp_name,' observed variable ', vvarvecm{iy}]);
for j=1+5*(ix-1):min(length(ipar),5*ix)
subplot(2,3,j-5*(ix-1))
h0=cumplot(x(:,ipar(j)));
@ -782,18 +782,18 @@ else
set(h0,'fontsize',6,'position',[0.7 0.1 0.2 0.3],'interpreter','none');
end
if options_.opt_gsa.ppost
dyn_saveas(hh,[ OutDir filesep fname_ '_rmse_post_' vvarvecm{iy} '_' int2str(ix)],options_.nodisplay,options_.graph_format);
dyn_saveas(hh_fig,[ OutDir filesep fname_ '_rmse_post_' vvarvecm{iy} '_' int2str(ix)],options_.nodisplay,options_.graph_format);
if options_.TeX
create_TeX_loader(options_,[ OutDir filesep fname_ '_rmse_post_' vvarvecm{iy} '_' int2str(ix)],ix,[temp_name,' observed variable $',vvarvecm_tex{iy} '$'],['rmse_post_' vvarvecm{iy}],1)
end
else
if options_.opt_gsa.pprior
dyn_saveas(hh,[OutDir filesep fname_ '_rmse_prior_' vvarvecm{iy} '_' int2str(ix) ],options_.nodisplay,options_.graph_format);
dyn_saveas(hh_fig,[OutDir filesep fname_ '_rmse_prior_' vvarvecm{iy} '_' int2str(ix) ],options_.nodisplay,options_.graph_format);
if options_.TeX
create_TeX_loader(options_,[OutDir filesep fname_ '_rmse_prior_' vvarvecm{iy} '_' int2str(ix) ],ix,[temp_name,' observed variable $',vvarvecm_tex{iy} '$'],['rmse_prior_' vvarvecm{iy}],1)
end
else
dyn_saveas(hh,[OutDir filesep fname_ '_rmse_mc_' vvarvecm{iy} '_' int2str(ix)],options_.nodisplay,options_.graph_format);
dyn_saveas(hh_fig,[OutDir filesep fname_ '_rmse_mc_' vvarvecm{iy} '_' int2str(ix)],options_.nodisplay,options_.graph_format);
if options_.TeX
create_TeX_loader(options_,[OutDir filesep fname_ '_rmse_mc_' vvarvecm{iy} '_' int2str(ix)],ix,[temp_name,' observed variable $',vvarvecm_tex{iy} '$'],['rmse_mc_' vvarvecm{iy}],1)
end
@ -803,7 +803,7 @@ else
end
% now I plot by individual parameters
for ix=1:ceil(length(nsnam)/5)
hh = dyn_figure(options_.nodisplay,'name',[temp_name,' estimated params and shocks ',int2str(ix)]);
hh_fig = dyn_figure(options_.nodisplay,'name',[temp_name,' estimated params and shocks ',int2str(ix)]);
for j=1+5*(ix-1):min(size(snam2,1),5*ix)
subplot(2,3,j-5*(ix-1))
h0=cumplot(x(:,nsnam(j)));
@ -840,18 +840,18 @@ else
set(h0,'fontsize',6,'position',[0.7 0.1 0.2 0.3],'interpreter','none');
end
if options_.opt_gsa.ppost
dyn_saveas(hh,[ OutDir filesep fname_ '_rmse_post_params_' int2str(ix)],options_.nodisplay,options_.graph_format);
dyn_saveas(hh_fig,[ OutDir filesep fname_ '_rmse_post_params_' int2str(ix)],options_.nodisplay,options_.graph_format);
if options_.TeX
create_TeX_loader(options_,[ OutDir filesep fname_ '_rmse_post_params_' int2str(ix)],ix,[temp_name,' estimated params and shocks ',int2str(ix)],'rmse_post_params',1)
end
else
if options_.opt_gsa.pprior
dyn_saveas(hh,[OutDir filesep fname_ '_rmse_prior_params_' int2str(ix) ],options_.nodisplay,options_.graph_format);
dyn_saveas(hh_fig,[OutDir filesep fname_ '_rmse_prior_params_' int2str(ix) ],options_.nodisplay,options_.graph_format);
if options_.TeX
create_TeX_loader(options_,[OutDir filesep fname_ '_rmse_prior_params_' int2str(ix) ],ix,[temp_name,' estimated params and shocks ',int2str(ix)],'rmse_prior_params',1)
end
else
dyn_saveas(hh,[OutDir filesep fname_ '_rmse_mc_params_' int2str(ix)],options_.nodisplay,options_.graph_format);
dyn_saveas(hh_fig,[OutDir filesep fname_ '_rmse_mc_params_' int2str(ix)],options_.nodisplay,options_.graph_format);
if options_.TeX
create_TeX_loader(options_,[OutDir filesep fname_ '_rmse_mc_params_' int2str(ix)],ix,[temp_name,' estimated params and shocks ',int2str(ix)],'rmse_mc_params',1)
end

View File

@ -5,7 +5,7 @@ function map_ident_(OutputDirectoryName,opt_gsa)
% marco.ratto@ec.europa.eu
% Copyright © 2012-2016 European Commission
% Copyright © 2012-2018 Dynare Team
% Copyright © 2012-2023 Dynare Team
%
% This file is part of Dynare.
%
@ -90,7 +90,7 @@ if opt_gsa.load_ident_files==0
ifig=0;
for j=1:M_.exo_nbr
if mod(j,6)==1
hh=dyn_figure(options_.nodisplay,'name',['Variance decomposition shocks']);
hh_fig=dyn_figure(options_.nodisplay,'name',['Variance decomposition shocks']);
ifig=ifig+1;
iplo=0;
end
@ -108,7 +108,7 @@ if opt_gsa.load_ident_files==0
ylabel(' ')
title(M_.exo_names{j},'interpreter','none')
if mod(j,6)==0 | j==M_.exo_nbr
dyn_saveas(hh,[OutputDirectoryName,'/',fname_,'_vdec_exo_',int2str(ifig)],options_.nodisplay,options_.graph_format);
dyn_saveas(hh_fig,[OutputDirectoryName,'/',fname_,'_vdec_exo_',int2str(ifig)],options_.nodisplay,options_.graph_format);
create_TeX_loader(options_,[OutputDirectoryName,'/',fname_,'_vdec_exo_',int2str(ifig)],ifig,['Variance decomposition shocks'],'vdec_exo',options_.figures.textwidth*min(iplo/3,1))
end
end
@ -219,7 +219,7 @@ if opt_gsa.morris==1
load([OutputDirectoryName,'/',fname_,'_morris_IDE'],'SAvdec','vdec','ir_vdec','ic_vdec')
end
hh = dyn_figure(options_.nodisplay,'name','Screening identification: variance decomposition');
hh_fig = dyn_figure(options_.nodisplay,'name','Screening identification: variance decomposition');
% boxplot(SAvdec,'whis',10,'symbol','r.')
myboxplot(SAvdec,[],'.',[],10)
set(gca,'xticklabel',' ','fontsize',10,'xtick',[1:npT])
@ -232,7 +232,7 @@ if opt_gsa.morris==1
end
xlabel(' ')
title('Elementary effects variance decomposition')
dyn_saveas(hh,[OutputDirectoryName,'/',fname_,'_morris_vdec'],options_.nodisplay,options_.graph_format);
dyn_saveas(hh_fig,[OutputDirectoryName,'/',fname_,'_morris_vdec'],options_.nodisplay,options_.graph_format);
create_TeX_loader(options_,[OutputDirectoryName,'/',fname_,'_morris_vdec'],1,'Screening identification: variance decomposition','morris_vdec',1)
else
save([OutputDirectoryName,'/',fname_,'_morris_IDE.mat'],'vdec')
@ -325,7 +325,7 @@ if opt_gsa.morris==1
load([OutputDirectoryName,'/',fname_,'_morris_IDE'],'ac','ir_ac','ic_ac')
end
hh=dyn_figure(options_.nodisplay,'name','Screening identification: theoretical moments');
hh_fig=dyn_figure(options_.nodisplay,'name','Screening identification: theoretical moments');
% boxplot(SAcc,'whis',10,'symbol','r.')
myboxplot(SAcc,[],'.',[],10)
set(gca,'xticklabel',' ','fontsize',10,'xtick',[1:npT])
@ -338,7 +338,7 @@ if opt_gsa.morris==1
end
xlabel(' ')
title('Elementary effects in the moments')
dyn_saveas(hh,[OutputDirectoryName,'/',fname_,'_morris_moments'],options_.nodisplay,options_.graph_format);
dyn_saveas(hh_fig,[OutputDirectoryName,'/',fname_,'_morris_moments'],options_.nodisplay,options_.graph_format);
create_TeX_loader(options_,[OutputDirectoryName,'/',fname_,'_morris_moments'],1,'Screening identification: theoretical moments','morris_moments',1)
% close(gcf),
@ -722,7 +722,7 @@ if opt_gsa.morris==1
else
load([OutputDirectoryName,'/',fname_,'_morris_IDE'],'SAnorm','SAmunorm','SAsignorm')
end
hh=dyn_figure(options_.nodisplay,'name','Screening identification: model'); %bar(SAnorm(:,irel))
hh_fig=dyn_figure(options_.nodisplay,'name','Screening identification: model'); %bar(SAnorm(:,irel))
% boxplot(SAnorm','whis',10,'symbol','r.')
myboxplot(SAnorm',[],'.',[],10)
set(gca,'xticklabel',' ','fontsize',10,'xtick',[1:npT])
@ -736,10 +736,10 @@ if opt_gsa.morris==1
end
xlabel(' ')
title('Elementary effects in the model')
dyn_saveas(hh,[OutputDirectoryName,'/',fname_,'_morris_par'],options_.nodisplay,options_.graph_format);
dyn_saveas(hh_fig,[OutputDirectoryName,'/',fname_,'_morris_par'],options_.nodisplay,options_.graph_format);
create_TeX_loader(options_,[OutputDirectoryName,'/',fname_,'_morris_par'],1,'Screening identification: model','morris_par',1)
% hh=dyn_figure(options_.nodisplay); %bar(SAmunorm(:,irel))
% hh_fig=dyn_figure(options_.nodisplay); %bar(SAmunorm(:,irel))
% % boxplot(SAmunorm','whis',10,'symbol','r.')
% myboxplot(SAmunorm',[],'.',[],10)
% set(gca,'xticklabel',' ','fontsize',10,'xtick',[1:npT])
@ -752,9 +752,9 @@ if opt_gsa.morris==1
% end
% xlabel(' ')
% title('\mu in the model')
% dyn_saveas(hh,[OutputDirectoryName,'/',fname_,'_morrismu_par'],options_.nodisplay,options_.graph_format);
% dyn_saveas(hh_fig,[OutputDirectoryName,'/',fname_,'_morrismu_par'],options_.nodisplay,options_.graph_format);
%
% hh=dyn_figure(options_.nodisplay); %bar(SAsignorm(:,irel))
% hh_fig=dyn_figure(options_.nodisplay); %bar(SAsignorm(:,irel))
% % boxplot(SAsignorm','whis',10,'symbol','r.')
% myboxplot(SAsignorm',[],'.',[],10)
% set(gca,'xticklabel',' ','fontsize',10,'xtick',[1:npT])
@ -767,7 +767,7 @@ if opt_gsa.morris==1
% end
% xlabel(' ')
% title('\sigma in the model')
% dyn_saveas(hh,[OutputDirectoryName,'/',fname_,'_morrissig_par'],options_.nodisplay,options_.graph_format);
% dyn_saveas(hh_fig,[OutputDirectoryName,'/',fname_,'_morrissig_par'],options_.nodisplay,options_.graph_format);
% figure, bar(SAnorm(:,irel)')
% set(gca,'xtick',[1:j0])
@ -1521,7 +1521,7 @@ else % main effects analysis
% SAmeanexo=mean(SAmomN(:,1:nshock));
% figure, bar(latent'*SAcc),
hh=dyn_figure(options_.nodisplay,'Name',['Identifiability indices in the ',fsuffix,' moments.']);
hh_fig=dyn_figure(options_.nodisplay,'Name',['Identifiability indices in the ',fsuffix,' moments.']);
bar(sum(SAcc))
set(gca,'xticklabel',' ','fontsize',10,'xtick',[1:npT])
set(gca,'xlim',[0.5 npT+0.5])
@ -1534,7 +1534,7 @@ else % main effects analysis
end
xlabel(' ')
title(['Identifiability indices in the ',fsuffix,' moments.'],'interpreter','none')
dyn_saveas(hh,[OutputDirectoryName,'/',fname_,'_ident_ALL',fsuffix],options_.nodisplay,options_.graph_format);
dyn_saveas(hh_fig,[OutputDirectoryName,'/',fname_,'_ident_ALL',fsuffix],options_.nodisplay,options_.graph_format);
create_TeX_loader(options_,[OutputDirectoryName,'/',fname_,'_ident_ALL',fsuffix],1,['Identifiability indices in the ',fsuffix,' moments.'],['ident_ALL',fsuffix]',1)
% figure, bar(SAmeanexo),

View File

@ -1,7 +1,7 @@
function pick
%
% Copyright © 2001-2017 European Commission
% Copyright © 2017 DynareTeam
% Copyright © 2017-2023 DynareTeam
% This file is part of GLUEWIN
% GLUEWIN is a MATLAB code designed for analysing the output
@ -68,9 +68,9 @@ KK=K;
set(button1,'Label',['Save ',num2str(K)],'Callback',['scatter_callback(',num2str(KK),',''save'')']);
set(button2,'Label',['Eval ',num2str(K)],'Callback',['scatter_callback(',num2str(KK),',''eval'')']);
hh=findobj(gcf,'type','axes','Tag','scatter');
for k=1:length(hh)
axes(hh(k));
hh_obj=findobj(gcf,'type','axes','Tag','scatter');
for k=1:length(hh_obj)
axes(hh_obj(k));
dum=get(gca,'children');
dumx=get(dum(end),'xdata');
dumy=get(dum(end),'ydata');

View File

@ -16,7 +16,7 @@ function redform_map(dirname,options_gsa_)
% marco.ratto@ec.europa.eu
% Copyright © 2012-2016 European Commission
% Copyright © 2012-2018 Dynare Team
% Copyright © 2012-2023 Dynare Team
%
% This file is part of Dynare.
%
@ -165,7 +165,7 @@ for j = 1:length(anamendo)
if (max(y0)-min(y0))>1.e-10
if mod(iplo,9)==0 && isempty(threshold) && ~options_.nograph
ifig=ifig+1;
hfig = dyn_figure(options_.nodisplay,'name',['Reduced Form Mapping: ', namendo,' vs shocks ',int2str(ifig)]);
hh_fig = dyn_figure(options_.nodisplay,'name',['Reduced Form Mapping: ', namendo,' vs shocks ',int2str(ifig)]);
iplo=0;
end
iplo=iplo+1;
@ -273,7 +273,7 @@ for j = 1:length(anamendo)
end
if isempty(threshold) && ~options_.nograph
figure(hfig)
figure(hh_fig)
subplot(3,3,iplo),
if ilog
[saso, iso] = sort(-silog(:,js));
@ -292,7 +292,7 @@ for j = 1:length(anamendo)
end
title([logflag,' ',namendo,' vs ',namexo],'interpreter','none')
if iplo==9
dyn_saveas(hfig,[dirname,filesep,M_.fname,'_redform_', namendo,'_vs_shocks_',logflag,num2str(ifig)],options_.nodisplay,options_.graph_format);
dyn_saveas(hh_fig,[dirname,filesep,M_.fname,'_redform_', namendo,'_vs_shocks_',logflag,num2str(ifig)],options_.nodisplay,options_.graph_format);
create_TeX_loader(options_,[dirname,filesep,M_.fname,'_redform_', namendo,'_vs_shocks_',logflag,num2str(ifig)],[logflag,' ',strrep(namendo,'_','\_'),' vs ',strrep(namexo,'_','\_')],['redform_', namendo,'_vs_shocks_',logflag,num2str(ifig)],1)
end
end
@ -303,7 +303,7 @@ for j = 1:length(anamendo)
end
end
if iplo<9 && iplo>0 && ifig && ~options_.nograph
dyn_saveas(hfig,[dirname,filesep,M_.fname,'_redform_', namendo,'_vs_shocks_',logflag,num2str(ifig)],options_.nodisplay,options_.graph_format);
dyn_saveas(hh_fig,[dirname,filesep,M_.fname,'_redform_', namendo,'_vs_shocks_',logflag,num2str(ifig)],options_.nodisplay,options_.graph_format);
create_TeX_loader(options_,[dirname,filesep,M_.fname,'_redform_', namendo,'_vs_shocks_',logflag,num2str(ifig)],[logflag,' ',strrep(namendo,'_','\_'),' vs ',strrep(namexo,'_','\_')],['redform_', namendo,'_vs_shocks_',logflag,num2str(ifig)],options_.figures.textwidth*min(iplo/3,1))
end
ifig=0;
@ -320,7 +320,7 @@ for j = 1:length(anamendo)
if (max(y0)-min(y0))>1.e-10
if mod(iplo,9)==0 && isempty(threshold) && ~options_.nograph
ifig=ifig+1;
hfig = dyn_figure(options_.nodisplay,'name',['Reduced Form Mapping: ' namendo,' vs lags ',int2str(ifig)]);
hh_fig = dyn_figure(options_.nodisplay,'name',['Reduced Form Mapping: ' namendo,' vs lags ',int2str(ifig)]);
iplo=0;
end
iplo=iplo+1;
@ -429,7 +429,7 @@ for j = 1:length(anamendo)
end
if isempty(threshold) && ~options_.nograph
figure(hfig),
figure(hh_fig),
subplot(3,3,iplo),
if ilog
[saso, iso] = sort(-silog(:,js));
@ -448,7 +448,7 @@ for j = 1:length(anamendo)
end
title([logflag,' ',namendo,' vs ',namlagendo,'(-1)'],'interpreter','none')
if iplo==9
dyn_saveas(hfig,[dirname,filesep,M_.fname,'_redform_', namendo,'_vs_lags_',logflag,num2str(ifig)],options_.nodisplay,options_.graph_format);
dyn_saveas(hh_fig,[dirname,filesep,M_.fname,'_redform_', namendo,'_vs_lags_',logflag,num2str(ifig)],options_.nodisplay,options_.graph_format);
create_TeX_loader(options_,[dirname,filesep,M_.fname,'_redform_', namendo,'_vs_lags_',logflag,num2str(ifig)],[logflag,' ',strrep(namendo,'_','\_'),' vs ',strrep(namlagendo,'_','\_'),'(-1)'],['redform_', namendo,'_vs_lags_',logflag,':',num2str(ifig)],1)
end
end
@ -459,14 +459,14 @@ for j = 1:length(anamendo)
end
end
if iplo<9 && iplo>0 && ifig && ~options_.nograph
dyn_saveas(hfig,[dirname,filesep,M_.fname,'_redform_', namendo,'_vs_lags_',logflag,num2str(ifig)],options_.nodisplay,options_.graph_format);
dyn_saveas(hh_fig,[dirname,filesep,M_.fname,'_redform_', namendo,'_vs_lags_',logflag,num2str(ifig)],options_.nodisplay,options_.graph_format);
create_TeX_loader(options_,[dirname,filesep,M_.fname,'_redform_', namendo,'_vs_lags_',logflag,num2str(ifig)],[logflag,' ',strrep(namendo,'_','\_'),' vs ',strrep(namlagendo,'_','\_'),'(-1)'],['redform_', namendo,'_vs_lags_',logflag,':',num2str(ifig)],options_.figures.textwidth*min(iplo/3,1));
end
end
if isempty(threshold) && ~options_.nograph
if ilog==0
hfig=dyn_figure(options_.nodisplay,'name','Reduced Form GSA'); %bar(si)
hh_fig=dyn_figure(options_.nodisplay,'name','Reduced Form GSA'); %bar(si)
% boxplot(si','whis',10,'symbol','r.')
myboxplot(si',[],'.',[],10)
xlabel(' ')
@ -478,11 +478,11 @@ if isempty(threshold) && ~options_.nograph
text(ip,-0.02,deblank(pnames(ip,:)),'rotation',90,'HorizontalAlignment','right','interpreter','none')
end
title('Reduced form GSA')
dyn_saveas(hfig,[dirname,filesep,M_.fname,'_redform_gsa'],options_.nodisplay,options_.graph_format);
dyn_saveas(hh_fig,[dirname,filesep,M_.fname,'_redform_gsa'],options_.nodisplay,options_.graph_format);
create_TeX_loader(options_,[dirname,filesep,M_.fname,'_redform_gsa'],'Reduced Form GSA','redform_gsa')
else
hfig=dyn_figure(options_.nodisplay,'name','Reduced Form GSA'); %bar(silog)
hh_fig=dyn_figure(options_.nodisplay,'name','Reduced Form GSA'); %bar(silog)
% boxplot(silog','whis',10,'symbol','r.')
myboxplot(silog',[],'.',[],10)
set(gca,'xticklabel',' ','fontsize',10,'xtick',[1:np])
@ -494,7 +494,7 @@ if isempty(threshold) && ~options_.nograph
text(ip,-0.02,deblank(pnames(ip,:)),'rotation',90,'HorizontalAlignment','right','interpreter','none')
end
title('Reduced form GSA - Log-transformed elements')
dyn_saveas(hfig,[dirname,filesep,M_.fname,'_redform_gsa_log'],options_.nodisplay,options_.graph_format);
dyn_saveas(hh_fig,[dirname,filesep,M_.fname,'_redform_gsa_log'],options_.nodisplay,options_.graph_format);
create_TeX_loader(options_,[dirname,filesep,M_.fname,'_redform_gsa_log'],'Reduced form GSA - Log-transformed elements','redform_gsa_log')
end
@ -560,7 +560,7 @@ if iload==0
y1 = log(y0*isig+lam);
end
if ~options_.nograph
hfig=dyn_figure(options_.nodisplay,'name',options_map.figtitle);
hh_fig=dyn_figure(options_.nodisplay,'name',options_map.figtitle);
subplot(221)
if ilog
hist(y1,30)
@ -647,7 +647,7 @@ if iload==0
gsa_.x0=x0(ifit,:);
% copyfile([fname,'_est.mat'],[fname,'.mat'])
if ~options_.nograph
figure(hfig);
figure(hh_fig);
subplot(223),
plot(y0(ifit),[gsa_.fit y0(ifit)],'.'),
r2 = gsa_.r2;
@ -672,7 +672,7 @@ if iload==0
plot(yn,[yf yn],'.'),
title(['Out-of-sample prediction - R2=' num2str(r2,2)],'interpreter','none')
end
dyn_saveas(hfig,fname,options_.nodisplay,options_.graph_format);
dyn_saveas(hh_fig,fname,options_.nodisplay,options_.graph_format);
create_TeX_loader(options_,fname,['Out-of-sample prediction - R2=' num2str(r2,2)],'redform_gsa_log')
if options_.nodisplay
@ -685,10 +685,10 @@ else
load([fname,'_map.mat'],'gsa_')
if ~options_.nograph
yf = ss_anova_fcast(x0, gsa_);
hfig=dyn_figure(options_.nodisplay,'name',options_map.title);
hh_fig=dyn_figure(options_.nodisplay,'name',options_map.title);
plot(y0,[yf y0],'.'),
title([namy,' vs ', namx,' pred'],'interpreter','none')
dyn_saveas(hfig,[fname '_pred'],options_.nodisplay,options_.graph_format);
dyn_saveas(hh_fig,[fname '_pred'],options_.nodisplay,options_.graph_format);
create_TeX_loader(options_,[fname '_pred'],options_map.title,[namy,' vs ', namx,' pred'])
end
@ -762,7 +762,7 @@ return
function indmcf = redform_mcf(y0, x0, options_mcf, options_)
hfig=dyn_figure(options_.nodisplay,'name',options_mcf.amcf_title);
hh_fig=dyn_figure(options_.nodisplay,'name',options_mcf.amcf_title);
[post_mean, post_median, post_var, hpd_interval, post_deciles, ...
density] = posterior_moments(y0,1,0.9);
@ -813,7 +813,7 @@ if ~isoctave
'horizontalalignment','center');
end
dyn_saveas(hfig,[options_mcf.OutputDirectoryName filesep options_mcf.fname_,'_',options_mcf.amcf_name],options_.nodisplay,options_.graph_format);
dyn_saveas(hh_fig,[options_mcf.OutputDirectoryName filesep options_mcf.fname_,'_',options_mcf.amcf_name],options_.nodisplay,options_.graph_format);
create_TeX_loader(options_,[options_mcf.OutputDirectoryName filesep options_mcf.fname_,'_',options_mcf.amcf_name],strrep(options_mcf.amcf_title,'_','\_'),[options_mcf.fname_,'_',options_mcf.amcf_name])
return

View File

@ -11,7 +11,7 @@ function redform_screen(dirname, options_gsa_)
% marco.ratto@ec.europa.eu
% Copyright © 2012-2016 European Commission
% Copyright © 2012-2018 Dynare Team
% Copyright © 2012-2023 Dynare Team
%
% This file is part of Dynare.
%
@ -66,7 +66,7 @@ for j=1:size(anamendo,1)
if ~isempty(y0)
if mod(iplo,9)==0
ifig = ifig+1;
hh = dyn_figure(options_.nodisplay, 'name', [namendo,[' vs. shocks '], int2str(ifig)]);
hh_fig = dyn_figure(options_.nodisplay, 'name', [namendo,[' vs. shocks '], int2str(ifig)]);
iplo = 0;
end
iplo = iplo+1;
@ -84,7 +84,7 @@ for j=1:size(anamendo,1)
end
title([namendo,' vs. ',namexo],'interpreter','none')
if iplo==9
dyn_saveas(hh,[dirname,'/',M_.fname,'_', namendo,'_vs_shock_',num2str(ifig)],options_.nodisplay,options_.graph_format);
dyn_saveas(hh_fig,[dirname,'/',M_.fname,'_', namendo,'_vs_shock_',num2str(ifig)],options_.nodisplay,options_.graph_format);
create_TeX_loader(options_,[dirname,'/',M_.fname,'_', namendo,'_vs_shock_',num2str(ifig)],ifig,[namendo,' vs. shocks ',int2str(ifig)],[namendo,'_vs_shock'],1)
end
@ -92,7 +92,7 @@ for j=1:size(anamendo,1)
end
end
if iplo<9 && iplo>0 && ifig
dyn_saveas(hh,[dirname,'/',M_.fname,'_', namendo,'_vs_shocks_',num2str(ifig)],options_.nodisplay,options_.graph_format);
dyn_saveas(hh_fig,[dirname,'/',M_.fname,'_', namendo,'_vs_shocks_',num2str(ifig)],options_.nodisplay,options_.graph_format);
create_TeX_loader(options_,[dirname,'/',M_.fname,'_', namendo,'_vs_shock_',num2str(ifig)],ifig,[namendo,' vs. shocks ',int2str(ifig)],[namendo,'_vs_shock'],options_.figures.textwidth*min(iplo/3))
end
@ -107,7 +107,7 @@ for j=1:size(anamendo,1)
if ~isempty(y0)
if mod(iplo,9)==0
ifig=ifig+1;
hh=dyn_figure(options_.nodisplay,'name',[namendo,' vs. lagged endogenous ',int2str(ifig)]);
hh_fig=dyn_figure(options_.nodisplay,'name',[namendo,' vs. lagged endogenous ',int2str(ifig)]);
iplo=0;
end
iplo=iplo+1;
@ -127,19 +127,19 @@ for j=1:size(anamendo,1)
title([namendo,' vs. ',namlagendo,'(-1)'],'interpreter','none')
if iplo==9
dyn_saveas(hh,[dirname,'/',M_.fname,'_', namendo,'_vs_lags_',num2str(ifig)],options_.nodisplay,options_.graph_format);
dyn_saveas(hh_fig,[dirname,'/',M_.fname,'_', namendo,'_vs_lags_',num2str(ifig)],options_.nodisplay,options_.graph_format);
create_TeX_loader(options_,[dirname,'/',M_.fname,'_', namendo,'_vs_lags_',num2str(ifig)],ifig,[namendo,' vs. lagged endogenous ',int2str(ifig)],[namendo,'_vs_lags'],1)
end
end
end
end
if iplo<9 && iplo>0 && ifig
dyn_saveas(hh,[dirname,'/',M_.fname,'_', namendo,'_vs_lags_',num2str(ifig)],options_.nodisplay,options_.graph_format);
dyn_saveas(hh_fig,[dirname,'/',M_.fname,'_', namendo,'_vs_lags_',num2str(ifig)],options_.nodisplay,options_.graph_format);
create_TeX_loader(options_,[dirname,'/',M_.fname,'_', namendo,'_vs_lags_',num2str(ifig)],ifig,[namendo,' vs. lagged endogenous ',int2str(ifig)],[namendo,'_vs_lags'],options_.figures.textwidth*min(iplo/3))
end
end
hh=dyn_figure(options_.nodisplay,'Name','Reduced form screening');
hh_fig=dyn_figure(options_.nodisplay,'Name','Reduced form screening');
%bar(SA)
% boxplot(SA','whis',10,'symbol','r.')
myboxplot(SA',[],'.',[],10)
@ -153,7 +153,7 @@ end
xlabel(' ')
ylabel('Elementary Effects')
title('Reduced form screening')
dyn_saveas(hh,[dirname,'/',M_.fname,'_redform_screen'],options_.nodisplay,options_.graph_format);
dyn_saveas(hh_fig,[dirname,'/',M_.fname,'_redform_screen'],options_.nodisplay,options_.graph_format);
create_TeX_loader(options_,[dirname,'/',M_.fname,'_redform_screen'],1,'Reduced form screening','redform_screen',1)

View File

@ -5,7 +5,7 @@ function scatter_mcf(X,Y,vnames,plotsymbol, fnam, dirname, figtitle, xparam1, D
% marco.ratto@ec.europa.eu
% Copyright © 2014-2016 European Commission
% Copyright © 2014-2017 Dynare Team
% Copyright © 2014-2023 Dynare Team
%
% This file is part of Dynare.
%
@ -84,7 +84,7 @@ figtitle_tex=strrep(figtitle,'_','\_');
fig_nam_=[fnam];
if ~nograph
hh=dyn_figure(DynareOptions.nodisplay,'name',figtitle);
hh_fig=dyn_figure(DynareOptions.nodisplay,'name',figtitle);
end
bf = 0.1;
@ -166,7 +166,7 @@ if ~isoctave
end
if ~nograph
dyn_saveas(hh,[dirname,filesep,fig_nam_],DynareOptions.nodisplay,DynareOptions.graph_format);
dyn_saveas(hh_fig,[dirname,filesep,fig_nam_],DynareOptions.nodisplay,DynareOptions.graph_format);
if DynareOptions.TeX && any(strcmp('eps',cellstr(DynareOptions.graph_format)))
fidTeX = fopen([dirname,'/',fig_nam_ '.tex'],'w');
fprintf(fidTeX,'%% TeX eps-loader file generated by scatter_mcf.m (Dynare).\n');

View File

@ -6,7 +6,7 @@ function scatter_plots(X,xp,vnames,plotsymbol, fnam, dirname, figtitle, xparam1,
%
% Copyright © 2017 European Commission
% Copyright © 2017 Dynare Team
% Copyright © 2017-2023 Dynare Team
%
% This file is part of Dynare.
%
@ -73,8 +73,8 @@ figtitle_tex=strrep(figtitle,'_','\_');
fig_nam_=[fnam];
hh=dyn_figure(DynareOptions.nodisplay,'name',figtitle);
set(hh,'userdata',{X,xp})
hh_fig=dyn_figure(DynareOptions.nodisplay,'name',figtitle);
set(hh_fig,'userdata',{X,xp})
bf = 0.1;
ffs = 0.05/(p-1);
@ -172,7 +172,7 @@ end
% end
if ~nograph
dyn_saveas(hh,[dirname,filesep,fig_nam_],DynareOptions.nodisplay,DynareOptions.graph_format);
dyn_saveas(hh_fig,[dirname,filesep,fig_nam_],DynareOptions.nodisplay,DynareOptions.graph_format);
if DynareOptions.TeX && any(strcmp('eps',cellstr(DynareOptions.graph_format)))
fidTeX = fopen([dirname,'/',fig_nam_ '.tex'],'w');
fprintf(fidTeX,'%% TeX eps-loader file generated by scatter_plots.m (Dynare).\n');

View File

@ -21,7 +21,7 @@ function [proba, dproba] = stab_map_1(lpmat, ibehaviour, inonbehaviour, aname, i
% marco.ratto@ec.europa.eu
% Copyright © 2012-2016 European Commission
% Copyright © 2012-2017 Dynare Team
% Copyright © 2012-2023 Dynare Team
%
% This file is part of Dynare.
%
@ -82,7 +82,7 @@ if iplot && ~options_.nograph
ftit=bayestopt_.name(ipar+nshock*(1-ishock));
for i=1:ceil(nparplot/12)
hh=dyn_figure(options_.nodisplay,'name',atitle);
hh_fig=dyn_figure(options_.nodisplay,'name',atitle);
for j=1+12*(i-1):min(nparplot,12*i)
subplot(3,4,j-12*(i-1))
if ~isempty(ibehaviour)
@ -98,7 +98,7 @@ if iplot && ~options_.nograph
title([ftit{j},'. p-value ', num2str(proba(ipar(j)),2)],'interpreter','none')
end
if nparplot>12
dyn_saveas(hh,[dirname,filesep,fname_,'_',aname,'_SA_',int2str(i)],options_.nodisplay,options_.graph_format);
dyn_saveas(hh_fig,[dirname,filesep,fname_,'_',aname,'_SA_',int2str(i)],options_.nodisplay,options_.graph_format);
if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format)))
fidTeX = fopen([dirname,filesep,fname_,'_',aname,'_SA_',int2str(i) '.tex'],'w');
fprintf(fidTeX,'%% TeX eps-loader file generated by stab_map_1.m (Dynare).\n');
@ -113,7 +113,7 @@ if iplot && ~options_.nograph
fclose(fidTeX);
end
else
dyn_saveas(hh,[dirname,filesep,fname_,'_',aname,'_SA'],options_.nodisplay,options_.graph_format);
dyn_saveas(hh_fig,[dirname,filesep,fname_,'_',aname,'_SA'],options_.nodisplay,options_.graph_format);
if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format)))
fidTeX = fopen([dirname,filesep,fname_,'_',aname,'_SA.tex'],'w');
fprintf(fidTeX,'%% TeX eps-loader file generated by stab_map_1.m (Dynare).\n');

View File

@ -6,7 +6,7 @@ function indcorr = stab_map_2(x,alpha2, pvalue_crit, fnam, dirname,xparam1,figti
% marco.ratto@ec.europa.eu
% Copyright © 2011-2016 European Commission
% Copyright © 2011-2018 Dynare Team
% Copyright © 2011-2023 Dynare Team
% This file is part of Dynare.
%
% Dynare is free software: you can redistribute it and/or modify
@ -118,7 +118,7 @@ for j=1:npar
if ~nograph
if mod(j2,12)==1
ifig=ifig+1;
hh=dyn_figure(options_.nodisplay,'name',[figtitle,' sample bivariate projection ', num2str(ifig)]);
hh_fig=dyn_figure(options_.nodisplay,'name',[figtitle,' sample bivariate projection ', num2str(ifig)]);
end
subplot(3,4,j2-(ifig-1)*12)
% bar(c0(i2,j)),
@ -141,7 +141,7 @@ for j=1:npar
end
title(['cc = ',num2str(c0(i2(jx),j))])
if (mod(j2,12)==0) && j2>0
dyn_saveas(hh,[dirname,filesep,fig_nam_,int2str(ifig)],options_.nodisplay,options_.graph_format);
dyn_saveas(hh_fig,[dirname,filesep,fig_nam_,int2str(ifig)],options_.nodisplay,options_.graph_format);
if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format)))
fidTeX = fopen([dirname,filesep,fig_nam_,int2str(ifig),'.tex'],'w');
fprintf(fidTeX,'%% TeX eps-loader file generated by stab_map_2.m (Dynare).\n');
@ -162,7 +162,7 @@ for j=1:npar
end
end
if ~nograph && (j==(npar)) && j2>0 && (mod(j2,12)~=0)
dyn_saveas(hh,[dirname,filesep,fig_nam_,int2str(ifig)],options_.nodisplay,options_.graph_format);
dyn_saveas(hh_fig,[dirname,filesep,fig_nam_,int2str(ifig)],options_.nodisplay,options_.graph_format);
if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format)))
fidTeX = fopen([dirname,filesep,fig_nam_,int2str(ifig),'.tex'],'w');
fprintf(fidTeX,'%% TeX eps-loader file generated by stab_map_2.m (Dynare).\n');

View File

@ -1,5 +1,5 @@
function [marginal,oo_] = marginal_density(M_, options_, estim_params_, oo_, bayestopt_)
% function [marginal,oo_] = marginal_density(M_, options_, estim_params_, oo_, bayestopt_)
function [marginal,oo_] = marginal_density(M_, options_, estim_params_, oo_, bayestopt_, outputFolderName)
% function [marginal,oo_] = marginal_density(M_, options_, estim_params_, oo_, bayestopt_, outputFolderName)
% Computes the marginal density
%
% INPUTS
@ -7,6 +7,7 @@ function [marginal,oo_] = marginal_density(M_, options_, estim_params_, oo_, bay
% estim_params_ [structure] Dynare estimation parameter structure
% M_ [structure] Dynare model structure
% oo_ [structure] Dynare results structure
% outputFolderName [string] name of folder with results
%
% OUTPUTS
% marginal: [double] marginal density (modified harmonic mean)
@ -31,7 +32,9 @@ function [marginal,oo_] = marginal_density(M_, options_, estim_params_, oo_, bay
%
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
if nargin < 6
outputFolderName = 'Output';
end
MetropolisFolder = CheckPath('metropolis',M_.dname);
ModelName = M_.fname;
@ -47,8 +50,8 @@ TotalNumberOfMhFiles = sum(record.MhDraws(:,2));
TotalNumberOfMhDraws = sum(record.MhDraws(:,1));
TODROP = floor(options_.mh_drop*TotalNumberOfMhDraws);
fprintf('Estimation::marginal density: I''m computing the posterior mean and covariance... ');
[posterior_mean,posterior_covariance,posterior_mode,posterior_kernel_at_the_mode] = compute_mh_covariance_matrix(bayestopt_,M_.fname,M_.dname);
fprintf('marginal density: I''m computing the posterior mean and covariance... ');
[posterior_mean,posterior_covariance,posterior_mode,posterior_kernel_at_the_mode] = compute_mh_covariance_matrix(bayestopt_,M_.fname,M_.dname,outputFolderName);
MU = transpose(posterior_mean);
SIGMA = posterior_covariance;
@ -64,16 +67,16 @@ end
% (usefull if the user wants to perform some computations using
% the posterior mean instead of the posterior mode ==> ).
parameter_names = bayestopt_.name;
save([M_.dname filesep 'Output' filesep M_.fname '_mean.mat'],'xparam1','hh','parameter_names','SIGMA');
save([M_.dname filesep outputFolderName filesep M_.fname '_mean.mat'],'xparam1','hh','parameter_names','SIGMA');
fprintf('Estimation::marginal density: I''m computing the posterior log marginal density (modified harmonic mean)... ');
fprintf('marginal density: I''m computing the posterior log marginal density (modified harmonic mean)... ');
try
% use this robust option to avoid inf/nan
logdetSIGMA = 2*sum(log(diag(chol(SIGMA))));
catch
% in case SIGMA is not positive definite
logdetSIGMA = nan;
fprintf('Estimation::marginal density: the covariance of MCMC draws is not positive definite. You may have too few MCMC draws.');
fprintf('marginal density: the covariance of MCMC draws is not positive definite. You may have too few MCMC draws.');
end
invSIGMA = hh;
marginal = zeros(9,2);
@ -108,18 +111,18 @@ while check_coverage
if abs((marginal(9,2)-marginal(1,2))/marginal(9,2)) > options_.marginal_data_density.harmonic_mean.tolerance || isinf(marginal(1,2))
fprintf('\n')
if increase == 1
disp('Estimation::marginal density: The support of the weighting density function is not large enough...')
disp('Estimation::marginal density: I increase the variance of this distribution.')
disp('marginal density: The support of the weighting density function is not large enough...')
disp('marginal density: I increase the variance of this distribution.')
increase = 1.2*increase;
linee = 0;
else
disp('Estimation::marginal density: Let me try again.')
disp('marginal density: Let me try again.')
increase = 1.2*increase;
linee = 0;
if increase > 20
check_coverage = 0;
clear invSIGMA detSIGMA increase;
disp('Estimation::marginal density: There''s probably a problem with the modified harmonic mean estimator.')
disp('marginal density: There''s probably a problem with the modified harmonic mean estimator.')
end
end
else

View File

@ -60,7 +60,7 @@ nblck = size(record.LastParameters,1);
clear record;
% Get all the posterior draws:
PosteriorDraws = GetAllPosteriorDraws(column, FirstMhFile, FirstLine, TotalNumberOfMhFiles, NumberOfDraws, nblck, blck);
PosteriorDraws = GetAllPosteriorDraws(M_.dname, M_.fname, column, FirstMhFile, FirstLine, TotalNumberOfMhFiles, NumberOfDraws, nblck, blck);
% Compute the autocorrelation function:
[autocov,autocor] = sample_autocovariance(PosteriorDraws,options_.mh_autocorrelation_function_size);
@ -93,7 +93,7 @@ if options_.mh_nblck>1
FigureName = [ FigureName , ' (block number' int2str(blck) ').'];
end
hh=dyn_figure(options_.nodisplay,'Name',FigureName);
hh_fig=dyn_figure(options_.nodisplay,'Name',FigureName);
bar(0:options_.mh_autocorrelation_function_size,autocor,'k');
axis tight
@ -106,4 +106,4 @@ if ~exist([M_.dname filesep 'graphs'])
end
plot_name=get_the_name(column,0,M_,estim_params_,options_);
dyn_saveas(hh,[M_.dname, filesep, 'graphs', filesep, 'MH_Autocorrelation_' plot_name],options_.nodisplay,options_.graph_format)
dyn_saveas(hh_fig,[M_.dname, filesep, 'graphs', filesep, 'MH_Autocorrelation_' plot_name],options_.nodisplay,options_.graph_format)

View File

@ -64,7 +64,7 @@ function [alphahat,epsilonhat,etahat,a,P1,aK,PK,decomp,V, aalphahat,eetahat,d,al
% Models", S.J. Koopman and J. Durbin (2003), in Journal of Time Series
% Analysis, vol. 24(1), pp. 85-98.
% Copyright © 2004-2021 Dynare Team
% Copyright © 2004-2023 Dynare Team
%
% This file is part of Dynare.
%
@ -315,8 +315,8 @@ if isoccbin
% kalman update is not yet robust to accommodate diffuse steps
end
if occbin_options.opts_regime.waitbar
hh = dyn_waitbar(0,'Occbin: Piecewise Kalman Filter');
set(hh,'Name','Occbin: Piecewise Kalman Filter.');
hh_fig = dyn_waitbar(0,'Occbin: Piecewise Kalman Filter');
set(hh_fig,'Name','Occbin: Piecewise Kalman Filter.');
waitbar_indicator=1;
else
waitbar_indicator=0;
@ -346,7 +346,7 @@ while notsteady && t<smpl
di = data_index{t}';
if t>=first_period_occbin_update
if waitbar_indicator
dyn_waitbar(t/smpl, hh, sprintf('Period %u of %u', t,smpl));
dyn_waitbar(t/smpl, hh_fig, sprintf('Period %u of %u', t,smpl));
end
occbin_options.opts_regime.waitbar=0;
if t==1
@ -530,7 +530,7 @@ while notsteady && t<smpl
end
end
if waitbar_indicator
dyn_waitbar_close(hh);
dyn_waitbar_close(hh_fig);
end
P1(:,:,t+1) = P(:,:,t+1);

View File

@ -1,46 +1,32 @@
function mode_check(fun,x,hessian_mat,DynareDataset,DatasetInfo,DynareOptions,Model,EstimatedParameters,BayesInfo,BoundsInfo,DynareResults)
% Checks the estimated ML mode or Posterior mode.
function mcheck = mode_check(fun,xparam,hessian_mat,options_,M_,estim_params_,bayestopt_,bounds,isMinimum, varargin)
% function mcheck = mode_check(fun,xparam,hessian_mat,options_,M_,estim_params_,bayestopt_,bounds,isMinimum, varargin)
% -------------------------------------------------------------------------
% Checks the estimated ML or Posterior mode/minimum by plotting sections of
% the likelihood/posterior kernel. Each plot shows the variation of the
% function implied by the variations of a single parameter ( ceteris paribus)
% -------------------------------------------------------------------------
% INPUTS
% - fun: [func_handle] objective function
% - xparam: [vector] estimated mode/minimum
% - hessian_mat: [matrix] hessian of the objective function at the estimated mode/minimum
% - options_: [structure] Dynare options structure
% - M_: [structure] Dynare model structure
% - estim_params_: [structure] Dynare estimated parameters structure
% - bayestopt_: [structure] information on the priors
% - bounds: [structure] information on the bounds
% - isMinimum: [boolean] true if xparam is a minimum, false if it is a mode
% - varargin: [cell] additional arguments to be passed to fun
% -------------------------------------------------------------------------
% OUTPUTS
% - mcheck: [structure] structure containing the data for the check plots
% - Saves the plots in the graphs folder and the data in a mat file
% -------------------------------------------------------------------------
% This function is called by
% - dynare_estimation_1
% - mom.run
% -------------------------------------------------------------------------
%@info:
%! @deftypefn {Function File} mode_check (@var{fun}, @var{x}, @var{hessian_mat}, @var{DynareDataset}, @var{DynareOptions}, @var{Model}, @var{EstimatedParameters}, @var{BayesInfo}, @var{DynareResults})
%! @anchor{mode_check}
%! @sp 1
%! Checks the estimated ML mode or Posterior mode by plotting sections of the likelihood/posterior kernel.
%! Each plot shows the variation of the likelihood implied by the variations of a single parameter, ceteris paribus)
%! @sp 2
%! @strong{Inputs}
%! @sp 1
%! @table @ @var
%! @item fun
%! Objective function.
%! @item x
%! Estimated mode.
%! @item start
%! Hessian of the objective function at the estimated mode @var{x}.
%! @item DynareDataset
%! Structure specifying the dataset used for estimation (dataset_).
%! @item DynareOptions
%! Structure defining dynare's options (options_).
%! @item Model
%! Structure specifying the (estimated) model (M_).
%! @item EstimatedParameters
%! Structure specifying the estimated parameters (estimated_params_).
%! @item BayesInfo
%! Structure containing information about the priors used for estimation (bayestopt_).
%! @item DynareResults
%! Structure gathering the results (oo_).
%! @end table
%! @sp 2
%! @strong{Outputs}
%! @sp 2
%! @strong{This function is called by:}
%! @sp 2
%! @strong{This function calls:}
%! The objective function (@var{func}).
%! @end deftypefn
%@eod:
% Copyright © 2003-2017 Dynare Team
% Copyright © 2023 Dynare Team
%
% This file is part of Dynare.
%
@ -57,165 +43,188 @@ function mode_check(fun,x,hessian_mat,DynareDataset,DatasetInfo,DynareOptions,Mo
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
TeX = DynareOptions.TeX;
tolBounds = 1e-8;
fval = feval(fun,xparam,varargin{:});
if ~isempty(hessian_mat)
[ s_min, k ] = min(diag(hessian_mat));
end
fval = feval(fun,x,DynareDataset,DatasetInfo,DynareOptions,Model,EstimatedParameters,BayesInfo,BoundsInfo,DynareResults);
if ~isempty(hessian_mat)
skipline()
disp('MODE CHECK')
skipline()
fprintf('Fval obtained by the minimization routine (minus the posterior/likelihood)): %f', fval);
skipline()
if isMinimum
fprintf('\nMINIMUM CHECK\n\nFval obtained by the optimization routine: %f\n', fval)
else
fprintf('\nMODE CHECK\n\nFval obtained by the optimization routine: %f\n', fval)
end
if s_min<eps
disp(sprintf('Most negative variance %f for parameter %d (%s = %f)', s_min, k , BayesInfo.name{k}, x(k)))
fprintf('Most negative variance %f for parameter %d (%s = %f)\n', s_min, k , bayestopt_.name{k}, xparam(k));
end
end
[nbplt,nr,nc,lr,lc,nstar] = pltorg(length(x));
[nbplt,nr,nc,~,~,nstar] = pltorg(length(xparam));
if ~exist([Model.dname filesep 'graphs'],'dir')
mkdir(Model.dname,'graphs');
end
if TeX && any(strcmp('eps',cellstr(DynareOptions.graph_format)))
fidTeX = fopen([Model.dname, '/graphs/', Model.fname '_CheckPlots.tex'],'w');
graphsFolder = CheckPath('graphs',M_.dname);
latexFolder = CheckPath('latex',M_.dname);
if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format)))
fidTeX = fopen([latexFolder filesep M_.fname '_CheckPlots.tex'],'w');
fprintf(fidTeX,'%% TeX eps-loader file generated by mode_check.m (Dynare).\n');
fprintf(fidTeX,['%% ' datestr(now,0) '\n']);
fprintf(fidTeX,' \n');
end
ll = DynareOptions.mode_check.neighbourhood_size;
ll = options_.mode_check.neighbourhood_size;
if isinf(ll)
DynareOptions.mode_check.symmetric_plots = false;
options_.mode_check.symmetric_plots = false;
end
mcheck = struct('cross',struct(),'emode',struct());
if isMinimum
mcheck = struct('cross',struct(),'emin',struct());
else
mcheck = struct('cross',struct(),'emode',struct());
end
for plt = 1:nbplt
if TeX
if options_.TeX
NAMES = [];
TeXNAMES = [];
end
hh = dyn_figure(DynareOptions.nodisplay,'Name','Mode check plots');
for k=1:min(nstar,length(x)-(plt-1)*nstar)
if isMinimum
hh_fig = dyn_figure(options_.nodisplay,'Name','Minimum check plots');
else
hh_fig = dyn_figure(options_.nodisplay,'Name','Mode check plots');
end
for k = 1:min(nstar,length(xparam)-(plt-1)*nstar)
subplot(nr,nc,k)
kk = (plt-1)*nstar+k;
[name,texname] = get_the_name(kk,TeX,Model,EstimatedParameters,DynareOptions);
xx = x;
if x(kk)~=0 && ~isinf(BoundsInfo.lb(kk)) && ~isinf(BoundsInfo.ub(kk))
l1 = max(BoundsInfo.lb(kk),(1-sign(x(kk))*ll)*x(kk)); m1 = 0; %lower bound
l2 = min(BoundsInfo.ub(kk),(1+sign(x(kk))*ll)*x(kk)); %upper bound
[name,texname] = get_the_name(kk,options_.TeX,M_,estim_params_,options_);
xx = xparam;
if xparam(kk)~=0 && ~isinf(bounds.lb(kk)) && ~isinf(bounds.ub(kk))
l1 = max(bounds.lb(kk),(1-sign(xparam(kk))*ll)*xparam(kk)); m1 = 0; % lower bound
l2 = min(bounds.ub(kk),(1+sign(xparam(kk))*ll)*xparam(kk)); % upper bound
else
%size info for 0 parameter is missing, use prior standard
%deviation
upper_bound=BoundsInfo.lb(kk);
% size info for 0 parameter is missing, use prior standard deviation
upper_bound = bounds.lb(kk);
if isinf(upper_bound)
upper_bound=-1e-6*DynareOptions.huge_number;
upper_bound = -1e-6*options_.huge_number;
end
lower_bound=BoundsInfo.ub(kk);
lower_bound = bounds.ub(kk);
if isinf(lower_bound)
lower_bound=-1e-6*DynareOptions.huge_number;
lower_bound = -1e-6*options_.huge_number;
end
l1 = max(lower_bound,-BayesInfo.p2(kk)); m1 = 0; %lower bound
l2 = min(upper_bound,BayesInfo.p2(kk)); %upper bound
l1 = max(lower_bound,-bayestopt_.p2(kk)); m1 = 0; % lower bound
l2 = min(upper_bound,bayestopt_.p2(kk)); % upper bound
end
binding_lower_bound=0;
binding_upper_bound=0;
if abs(x(kk)-BoundsInfo.lb(kk))<1e-8
binding_lower_bound=1;
bound_value=BoundsInfo.lb(kk);
elseif abs(x(kk)-BoundsInfo.ub(kk))<1e-8
binding_upper_bound=1;
bound_value=BoundsInfo.ub(kk);
binding_lower_bound = 0;
binding_upper_bound = 0;
if abs(xparam(kk)-bounds.lb(kk))<tolBounds
binding_lower_bound = 1;
bound_value = bounds.lb(kk);
elseif abs(xparam(kk)-bounds.ub(kk))<tolBounds
binding_upper_bound = 1;
bound_value = bounds.ub(kk);
end
if DynareOptions.mode_check.symmetric_plots && ~binding_lower_bound && ~binding_upper_bound
if l2<(1+ll)*x(kk) %test whether upper bound is too small due to prior binding
l1 = x(kk) - (l2-x(kk)); %adjust lower bound to become closer
if options_.mode_check.symmetric_plots && ~binding_lower_bound && ~binding_upper_bound
if l2<(1+ll)*xparam(kk) % test whether upper bound is too small due to prior binding
l1 = xparam(kk) - (l2-xparam(kk)); % adjust lower bound to become closer
m1 = 1;
end
if ~m1 && (l1>(1-ll)*x(kk)) && (x(kk)+(x(kk)-l1)<BoundsInfo.ub(kk)) % if lower bound was truncated and using difference from lower bound does not violate upper bound
l2 = x(kk) + (x(kk)-l1); %set upper bound to same distance as lower bound
if ~m1 && (l1>(1-ll)*xparam(kk)) && (xparam(kk)+(xparam(kk)-l1)<bounds.ub(kk)) % if lower bound was truncated and using difference from lower bound does not violate upper bound
l2 = xparam(kk) + (xparam(kk)-l1); % set upper bound to same distance as lower bound
end
end
z1 = l1:((x(kk)-l1)/(DynareOptions.mode_check.number_of_points/2)):x(kk);
z2 = x(kk):((l2-x(kk))/(DynareOptions.mode_check.number_of_points/2)):l2;
z1 = l1:((xparam(kk)-l1)/(options_.mode_check.number_of_points/2)):xparam(kk);
z2 = xparam(kk):((l2-xparam(kk))/(options_.mode_check.number_of_points/2)):l2;
z = union(z1,z2);
if ~DynareOptions.mode_check.nolik
if ~options_.mode_check.nolik
y = zeros(length(z),2);
dy = priordens(xx,BayesInfo.pshape,BayesInfo.p6,BayesInfo.p7,BayesInfo.p3,BayesInfo.p4);
if isfield(options_,'mom') && ( (strcmp(options_.mom.mom_method,'GMM') || strcmp(options_.mom.mom_method,'SMM')) && options_.mom.penalized_estimator )
dy = (xx-bayestopt_.p1)'/diag(bayestopt_.p2.^2)*(xx-bayestopt_.p1);
else
dy = priordens(xx,bayestopt_.pshape,bayestopt_.p6,bayestopt_.p7,bayestopt_.p3,bayestopt_.p4);
end
end
for i=1:length(z)
for i = 1:length(z)
xx(kk) = z(i);
[fval, info, exit_flag] = feval(fun,xx,DynareDataset,DatasetInfo,DynareOptions,Model,EstimatedParameters,BayesInfo,BoundsInfo,DynareResults);
[fval, info, exit_flag] = feval(fun,xx, varargin{:});
if exit_flag
y(i,1) = fval;
else
y(i,1) = NaN;
if DynareOptions.debug
fprintf('mode_check:: could not solve model for parameter %s at value %4.3f, error code: %u (%s)\n',name,z(i),info(1),get_error_message(info, DynareOptions))
if options_.debug
fprintf('mode_check:: could not solve model for parameter %s at value %4.3f, error code: %u (%s)\n',name,z(i),info(1),get_error_message(info, options_));
end
end
if ~DynareOptions.mode_check.nolik
lnprior = priordens(xx,BayesInfo.pshape,BayesInfo.p6,BayesInfo.p7,BayesInfo.p3,BayesInfo.p4);
if ~options_.mode_check.nolik
if isfield(options_,'mom') && ( (strcmp(options_.mom.mom_method,'GMM') || strcmp(options_.mom.mom_method,'SMM')) && options_.mom.penalized_estimator )
lnprior = (xx-bayestopt_.p1)'/diag(bayestopt_.p2.^2)*(xx-bayestopt_.p1);
else
lnprior = priordens(xx,bayestopt_.pshape,bayestopt_.p6,bayestopt_.p7,bayestopt_.p3,bayestopt_.p4);
end
y(i,2) = (y(i,1)+lnprior-dy);
end
end
mcheck.cross = setfield(mcheck.cross, name, [transpose(z), -y]);
mcheck.emode = setfield(mcheck.emode, name, x(kk));
fighandle=plot(z,-y);
if isMinimum
mcheck.cross = setfield(mcheck.cross, name, [transpose(z), y]); % keep y
mcheck.emin = setfield(mcheck.emin, name, xparam(kk)); % store as min
fighandle = plot(z,y);
else
mcheck.cross = setfield(mcheck.cross, name, [transpose(z), -y]); % multiply y by -1
mcheck.emode = setfield(mcheck.emode, name, xparam(kk)); % store as mode
fighandle = plot(z,-y);
end
hold on
yl=get(gca,'ylim');
plot( [x(kk) x(kk)], yl, 'c', 'LineWidth', 1)
yl = get(gca,'ylim');
plot( [xparam(kk) xparam(kk)], yl, 'c', 'LineWidth', 1);
NaN_index = find(isnan(y(:,1)));
zNaN = z(NaN_index);
yNaN = yl(1)*ones(size(NaN_index));
plot(zNaN,yNaN,'o','MarkerEdgeColor','r','MarkerFaceColor','r','MarkerSize',6);
if TeX
if options_.TeX
title(texname,'interpreter','latex')
else
title(name,'interpreter','none')
end
axis tight
if binding_lower_bound || binding_upper_bound
xl=get(gca,'xlim');
plot( [bound_value bound_value], yl, 'r--', 'LineWidth', 1)
xlim([xl(1)-0.5*binding_lower_bound*(xl(2)-xl(1)) xl(2)+0.5*binding_upper_bound*(xl(2)-xl(1))])
xl = get(gca,'xlim');
plot( [bound_value bound_value], yl, 'r--', 'LineWidth', 1);
xlim([xl(1)-0.5*binding_lower_bound*(xl(2)-xl(1)) xl(2)+0.5*binding_upper_bound*(xl(2)-xl(1))]);
end
hold off
drawnow
end
if ~DynareOptions.mode_check.nolik
if ~options_.mode_check.nolik
if isoctave
axes('outerposition',[0.3 0.93 0.42 0.07],'box','on'),
axes('outerposition',[0.3 0.93 0.42 0.07],'box','on');
else
axes('position',[0.3 0.01 0.42 0.05],'box','on'),
axes('position',[0.3 0.01 0.42 0.05],'box','on');
end
line_color=get(fighandle,'color');
plot([0.48 0.68],[0.5 0.5],'color',line_color{2})
hold on, plot([0.04 0.24],[0.5 0.5],'color',line_color{1})
set(gca,'xlim',[0 1],'ylim',[0 1],'xtick',[],'ytick',[])
text(0.25,0.5,'log-post')
text(0.69,0.5,'log-lik kernel')
plot([0.48 0.68],[0.5 0.5],'color',line_color{2});
hold on;
plot([0.04 0.24],[0.5 0.5],'color',line_color{1});
set(gca,'xlim',[0 1],'ylim',[0 1],'xtick',[],'ytick',[]);
if isMinimum
text(0.25,0.5,'log-post');
text(0.69,0.5,'log-dist kernel');
else
text(0.25,0.5,'log-post');
text(0.69,0.5,'log-lik kernel');
end
end
dyn_saveas(hh,[Model.dname, '/graphs/', Model.fname '_CheckPlots' int2str(plt) ],DynareOptions.nodisplay,DynareOptions.graph_format);
if TeX && any(strcmp('eps',cellstr(DynareOptions.graph_format)))
dyn_saveas(hh_fig,[graphsFolder filesep M_.fname '_CheckPlots' int2str(plt) ],options_.nodisplay,options_.graph_format);
if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format)))
% TeX eps loader file
fprintf(fidTeX,'\\begin{figure}[H]\n');
fprintf(fidTeX,'\\centering \n');
fprintf(fidTeX,'\\includegraphics[width=%2.2f\\textwidth]{%s_CheckPlots%s}\n',DynareOptions.figures.textwidth*min(k/nc,1),[Model.dname, '/graphs/',Model.fname],int2str(plt));
fprintf(fidTeX,'\\includegraphics[width=%2.2f\\textwidth]{%s_CheckPlots%s}\n',options_.figures.textwidth*min(k/nc,1),[graphsFolder filesep M_.fname],int2str(plt));
fprintf(fidTeX,'\\caption{Check plots.}');
fprintf(fidTeX,'\\label{Fig:CheckPlots:%s}\n',int2str(plt));
fprintf(fidTeX,'\\end{figure}\n');
fprintf(fidTeX,' \n');
end
end
if TeX && any(strcmp('eps',cellstr(DynareOptions.graph_format)))
if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format)))
fclose(fidTeX);
end
OutputDirectoryName = CheckPath('modecheck',Model.dname);
save([OutputDirectoryName '/check_plot_data.mat'],'mcheck');
save([graphsFolder filesep M_.fname '_check_plot_data.mat'],'mcheck');

View File

@ -21,7 +21,7 @@ function [pmean, pmode, pmedian, pstdev, p025, p975, covariance] = online_auxili
% - p975 [double] n×1 vector, 97.5 percent of the particles are below p975(i) for i=1,…,n.
% - covariance [double] n×n matrix, covariance of the particles at the end of the sample.
% Copyright © 2013-2022 Dynare Team
% Copyright © 2013-2023 Dynare Team
%
% This file is part of Dynare.
%
@ -386,7 +386,7 @@ if TeX
end
for plt = 1:nbplt
hh = dyn_figure(DynareOptions.nodisplay,'Name','Parameters Trajectories');
hh_fig = dyn_figure(DynareOptions.nodisplay,'Name','Parameters Trajectories');
for k=1:length(pmean)
subplot(nr,nc,k)
[name,texname] = get_the_name(k,TeX,Model,EstimatedParameters,DynareOptions);
@ -405,7 +405,7 @@ for plt = 1:nbplt
axis tight
drawnow
end
dyn_saveas(hh, [Model.fname '_param_traj' int2str(plt)], DynareOptions.nodisplay, DynareOptions.graph_format);
dyn_saveas(hh_fig, [Model.fname '_param_traj' int2str(plt)], DynareOptions.nodisplay, DynareOptions.graph_format);
if TeX
% TeX eps loader file
fprintf(fidTeX,'\\begin{figure}[H]\n');
@ -423,7 +423,7 @@ number_of_grid_points = 2^9; % 2^9 = 512 !... Must be a power of two.
bandwidth = 0; % Rule of thumb optimal bandwidth parameter.
kernel_function = 'gaussian'; % Gaussian kernel for Fast Fourier Transform approximation.
for plt = 1:nbplt
hh = dyn_figure(DynareOptions.nodisplay,'Name','Parameters Densities');
hh_fig = dyn_figure(DynareOptions.nodisplay,'Name','Parameters Densities');
for k=1:length(pmean)
subplot(nr,nc,k)
[name,texname] = get_the_name(k,TeX,Model,EstimatedParameters,DynareOptions);
@ -441,7 +441,7 @@ for plt = 1:nbplt
axis tight
drawnow
end
dyn_saveas(hh,[ Model.fname '_param_density' int2str(plt) ],DynareOptions.nodisplay,DynareOptions.graph_format);
dyn_saveas(hh_fig,[ Model.fname '_param_density' int2str(plt) ],DynareOptions.nodisplay,DynareOptions.graph_format);
if TeX && any(strcmp('eps',cellstr(DynareOptions.graph_format)))
% TeX eps loader file
fprintf(fidTeX, '\\begin{figure}[H]\n');

View File

@ -30,7 +30,7 @@ function ds = olsgibbs(ds, eqtag, BetaPriorExpectation, BetaPriorVariance, s2, n
% SPECIAL REQUIREMENTS
% dynare must have been run with the option: json=compute
% Copyright © 2018-2021 Dynare Team
% Copyright © 2018-2023 Dynare Team
%
% This file is part of Dynare.
%
@ -183,11 +183,11 @@ for i=1:discarddraws
h = gamrnd(PosteriorDegreesOfFreedom/2.0, 2.0/(PosteriorDegreesOfFreedom*s2_));
end
hh = dyn_waitbar(0,'Please wait. Gibbs sampler...');
set(hh,'Name','Olsgibbs estimation.');
hh_fig = dyn_waitbar(0,'Please wait. Gibbs sampler...');
set(hh_fig,'Name','Olsgibbs estimation.');
for i = discarddraws+1:ndraws
if ~mod(i,10)
dyn_waitbar((i-discarddraws)/(ndraws-discarddraws),hh,'Please wait. Gibbs sampler...');
dyn_waitbar((i-discarddraws)/(ndraws-discarddraws),hh_fig,'Please wait. Gibbs sampler...');
end
% Set conditional distribution of β
InverseConditionalPoseriorVariance = BetaInversePriorVariance + h*(X'*X);
@ -211,7 +211,7 @@ for i = discarddraws+1:ndraws
periods = periods+1;
end
end
dyn_waitbar_close(hh);
dyn_waitbar_close(hh_fig);
%% Save posterior moments.
oo_.olsgibbs.(model_name).posterior.mean.beta = mean(oo_.olsgibbs.(model_name).draws(:,1:n))';

View File

@ -56,7 +56,7 @@ function [PostMod,PostVar,Scale,PostMean] = gmhmaxlik_core(ObjFun,xparam1,mh_bou
% SPECIAL REQUIREMENTS
% None.
% Copyright © 2006-2017 Dynare Team
% Copyright © 2006-2023 Dynare Team
%
% This file is part of Dynare.
%
@ -87,8 +87,8 @@ CovJump = VarCov;
ModePar = xparam1;
%% [1] I tune the scale parameter.
hh = dyn_waitbar(0,'Tuning of the scale parameter...');
set(hh,'Name','Tuning of the scale parameter.');
hh_fig = dyn_waitbar(0,'Tuning of the scale parameter...');
set(hh_fig,'Name','Tuning of the scale parameter.');
j = 1; jj = 1;
isux = 0; jsux = 0; test = 0;
ix2 = ModePar;% initial condition!
@ -119,7 +119,7 @@ while j<=MaxNumberOfTuningSimulations
end % ... otherwise I don't move.
prtfrc = j/MaxNumberOfTuningSimulations;
if mod(j, 10)==0
dyn_waitbar(prtfrc,hh,sprintf('Acceptance ratio [during last 500]: %f [%f]',isux/j,jsux/jj));
dyn_waitbar(prtfrc,hh_fig,sprintf('Acceptance ratio [during last 500]: %f [%f]',isux/j,jsux/jj));
end
if j/500 == round(j/500)
test1 = jsux/jj;
@ -141,10 +141,10 @@ while j<=MaxNumberOfTuningSimulations
jj = jj + 1;
end
dyn_waitbar_close(hh);
dyn_waitbar_close(hh_fig);
%% [2] One block metropolis, I update the covariance matrix of the jumping distribution
hh = dyn_waitbar(0,'Metropolis-Hastings...');
set(hh,'Name','Estimation of the posterior covariance...'),
hh_fig = dyn_waitbar(0,'Metropolis-Hastings...');
set(hh_fig,'Name','Estimation of the posterior covariance...'),
j = 1;
isux = 0;
ilogpo2 = - feval(ObjFun,ix2,varargin{:});
@ -169,7 +169,7 @@ while j<= NumberOfIterations
end % ... otherwise I don't move.
prtfrc = j/NumberOfIterations;
if mod(j, 10)==0
dyn_waitbar(prtfrc,hh,sprintf('Acceptance ratio: %f',isux/j));
dyn_waitbar(prtfrc,hh_fig,sprintf('Acceptance ratio: %f',isux/j));
end
% I update the covariance matrix and the mean:
oldMeanPar = MeanPar;
@ -177,7 +177,7 @@ while j<= NumberOfIterations
CovJump = CovJump + oldMeanPar*oldMeanPar' - MeanPar*MeanPar' + ...
(1/j)*(ix2*ix2' - CovJump - oldMeanPar*oldMeanPar');
end
dyn_waitbar_close(hh);
dyn_waitbar_close(hh_fig);
PostVar = CovJump;
PostMean = MeanPar;
%% [3 & 4] I tune the scale parameter (with the new covariance matrix) if
@ -185,8 +185,8 @@ PostMean = MeanPar;
%% updating the covariance matrix)...
if strcmpi(info,'LastCall')
hh = dyn_waitbar(0,'Tuning of the scale parameter...');
set(hh,'Name','Tuning of the scale parameter.'),
hh_fig = dyn_waitbar(0,'Tuning of the scale parameter...');
set(hh_fig,'Name','Tuning of the scale parameter.'),
j = 1; jj = 1;
isux = 0; jsux = 0;
test = 0;
@ -212,7 +212,7 @@ if strcmpi(info,'LastCall')
end % ... otherwise I don't move.
prtfrc = j/MaxNumberOfTuningSimulations;
if mod(j, 10)==0
dyn_waitbar(prtfrc,hh,sprintf('Acceptance ratio [during last 1000]: %f [%f]',isux/j,jsux/jj));
dyn_waitbar(prtfrc,hh_fig,sprintf('Acceptance ratio [during last 1000]: %f [%f]',isux/j,jsux/jj));
end
if j/1000 == round(j/1000)
test1 = jsux/jj;
@ -229,14 +229,14 @@ if strcmpi(info,'LastCall')
j = j+1;
jj = jj + 1;
end
dyn_waitbar_close(hh);
dyn_waitbar_close(hh_fig);
Scale = iScale;
%%
%% Now I climb the hill
%%
if options.nclimb
hh = dyn_waitbar(0,' ');
set(hh,'Name','Now I am climbing the hill...'),
hh_fig = dyn_waitbar(0,' ');
set(hh_fig,'Name','Now I am climbing the hill...'),
j = 1; jj = 1;
jsux = 0;
test = 0;
@ -254,7 +254,7 @@ if strcmpi(info,'LastCall')
end % otherwise I don't move...
prtfrc = j/MaxNumberOfClimbingSimulations;
if mod(j, 10)==0
dyn_waitbar(prtfrc,hh,sprintf('%f Jumps / MaxStepSize %f',jsux,sqrt(max(diag(iScale*CovJump)))));
dyn_waitbar(prtfrc,hh_fig,sprintf('%f Jumps / MaxStepSize %f',jsux,sqrt(max(diag(iScale*CovJump)))));
end
if j/200 == round(j/200)
if jsux<=1
@ -275,7 +275,7 @@ if strcmpi(info,'LastCall')
j = j+1;
jj = jj + 1;
end
dyn_waitbar_close(hh);
dyn_waitbar_close(hh_fig);
end %climb
else
Scale = iScale;

View File

@ -13,7 +13,7 @@ function plot_icforecast(Variables,periods,options_,oo_)
% SPECIAL REQUIREMENTS
% This routine has to be called after imcforecast.m.
% Copyright © 2006-2019 Dynare Team
% Copyright © 2006-2023 Dynare Team
%
% This file is part of Dynare.
%
@ -59,7 +59,7 @@ for i=1:length(Variables)
end
function build_figure(name,cci1,cci2,mm1,mm2,options_,graphoptions)
hh = dyn_figure(options_.nodisplay,'Name',['Conditional forecast (' graphoptions.title ,'): ' name '.']);
hh_fig = dyn_figure(options_.nodisplay,'Name',['Conditional forecast (' graphoptions.title ,'): ' name '.']);
H = length(mm1);
h1 = area(1:H,cci1(2,1:H),'BaseValue',min([min(cci1(1,:)),min(cci2(1,:))]),'FaceColor',[.9 .9 .9]);
hold on
@ -70,4 +70,4 @@ plot(1:H,cci2(1,:),'--k','linewidth',1)
plot(1:H,cci2(2,:),'--k','linewidth',1)
axis tight
hold off
dyn_saveas(hh,[graphoptions.OutputDirectoryName '/Conditional_forecast_',strrep(deblank(graphoptions.title),' ','_'),'_',name],options_.nodisplay,options_.graph_format)
dyn_saveas(hh_fig,[graphoptions.OutputDirectoryName '/Conditional_forecast_',strrep(deblank(graphoptions.title),' ','_'),'_',name],options_.nodisplay,options_.graph_format)

View File

@ -19,7 +19,7 @@ function plot_identification(params, idemoments, idehess, idemodel, idelre, adva
% SPECIAL REQUIREMENTS
% None
% Copyright © 2008-2021 Dynare Team
% Copyright © 2008-2023 Dynare Team
%
% This file is part of Dynare.
%
@ -55,7 +55,7 @@ tittxt1=regexprep(tittxt, ' ', '_');
tittxt1=strrep(tittxt1, '.', '');
if SampleSize == 1
si_dMOMENTS = idemoments.si_dMOMENTS;
hh = dyn_figure(options_.nodisplay,'Name',[tittxt, ' - Identification using info from observables']);
hh_fig = dyn_figure(options_.nodisplay,'Name',[tittxt, ' - Identification using info from observables']);
subplot(211)
mmm = (idehess.ide_strength_dMOMENTS);
[ss, is] = sort(mmm);
@ -156,7 +156,7 @@ if SampleSize == 1
fprintf(fidTeX,'%% End Of TeX file. \n');
fclose(fidTeX);
end
dyn_saveas(hh,[IdentifDirectoryName '/' M_.fname '_ident_strength_' tittxt1],options_.nodisplay,options_.graph_format);
dyn_saveas(hh_fig,[IdentifDirectoryName '/' M_.fname '_ident_strength_' tittxt1],options_.nodisplay,options_.graph_format);
if advanced
if ~options_.nodisplay
@ -166,7 +166,7 @@ if SampleSize == 1
if all(isnan([si_dMOMENTSnorm';si_dTAUnorm';si_dLREnorm']))
fprintf('\nIDENTIFICATION: Skipping sensitivity plot, because standard deviation of parameters is NaN, possibly due to the use of ML.\n')
else
hh = dyn_figure(options_.nodisplay,'Name',[tittxt, ' - Sensitivity plot']);
hh_fig = dyn_figure(options_.nodisplay,'Name',[tittxt, ' - Sensitivity plot']);
subplot(211)
mmm = (si_dMOMENTSnorm)'./max(si_dMOMENTSnorm);
mmm1 = (si_dTAUnorm)'./max(si_dTAUnorm);
@ -185,7 +185,7 @@ if SampleSize == 1
end
legend('Moments','Model','LRE model','Location','Best')
title('Sensitivity bars using derivatives (log-scale)')
dyn_saveas(hh,[IdentifDirectoryName '/' M_.fname '_sensitivity_' tittxt1 ],options_.nodisplay,options_.graph_format);
dyn_saveas(hh_fig,[IdentifDirectoryName '/' M_.fname '_sensitivity_' tittxt1 ],options_.nodisplay,options_.graph_format);
if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format)))
fidTeX = fopen([IdentifDirectoryName '/' M_.fname '_sensitivity_' tittxt1,'.tex'],'w');
fprintf(fidTeX,'%% TeX eps-loader file generated by plot_identification.m (Dynare).\n');
@ -219,7 +219,7 @@ if SampleSize == 1
end
% fprintf('%-15s [%s] %10.3f\n',name{i},namx,idemoments.cosndMOMENTS(i,j))
end
hh = dyn_figure(options_.nodisplay,'Name',[tittxt,' - Collinearity patterns with ', int2str(j) ,' parameter(s)']);
hh_fig = dyn_figure(options_.nodisplay,'Name',[tittxt,' - Collinearity patterns with ', int2str(j) ,' parameter(s)']);
imagesc(pax,[0 1]);
set(gca,'xticklabel','')
set(gca,'yticklabel','')
@ -239,7 +239,7 @@ if SampleSize == 1
set(gca,'xgrid','on')
set(gca,'ygrid','on')
xlabel([tittxt,' - Collinearity patterns with ', int2str(j) ,' parameter(s)'],'interpreter','none')
dyn_saveas(hh,[ IdentifDirectoryName '/' M_.fname '_ident_collinearity_' tittxt1 '_' int2str(j) ],options_.nodisplay,options_.graph_format);
dyn_saveas(hh_fig,[ IdentifDirectoryName '/' M_.fname '_ident_collinearity_' tittxt1 '_' int2str(j) ],options_.nodisplay,options_.graph_format);
if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format)))
fidTeX = fopen([ IdentifDirectoryName '/' M_.fname '_ident_collinearity_' tittxt1 '_' int2str(j),'.tex'],'w');
fprintf(fidTeX,'%% TeX eps-loader file generated by plot_identification.m (Dynare).\n');
@ -337,7 +337,7 @@ if SampleSize == 1
end
else
hh = dyn_figure(options_.nodisplay,'Name',['MC sensitivities']);
hh_fig = dyn_figure(options_.nodisplay,'Name',['MC sensitivities']);
subplot(211)
mmm = (idehess.ide_strength_dMOMENTS);
[ss, is] = sort(mmm);
@ -363,7 +363,7 @@ else
legend('Moments','Model','LRE model','Location','Best')
end
title('MC mean of sensitivity measures')
dyn_saveas(hh,[ IdentifDirectoryName '/' M_.fname '_MC_sensitivity' ],options_.nodisplay,options_.graph_format);
dyn_saveas(hh_fig,[ IdentifDirectoryName '/' M_.fname '_MC_sensitivity' ],options_.nodisplay,options_.graph_format);
if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format)))
fidTeX = fopen([ IdentifDirectoryName '/' M_.fname '_MC_sensitivity.tex'],'w');
fprintf(fidTeX,'%% TeX eps-loader file generated by plot_identification.m (Dynare).\n');
@ -384,7 +384,7 @@ else
disp('Displaying advanced diagnostics')
end
% options_.nograph=1;
hh = dyn_figure(options_.nodisplay,'Name','MC Condition Number');
hh_fig = dyn_figure(options_.nodisplay,'Name','MC Condition Number');
subplot(221)
hist(log10(idemodel.cond))
title('log10 of Condition number in the model')
@ -394,7 +394,7 @@ else
subplot(223)
hist(log10(idelre.cond))
title('log10 of Condition number in the LRE model')
dyn_saveas(hh,[IdentifDirectoryName '/' M_.fname '_ident_COND' ],options_.nodisplay,options_.graph_format);
dyn_saveas(hh_fig,[IdentifDirectoryName '/' M_.fname '_ident_COND' ],options_.nodisplay,options_.graph_format);
options_mcf.pvalue_ks = 0.1;
options_mcf.pvalue_corr = 0.001;
options_mcf.alpha2 = 0;

View File

@ -15,7 +15,7 @@ function plot_priors(bayestopt_,M_,estim_params_,options_,optional_title)
% SPECIAL REQUIREMENTS
% None
% Copyright © 2004-2020 Dynare Team
% Copyright © 2004-2023 Dynare Team
%
% This file is part of Dynare.
%
@ -31,6 +31,8 @@ function plot_priors(bayestopt_,M_,estim_params_,options_,optional_title)
%
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
latexDirectoryName = CheckPath('latex',M_.dname);
graphDirectoryName = CheckPath('graphs',M_.dname);
TeX = options_.TeX;
if nargin<5
@ -41,17 +43,14 @@ end
npar = length(bayestopt_.p1);
[nbplt,nr,nc,lr,lc,nstar] = pltorg(npar);
if ~exist([M_.dname '/graphs'],'dir')
mkdir(M_.dname,'graphs');
end
if TeX && any(strcmp('eps',cellstr(options_.graph_format)))
fidTeX = fopen([M_.dname, '/graphs/' M_.fname '_Priors.tex'],'w');
fidTeX = fopen([latexDirectoryName filesep M_.fname '_Priors.tex'],'w');
fprintf(fidTeX,'%% TeX eps-loader file generated by plot_priors.m (Dynare).\n');
fprintf(fidTeX,['%% ' datestr(now,0) '\n']);
fprintf(fidTeX,' \n');
end
for plt = 1:nbplt
hplt = dyn_figure(options_.nodisplay,'Name',figurename);
hh_fig = dyn_figure(options_.nodisplay,'Name',figurename);
if TeX
TeXNAMES = [];
NAMES = [];
@ -63,8 +62,8 @@ for plt = 1:nbplt
[x,f,abscissa,dens,binf,bsup] = draw_prior_density(i,bayestopt_);
[nam,texnam] = get_the_name(i,TeX,M_,estim_params_,options_);
subplot(nr,nc,index)
hh = plot(x,f,'-k','linewidth',2);
set(hh,'color',[0.7 0.7 0.7]);
hh_plt = plot(x,f,'-k','linewidth',2);
set(hh_plt,'color',[0.7 0.7 0.7]);
box on
if TeX
title(texnam,'Interpreter','latex')
@ -73,11 +72,11 @@ for plt = 1:nbplt
end
drawnow
end
dyn_saveas(hplt,[M_.dname, '/graphs/' M_.fname '_Priors' int2str(plt)],options_.nodisplay,options_.graph_format);
dyn_saveas(hh_fig,[graphDirectoryName filesep M_.fname '_Priors' int2str(plt)],options_.nodisplay,options_.graph_format);
if TeX && any(strcmp('eps',cellstr(options_.graph_format)))
fprintf(fidTeX,'\\begin{figure}[H]\n');
fprintf(fidTeX,'\\centering\n');
fprintf(fidTeX,'\\includegraphics[width=%2.2f\\textwidth]{%s_Priors%s}\n',options_.figures.textwidth*min(index/nc,1),[M_.dname, '/graphs/' M_.fname],int2str(plt));
fprintf(fidTeX,'\\includegraphics[width=%2.2f\\textwidth]{%s_Priors%s}\n',options_.figures.textwidth*min(index/nc,1),[graphDirectoryName filesep M_.fname],int2str(plt));
fprintf(fidTeX,'\\caption{Priors.}');
fprintf(fidTeX,'\\label{Fig:Priors:%s}\n',int2str(plt));
fprintf(fidTeX,'\\end{figure}\n');

View File

@ -1,4 +1,4 @@
function pm3(n1,n2,ifil,B,tit1,tit2,tit3,tit_tex,names1,names2,name3,DirectoryName,var_type)
function pm3(n1,n2,ifil,B,tit1,tit2,tit3,tit_tex,names1,names2,name3,DirectoryName,var_type,dispString)
% Computes, stores and plots the posterior moment statistics.
%
@ -19,6 +19,7 @@ function pm3(n1,n2,ifil,B,tit1,tit2,tit3,tit_tex,names1,names2,name3,DirectoryNa
% where to read
% var_type [string] suffix of the filename from which to load moment
% matrix
% dispString [string] string to be displayes in the command window
% PARALLEL CONTEXT
% See also the comment in posterior_sampler.m funtion.
@ -43,8 +44,6 @@ function pm3(n1,n2,ifil,B,tit1,tit2,tit3,tit_tex,names1,names2,name3,DirectoryNa
global options_ M_ oo_
dispString = 'Estimation::mcmc';
nn = 3;
MaxNumberOfPlotsPerFigure = nn^2; % must be square
varlist = names2;

View File

@ -13,7 +13,7 @@ function myoutput=pm3_core(myinputs,fpar,nvar,whoiam, ThisMatlab)
% SPECIAL REQUIREMENTS.
% None.
% Copyright © 2007-2018 Dynare Team
% Copyright © 2007-2023 Dynare Team
%
% This file is part of Dynare.
%
@ -68,7 +68,7 @@ end
figunumber = 0;
subplotnum = 0;
hh = dyn_figure(options_.nodisplay,'Name',[tit1 ' ' int2str(figunumber+1)]);
hh_fig = dyn_figure(options_.nodisplay,'Name',[tit1 ' ' int2str(figunumber+1)]);
RemoteFlag = 0;
if whoiam
if Parallel(ThisMatlab).Local ==0
@ -81,7 +81,7 @@ OutputFileName = {};
for i=fpar:nvar
if max(abs(Mean(:,i))) > 10^(-6)
subplotnum = subplotnum+1;
set(0,'CurrentFigure',hh);
set(0,'CurrentFigure',hh_fig);
subplot(nn,nn,subplotnum);
if ~(all(all(Distrib(:,:,i)))>0 || ~all(all(Distrib(:,:,i)))<0)
plot([1 n2],[0 0],'-r','linewidth',0.5);
@ -115,14 +115,14 @@ for i=fpar:nvar
end
if subplotnum == MaxNumberOfPlotsPerFigure || i == nvar
dyn_saveas(hh,[M_.dname '/Output/' M_.fname '_' name3 '_' tit3{i}],options_.nodisplay,options_.graph_format);
dyn_saveas(hh_fig,[M_.dname '/Output/' M_.fname '_' name3 '_' tit3{i}],options_.nodisplay,options_.graph_format);
if RemoteFlag==1
OutputFileName = [OutputFileName; {[M_.dname, filesep, 'Output',filesep], [M_.fname '_' name3 '_' deblank(tit3(i,:)) '.*']}];
end
subplotnum = 0;
figunumber = figunumber+1;
if (i ~= nvar)
hh = dyn_figure(options_.nodisplay,'Name',[name3 ' ' int2str(figunumber+1)]);
hh_fig = dyn_figure(options_.nodisplay,'Name',[name3 ' ' int2str(figunumber+1)]);
end
end

View File

@ -1,5 +1,5 @@
function posterior_sampler(TargetFun,ProposalFun,xparam1,sampler_options,mh_bounds,dataset_,dataset_info,options_,M_,estim_params_,bayestopt_,oo_)
% function posterior_sampler(TargetFun,ProposalFun,xparam1,sampler_options,mh_bounds,dataset_,dataset_info,options_,M_,estim_params_,bayestopt_,oo_)
function posterior_sampler(TargetFun,ProposalFun,xparam1,sampler_options,mh_bounds,dataset_,dataset_info,options_,M_,estim_params_,bayestopt_,oo_,dispString)
% function posterior_sampler(TargetFun,ProposalFun,xparam1,sampler_options,mh_bounds,dataset_,dataset_info,options_,M_,estim_params_,bayestopt_,oo_,dispString)
% Random Walk Metropolis-Hastings algorithm.
%
% INPUTS
@ -17,6 +17,7 @@ function posterior_sampler(TargetFun,ProposalFun,xparam1,sampler_options,mh_boun
% o estim_params_ [structure] estimated parameters structure
% o bayestopt_ [structure] prior specification structure
% o oo_ [structure] output structure
% o dispString [string] string prependening the messages printed to the command window
%
% SPECIAL REQUIREMENTS
% None.
@ -53,12 +54,10 @@ function posterior_sampler(TargetFun,ProposalFun,xparam1,sampler_options,mh_boun
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
dispString = 'Estimation::mcmc';
vv = sampler_options.invhess;
% Initialization of the sampler
[ ix2, ilogpo2, ModelName, MetropolisFolder, fblck, fline, npar, nblck, nruns, NewFile, MAX_nruns, d, bayestopt_] = ...
posterior_sampler_initialization(TargetFun, xparam1, vv, mh_bounds,dataset_,dataset_info,options_,M_,estim_params_,bayestopt_,oo_);
posterior_sampler_initialization(TargetFun, xparam1, vv, mh_bounds,dataset_,dataset_info,options_,M_,estim_params_,bayestopt_,oo_, dispString);
InitSizeArray = min([repmat(MAX_nruns,nblck,1) fline+nruns-1],[],2);

View File

@ -174,12 +174,12 @@ for curr_block = fblck:nblck
refresh_rate = sampler_options.parallel_bar_refresh_rate;
bar_title = sampler_options.parallel_bar_title;
prc0=(curr_block-fblck)/(nblck-fblck+1)*(isoctave || options_.console_mode);
hh = dyn_waitbar({prc0,whoiam,options_.parallel(ThisMatlab)},[bar_title ' (' int2str(curr_block) '/' int2str(options_.mh_nblck) ')...']);
hh_fig = dyn_waitbar({prc0,whoiam,options_.parallel(ThisMatlab)},[bar_title ' (' int2str(curr_block) '/' int2str(options_.mh_nblck) ')...']);
else
refresh_rate = sampler_options.serial_bar_refresh_rate;
bar_title = sampler_options.serial_bar_title;
hh = dyn_waitbar(0,[bar_title ' (' int2str(curr_block) '/' int2str(options_.mh_nblck) ')...']);
set(hh,'Name',bar_title);
hh_fig = dyn_waitbar(0,[bar_title ' (' int2str(curr_block) '/' int2str(options_.mh_nblck) ')...']);
set(hh_fig,'Name',bar_title);
end
if mh_recover_flag==0
accepted_draws_this_chain = 0;
@ -207,9 +207,9 @@ for curr_block = fblck:nblck
prtfrc = draw_iter/nruns(curr_block);
if mod(draw_iter, refresh_rate)==0
if accepted_draws_this_chain/draw_iter==1 && sum(neval)>1
dyn_waitbar(prtfrc,hh,[bar_title ' (' int2str(curr_block) '/' int2str(options_.mh_nblck) ') ' sprintf('Function eval per draw %4.3f', feval_this_chain/draw_iter)]);
dyn_waitbar(prtfrc,hh_fig,[bar_title ' (' int2str(curr_block) '/' int2str(options_.mh_nblck) ') ' sprintf('Function eval per draw %4.3f', feval_this_chain/draw_iter)]);
else
dyn_waitbar(prtfrc,hh,[bar_title ' (' int2str(curr_block) '/' int2str(options_.mh_nblck) ') ' sprintf('Current acceptance ratio %4.3f', accepted_draws_this_chain/draw_iter)]);
dyn_waitbar(prtfrc,hh_fig,[bar_title ' (' int2str(curr_block) '/' int2str(options_.mh_nblck) ') ' sprintf('Current acceptance ratio %4.3f', accepted_draws_this_chain/draw_iter)]);
end
if save_tmp_file
[LastSeeds.(['file' int2str(NewFile(curr_block))]).Unifor, LastSeeds.(['file' int2str(NewFile(curr_block))]).Normal] = get_dynare_random_generator_state();
@ -265,7 +265,7 @@ for curr_block = fblck:nblck
draw_iter=draw_iter+1;
draw_index_current_file = draw_index_current_file + 1;
end % End of the simulations for one mh-block.
dyn_waitbar_close(hh);
dyn_waitbar_close(hh_fig);
if nruns(curr_block)
record.AcceptanceRatio(curr_block) = accepted_draws_this_chain/(draw_iter-1);
record.FunctionEvalPerIteration(curr_block) = feval_this_chain/(draw_iter-1);

View File

@ -1,7 +1,7 @@
function [ ix2, ilogpo2, ModelName, MetropolisFolder, FirstBlock, FirstLine, npar, NumberOfBlocks, nruns, NewFile, MAX_nruns, d, bayestopt_] = ...
posterior_sampler_initialization(TargetFun, xparam1, vv, mh_bounds,dataset_,dataset_info,options_,M_,estim_params_,bayestopt_,oo_)
posterior_sampler_initialization(TargetFun, xparam1, vv, mh_bounds,dataset_,dataset_info,options_,M_,estim_params_,bayestopt_,oo_, dispString)
% function [ ix2, ilogpo2, ModelName, MetropolisFolder, FirstBlock, FirstLine, npar, NumberOfBlocks, nruns, NewFile, MAX_nruns, d, bayestopt_] = ...
% metropolis_hastings_initialization(TargetFun, xparam1, vv, mh_bounds,dataset_,dataset_info,options_,M_,estim_params_,bayestopt_,oo_)
% metropolis_hastings_initialization(TargetFun, xparam1, vv, mh_bounds,dataset_,dataset_info,options_,M_,estim_params_,bayestopt_,oo_, dispString)
% Metropolis-Hastings initialization.
%
% INPUTS
@ -17,6 +17,7 @@ function [ ix2, ilogpo2, ModelName, MetropolisFolder, FirstBlock, FirstLine, npa
% o estim_params_ estimated parameters structure
% o bayestopt_ estimation options structure
% o oo_ outputs structure
% o dispString string to be displayed in the command window
%
% OUTPUTS
% o ix2 [double] (NumberOfBlocks*npar) vector of starting points for different chains
@ -55,8 +56,6 @@ function [ ix2, ilogpo2, ModelName, MetropolisFolder, FirstBlock, FirstLine, npa
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
dispString = 'Estimation::mcmc';
%Initialize outputs
ix2 = [];
ilogpo2 = [];

View File

@ -26,7 +26,7 @@ function [par, logpost, accepted, neval] = posterior_sampler_iteration(TargetFu
% SPECIAL REQUIREMENTS
% none
% Copyright © 2015-18 Dynare Team
% Copyright © 2015-2023 Dynare Team
%
% This file is part of Dynare.
%

View File

@ -1,5 +1,5 @@
function prior_posterior_statistics(type,dataset,dataset_info)
% function prior_posterior_statistics(type,dataset,dataset_info)
function prior_posterior_statistics(type,dataset,dataset_info,dispString)
% function prior_posterior_statistics(type,dataset,dataset_info,dispString)
% Computes Monte Carlo filter smoother and forecasts
%
% INPUTS
@ -8,6 +8,7 @@ function prior_posterior_statistics(type,dataset,dataset_info)
% gsa
% dataset: data structure
% dataset_info: dataset structure
% dispString: string to display in the command window
%
% OUTPUTS
% none
@ -36,6 +37,10 @@ function prior_posterior_statistics(type,dataset,dataset_info)
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
if nargin < 4
dispString = 'prior_posterior_statistics';
end
global options_ estim_params_ oo_ M_ bayestopt_
localVars=[];
@ -218,9 +223,9 @@ if strcmpi(type,'posterior')
mh_nblck = options_.mh_nblck;
if B==NumberOfDraws*mh_nblck
% we load all retained MH runs !
logpost=GetAllPosteriorDraws(0, FirstMhFile, FirstLine, TotalNumberOfMhFiles, NumberOfDraws, nblck);
logpost=GetAllPosteriorDraws(M_.dname, M_.fname, 0, FirstMhFile, FirstLine, TotalNumberOfMhFiles, NumberOfDraws, nblck);
for column=1:npar
x(:,column) = GetAllPosteriorDraws(column, FirstMhFile, FirstLine, TotalNumberOfMhFiles, NumberOfDraws, nblck);
x(:,column) = GetAllPosteriorDraws(M_.dname, M_.fname, column, FirstMhFile, FirstLine, TotalNumberOfMhFiles, NumberOfDraws, nblck);
end
else
logpost=NaN(B,1);
@ -327,27 +332,27 @@ end
if options_.smoother
pm3(endo_nbr,gend,ifil(1),B,'Smoothed variables',...
'',varlist, M_.endo_names_tex,M_.endo_names,...
varlist,'SmoothedVariables',DirectoryName,'_smooth');
varlist,'SmoothedVariables',DirectoryName,'_smooth',dispString);
pm3(exo_nbr,gend,ifil(2),B,'Smoothed shocks',...
'',M_.exo_names,M_.exo_names_tex,M_.exo_names,...
M_.exo_names,'SmoothedShocks',DirectoryName,'_inno');
M_.exo_names,'SmoothedShocks',DirectoryName,'_inno',dispString);
pm3(endo_nbr,1,ifil(9),B,'Trend_coefficients',...
'',varlist,M_.endo_names_tex,M_.endo_names,...
varlist,'TrendCoeff',DirectoryName,'_trend_coeff');
varlist,'TrendCoeff',DirectoryName,'_trend_coeff',dispString);
pm3(endo_nbr,gend,ifil(10),B,'Smoothed constant',...
'',varlist,M_.endo_names_tex,M_.endo_names,...
varlist,'Constant',DirectoryName,'_smoothed_constant');
varlist,'Constant',DirectoryName,'_smoothed_constant',dispString);
pm3(endo_nbr,gend,ifil(11),B,'Smoothed trend',...
'',varlist,M_.endo_names_tex,M_.endo_names,...
varlist,'Trend',DirectoryName,'_smoothed_trend');
varlist,'Trend',DirectoryName,'_smoothed_trend',dispString);
pm3(endo_nbr,gend,ifil(1),B,'Updated Variables',...
'',varlist,M_.endo_names_tex,M_.endo_names,...
varlist,'UpdatedVariables',DirectoryName, ...
'_update');
'_update',dispString);
if smoothed_state_uncertainty
pm3(endo_nbr,endo_nbr,ifil(13),B,'State Uncertainty',...
'',varlist,M_.endo_names_tex,M_.endo_names,...
varlist,'StateUncertainty',DirectoryName,'_state_uncert');
varlist,'StateUncertainty',DirectoryName,'_state_uncert',dispString);
end
if nvn
@ -357,23 +362,23 @@ if options_.smoother
end
pm3(meas_err_nbr,gend,ifil(3),B,'Smoothed measurement errors',...
'',meas_error_names,texnames,meas_error_names,...
meas_error_names,'SmoothedMeasurementErrors',DirectoryName,'_error')
meas_error_names,'SmoothedMeasurementErrors',DirectoryName,'_error',dispString)
end
end
if options_.filtered_vars
pm3(endo_nbr,gend,ifil(4),B,'One step ahead forecast (filtered variables)',...
'',varlist,M_.endo_names_tex,M_.endo_names,...
varlist,'FilteredVariables',DirectoryName,'_filter_step_ahead');
varlist,'FilteredVariables',DirectoryName,'_filter_step_ahead',dispString);
end
if options_.forecast
pm3(endo_nbr,horizon,ifil(6),B,'Forecasted variables (mean)',...
'',varlist,M_.endo_names_tex,M_.endo_names,...
varlist,'MeanForecast',DirectoryName,'_forc_mean');
varlist,'MeanForecast',DirectoryName,'_forc_mean',dispString);
pm3(endo_nbr,horizon,ifil(7),B,'Forecasted variables (point)',...
'',varlist,M_.endo_names_tex,M_.endo_names,...
varlist,'PointForecast',DirectoryName,'_forc_point');
varlist,'PointForecast',DirectoryName,'_forc_point',dispString);
if ~isequal(M_.H,0) && ~isempty(intersect(options_.varobs,varlist))
texnames = cell(length(options_.varobs), 1);
obs_names = cell(length(options_.varobs), 1);
@ -384,14 +389,14 @@ if options_.forecast
varlist_forecast_ME=intersect(options_.varobs,varlist);
pm3(meas_err_nbr,horizon,ifil(12),B,'Forecasted variables (point) with ME',...
'',varlist_forecast_ME,texnames,obs_names,...
varlist_forecast_ME,'PointForecastME',DirectoryName,'_forc_point_ME')
varlist_forecast_ME,'PointForecastME',DirectoryName,'_forc_point_ME',dispString)
end
end
if options_.filter_covariance
pm3(endo_nbr,endo_nbr,ifil(8),B,'Filtered covariances',...
'',varlist,M_.endo_names_tex,M_.endo_names,...
varlist,'FilterCovariance',DirectoryName,'_filter_covar');
varlist,'FilterCovariance',DirectoryName,'_filter_covar',dispString);
end

View File

@ -85,13 +85,13 @@ file_indx_number = 0;
oo_.dr=set_state_space(oo_.dr,M_,options_);
hh = dyn_waitbar(0,'Please wait. Prior sampler...');
set(hh,'Name','Prior sampler.');
hh_fig = dyn_waitbar(0,'Please wait. Prior sampler...');
set(hh_fig,'Name','Prior sampler.');
% Simulations.
while iteration < NumberOfSimulations
if ~mod(iteration,10)
dyn_waitbar(iteration/NumberOfSimulations,hh,'Please wait. Prior sampler...');
dyn_waitbar(iteration/NumberOfSimulations,hh_fig,'Please wait. Prior sampler...');
end
loop_indx = loop_indx+1;
params = Prior.draw();
@ -162,7 +162,7 @@ while iteration < NumberOfSimulations
end
end
dyn_waitbar_close(hh);
dyn_waitbar_close(hh_fig);
% Get informations about BK conditions and other things...
results.bk.indeterminacy_share = count_bk_indeterminacy/loop_indx;

View File

@ -14,7 +14,7 @@ function rplot(s1)
% SPECIAL REQUIREMENTS
% none
% Copyright © 2001-2021 Dynare Team
% Copyright © 2001-2023 Dynare Team
%
% This file is part of Dynare.
%
@ -75,7 +75,7 @@ if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format)))
end
if options_.rplottype == 0 %all in one plot
hh=dyn_figure(options_.nodisplay,'Name', 'Simulated Trajectory');
hh_fig=dyn_figure(options_.nodisplay,'Name', 'Simulated Trajectory');
plot(ix(i),y(:,i)) ;
if options_.TeX
title (['Plot of $' strjoin(s1_TeX', '~') '$'],'Interpreter','latex') ;
@ -94,13 +94,13 @@ if options_.rplottype == 0 %all in one plot
legend(s1,'interpreter','none');
end
end
dyn_saveas(hh,[M_.dname, filesep, 'graphs', filesep, 'SimulatedTrajectory_' s1{1}],options_.nodisplay,options_.graph_format)
dyn_saveas(hh_fig,[M_.dname, filesep, 'graphs', filesep, 'SimulatedTrajectory_' s1{1}],options_.nodisplay,options_.graph_format)
if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format)))
create_TeX_loader(fidTeX,[M_.dname, '/graphs/', 'SimulatedTrajectory_' s1{1}],'Simulated trajectories','SimulatedTrajectory_',s1{1},1)
end
elseif options_.rplottype == 1 %separate figures each
for j = 1:size(y,1)
hh=dyn_figure(options_.nodisplay,'Name', 'Simulated Trajectory');
hh_fig=dyn_figure(options_.nodisplay,'Name', 'Simulated Trajectory');
plot(ix(i),y(j,i)) ;
xlim([min(ix(i)) max(ix(i))])
if options_.TeX
@ -109,13 +109,13 @@ elseif options_.rplottype == 1 %separate figures each
title(['Plot of ' s1{j}],'Interpreter','none') ;
end
xlabel('Periods') ;
dyn_saveas(hh,[M_.dname, filesep, 'graphs', filesep, 'SimulatedTrajectory_' s1{j}],options_.nodisplay,options_.graph_format)
dyn_saveas(hh_fig,[M_.dname, filesep, 'graphs', filesep, 'SimulatedTrajectory_' s1{j}],options_.nodisplay,options_.graph_format)
if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format)))
create_TeX_loader(fidTeX,[M_.dname, '/graphs/', 'SimulatedTrajectory_' s1{j}],'Simulated trajectories','SimulatedTrajectory_',s1{j},1);
end
end
elseif options_.rplottype == 2 %different subplots
hh=dyn_figure(options_.nodisplay,'Name', 'Simulated Trajectory');
hh_fig=dyn_figure(options_.nodisplay,'Name', 'Simulated Trajectory');
nl = max(1,fix(size(y,1)/4)) ;
nc = ceil(size(y,1)/nl) ;
for j = 1:size(y,1)
@ -137,7 +137,7 @@ elseif options_.rplottype == 2 %different subplots
end
axis tight;
end
dyn_saveas(hh,[M_.dname, filesep, 'graphs', filesep, 'SimulatedTrajectory_' s1{1}],options_.nodisplay,options_.graph_format)
dyn_saveas(hh_fig,[M_.dname, filesep, 'graphs', filesep, 'SimulatedTrajectory_' s1{1}],options_.nodisplay,options_.graph_format)
if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format)))
create_TeX_loader(fidTeX,[M_.dname, '/graphs/', 'SimulatedTrajectory_' s1{1}],'Simulated trajectories','SimulatedTrajectory_', s1{1},min(j/nc,1));
end

View File

@ -310,10 +310,10 @@ if options_.irf
if nbplt == 0
elseif nbplt == 1
if options_.relative_irf
hh = dyn_figure(options_.nodisplay,'Name',['Relative response to' ...
hh_fig = dyn_figure(options_.nodisplay,'Name',['Relative response to' ...
' orthogonalized shock to ' tit{i}]);
else
hh = dyn_figure(options_.nodisplay,'Name',['Orthogonalized shock to' ...
hh_fig = dyn_figure(options_.nodisplay,'Name',['Orthogonalized shock to' ...
' ' tit{i}]);
end
for j = 1:number_of_plots_to_draw
@ -330,7 +330,7 @@ if options_.irf
title(deblank(mylist(j,:)),'Interpreter','none');
end
end
dyn_saveas(hh,[M_.dname, '/graphs/' M_.fname '_IRF_' tit{i}],options_.nodisplay,options_.graph_format);
dyn_saveas(hh_fig,[M_.dname, '/graphs/' M_.fname '_IRF_' tit{i}],options_.nodisplay,options_.graph_format);
if TeX && any(strcmp('eps',cellstr(options_.graph_format)))
fprintf(fidTeX,'\\begin{figure}[H]\n');
fprintf(fidTeX,'\\centering \n');
@ -343,10 +343,10 @@ if options_.irf
else
for fig = 1:nbplt-1
if options_.relative_irf
hh = dyn_figure(options_.nodisplay,'Name',['Relative response to orthogonalized shock' ...
hh_fig = dyn_figure(options_.nodisplay,'Name',['Relative response to orthogonalized shock' ...
' to ' tit{i} ' figure ' int2str(fig)]);
else
hh = dyn_figure(options_.nodisplay,'Name',['Orthogonalized shock to ' tit{i} ...
hh_fig = dyn_figure(options_.nodisplay,'Name',['Orthogonalized shock to ' tit{i} ...
' figure ' int2str(fig)]);
end
for plt = 1:nstar
@ -363,7 +363,7 @@ if options_.irf
title(deblank(mylist((fig-1)*nstar+plt,:)),'Interpreter','none');
end
end
dyn_saveas(hh,[M_.dname, '/graphs/' M_.fname '_IRF_' tit{i} int2str(fig)],options_.nodisplay,options_.graph_format);
dyn_saveas(hh_fig,[M_.dname, '/graphs/' M_.fname '_IRF_' tit{i} int2str(fig)],options_.nodisplay,options_.graph_format);
if TeX && any(strcmp('eps',cellstr(options_.graph_format)))
fprintf(fidTeX,'\\begin{figure}[H]\n');
fprintf(fidTeX,'\\centering \n');
@ -378,7 +378,7 @@ if options_.irf
fprintf(fidTeX,' \n');
end
end
hh = dyn_figure(options_.nodisplay,'Name',['Orthogonalized shock to ' tit{i} ' figure ' int2str(nbplt) '.']);
hh_fig = dyn_figure(options_.nodisplay,'Name',['Orthogonalized shock to ' tit{i} ' figure ' int2str(nbplt) '.']);
m = 0;
for plt = 1:number_of_plots_to_draw-(nbplt-1)*nstar
m = m+1;
@ -395,7 +395,7 @@ if options_.irf
title(deblank(mylist((nbplt-1)*nstar+plt,:)),'Interpreter','none');
end
end
dyn_saveas(hh,[M_.dname, '/graphs/' M_.fname '_IRF_' tit{i} int2str(nbplt) ],options_.nodisplay,options_.graph_format);
dyn_saveas(hh_fig,[M_.dname, '/graphs/' M_.fname '_IRF_' tit{i} int2str(nbplt) ],options_.nodisplay,options_.graph_format);
if TeX && any(strcmp('eps',cellstr(options_.graph_format)))
fprintf(fidTeX,'\\begin{figure}[H]\n');
fprintf(fidTeX,'\\centering \n');

View File

@ -27,7 +27,7 @@ function ds = surgibbs(ds, param_names, beta0, A, ndraws, discarddraws, thin, eq
% Combination of Direct Monte Carlo and Importance Sampling Techniques.
% Bayesian Analysis Volume 5, Number 1, pp. 65-96.
% Copyright © 2017-2021 Dynare Team
% Copyright © 2017-2023 Dynare Team
%
% This file is part of Dynare.
%
@ -106,12 +106,12 @@ if ~options_.noprint
disp('surgibbs: estimating, please wait...')
end
hh = dyn_waitbar(0,'Please wait. Gibbs sampler...');
set(hh,'Name','Surgibbs estimation.');
hh_fig = dyn_waitbar(0,'Please wait. Gibbs sampler...');
set(hh_fig,'Name','Surgibbs estimation.');
residdraws = zeros(floor((ndraws-discarddraws)/thin), nobs, m);
for i = 1:ndraws
if ~mod(i,10)
dyn_waitbar(i/ndraws,hh,'Please wait. Gibbs sampler...');
dyn_waitbar(i/ndraws,hh_fig,'Please wait. Gibbs sampler...');
end
% Draw Omega, given X, Y, Beta
resid = reshape(Y - X*beta, nobs, m);
@ -135,7 +135,7 @@ for i = 1:ndraws
end
end
end
dyn_waitbar_close(hh);
dyn_waitbar_close(hh_fig);
%
% Save results.

View File

@ -67,7 +67,7 @@ n_nblocks_to_plot=length(blck);
if n_nblocks_to_plot==1
% Get all the posterior draws:
PosteriorDraws = GetAllPosteriorDraws(column, FirstMhFile, FirstLine, TotalNumberOfMhFiles, TotalNumberOfMhDraws, mh_nblck, blck);
PosteriorDraws = GetAllPosteriorDraws(M_.dname,M_.fname,column, FirstMhFile, FirstLine, TotalNumberOfMhFiles, TotalNumberOfMhDraws, mh_nblck, blck);
else
PosteriorDraws=NaN(TotalNumberOfMhDraws,n_nblocks_to_plot);
save_string='';
@ -75,7 +75,7 @@ else
title_string_tex='';
end
for block_iter=1:n_nblocks_to_plot
PosteriorDraws(:,block_iter) = GetAllPosteriorDraws(column, FirstMhFile, FirstLine, TotalNumberOfMhFiles, TotalNumberOfMhDraws, mh_nblck, blck(block_iter));
PosteriorDraws(:,block_iter) = GetAllPosteriorDraws(M_.dname, M_.fname, column, FirstMhFile, FirstLine, TotalNumberOfMhFiles, TotalNumberOfMhDraws, mh_nblck, blck(block_iter));
save_string=[save_string,'_',num2str(blck(block_iter))];
if options_.TeX
title_string_tex=[title_string_tex, ', ' num2str(blck(block_iter))];
@ -118,7 +118,7 @@ if n_nblocks_to_plot==1
if options_.mh_nblck>1
FigureName = [ FigureName , ' (block number ' int2str(blck) ').'];
end
hh=dyn_figure(options_.nodisplay,'Name',FigureName);
hh_fig=dyn_figure(options_.nodisplay,'Name',FigureName);
plot(1:TotalNumberOfMhDraws,PosteriorDraws,'Color',[.7 .7 .7]);
% Compute the moving average of the posterior draws:
@ -137,7 +137,7 @@ if n_nblocks_to_plot==1
axis tight
legend({'MCMC draw';[num2str(N) ' period moving average']},'Location','NorthEast')
else
hh=dyn_figure(options_.nodisplay,'Name',FigureName);
hh_fig=dyn_figure(options_.nodisplay,'Name',FigureName);
pp=plot(1:TotalNumberOfMhDraws,PosteriorDraws);
legend(pp,strcat(repmat({'Chain '},n_nblocks_to_plot,1),num2str(blck(:))));
end
@ -160,7 +160,7 @@ if n_nblocks_to_plot==1
else
plot_name=[plot_name,'_blck_',save_string];
end
dyn_saveas(hh,[M_.dname, filesep, 'graphs', filesep, 'TracePlot_' plot_name],options_.nodisplay,options_.graph_format)
dyn_saveas(hh_fig,[M_.dname, filesep, 'graphs', filesep, 'TracePlot_' plot_name],options_.nodisplay,options_.graph_format)
if options_.TeX
fid=fopen([M_.dname,'/graphs/',M_.fname,'_TracePlot_' plot_name,'.tex'],'w+');

View File

@ -7,7 +7,7 @@ function update_last_mh_history_file(MetropolisFolder, ModelName, record)
% record [structure] structure storing the MH history
% Outputs: none
% Copyright © 2013-2017 Dynare Team
% Copyright © 2013-2023 Dynare Team
%
% This file is part of Dynare.
%
@ -31,7 +31,7 @@ mh_history_files = dir([BaseName '_mh_history_*.mat']);
% Check the existence of mh-files (assuming version 2, ie dynare version greater than 4.3.x).
if isequal(length(mh_history_files),0)
error(['Estimation::update_mh_file: I cannot find any mh-history file in ' MetropolisFolder '!'])
error(['update_last_mh_history_file: I cannot find any mh-history file in ' MetropolisFolder '!'])
end
BaseName = [BaseName '_mh_history_'];

View File

@ -2,7 +2,7 @@ function check_hessian_at_the_mode(hessian_xparam1, xparam1, M_, estim_params_,
% check_hessian_at_the_mode(hessian_xparam1, xparam1, M_, estim_params_, options_, bounds)
% -------------------------------------------------------------------------
% This function checks whether the hessian matrix at the mode is positive definite.
% =========================================================================
% -------------------------------------------------------------------------
% INPUTS
% o hessian_xparam1: [matrix] hessian matrix at the mode
% o xparam1: [vector] vector of parameter values at the mode
@ -17,6 +17,7 @@ function check_hessian_at_the_mode(hessian_xparam1, xparam1, M_, estim_params_,
% This function is called by
% o dynare_estimation_1.m
% -------------------------------------------------------------------------
% Copyright © 2023 Dynare Team
%
% This file is part of Dynare.
@ -33,7 +34,6 @@ function check_hessian_at_the_mode(hessian_xparam1, xparam1, M_, estim_params_,
%
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
% =========================================================================
try
chol(hessian_xparam1);

View File

@ -2,7 +2,7 @@ function [xparam1, hh] = check_mode_file(xparam1, hh, options_, bayestopt_)
% function [xparam1, hh] = check_mode_file(xparam1, hh, options_, bayestopt_)
% -------------------------------------------------------------------------
% Check that the provided mode_file is compatible with the current estimation settings.
% =========================================================================
% -------------------------------------------------------------------------
% INPUTS
% o xparam1: [vector] current vector of parameter values at the mode
% o hh: [matrix] current hessian matrix at the mode
@ -16,6 +16,7 @@ function [xparam1, hh] = check_mode_file(xparam1, hh, options_, bayestopt_)
% This function is called by
% o dynare_estimation_init.m
% -------------------------------------------------------------------------
% Copyright © 2023 Dynare Team
%
% This file is part of Dynare.
@ -32,7 +33,6 @@ function [xparam1, hh] = check_mode_file(xparam1, hh, options_, bayestopt_)
%
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
% =========================================================================
number_of_estimated_parameters = length(xparam1);
mode_file = load(options_.mode_file);

View File

@ -3,7 +3,7 @@ function check_prior_stderr_corr(estim_params_,bayestopt_)
% -------------------------------------------------------------------------
% Check if the prior allows for negative standard deviations and
% correlations larger than +-1. If so, issue a warning.
% =========================================================================
% -------------------------------------------------------------------------
% INPUTS
% o estim_params_: [struct] information on estimated parameters
% o bayestopt_: [struct] information on priors
@ -14,6 +14,7 @@ function check_prior_stderr_corr(estim_params_,bayestopt_)
% This function is called by
% o initial_estimation_checks.m
% -------------------------------------------------------------------------
% Copyright © 2023 Dynare Team
%
% This file is part of Dynare.
@ -30,7 +31,6 @@ function check_prior_stderr_corr(estim_params_,bayestopt_)
%
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
% =========================================================================
nvx = estim_params_.nvx; % number of stderr parameters for structural shocks
if nvx && any(bayestopt_.p3(1:nvx)<0)

View File

@ -2,7 +2,7 @@ function [steady_state, info, steady_state_changes_parameters] = check_steady_st
% function [steady_state, info, steady_state_changes_parameters] = check_steady_state_changes_parameters(M_,estim_params_,oo_,options_,steadystate_check_flag_vec)
% -------------------------------------------------------------------------
% Check if steady-state solves static model and if it changes estimated parameters
% =========================================================================
% -------------------------------------------------------------------------
% INPUTS
% o M_: [struct] information on the model
% o estim_params_: [struct] information on estimated parameters
@ -18,6 +18,7 @@ function [steady_state, info, steady_state_changes_parameters] = check_steady_st
% This function is called by
% o initial_estimation_checks.m
% -------------------------------------------------------------------------
% Copyright © 2023 Dynare Team
%
% This file is part of Dynare.
@ -34,7 +35,6 @@ function [steady_state, info, steady_state_changes_parameters] = check_steady_st
%
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
% =========================================================================
value_parameter_change = 1.01; % value with which parameters are slightly changed.
steady_state_changes_parameters = false; % initialize

View File

@ -4,7 +4,7 @@ function check_varobs_are_endo_and_declared_once(varobs,endo_names)
% Check that each declared observed variable:
% - is also an endogenous variable
% - is declared only once
% =========================================================================
% -------------------------------------------------------------------------
% INPUTS
% o varobs: [cell] list of observed variables
% o endo_names: [cell] list of endogenous variables
@ -15,6 +15,7 @@ function check_varobs_are_endo_and_declared_once(varobs,endo_names)
% This function is called by
% o dynare_estimation_init.m
% -------------------------------------------------------------------------
% Copyright © 2023 Dynare Team
%
% This file is part of Dynare.
@ -31,7 +32,6 @@ function check_varobs_are_endo_and_declared_once(varobs,endo_names)
%
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
% =========================================================================
number_of_observed_variables = length(varobs);
for i = 1:number_of_observed_variables

View File

@ -2,7 +2,7 @@ function invhess = set_mcmc_jumping_covariance(invhess, xparam_nbr, MCMC_jumping
% function invhess = set_mcmc_jumping_covariance(invhess, xparam_nbr, MCMC_jumping_covariance, bayestopt_, stringForErrors)
% -------------------------------------------------------------------------
% sets the jumping covariance matrix for the MCMC algorithm
% =========================================================================
% -------------------------------------------------------------------------
% INPUTS
% o invhess: [matrix] already computed inverse of the hessian matrix
% o xparam_nbr: [integer] number of estimated parameters
@ -16,6 +16,7 @@ function invhess = set_mcmc_jumping_covariance(invhess, xparam_nbr, MCMC_jumping
% This function is called by
% o dynare_estimation_1.m
% -------------------------------------------------------------------------
% Copyright © 2023 Dynare Team
%
% This file is part of Dynare.
@ -32,7 +33,6 @@ function invhess = set_mcmc_jumping_covariance(invhess, xparam_nbr, MCMC_jumping
%
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
% =========================================================================
switch MCMC_jumping_covariance
case 'hessian' % do nothing and use hessian from previous mode optimization

View File

@ -15,6 +15,7 @@ function bounds = set_mcmc_prior_bounds(xparam, bayestopt_, options_, stringForE
% This function is called by
% o dynare_estimation_1.m
% -------------------------------------------------------------------------
% Copyright © 2023 Dynare Team
%
% This file is part of Dynare.
@ -31,7 +32,6 @@ function bounds = set_mcmc_prior_bounds(xparam, bayestopt_, options_, stringForE
%
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
% =========================================================================
bounds = prior_bounds(bayestopt_, options_.prior_trunc);
outside_bound_pars = find(xparam < bounds.lb | xparam > bounds.ub);

View File

@ -3,7 +3,7 @@ function mh_jscale = tune_mcmc_mh_jscale_wrapper(invhess, options_, M_, objectiv
% -------------------------------------------------------------------------
% Wrapper to call the algorithm to tune the jumping scale parameter for the
% Metropolis-Hastings algorithm; currently only supports RW-MH algorithm.
% =========================================================================
% -------------------------------------------------------------------------
% INPUTS
% o invhess: [matrix] jumping covariance matrix
% o options_: [struct] Dynare options
@ -17,8 +17,9 @@ function mh_jscale = tune_mcmc_mh_jscale_wrapper(invhess, options_, M_, objectiv
% o mh_jscale: [double] tuned jumping scale parameter
% -------------------------------------------------------------------------
% This function is called by
% o dynare_estimation_1.m
% o dynare_estimation_1
% -------------------------------------------------------------------------
% Copyright © 2023 Dynare Team
%
% This file is part of Dynare.
@ -35,9 +36,7 @@ function mh_jscale = tune_mcmc_mh_jscale_wrapper(invhess, options_, M_, objectiv
%
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
% =========================================================================
% get invhess in case of use_mh_covariance_matrix
posterior_sampler_options_temp = options_.posterior_sampler_options.current_options;
posterior_sampler_options_temp.invhess = invhess;
posterior_sampler_options_temp = check_posterior_sampler_options(posterior_sampler_options_temp, M_.fname, M_.dname, options_);

View File

@ -147,13 +147,13 @@ end;
varobs yhat;
% Run prior function to get prior slope of the PC based on independent priors
hh=figure('Name','Slope of the Phillips Curve');
hh_fig=figure('Name','Slope of the Phillips Curve');
prior_function(function='Gali_2015_PC_slope');
PC_slope_vec=cell2mat(oo_.prior_function_results(:,1));
optimal_bandwidth = mh_optimal_bandwidth(PC_slope_vec,length(PC_slope_vec),0,'gaussian');
[density(:,1),density(:,2)] = kernel_density_estimate(PC_slope_vec,512,length(PC_slope_vec),optimal_bandwidth,'gaussian');
figure(hh)
figure(hh_fig)
subplot(3,1,1)
plot(density(:,1),density(:,2));
title('Prior')
@ -165,7 +165,7 @@ posterior_function(function='Gali_2015_PC_slope');
PC_slope_vec=cell2mat(oo_.posterior_function_results(:,1));
optimal_bandwidth = mh_optimal_bandwidth(PC_slope_vec,length(PC_slope_vec),0,'gaussian');
[density(:,1),density(:,2)] = kernel_density_estimate(PC_slope_vec,512,length(PC_slope_vec),optimal_bandwidth,'gaussian');
figure(hh)
figure(hh_fig)
subplot(3,1,2)
plot(density(:,1),density(:,2));
title('Updated Prior')
@ -178,7 +178,7 @@ posterior_function(function='Gali_2015_PC_slope');
PC_slope_vec=cell2mat(oo_.posterior_function_results(:,1));
optimal_bandwidth = mh_optimal_bandwidth(PC_slope_vec,length(PC_slope_vec),0,'gaussian');
[density(:,1),density(:,2)] = kernel_density_estimate(PC_slope_vec,512,length(PC_slope_vec),optimal_bandwidth,'gaussian');
figure(hh)
figure(hh_fig)
subplot(3,1,3)
plot(density(:,1),density(:,2));
title('Posterior')