Merge pull request #371 from rattoma/master

bug fixes for GSA tools
time-shift
Sébastien Villemot 2013-04-19 01:35:00 -07:00
commit b916346176
4 changed files with 40 additions and 20 deletions

View File

@ -1,4 +1,4 @@
function c = dat_fil_(data_file); function list_of_exported_variables_ = dat_fil_(dat_fil_to_load_);
% Written by Marco Ratto % Written by Marco Ratto
% Joint Research Centre, The European Commission, % Joint Research Centre, The European Commission,
% (http://eemc.jrc.ec.europa.eu/), % (http://eemc.jrc.ec.europa.eu/),
@ -25,14 +25,14 @@ function c = dat_fil_(data_file);
% along with Dynare. If not, see <http://www.gnu.org/licenses/>. % along with Dynare. If not, see <http://www.gnu.org/licenses/>.
try try
eval(data_file); eval(dat_fil_to_load_);
catch catch
load(data_file); load(dat_fil_to_load_);
end end
clear data_file; clear dat_fil_to_load_;
a=who; list_of_local_variables_=who;
for j=1:length(a) for j=1:length(list_of_local_variables_),
eval(['c.',a{j},'=',a{j},';']); eval(['list_of_exported_variables_.',list_of_local_variables_{j},'=',list_of_local_variables_{j},';']);
end end

View File

@ -836,7 +836,12 @@ else, % main effects analysis
imap=[1:npT]; imap=[1:npT];
x0=[lpmat0(istable,:), lpmat(istable,:)]; if isempty(lpmat0),
x0=lpmat(istable,:);
else
x0=[lpmat0(istable,:), lpmat(istable,:)];
end
nrun=length(istable); nrun=length(istable);
nest=min(250,nrun); nest=min(250,nrun);
nfit=min(1000,nrun); nfit=min(1000,nrun);

View File

@ -87,7 +87,13 @@ adir0=pwd;
nspred=size(T,2)-M_.exo_nbr; nspred=size(T,2)-M_.exo_nbr;
x0=lpmat(istable,:); 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); [kn, np]=size(x0);
offset = length(bayestopt_.pshape)-np; offset = length(bayestopt_.pshape)-np;
if options_gsa_.prior_range, if options_gsa_.prior_range,
@ -99,7 +105,8 @@ else
end end
nsok = length(find(M_.lead_lag_incidence(M_.maximum_lag,:))); nsok = length(find(M_.lead_lag_incidence(M_.maximum_lag,:)));
clear lpmat lpmat0 lpmat=[];
lpmat0=[];
js=0; js=0;
for j=1:size(anamendo,1) for j=1:size(anamendo,1)
namendo=deblank(anamendo(j,:)); namendo=deblank(anamendo(j,:));
@ -147,7 +154,7 @@ for j=1:size(anamendo,1)
% else % else
si(:,js) = NaN(np,1); si(:,js) = NaN(np,1);
% end % end
if ~isempty(iy) && ~isempty(iyc) if length(iy)>size(x0,2) && length(iyc)>size(x0,2)
delete([xdir, '/*threshold*.*']) delete([xdir, '/*threshold*.*'])
[proba, dproba] = stab_map_1(x0, iy, iyc, 'threshold',0); [proba, dproba] = stab_map_1(x0, iy, iyc, 'threshold',0);
% indsmirnov = find(dproba>ksstat); % 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')]) 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 end
disp(' '); 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(iy,:),alpha2,pvalue_corr,'inside_threshold',xdir)
stab_map_2(x0(iyc,:),alpha2,pvalue_corr,'outside_threshold',xdir) stab_map_2(x0(iyc,:),alpha2,pvalue_corr,'outside_threshold',xdir)
lpmat=x0(iy,:); lpmat=x0(iy,:);
lpmat0=xx0(iy,:); if nshocks,
lpmat0=xx0(iy,:);
end
istable=[1:length(iy)]; istable=[1:length(iy)];
save([xdir,filesep,'threshold.mat'],'lpmat','lpmat0','istable','y0','x0','xx0','iy','iyc') save([xdir,filesep,'threshold.mat'],'lpmat','lpmat0','istable','y0','x0','xx0','iy','iyc')
clear lpmat lpmat0 istable lpmat=[]; lpmat0=[]; istable=[];
end end
end end
else else
@ -244,7 +253,7 @@ for j=1:size(anamendo,1)
hf=dyn_figure(options_); hist(y0,30), title([namendo,' vs. ', namlagendo]) hf=dyn_figure(options_); hist(y0,30), title([namendo,' vs. ', namlagendo])
dyn_saveas(hf,[xdir,'/', namendo,'_vs_', namlagendo],options_); dyn_saveas(hf,[xdir,'/', namendo,'_vs_', namlagendo],options_);
end end
if ~isempty(iy) && ~isempty(iyc), if length(iy)>size(x0,2) && length(iyc)>size(x0,2),
delete([xdir, '/*threshold*.*']) delete([xdir, '/*threshold*.*'])
[proba, dproba] = stab_map_1(x0, iy, iyc, 'threshold',0); [proba, dproba] = stab_map_1(x0, iy, iyc, 'threshold',0);
% indsmirnov = find(dproba>ksstat); % 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')]) 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 end
disp(' '); 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(iy,:),alpha2,pvalue_corr,'inside_threshold',xdir)
stab_map_2(x0(iyc,:),alpha2,pvalue_corr,'outside_threshold',xdir) stab_map_2(x0(iyc,:),alpha2,pvalue_corr,'outside_threshold',xdir)
lpmat=x0(iy,:); lpmat=x0(iy,:);
lpmat0=xx0(iy,:); if nshocks,
lpmat0=xx0(iy,:);
end
istable=[1:length(iy)]; istable=[1:length(iy)];
save([xdir,filesep,'threshold.mat'],'lpmat','lpmat0','istable','y0','x0','xx0','iy','iyc') save([xdir,filesep,'threshold.mat'],'lpmat','lpmat0','istable','y0','x0','xx0','iy','iyc')
clear lpmat lpmat0 istable lpmat=[]; lpmat0=[]; istable=[];
end end
end end

View File

@ -94,8 +94,12 @@ elseif strcmpi(type,'gsa')
DirectoryName = CheckPath(['gsa',filesep,'mc'],M_.dname); DirectoryName = CheckPath(['gsa',filesep,'mc'],M_.dname);
load([ RootDirectoryName filesep M_.fname '_mc.mat'],'lpmat0','lpmat','istable') load([ RootDirectoryName filesep M_.fname '_mc.mat'],'lpmat0','lpmat','istable')
end end
x=[lpmat0(istable,:) lpmat(istable,:)]; if ~isempty(lpmat0),
clear lpmat istable x=[lpmat0(istable,:) lpmat(istable,:)];
else
x=lpmat(istable,:);
end
clear lpmat lpmat0 istable
NumberOfDraws=size(x,1); NumberOfDraws=size(x,1);
B=NumberOfDraws; B=NumberOfDraws;
elseif strcmpi(type,'prior') elseif strcmpi(type,'prior')