/usr/share/dynare/matlab/PlotPosteriorDistributions.m is in dynare-common 4.4.1-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 | function oo_ = PlotPosteriorDistributions(estim_params_, M_, options_, bayestopt_, oo_)
% function PlotPosteriorDistributions()
% plots posterior distributions
%
% INPUTS
% estim_params_ [structure]
% M_ [structure]
% options_ [structure]
% bayestopt_ [structure]
% oo_ [structure]
%
% OUTPUTS
% oo_ [structure]
%
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2005-2013 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 <http://www.gnu.org/licenses/>.
OutputDirectoryName = CheckPath('Output',M_.dname);
TeX = options_.TeX;
nblck = options_.mh_nblck;
nvx = estim_params_.nvx;
nvn = estim_params_.nvn;
ncx = estim_params_.ncx;
ncn = estim_params_.ncn;
np = estim_params_.np ;
npar = nvx+nvn+ncx+ncn+np;
MaxNumberOfPlotPerFigure = 9;% The square root must be an integer!
nn = sqrt(MaxNumberOfPlotPerFigure);
figurename = 'Priors and posteriors';
if TeX
fidTeX = fopen([OutputDirectoryName '/' 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');
end
figunumber = 0;
subplotnum = 0;
for i=1:npar
subplotnum = subplotnum+1;
if subplotnum == 1
figunumber = figunumber+1;
hfig=dyn_figure(options_,'Name',figurename);
end
[nam,texnam] = get_the_name(i,TeX,M_,estim_params_,options_);
if subplotnum == 1
NAMES = nam;
if TeX
TeXNAMES = texnam;
end
else
NAMES = char(NAMES,nam);
if TeX
TeXNAMES = char(TeXNAMES,texnam);
end
end
[x2,f2,abscissa,dens,binf2,bsup2] = draw_prior_density(i,bayestopt_);
top2 = max(f2);
if i <= nvx
name = deblank(M_.exo_names(estim_params_.var_exo(i,1),:));
eval(['x1 = oo_.posterior_density.shocks_std.' name '(:,1);'])
eval(['f1 = oo_.posterior_density.shocks_std.' name '(:,2);'])
eval(['oo_.prior_density.shocks_std.' name '(:,1) = x2;'])
eval(['oo_.prior_density.shocks_std.' name '(:,2) = f2;'])
if ~options_.mh_posterior_mode_estimation
eval(['pmod = oo_.posterior_mode.shocks_std.' name ';'])
end
elseif i <= nvx+nvn
name = deblank(options_.varobs(estim_params_.nvn_observable_correspondence(i-nvx,1),:));
eval(['x1 = oo_.posterior_density.measurement_errors_std.' name '(:,1);'])
eval(['f1 = oo_.posterior_density.measurement_errors_std.' name '(:,2);'])
eval(['oo_.prior_density.mearsurement_errors_std.' name '(:,1) = x2;'])
eval(['oo_.prior_density.measurement_errors_std.' name '(:,2) = f2;'])
if ~options_.mh_posterior_mode_estimation
eval(['pmod = oo_.posterior_mode.measurement_errors_std.' name ';'])
end
elseif i <= nvx+nvn+ncx
j = i - (nvx+nvn);
k1 = estim_params_.corrx(j,1);
k2 = estim_params_.corrx(j,2);
name = [deblank(M_.exo_names(k1,:)) '_' deblank(M_.exo_names(k2,:))];
eval(['x1 = oo_.posterior_density.shocks_corr.' name '(:,1);'])
eval(['f1 = oo_.posterior_density.shocks_corr.' name '(:,2);'])
eval(['oo_.prior_density.shocks_corr.' name '(:,1) = x2;'])
eval(['oo_.prior_density.shocks_corr.' name '(:,2) = f2;'])
if ~options_.mh_posterior_mode_estimation
eval(['pmod = oo_.posterior_mode.shocks_corr.' name ';'])
end
elseif i <= nvx+nvn+ncx+ncn
j = i - (nvx+nvn+ncx);
k1 = estim_params_.corrn(j,1);
k2 = estim_params_.corrn(j,2);
name = [deblank(M_.endo_names(k1,:)) '_' deblank(M_.endo_names(k2,:))];
eval(['x1 = oo_.posterior_density.measurement_errors_corr.' name '(:,1);'])
eval(['f1 = oo_.posterior_density.measurement_errors_corr.' name '(:,2);'])
eval(['oo_.prior_density.mearsurement_errors_corr.' name '(:,1) = x2;'])
eval(['oo_.prior_density.measurement_errors_corr.' name '(:,2) = f2;'])
if ~options_.mh_posterior_mode_estimation
eval(['pmod = oo_.posterior_mode.measurement_errors_corr.' name ';'])
end
else
j = i - (nvx+nvn+ncx+ncn);
name = deblank(M_.param_names(estim_params_.param_vals(j,1),:));
eval(['x1 = oo_.posterior_density.parameters.' name '(:,1);'])
eval(['f1 = oo_.posterior_density.parameters.' name '(:,2);'])
eval(['oo_.prior_density.parameters.' name '(:,1) = x2;'])
eval(['oo_.prior_density.parameters.' name '(:,2) = f2;'])
if ~options_.mh_posterior_mode_estimation
eval(['pmod = oo_.posterior_mode.parameters.' name ';'])
end
end
top1 = max(f1);
top0 = max([top1;top2]);
binf1 = x1(1);
bsup1 = x1(end);
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]);
hold on;
plot(x1,f1,'-k','linewidth',2);
if ~options_.mh_posterior_mode_estimation
plot( [pmod pmod], [0.0 1.1*top0], '--g', 'linewidth', 2);
end
box on;
axis([borneinf bornesup 0 1.1*top0]);
title(nam,'Interpreter','none');
hold off;
drawnow
if subplotnum == MaxNumberOfPlotPerFigure || i == npar;
dyn_saveas(hfig,[OutputDirectoryName '/' M_.fname '_PriorsAndPosteriors' int2str(figunumber)],options_);
if TeX
fprintf(fidTeX,'\\begin{figure}[H]\n');
for j = 1:size(NAMES,1)
fprintf(fidTeX,'\\psfrag{%s}[1][][0.5][0]{%s}\n',deblank(NAMES(j,:)),deblank(TeXNAMES(j,:)));
end
fprintf(fidTeX,'\\centering\n');
fprintf(fidTeX,'\\includegraphics[scale=0.5]{%s/%s_PriorsAndPosteriors%s}\n',OutputDirectoryName,M_.fname,int2str(figunumber));
fprintf(fidTeX,'\\caption{Priors and posteriors.}');
fprintf(fidTeX,'\\label{Fig:PriorsAndPosteriors:%s}\n',int2str(figunumber));
fprintf(fidTeX,'\\end{figure}\n');
fprintf(fidTeX,' \n');
if i == npar
fprintf(fidTeX,'%% End of TeX file.\n');
fclose(fidTeX);
end
end
subplotnum = 0;
end
end
|