2014-11-14 17:59:08 +01:00
|
|
|
function indcorr = stab_map_2(x,alpha2, pvalue_crit, fnam, dirname,xparam1,figtitle)
|
2012-06-11 01:33:01 +02:00
|
|
|
% function stab_map_2(x, alpha2, pvalue, fnam, dirname,xparam1)
|
2011-12-09 21:13:16 +01:00
|
|
|
%
|
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
|
|
|
|
2017-02-03 12:48:27 +01:00
|
|
|
% Copyright (C) 2011-2016 European Commission
|
2017-10-10 10:05:59 +02:00
|
|
|
% Copyright (C) 2011-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
|
|
|
|
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
2011-12-09 21:13:16 +01:00
|
|
|
|
|
|
|
%global bayestopt_ estim_params_ dr_ options_ ys_ fname_
|
|
|
|
global bayestopt_ estim_params_ options_ oo_ M_
|
|
|
|
|
|
|
|
npar=size(x,2);
|
|
|
|
nsam=size(x,1);
|
|
|
|
ishock= npar>estim_params_.np;
|
2014-11-14 17:59:08 +01:00
|
|
|
nograph = options_.nograph;
|
2017-05-16 12:42:01 +02:00
|
|
|
if nargin<4
|
2017-05-16 15:10:20 +02:00
|
|
|
fnam='';
|
2011-12-09 21:13:16 +01:00
|
|
|
end
|
2017-05-16 12:42:01 +02:00
|
|
|
if nargin<5
|
2017-05-16 15:10:20 +02:00
|
|
|
dirname='';
|
|
|
|
nograph=1;
|
2011-12-09 21:13:16 +01:00
|
|
|
end
|
2017-05-16 12:42:01 +02:00
|
|
|
if nargin<6
|
2017-05-16 15:10:20 +02:00
|
|
|
xparam1=[];
|
2012-02-06 16:01:09 +01:00
|
|
|
end
|
2017-05-16 12:42:01 +02:00
|
|
|
if nargin<7
|
2017-05-16 15:10:20 +02:00
|
|
|
figtitle=fnam;
|
2013-04-27 10:58:36 +02:00
|
|
|
end
|
2011-12-09 21:13:16 +01:00
|
|
|
|
|
|
|
ys_ = oo_.dr.ys;
|
|
|
|
dr_ = oo_.dr;
|
|
|
|
fname_ = M_.fname;
|
|
|
|
nshock = estim_params_.nvx;
|
|
|
|
nshock = nshock + estim_params_.nvn;
|
|
|
|
nshock = nshock + estim_params_.ncx;
|
|
|
|
nshock = nshock + estim_params_.ncn;
|
|
|
|
|
2014-11-14 17:59:08 +01:00
|
|
|
[c0, pvalue] = corrcoef(x);
|
2011-12-09 21:13:16 +01:00
|
|
|
c00=tril(c0,-1);
|
|
|
|
fig_nam_=[fname_,'_',fnam,'_corr_'];
|
2016-06-01 12:59:13 +02:00
|
|
|
fig_nam_tex_table=strrep([fnam,'_corr'],' ','_');
|
2016-05-31 15:52:50 +02:00
|
|
|
fig_nam_=strrep(fig_nam_,' ','_');
|
2011-12-09 21:13:16 +01:00
|
|
|
|
|
|
|
ifig=0;
|
|
|
|
j2=0;
|
|
|
|
if ishock==0
|
2017-05-16 15:10:20 +02:00
|
|
|
npar=estim_params_.np;
|
|
|
|
if ~isempty(xparam1)
|
|
|
|
xparam1=xparam1(nshock+1:end);
|
|
|
|
end
|
2011-12-09 21:13:16 +01:00
|
|
|
else
|
2017-05-16 15:10:20 +02:00
|
|
|
npar=estim_params_.np+nshock;
|
2011-12-09 21:13:16 +01:00
|
|
|
end
|
2016-05-31 15:52:50 +02:00
|
|
|
skipline();
|
2016-05-31 20:58:12 +02:00
|
|
|
title_string=['Correlation analysis for ',fnam];
|
2016-06-01 12:59:13 +02:00
|
|
|
title_string_tex=['Correlation analysis for ',strrep(fnam,'_','\\_')];
|
2012-06-15 12:29:22 +02:00
|
|
|
|
2014-11-14 17:59:08 +01:00
|
|
|
indcorr = [];
|
2016-05-31 15:52:50 +02:00
|
|
|
entry_iter=1;
|
2017-05-16 12:42:01 +02:00
|
|
|
for j=1:npar
|
2012-06-15 12:29:22 +02:00
|
|
|
i2=find(abs(c00(:,j))>alpha2);
|
2017-05-16 12:42:01 +02:00
|
|
|
if length(i2)>0
|
|
|
|
for jx=1:length(i2)
|
|
|
|
if pvalue(j,i2(jx))<pvalue_crit
|
2014-11-14 17:59:08 +01:00
|
|
|
indcorr = [indcorr; [j i2(jx)]];
|
2012-06-15 12:29:22 +02:00
|
|
|
j2=j2+1;
|
2017-05-16 12:42:01 +02:00
|
|
|
if ishock
|
2016-05-31 15:52:50 +02:00
|
|
|
if options_.TeX
|
|
|
|
[param_name_temp1, param_name_tex_temp1]= get_the_name(j,options_.TeX,M_,estim_params_,options_);
|
|
|
|
param_name_tex_temp1 = strrep(param_name_tex_temp1,'$','');
|
|
|
|
[param_name_temp2, param_name_tex_temp2]= get_the_name(i2(jx),options_.TeX,M_,estim_params_,options_);
|
|
|
|
param_name_tex_temp2 = strrep(param_name_tex_temp2,'$','');
|
|
|
|
tmp_name=(['[',param_name_temp1,',',param_name_temp2,']']);
|
|
|
|
tmp_name_tex=(['[',param_name_tex_temp1,',',param_name_tex_temp2,']']);
|
|
|
|
name{entry_iter,1}=tmp_name;
|
|
|
|
name_tex{entry_iter,1}=tmp_name_tex;
|
|
|
|
else
|
|
|
|
[param_name_temp1]= get_the_name(j,options_.TeX,M_,estim_params_,options_);
|
|
|
|
[param_name_temp2]= get_the_name(i2(jx),options_.TeX,M_,estim_params_,options_);
|
|
|
|
tmp_name=(['[',param_name_temp1,',',param_name_temp2,']']);
|
|
|
|
name{entry_iter,1}=tmp_name;
|
|
|
|
end
|
2012-06-15 12:29:22 +02:00
|
|
|
else
|
2016-05-31 15:52:50 +02:00
|
|
|
if options_.TeX
|
|
|
|
[param_name_temp1, param_name_tex_temp1]= get_the_name(j+nshock,options_.TeX,M_,estim_params_,options_);
|
|
|
|
param_name_tex_temp1 = strrep(param_name_tex_temp1,'$','');
|
|
|
|
[param_name_temp2, param_name_tex_temp2]= get_the_name(i2(jx)+nshock,options_.TeX,M_,estim_params_,options_);
|
|
|
|
param_name_tex_temp2 = strrep(param_name_tex_temp2,'$','');
|
|
|
|
tmp_name=(['[',param_name_temp1,',',param_name_temp2,']']);
|
|
|
|
tmp_name_tex=(['[',param_name_tex_temp1,',',param_name_tex_temp2,']']);
|
|
|
|
name{entry_iter,1}=tmp_name;
|
|
|
|
name_tex{entry_iter,1}=tmp_name_tex;
|
|
|
|
else
|
|
|
|
[param_name_temp1]= get_the_name(j+nshock,options_.TeX,M_,estim_params_,options_);
|
|
|
|
[param_name_temp2]= get_the_name(i2(jx)+nshock,options_.TeX,M_,estim_params_,options_);
|
|
|
|
tmp_name=(['[',param_name_temp1,',',param_name_temp2,']']);
|
|
|
|
name{entry_iter,1}=tmp_name;
|
|
|
|
end
|
2017-05-16 15:10:20 +02:00
|
|
|
end
|
2016-05-31 15:52:50 +02:00
|
|
|
data_mat(entry_iter,1)=c0(i2(jx),j);
|
|
|
|
entry_iter=entry_iter+1;
|
2017-05-16 15:10:20 +02:00
|
|
|
|
2017-05-16 12:42:01 +02:00
|
|
|
if ~nograph
|
|
|
|
if mod(j2,12)==1
|
2017-05-16 15:10:20 +02:00
|
|
|
ifig=ifig+1;
|
|
|
|
hh=dyn_figure(options_.nodisplay,'name',[figtitle,' sample bivariate projection ', num2str(ifig)]);
|
|
|
|
end
|
|
|
|
subplot(3,4,j2-(ifig-1)*12)
|
|
|
|
% bar(c0(i2,j)),
|
|
|
|
% set(gca,'xticklabel',bayestopt_.name(i2)),
|
|
|
|
% set(gca,'xtick',[1:length(i2)])
|
|
|
|
%plot(stock_par(ixx(nfilt+1:end,i),j),stock_par(ixx(nfilt+1:end,i),i2(jx)),'.k')
|
|
|
|
%hold on,
|
|
|
|
plot(x(:,j),x(:,i2(jx)),'.')
|
|
|
|
if ~isempty(xparam1)
|
|
|
|
hold on, plot(xparam1(j),xparam1(i2(jx)),'ro')
|
|
|
|
end
|
|
|
|
% xlabel(deblank(estim_params_.param_names(j,:)),'interpreter','none'),
|
|
|
|
% ylabel(deblank(estim_params_.param_names(i2(jx),:)),'interpreter','none'),
|
|
|
|
if ishock
|
|
|
|
xlabel(bayestopt_.name{j},'interpreter','none'),
|
|
|
|
ylabel(bayestopt_.name{i2(jx)},'interpreter','none'),
|
|
|
|
else
|
|
|
|
xlabel(bayestopt_.name{j+nshock},'interpreter','none'),
|
|
|
|
ylabel(bayestopt_.name{i2(jx)+nshock},'interpreter','none'),
|
|
|
|
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);
|
|
|
|
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');
|
|
|
|
fprintf(fidTeX,['%% ' datestr(now,0) '\n\n']);
|
|
|
|
fprintf(fidTeX,'\\begin{figure}[H]\n');
|
|
|
|
fprintf(fidTeX,'\\centering \n');
|
|
|
|
fprintf(fidTeX,'\\includegraphics[width=0.8\\textwidth]{%s}\n',strrep([dirname,'/',fig_nam_,int2str(ifig)],'\','/'));
|
|
|
|
fprintf(fidTeX,'\\caption{%s.}',[figtitle,' sample bivariate projection ', num2str(ifig)]);
|
|
|
|
fprintf(fidTeX,'\\label{Fig:%s:%u}\n',fig_nam_,ifig);
|
|
|
|
fprintf(fidTeX,'\\end{figure}\n\n');
|
|
|
|
fprintf(fidTeX,'%% End Of TeX file. \n');
|
|
|
|
fclose(fidTeX);
|
|
|
|
end
|
2015-12-14 14:09:37 +01:00
|
|
|
end
|
2012-06-15 12:29:22 +02:00
|
|
|
end
|
|
|
|
end
|
2017-05-16 15:10:20 +02:00
|
|
|
|
2012-06-15 12:29:22 +02:00
|
|
|
end
|
|
|
|
end
|
2017-05-16 12:42:01 +02:00
|
|
|
if ~nograph && (j==(npar)) && j2>0 && (mod(j2,12)~=0)
|
2017-03-23 17:59:05 +01:00
|
|
|
dyn_saveas(hh,[dirname,filesep,fig_nam_,int2str(ifig)],options_.nodisplay,options_.graph_format);
|
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([dirname,filesep,fig_nam_,int2str(ifig),'.tex'],'w');
|
2015-12-14 14:09:37 +01:00
|
|
|
fprintf(fidTeX,'%% TeX eps-loader file generated by stab_map_2.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',options_.figures.textwidth*min((j2-(ifig-1)*12)/3,1),strrep([dirname,'/',fig_nam_,int2str(ifig)],'\','/'));
|
2015-12-14 14:09:37 +01:00
|
|
|
fprintf(fidTeX,'\\caption{%s.}',[figtitle,' sample bivariate projection ', num2str(ifig)]);
|
|
|
|
fprintf(fidTeX,'\\label{Fig:%s:%u}\n',fig_nam_,ifig);
|
|
|
|
fprintf(fidTeX,'\\end{figure}\n\n');
|
|
|
|
fprintf(fidTeX,'%% End Of TeX file. \n');
|
|
|
|
fclose(fidTeX);
|
|
|
|
end
|
2017-05-16 15:10:20 +02:00
|
|
|
end
|
2011-12-09 21:13:16 +01:00
|
|
|
end
|
2016-05-31 15:52:50 +02:00
|
|
|
|
2017-05-16 12:42:01 +02:00
|
|
|
if j2==0
|
2014-11-14 17:59:08 +01:00
|
|
|
disp(['No correlation term with pvalue <', num2str(pvalue_crit),' and |corr. coef.| >',num2str(alpha2),' found for ',fnam])
|
2016-05-31 15:52:50 +02:00
|
|
|
else
|
2017-10-10 10:05:59 +02:00
|
|
|
headers={'Parameters'; 'corrcoef'};
|
|
|
|
dyntable(options_,title_string,headers, name, data_mat, 0, 7, 3);
|
2016-05-31 15:52:50 +02:00
|
|
|
if options_.TeX
|
2017-10-10 10:05:59 +02:00
|
|
|
dyn_latex_table(M_, options_, title_string_tex, fig_nam_tex_table, headers, name_tex, data_mat, 0, 7, 3);
|
2016-05-31 15:52:50 +02:00
|
|
|
end
|
2011-12-09 21:13:16 +01:00
|
|
|
end
|
|
|
|
%close all
|