2020-06-29 07:39:55 +02:00
function plot_priors ( bayestopt_,M_,estim_params_,options_,optional_title)
2008-01-10 16:12:20 +01:00
% function plot_priors
% plots prior density
%
% INPUTS
2020-06-29 07:39:55 +02:00
% o bayestopt_ [structure]
% o M_ [structure]
% o estim_params_ [structure]
% o options_ [structure]
% o optional_title [string]
2008-01-10 16:12:20 +01:00
% OUTPUTS
2008-10-04 23:22:08 +02:00
% None
2011-09-14 19:03:56 +02:00
%
2008-01-10 16:12:20 +01:00
% SPECIAL REQUIREMENTS
2008-10-04 23:22:08 +02:00
% None
2008-08-01 14:40:33 +02:00
2023-09-13 18:10:16 +02:00
% Copyright © 2004-2023 Dynare Team
2008-08-01 14:40:33 +02:00
%
% 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
2021-06-09 17:33:48 +02:00
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
2023-09-13 18:10:16 +02:00
latexDirectoryName = CheckPath ( ' latex' , M_ . dname ) ;
graphDirectoryName = CheckPath ( ' graphs' , M_ . dname ) ;
2008-01-10 16:12:20 +01:00
2005-02-18 20:54:39 +01:00
TeX = options_ . TeX ;
2020-06-29 07:39:55 +02:00
if nargin < 5
figurename = ' Priors' ;
else
figurename = optional_title ;
end
2009-04-06 16:38:37 +02:00
npar = length ( bayestopt_ . p1 ) ;
2005-02-18 20:54:39 +01:00
[ nbplt , nr , nc , lr , lc , nstar ] = pltorg ( npar ) ;
2015-05-12 08:53:57 +02:00
if TeX && any ( strcmp ( ' eps' , cellstr ( options_ . graph_format ) ) )
2023-09-13 18:10:16 +02:00
fidTeX = fopen ( [ latexDirectoryName filesep M_ . fname ' _Priors.tex' ] , ' w' ) ;
2009-12-16 18:17:34 +01:00
fprintf ( fidTeX , ' %% TeX eps-loader file generated by plot_priors.m (Dynare).\n' ) ;
fprintf ( fidTeX , [ ' %% ' datestr ( now , 0 ) ' \n' ] ) ;
fprintf ( fidTeX , ' \n' ) ;
2005-02-18 20:54:39 +01:00
end
2017-05-16 12:42:01 +02:00
for plt = 1 : nbplt
2023-09-13 18:10:16 +02:00
hh_fig = dyn_figure ( options_ . nodisplay , ' Name' , figurename ) ;
2005-02-18 20:54:39 +01:00
if TeX
TeXNAMES = [ ] ;
2011-09-14 19:03:56 +02:00
NAMES = [ ] ;
end
2012-02-13 11:58:28 +01:00
nstar0 = min ( nstar , npar - ( plt - 1 ) * nstar ) ;
for index = 1 : nstar0
names = [ ] ;
i = ( plt - 1 ) * nstar + index ;
2009-02-04 11:44:54 +01:00
[ x , f , abscissa , dens , binf , bsup ] = draw_prior_density ( i , bayestopt_ ) ;
2011-09-14 19:03:56 +02:00
[ nam , texnam ] = get_the_name ( i , TeX , M_ , estim_params_ , options_ ) ;
2012-02-13 11:58:28 +01:00
subplot ( nr , nc , index )
2023-09-13 18:10:16 +02:00
hh_plt = plot ( x , f , ' -k' , ' linewidth' , 2 ) ;
set ( hh_plt , ' color' , [ 0.7 0.7 0.7 ] ) ;
2005-02-18 20:54:39 +01:00
box on
2020-06-17 20:23:49 +02:00
if TeX
title ( texnam , ' Interpreter' , ' latex' )
else
title ( nam , ' Interpreter' , ' none' )
end
2005-02-18 20:54:39 +01:00
drawnow
2008-06-24 20:20:48 +02:00
end
2023-09-13 18:10:16 +02:00
dyn_saveas ( hh_fig , [ graphDirectoryName filesep M_ . fname ' _Priors' int2str ( plt ) ] , options_ . nodisplay , options_ . graph_format ) ;
2015-05-12 08:53:57 +02:00
if TeX && any ( strcmp ( ' eps' , cellstr ( options_ . graph_format ) ) )
2005-02-18 20:54:39 +01:00
fprintf ( fidTeX , ' \\begin{figure}[H]\n' ) ;
fprintf ( fidTeX , ' \\centering\n' ) ;
2023-11-21 02:29:54 +01:00
fprintf ( fidTeX , ' \\includegraphics[width=%2.2f\\textwidth]{%s_Priors%s}\n' , options_ . figures . textwidth * min ( index / nc , 1 ) , [ graphDirectoryName ' /' M_ . fname ] , int2str ( plt ) ) ; % don't use filesep as it will create issues with LaTeX on Windows
2005-02-18 20:54:39 +01:00
fprintf ( fidTeX , ' \\caption{Priors.}' ) ;
2012-02-13 11:58:28 +01:00
fprintf ( fidTeX , ' \\label{Fig:Priors:%s}\n' , int2str ( plt ) ) ;
2005-02-18 20:54:39 +01:00
fprintf ( fidTeX , ' \\end{figure}\n' ) ;
end
2012-02-13 11:58:28 +01:00
end
2015-05-12 08:53:57 +02:00
if TeX && any ( strcmp ( ' eps' , cellstr ( options_ . graph_format ) ) )
2012-02-13 11:58:28 +01:00
fprintf ( fidTeX , ' \n' ) ;
fprintf ( fidTeX , ' %% End of TeX file.\n' ) ;
fclose ( fidTeX ) ;
2011-09-14 19:03:56 +02:00
end