From 8ba17f6f37a8fed14df8b4c3df5e90eebdb8ee0d Mon Sep 17 00:00:00 2001 From: Marco Ratto <marco.ratto@jrc.ec.europa.eu> Date: Thu, 11 Apr 2013 10:11:04 +0200 Subject: [PATCH] 1) Allow threshold reduced form mapping also for posterior samples; 2) Improve the notation of info saved of threshold reduced form mapping which was obscure. Manual cherry-pick from commit aa4e81f84bc7bf80cba888943263e6458a236065 --- matlab/dynare_sensitivity.m | 28 ++++++++++++++++++++++++++-- matlab/gsa/redform_map.m | 28 ++++++++++++++-------------- 2 files changed, 40 insertions(+), 16 deletions(-) diff --git a/matlab/dynare_sensitivity.m b/matlab/dynare_sensitivity.m index 38a975d452..55217d360f 100644 --- a/matlab/dynare_sensitivity.m +++ b/matlab/dynare_sensitivity.m @@ -233,8 +233,32 @@ if options_gsa.identification, map_ident_(OutputDirectoryName,options_gsa); end -if options_gsa.redform && ~isempty(options_gsa.namendo) ... - && ~options_gsa.ppost, +if options_gsa.redform && ~isempty(options_gsa.namendo),% ... + % && ~options_gsa.ppost, + if options_gsa.ppost, + filnam = dir([M_.dname filesep 'metropolis' filesep '*param_irf*.mat']); + lpmat=[]; + for j=1:length(filnam), + load ([M_.dname filesep 'metropolis' filesep M_.fname '_param_irf' int2str(j) '.mat']) + lpmat=[lpmat; stock]; + end + clear stock + nshock = estim_params_.nvx; + nshock = nshock + estim_params_.nvn; + nshock = nshock + estim_params_.ncx; + nshock = nshock + estim_params_.ncn; + + lpmat0=lpmat(:,1:nshock); + lpmat=lpmat(:,nshock+1:end); + istable=(1:size(lpmat,1)); + iunstable=[]; + iwrong=[]; + iindeterm=[]; + save([OutputDirectoryName filesep M_.fname '_mc.mat'],'lpmat','lpmat0','istable','iunstable','iwrong','iindeterm') + options_gsa.load_stab=1; + + x0 = stab_map_(OutputDirectoryName,options_gsa); + end if strmatch(':',options_gsa.namendo,'exact'), options_gsa.namendo=M_.endo_names; end diff --git a/matlab/gsa/redform_map.m b/matlab/gsa/redform_map.m index 35e7421e95..b80a2d52bb 100644 --- a/matlab/gsa/redform_map.m +++ b/matlab/gsa/redform_map.m @@ -134,7 +134,7 @@ for j=1:size(anamendo,1) else iy=find( (y0>threshold(1)) & (y0<threshold(2))); iyc=find( (y0<=threshold(1)) | (y0>=threshold(2))); - xdir = [xdir0,'_cut']; + xdir = [xdir0,'_threshold']; if isempty(dir(xdir)) mkdir(xdir) end @@ -148,21 +148,21 @@ for j=1:size(anamendo,1) si(:,js) = NaN(np,1); % end if ~isempty(iy) && ~isempty(iyc) - delete([xdir, '/*cut*.*']) - [proba, dproba] = stab_map_1(x0, iy, iyc, 'cut',0); + delete([xdir, '/*threshold*.*']) + [proba, dproba] = stab_map_1(x0, iy, iyc, 'threshold',0); % indsmirnov = find(dproba>ksstat); indsmirnov = find(proba<pvalue_ks); for jp=1:length(indsmirnov), disp([M_.param_names(estim_params_.param_vals(indsmirnov(jp),1),:),' d-stat = ', num2str(dproba(indsmirnov(jp)),'%1.3f'),' p-value = ', num2str(proba(indsmirnov(jp)),'%1.3f')]) end disp(' '); - stab_map_1(x0, iy, iyc, 'cut',1,indsmirnov,xdir); - stab_map_2(x0(iy,:),alpha2,pvalue_corr,'cut',xdir) - stab_map_2(x0(iyc,:),alpha2,pvalue_corr,'trim',xdir) + stab_map_1(x0, iy, iyc, 'threshold',1,indsmirnov,xdir); + stab_map_2(x0(iy,:),alpha2,pvalue_corr,'inside_threshold',xdir) + stab_map_2(x0(iyc,:),alpha2,pvalue_corr,'outside_threshold',xdir) lpmat=x0(iy,:); lpmat0=xx0(iy,:); istable=[1:length(iy)]; - save([xdir,filesep,'threshold.mat'],'lpmat','lpmat0','istable') + save([xdir,filesep,'threshold.mat'],'lpmat','lpmat0','istable','y0','x0','xx0','iy','iyc') clear lpmat lpmat0 istable end end @@ -233,7 +233,7 @@ for j=1:size(anamendo,1) else iy=find( (y0>threshold(1)) & (y0<threshold(2))); iyc=find( (y0<=threshold(1)) | (y0>=threshold(2))); - xdir = [xdir0,'_cut']; + xdir = [xdir0,'_threshold']; if isempty(dir(xdir)) mkdir(xdir) end @@ -245,21 +245,21 @@ for j=1:size(anamendo,1) dyn_saveas(hf,[xdir,'/', namendo,'_vs_', namlagendo],options_); end if ~isempty(iy) && ~isempty(iyc), - delete([xdir, '/*cut*.*']) - [proba, dproba] = stab_map_1(x0, iy, iyc, 'cut',0); + delete([xdir, '/*threshold*.*']) + [proba, dproba] = stab_map_1(x0, iy, iyc, 'threshold',0); % indsmirnov = find(dproba>ksstat); indsmirnov = find(proba<pvalue_ks); for jp=1:length(indsmirnov), disp([M_.param_names(estim_params_.param_vals(indsmirnov(jp),1),:),' d-stat = ', num2str(dproba(indsmirnov(jp)),'%1.3f'),' p-value = ', num2str(proba(indsmirnov(jp)),'%1.3f')]) end disp(' '); - stab_map_1(x0, iy, iyc, 'cut',1,indsmirnov,xdir); - stab_map_2(x0(iy,:),alpha2,pvalue_corr,'cut',xdir) - stab_map_2(x0(iyc,:),alpha2,pvalue_corr,'trim',xdir) + stab_map_1(x0, iy, iyc, 'threshold',1,indsmirnov,xdir); + stab_map_2(x0(iy,:),alpha2,pvalue_corr,'inside_threshold',xdir) + stab_map_2(x0(iyc,:),alpha2,pvalue_corr,'outside_threshold',xdir) lpmat=x0(iy,:); lpmat0=xx0(iy,:); istable=[1:length(iy)]; - save([xdir,filesep,'threshold.mat'],'lpmat','lpmat0','istable') + save([xdir,filesep,'threshold.mat'],'lpmat','lpmat0','istable','y0','x0','xx0','iy','iyc') clear lpmat lpmat0 istable end -- GitLab