From db9b61df7826fa8666f5a2831e379a535b929105 Mon Sep 17 00:00:00 2001 From: Marco Ratto Date: Tue, 10 Dec 2013 17:10:04 +0100 Subject: [PATCH] Bug fixes, reduced the number of graphs and improved info on graphical output for screening identification and MC theoretical moments in GSA. --- matlab/gsa/map_ident_.m | 68 ++++++++++++++++++++--------------------- matlab/gsa/mc_moments.m | 12 +++++--- matlab/gsa/th_moments.m | 7 +++-- 3 files changed, 46 insertions(+), 41 deletions(-) diff --git a/matlab/gsa/map_ident_.m b/matlab/gsa/map_ident_.m index 591c547c2..867dfcfd6 100644 --- a/matlab/gsa/map_ident_.m +++ b/matlab/gsa/map_ident_.m @@ -209,7 +209,7 @@ if opt_gsa.morris==1, load([OutputDirectoryName,'/',fname_,'_morris_IDE'],'SAvdec','vdec','ir_vdec','ic_vdec') end - hh = dyn_figure(options_); + hh = dyn_figure(options_,'name','Screening identification: variance decomposition'); % boxplot(SAvdec,'whis',10,'symbol','r.') myboxplot(SAvdec,[],'.',[],10) set(gca,'xticklabel',' ','fontsize',10,'xtick',[1:npT]) @@ -221,7 +221,7 @@ if opt_gsa.morris==1, text(ip,-2,bayestopt_.name{ip},'rotation',90,'HorizontalAlignment','right','interpreter','none') end xlabel(' ') - title('All variance decomposition') + title('Elementary effects variance decomposition') dyn_saveas(hh,[OutputDirectoryName,'/',fname_,'_morris_vdec'],options_); else save([OutputDirectoryName,'/',fname_,'_morris_IDE'],'vdec') @@ -314,7 +314,7 @@ if opt_gsa.morris==1, load([OutputDirectoryName,'/',fname_,'_morris_IDE'],'ac','ir_ac','ic_ac') end - hh=dyn_figure(options_); + hh=dyn_figure(options_,'name','Screening identification: theoretical moments'); % boxplot(SAcc,'whis',10,'symbol','r.') myboxplot(SAcc,[],'.',[],10) set(gca,'xticklabel',' ','fontsize',10,'xtick',[1:npT]) @@ -326,7 +326,7 @@ if opt_gsa.morris==1, text(ip,-0.02,bayestopt_.name{ip},'rotation',90,'HorizontalAlignment','right','interpreter','none') end xlabel(' ') - title('EET All moments') + title('Elementary effects in the moments') dyn_saveas(hh,[OutputDirectoryName,'/',fname_,'_morris_moments'],options_); % close(gcf), @@ -709,7 +709,7 @@ if opt_gsa.morris==1, else load([OutputDirectoryName,'/',fname_,'_morris_IDE'],'SAnorm','SAmunorm','SAsignorm') end - hh=dyn_figure(options_); %bar(SAnorm(:,irel)) + hh=dyn_figure(options_,'name','Screening identification: model'); %bar(SAnorm(:,irel)) % boxplot(SAnorm','whis',10,'symbol','r.') myboxplot(SAnorm',[],'.',[],10) set(gca,'xticklabel',' ','fontsize',10,'xtick',[1:npT]) @@ -725,35 +725,35 @@ if opt_gsa.morris==1, title('Elementary effects in the model') dyn_saveas(hh,[OutputDirectoryName,'/',fname_,'_morris_par'],options_); - hh=dyn_figure(options_); %bar(SAmunorm(:,irel)) -% boxplot(SAmunorm','whis',10,'symbol','r.') - myboxplot(SAmunorm',[],'.',[],10) - set(gca,'xticklabel',' ','fontsize',10,'xtick',[1:npT]) - set(gca,'xlim',[0.5 npT+0.5]) - set(gca,'ylim',[-1 1]) - set(gca,'position',[0.13 0.2 0.775 0.7]) - xlabel(' ') - for ip=1:npT, - text(ip,-0.02,bayestopt_.name{ip},'rotation',90,'HorizontalAlignment','right','interpreter','none') - end - xlabel(' ') - title('\mu in the model') - dyn_saveas(hh,[OutputDirectoryName,'/',fname_,'_morrismu_par'],options_); - - hh=dyn_figure(options_); %bar(SAsignorm(:,irel)) -% boxplot(SAsignorm','whis',10,'symbol','r.') - myboxplot(SAsignorm',[],'.',[],10) - set(gca,'xticklabel',' ','fontsize',10,'xtick',[1:npT]) - set(gca,'xlim',[0.5 npT+0.5]) - set(gca,'ylim',[0 1]) - set(gca,'position',[0.13 0.2 0.775 0.7]) - xlabel(' ') - for ip=1:npT, - text(ip,-0.02,bayestopt_.name{ip},'rotation',90,'HorizontalAlignment','right','interpreter','none') - end - xlabel(' ') - title('\sigma in the model') - dyn_saveas(hh,[OutputDirectoryName,'/',fname_,'_morrissig_par'],options_); +% hh=dyn_figure(options_); %bar(SAmunorm(:,irel)) +% % boxplot(SAmunorm','whis',10,'symbol','r.') +% myboxplot(SAmunorm',[],'.',[],10) +% set(gca,'xticklabel',' ','fontsize',10,'xtick',[1:npT]) +% set(gca,'xlim',[0.5 npT+0.5]) +% set(gca,'ylim',[-1 1]) +% set(gca,'position',[0.13 0.2 0.775 0.7]) +% xlabel(' ') +% for ip=1:npT, +% text(ip,-0.02,bayestopt_.name{ip},'rotation',90,'HorizontalAlignment','right','interpreter','none') +% end +% xlabel(' ') +% title('\mu in the model') +% dyn_saveas(hh,[OutputDirectoryName,'/',fname_,'_morrismu_par'],options_); +% +% hh=dyn_figure(options_); %bar(SAsignorm(:,irel)) +% % boxplot(SAsignorm','whis',10,'symbol','r.') +% myboxplot(SAsignorm',[],'.',[],10) +% set(gca,'xticklabel',' ','fontsize',10,'xtick',[1:npT]) +% set(gca,'xlim',[0.5 npT+0.5]) +% set(gca,'ylim',[0 1]) +% set(gca,'position',[0.13 0.2 0.775 0.7]) +% xlabel(' ') +% for ip=1:npT, +% text(ip,-0.02,bayestopt_.name{ip},'rotation',90,'HorizontalAlignment','right','interpreter','none') +% end +% xlabel(' ') +% title('\sigma in the model') +% dyn_saveas(hh,[OutputDirectoryName,'/',fname_,'_morrissig_par'],options_); % figure, bar(SAnorm(:,irel)') % set(gca,'xtick',[1:j0]) diff --git a/matlab/gsa/mc_moments.m b/matlab/gsa/mc_moments.m index 31fd3bce6..4b0624145 100644 --- a/matlab/gsa/mc_moments.m +++ b/matlab/gsa/mc_moments.m @@ -17,19 +17,23 @@ function [vdec, cc, ac] = mc_moments(mm, ss, dr) % You should have received a copy of the GNU General Public License % along with Dynare. If not, see . -global options_ M_ +global options_ M_ estim_params_ oo_ [nr1, nc1, nsam] = size(mm); + nobs=size(options_.varobs,1); disp('Computing theoretical moments ...') h = dyn_waitbar(0,'Theoretical moments ...'); + vdec = zeros(nobs,M_.exo_nbr,nsam); + cc = zeros(size(options_.varobs,1),size(options_.varobs,1),nsam); + ac = zeros(size(options_.varobs,1),size(options_.varobs,1)*options_.ar,nsam); for j=1:nsam, - dr.ghx = mm(:, [1:(nc1-M_.exo_nbr)],j); - dr.ghu = mm(:, [(nc1-M_.exo_nbr+1):end], j); + oo_.dr.ghx = mm(:, [1:(nc1-M_.exo_nbr)],j); + oo_.dr.ghu = mm(:, [(nc1-M_.exo_nbr+1):end], j); if ~isempty(ss), set_shocks_param(ss(j,:)); end - [vdec(:,:,j), corr, autocorr, z, zz] = th_moments(dr,options_.varobs); + [vdec(:,:,j), corr, autocorr, z, zz] = th_moments(oo_.dr,options_.varobs); cc(:,:,j)=triu(corr); dum=[]; for i=1:options_.ar diff --git a/matlab/gsa/th_moments.m b/matlab/gsa/th_moments.m index 2837fb696..9dbe7f8f6 100644 --- a/matlab/gsa/th_moments.m +++ b/matlab/gsa/th_moments.m @@ -35,11 +35,12 @@ function [vdec, corr, autocorr, z, zz] = th_moments(dr,var_list) end end - [gamma_y,ivar] = th_autocovariances(dr,ivar,M_, options_); - m = dr.ys(ivar); + [gamma_y,stationary_vars] = th_autocovariances(dr,ivar,M_, options_); + m = dr.ys(ivar(stationary_vars)); - i1 = find(abs(diag(gamma_y{1})) > 1e-12); +% i1 = find(abs(diag(gamma_y{1})) > 1e-12); + i1 = [1:length(ivar)]; s2 = diag(gamma_y{1}); sd = sqrt(s2);