2012-06-11 01:33:01 +02:00
function redform_screen ( dirname, options_gsa_)
%function redform_map(dirname, options_gsa_)
2011-12-09 21:13:16 +01:00
% inputs (from opt_gsa structure
% anamendo = options_gsa_.namendo;
% anamlagendo = options_gsa_.namlagendo;
% anamexo = options_gsa_.namexo;
% iload = options_gsa_.load_redform;
%
2012-01-09 13:12:31 +01:00
% Written by Marco Ratto
2011-12-09 21:13:16 +01:00
% Joint Research Centre, The European Commission,
2017-05-16 15:10:20 +02:00
% marco.ratto@ec.europa.eu
2012-01-09 13:12:31 +01:00
2022-04-13 13:15:19 +02:00
% Copyright © 2012-2016 European Commission
% Copyright © 2012-2018 Dynare Team
2012-01-09 13:12:31 +01: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.
2011-12-09 21:13:16 +01:00
%
2012-01-09 13:12:31 +01:00
% 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/>.
2011-12-09 21:13:16 +01:00
global M_ oo_ estim_params_ options_ bayestopt_
2012-06-11 01:33:01 +02:00
% options_gsa_ = options_.opt_gsa;
2011-12-09 21:13:16 +01:00
anamendo = options_gsa_ . namendo ;
anamlagendo = options_gsa_ . namlagendo ;
anamexo = options_gsa_ . namexo ;
iload = options_gsa_ . load_redform ;
nliv = options_gsa_ . morris_nliv ;
2017-10-10 10:05:59 +02:00
pnames = M_ . param_names ( estim_params_ . param_vals ( : , 1 ) ) ;
2017-05-16 12:42:01 +02:00
if nargin == 0
2017-05-16 15:10:20 +02:00
dirname = ' ' ;
2011-12-09 21:13:16 +01:00
end
load ( [ dirname , ' /' , M_ . fname , ' _prior' ] , ' lpmat' , ' lpmat0' , ' istable' , ' T' ) ;
2012-11-16 20:05:13 +01:00
nspred = M_ . nspred ;
2011-12-09 21:13:16 +01:00
[ kn , np ] = size ( lpmat ) ;
nshock = length ( bayestopt_ . pshape ) - np ;
nsok = length ( find ( M_ . lead_lag_incidence ( M_ . maximum_lag , : ) ) ) ;
js = 0 ;
2017-05-16 12:42:01 +02:00
for j = 1 : size ( anamendo , 1 )
2017-10-10 10:05:59 +02:00
namendo = deblank ( anamendo ( j , : ) ) ;
iendo = strmatch ( namendo , M_ . endo_names ( oo_ . dr . order_var ) , ' exact' ) ;
2017-05-16 15:10:20 +02:00
iplo = 0 ;
ifig = 0 ;
for jx = 1 : size ( anamexo , 1 )
2017-10-10 10:05:59 +02:00
namexo = deblank ( anamexo ( jx , : ) ) ;
iexo = strmatch ( namexo , M_ . exo_names , ' exact' ) ;
2017-05-16 15:10:20 +02:00
if ~ isempty ( iexo )
2017-10-10 10:05:59 +02:00
y0 = teff ( T ( iendo , iexo + nspred , : ) , kn , istable ) ;
2017-05-16 15:10:20 +02:00
if ~ isempty ( y0 )
if mod ( iplo , 9 ) == 0
2017-10-10 10:05:59 +02:00
ifig = ifig + 1 ;
hh = dyn_figure ( options_ . nodisplay , ' name' , [ namendo , [ ' vs. shocks ' ] , int2str ( ifig ) ] ) ;
iplo = 0 ;
2017-05-16 15:10:20 +02:00
end
2017-10-10 10:05:59 +02:00
iplo = iplo + 1 ;
js = js + 1 ;
subplot ( 3 , 3 , iplo )
[ SAmeas , SAMorris ] = Morris_Measure_Groups ( np + nshock , [ lpmat0 lpmat ] , y0 , nliv ) ;
2017-05-16 15:10:20 +02:00
SAM = squeeze ( SAMorris ( nshock + 1 : end , 1 ) ) ;
2017-10-10 10:05:59 +02:00
SA ( : , js ) = SAM ./ ( max ( SAM ) + eps ) ;
2017-05-16 15:10:20 +02:00
[ saso , iso ] = sort ( - SA ( : , js ) ) ;
bar ( SA ( iso ( 1 : min ( np , 10 ) ) , js ) )
set ( gca , ' xticklabel' , ' ' , ' fontsize' , 10 )
set ( gca , ' xlim' , [ 0.5 10.5 ] )
for ip = 1 : min ( np , 10 )
2017-10-10 10:05:59 +02:00
text ( ip , - 0.02 , pnames ( iso ( ip ) ) , ' rotation' , 90 , ' HorizontalAlignment' , ' right' , ' interpreter' , ' none' )
2017-05-16 15:10:20 +02:00
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 ) ;
create_TeX_loader ( options_ , [ dirname , ' /' , M_ . fname , ' _' , namendo , ' _vs_shock_' , num2str ( ifig ) ] , ifig , [ namendo , ' vs. shocks ' , int2str ( ifig ) ] , [ namendo , ' _vs_shock' ] , 1 )
end
end
2011-12-09 21:13:16 +01:00
end
end
2017-05-16 15:10:20 +02:00
if iplo < 9 && iplo > 0 && ifig
dyn_saveas ( hh , [ 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
2011-12-09 21:13:16 +01:00
2017-05-16 15:10:20 +02:00
iplo = 0 ;
ifig = 0 ;
for je = 1 : size ( anamlagendo , 1 )
namlagendo = deblank ( anamlagendo ( je , : ) ) ;
2017-10-10 10:05:59 +02:00
ilagendo = strmatch ( namlagendo , M_ . endo_names ( oo_ . dr . order_var ( M_ . nstatic + 1 : M_ . nstatic + nsok ) ) , ' exact' ) ;
2017-05-16 15:10:20 +02:00
if ~ isempty ( ilagendo )
y0 = teff ( T ( iendo , ilagendo , : ) , kn , istable ) ;
if ~ isempty ( y0 )
if mod ( iplo , 9 ) == 0
ifig = ifig + 1 ;
hh = dyn_figure ( options_ . nodisplay , ' name' , [ namendo , ' vs. lagged endogenous ' , int2str ( ifig ) ] ) ;
iplo = 0 ;
end
iplo = iplo + 1 ;
js = js + 1 ;
subplot ( 3 , 3 , iplo ) ,
[ SAmeas , SAMorris ] = Morris_Measure_Groups ( np + nshock , [ lpmat0 lpmat ] , y0 , nliv ) ;
SAM = squeeze ( SAMorris ( nshock + 1 : end , 1 ) ) ;
SA ( : , js ) = SAM ./ ( max ( SAM ) + eps ) ;
[ saso , iso ] = sort ( - SA ( : , js ) ) ;
bar ( SA ( iso ( 1 : min ( np , 10 ) ) , js ) )
%set(gca,'xticklabel',pnames(iso(1:min(np,10)),:),'fontsize',8)
set ( gca , ' xticklabel' , ' ' , ' fontsize' , 10 )
set ( gca , ' xlim' , [ 0.5 10.5 ] )
for ip = 1 : min ( np , 10 )
text ( ip , - 0.02 , deblank ( pnames ( iso ( ip ) , : ) ) , ' rotation' , 90 , ' HorizontalAlignment' , ' right' , ' interpreter' , ' none' )
end
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 ) ;
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
2011-12-09 21:13:16 +01:00
end
end
2017-05-16 15:10:20 +02:00
if iplo < 9 && iplo > 0 && ifig
dyn_saveas ( hh , [ 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
2011-12-09 21:13:16 +01:00
end
2017-05-16 15:10:20 +02:00
hh = dyn_figure ( options_ . nodisplay , ' Name' , ' Reduced form screening' ) ;
2011-12-09 21:13:16 +01:00
%bar(SA)
% boxplot(SA','whis',10,'symbol','r.')
myboxplot ( SA ' , [ ] , ' .' , [ ] , 10 )
set ( gca , ' xticklabel' , ' ' , ' fontsize' , 10 , ' xtick' , [ 1 : np ] )
set ( gca , ' xlim' , [ 0.5 np + 0.5 ] )
set ( gca , ' ylim' , [ 0 1 ] )
set ( gca , ' position' , [ 0.13 0.2 0.775 0.7 ] )
2017-05-16 12:42:01 +02:00
for ip = 1 : np
2017-05-16 15:10:20 +02:00
text ( ip , - 0.02 , deblank ( pnames ( ip , : ) ) , ' rotation' , 90 , ' HorizontalAlignment' , ' right' , ' interpreter' , ' none' )
2011-12-09 21:13:16 +01:00
end
xlabel ( ' ' )
ylabel ( ' Elementary Effects' )
title ( ' Reduced form screening' )
2017-03-23 17:59:05 +01:00
dyn_saveas ( hh , [ dirname , ' /' , M_ . fname , ' _redform_screen' ] , options_ . nodisplay , options_ . graph_format ) ;
2016-06-19 12:38:31 +02:00
create_TeX_loader ( options_ , [ dirname , ' /' , M_ . fname , ' _redform_screen' ] , 1 , ' Reduced form screening' , ' redform_screen' , 1 )
2015-12-14 14:09:37 +01:00
2016-06-19 12:38:31 +02:00
function []= create_TeX_loader ( options_,figpath,label_number,caption,label_name,scale_factor)
if nargin < 6
scale_factor = 1 ;
end
2015-12-14 14:09:37 +01:00
if options_ . TeX && any ( strcmp ( ' eps' , cellstr ( options_ . graph_format ) ) )
2016-06-14 09:48:35 +02:00
fidTeX = fopen ( [ figpath ' .tex' ] , ' w' ) ;
2015-12-14 14:09:37 +01:00
fprintf ( fidTeX , ' %% TeX eps-loader file generated by redform_screen.m (Dynare).\n' ) ;
fprintf ( fidTeX , [ ' %% ' datestr ( now , 0 ) ' \n\n' ] ) ;
fprintf ( fidTeX , ' \\begin{figure}[H]\n' ) ;
fprintf ( fidTeX , ' \\centering \n' ) ;
2016-06-19 12:38:31 +02:00
fprintf ( fidTeX , ' \\includegraphics[width=%2.2f\\textwidth]{%s}\n' , scale_factor , strrep ( figpath , ' \' , ' /' ) ) ;
2015-12-14 14:09:37 +01:00
fprintf ( fidTeX , ' \\caption{%s.}' , caption ) ;
fprintf ( fidTeX , ' \\label{Fig:%s:%u}\n' , label_name , label_number ) ;
fprintf ( fidTeX , ' \\end{figure}\n\n' ) ;
fprintf ( fidTeX , ' %% End Of TeX file. \n' ) ;
fclose ( fidTeX ) ;
end