diff --git a/matlab/gsa/map_ident_.m b/matlab/gsa/map_ident_.m index 1b848ba71b06a70401f1c03107420bcd48617191..cea9d07807a9df5057a27a1e994503ce3b05b20b 100644 --- a/matlab/gsa/map_ident_.m +++ b/matlab/gsa/map_ident_.m @@ -836,7 +836,12 @@ else, % main effects analysis imap=[1:npT]; - x0=[lpmat0(istable,:), lpmat(istable,:)]; + if isempty(lpmat0), + x0=lpmat(istable,:); + else + + x0=[lpmat0(istable,:), lpmat(istable,:)]; + end nrun=length(istable); nest=min(250,nrun); nfit=min(1000,nrun); diff --git a/matlab/gsa/redform_map.m b/matlab/gsa/redform_map.m index b80a2d52bbc7dd8de8c8c1d4dd97d4551f9cf1bd..2919091f9c913d54b7220a4c4a01c95e97b5f86a 100644 --- a/matlab/gsa/redform_map.m +++ b/matlab/gsa/redform_map.m @@ -87,7 +87,13 @@ adir0=pwd; nspred=size(T,2)-M_.exo_nbr; x0=lpmat(istable,:); -xx0=lpmat0(istable,:); +if isempty(lpmat0), + xx0=[]; + nshocks=0; +else + xx0=lpmat0(istable,:); + nshocks=size(xx0,2); +end [kn, np]=size(x0); offset = length(bayestopt_.pshape)-np; if options_gsa_.prior_range, @@ -99,7 +105,8 @@ else end nsok = length(find(M_.lead_lag_incidence(M_.maximum_lag,:))); -clear lpmat lpmat0 +lpmat=[]; +lpmat0=[]; js=0; for j=1:size(anamendo,1) namendo=deblank(anamendo(j,:)); @@ -147,7 +154,7 @@ for j=1:size(anamendo,1) % else si(:,js) = NaN(np,1); % end - if ~isempty(iy) && ~isempty(iyc) + if length(iy)>size(x0,2) && length(iyc)>size(x0,2) delete([xdir, '/*threshold*.*']) [proba, dproba] = stab_map_1(x0, iy, iyc, 'threshold',0); % indsmirnov = find(dproba>ksstat); @@ -156,14 +163,16 @@ for j=1:size(anamendo,1) 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, 'threshold',1,indsmirnov,xdir); + stab_map_1(x0, iy, iyc, 'threshold',pvalue_ks,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,:); + if nshocks, + lpmat0=xx0(iy,:); + end istable=[1:length(iy)]; save([xdir,filesep,'threshold.mat'],'lpmat','lpmat0','istable','y0','x0','xx0','iy','iyc') - clear lpmat lpmat0 istable + lpmat=[]; lpmat0=[]; istable=[]; end end else @@ -244,7 +253,7 @@ for j=1:size(anamendo,1) hf=dyn_figure(options_); hist(y0,30), title([namendo,' vs. ', namlagendo]) dyn_saveas(hf,[xdir,'/', namendo,'_vs_', namlagendo],options_); end - if ~isempty(iy) && ~isempty(iyc), + if length(iy)>size(x0,2) && length(iyc)>size(x0,2), delete([xdir, '/*threshold*.*']) [proba, dproba] = stab_map_1(x0, iy, iyc, 'threshold',0); % indsmirnov = find(dproba>ksstat); @@ -253,14 +262,16 @@ for j=1:size(anamendo,1) 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, 'threshold',1,indsmirnov,xdir); + stab_map_1(x0, iy, iyc, 'threshold',pvalue_ks,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,:); + if nshocks, + lpmat0=xx0(iy,:); + end istable=[1:length(iy)]; save([xdir,filesep,'threshold.mat'],'lpmat','lpmat0','istable','y0','x0','xx0','iy','iyc') - clear lpmat lpmat0 istable + lpmat=[]; lpmat0=[]; istable=[]; end end diff --git a/matlab/prior_posterior_statistics.m b/matlab/prior_posterior_statistics.m index 625f10e00c77df5f6b01f04d9efc2a16679e1fdb..2bd265d05a7740f2d79c62b4cdaa454ae8ef79d0 100644 --- a/matlab/prior_posterior_statistics.m +++ b/matlab/prior_posterior_statistics.m @@ -94,8 +94,12 @@ elseif strcmpi(type,'gsa') DirectoryName = CheckPath(['gsa',filesep,'mc'],M_.dname); load([ RootDirectoryName filesep M_.fname '_mc.mat'],'lpmat0','lpmat','istable') end - x=[lpmat0(istable,:) lpmat(istable,:)]; - clear lpmat istable + if ~isempty(lpmat0), + x=[lpmat0(istable,:) lpmat(istable,:)]; + else + x=lpmat(istable,:); + end + clear lpmat lpmat0 istable NumberOfDraws=size(x,1); B=NumberOfDraws; elseif strcmpi(type,'prior')