Commit ac4f774d authored by Sébastien Villemot's avatar Sébastien Villemot

Merge remote-tracking branch 'ratto/master'

parents 7a16ab15 33670149
function h = dyn_waitbar(prctdone, varargin)
% h = dyn_waitbar(prctdone, varargin)
% adaptive waitbar, producing console mode waitbars with
% octave and when console_mode=1
%
% Copyright (C) 2011 Dynare Team
%
% 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.
%
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
global options_
persistent running_text newString
if prctdone==0,
init=1;
else
init=0;
end
if exist('OCTAVE_VERSION') || options_.console_mode,
if nargout,
h=[];
end
if init,
diary off;
running_text = varargin{1};
newString='';
return;
elseif nargin>2,
running_text = varargin{2};
end
if exist('OCTAVE_VERSION'),
printf([running_text,' %3.f%% done\r'], prctdone*100);
else
s0=repmat('\b',1,length(newString));
newString=sprintf([running_text,' %3.f%% done'], prctdone*100);
fprintf([s0,'%s'],newString);
end
else
if nargout,
h = waitbar(prctdone,varargin{:});
else
waitbar(prctdone,varargin{:});
end
end
function dyn_waitbar_close(h)
% h = dyn_waitbar_close(h)
% adaptive close waitbar, compatible with
% octave and when console_mode=1
%
% Copyright (C) 2011 Dynare Team
%
% 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.
%
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
global options_
if exist('OCTAVE_VERSION') || options_.console_mode,
clear dyn_waitbar;
diary on,
fprintf('\n');
else
close(h),
end
......@@ -267,7 +267,7 @@ if iload <=0,
if SampleSize > 1,
disp(' ')
disp('Monte Carlo Testing')
h = waitbar(0,'Monte Carlo identification checks ...');
h = dyn_waitbar(0,'Monte Carlo identification checks ...');
iteration = 0;
loop_indx = 0;
file_index = 0;
......@@ -364,7 +364,11 @@ if iload <=0,
end
if SampleSize > 1,
waitbar(iteration/SampleSize,h,['MC identification checks ',int2str(iteration),'/',int2str(SampleSize)])
% if exist('OCTAVE_VERSION') || options_.console_mode,
% console_waitbar(0,iteration/SampleSize);
% else
dyn_waitbar(iteration/SampleSize,h,['MC identification checks ',int2str(iteration),'/',int2str(SampleSize)])
% end
end
end
......@@ -372,7 +376,12 @@ if iload <=0,
if SampleSize > 1,
close(h),
if exist('OCTAVE_VERSION') || options_.console_mode,
fprintf('\n');
diary on;
else
close(h),
end
normTAU=std(TAU')';
normLRE=std(LRE')';
normGAM=std(GAM')';
......
......@@ -25,7 +25,7 @@ function [pars, cosnJ] = ident_bruteforce(J,n,TeX, pnames_TeX)
%
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licen
global M_
global M_ options_
OutputDirectoryName = CheckPath('Identification');
......@@ -41,7 +41,7 @@ end
cosnJ=zeros(k,n);
pars{k,n}=[];
for ll = 1:n,
h = waitbar(0,['Brute force collinearity for ' int2str(ll) ' parameters.']);
h = dyn_waitbar(0,['Brute force collinearity for ' int2str(ll) ' parameters.']);
for ii = 1:k
tmp = find([1:k]~=ii);
tmp2 = nchoosek(tmp,ll);
......@@ -61,9 +61,9 @@ for ll = 1:n,
else
pars{ii,ll} = NaN(1,ll);
end
waitbar(ii/k,h)
dyn_waitbar(ii/k,h)
end
close(h),
dyn_waitbar_close(h);
if TeX
filename = [OutputDirectoryName '/' M_.fname '_collinearity_patterns' int2str(ll) '.TeX'];
fidTeX = fopen(filename,'w');
......
......@@ -39,7 +39,7 @@ function plot_identification(params,idemoments,idehess,idemodel, idelre, advance
global M_ options_
if nargin<10 || isempty(save_figure),
save_figure=0;
save_figure=1;
end
[SampleSize, nparam]=size(params);
......@@ -88,9 +88,11 @@ if SampleSize == 1,
else
title('Sensitivity component with moments Information matrix (log-scale)')
end
saveas(gcf,[IdentifDirectoryName,'/',M_.fname,'_ident_strength_',tittxt1])
eval(['print -depsc2 ' IdentifDirectoryName '/' M_.fname '_ident_strength_' tittxt1]);
eval(['print -dpdf ' IdentifDirectoryName '/' M_.fname '_ident_strength_' tittxt1]);
eval(['print -depsc2 ' IdentifDirectoryName '/' M_.fname '_ident_strength_' tittxt1 '.eps']);
if ~exist('OCTAVE_VERSION'),
saveas(gcf,[IdentifDirectoryName,'/',M_.fname,'_ident_strength_',tittxt1])
eval(['print -dpdf ' IdentifDirectoryName '/' M_.fname '_ident_strength_' tittxt1]);
end
if advanced,
disp(' ')
......@@ -112,14 +114,14 @@ if SampleSize == 1,
for ip=1:nparam,
text(ip,dy(1),name{is(ip)},'rotation',90,'HorizontalAlignment','right','interpreter','none')
end
if advanced,
legend('Moments','Model','LRE model','Location','Best')
end
title('Sensitivity bars using derivatives (log-scale)')
if save_figure
saveas(gcf,[IdentifDirectoryName,'/',M_.fname,'_sensitivity_',tittxt1])
eval(['print -depsc2 ' IdentifDirectoryName '/' M_.fname '_sensitivity_' tittxt1]);
eval(['print -dpdf ' IdentifDirectoryName '/' M_.fname '_sensitivity_' tittxt1]);
eval(['print -depsc2 ' IdentifDirectoryName '/' M_.fname '_sensitivity_' tittxt1 '.eps']);
if ~exist('OCTAVE_VERSION'),
saveas(gcf,[IdentifDirectoryName,'/',M_.fname,'_sensitivity_',tittxt1])
eval(['print -dpdf ' IdentifDirectoryName '/' M_.fname '_sensitivity_' tittxt1]);
end
close(gcf);
end
% identificaton patterns
......@@ -159,12 +161,14 @@ if SampleSize == 1,
end
set(gca,'xgrid','on')
set(gca,'ygrid','on')
xlabel([tittxt,' - Collinearity patterns with ', int2str(j) ,' parameter(s)'])
xlabel([tittxt,' - Collinearity patterns with ', int2str(j) ,' parameter(s)'],'interpreter','none')
if save_figure
saveas(gcf,[IdentifDirectoryName,'/',M_.fname,'_ident_collinearity_', tittxt1, '_', int2str(j)])
eval(['print -depsc ' IdentifDirectoryName '/' M_.fname '_ident_collinearity_' tittxt1 '_' int2str(j)]);
eval(['print -dpdf ' IdentifDirectoryName '/' M_.fname '_ident_collinearity_' tittxt1 '_' int2str(j)]);
if options_.nograph, close(gcf); end
eval(['print -depsc ' IdentifDirectoryName '/' M_.fname '_ident_collinearity_' tittxt1 '_' int2str(j) '.eps']);
if ~exist('OCTAVE_VERSION'),
saveas(gcf,[IdentifDirectoryName,'/',M_.fname,'_ident_collinearity_', tittxt1, '_', int2str(j)])
eval(['print -dpdf ' IdentifDirectoryName '/' M_.fname '_ident_collinearity_' tittxt1 '_' int2str(j)]);
end
close(gcf);
end
end
disp('')
......@@ -213,14 +217,20 @@ if SampleSize == 1,
end
if save_figure,
figure(f1);
saveas(f1,[IdentifDirectoryName,'/',M_.fname,'_ident_pattern_',tittxt1,'_1'])
eval(['print -depsc2 ' IdentifDirectoryName '/' M_.fname '_ident_pattern_' tittxt1 '_1']);
eval(['print -dpdf ' IdentifDirectoryName '/' M_.fname '_ident_pattern_' tittxt1 '_1']);
eval(['print -depsc2 ' IdentifDirectoryName '/' M_.fname '_ident_pattern_' tittxt1 '_1.eps']);
if ~exist('OCTAVE_VERSION'),
saveas(f1,[IdentifDirectoryName,'/',M_.fname,'_ident_pattern_',tittxt1,'_1'])
eval(['print -dpdf ' IdentifDirectoryName '/' M_.fname '_ident_pattern_' tittxt1 '_1']);
end
close(f1);
if nparam>4,
figure(f2),
saveas(f2,[IdentifDirectoryName,'/',M_.fname,'_ident_pattern_',tittxt1,'_2'])
eval(['print -depsc2 ' IdentifDirectoryName '/' M_.fname '_ident_pattern_' tittxt1 '_2']);
eval(['print -dpdf ' IdentifDirectoryName '/' M_.fname '_ident_pattern_' tittxt1 '_2']);
eval(['print -depsc2 ' IdentifDirectoryName '/' M_.fname '_ident_pattern_' tittxt1 '_2.eps']);
if ~exist('OCTAVE_VERSION'),
saveas(f2,[IdentifDirectoryName,'/',M_.fname,'_ident_pattern_',tittxt1,'_2'])
eval(['print -dpdf ' IdentifDirectoryName '/' M_.fname '_ident_pattern_' tittxt1 '_2']);
end
close(f2);
end
end
end
......@@ -252,14 +262,16 @@ else
legend('Moments','Model','LRE model','Location','Best')
end
title('MC mean of sensitivity measures')
saveas(gcf,[IdentifDirectoryName,'/',M_.fname,'_MC_sensitivity'])
eval(['print -depsc2 ' IdentifDirectoryName '/' M_.fname '_MC_sensitivity']);
eval(['print -dpdf ' IdentifDirectoryName '/' M_.fname '_MC_sensitivity']);
if options_.nograph, close(gcf); end
eval(['print -depsc2 ' IdentifDirectoryName '/' M_.fname '_MC_sensitivity.eps']);
if ~exist('OCTAVE_VERSION'),
saveas(gcf,[IdentifDirectoryName,'/',M_.fname,'_MC_sensitivity'])
eval(['print -dpdf ' IdentifDirectoryName '/' M_.fname '_MC_sensitivity']);
end
close(gcf);
if advanced,
disp(' ')
disp('Press ENTER to display advanced diagnostics'), pause(5),
options_.nograph=1;
% options_.nograph=1;
figure('Name','MC Condition Number'),
subplot(221)
hist(log10(idemodel.cond))
......@@ -270,10 +282,12 @@ else
subplot(223)
hist(log10(idelre.cond))
title('log10 of Condition number in the LRE model')
saveas(gcf,[IdentifDirectoryName,'/',M_.fname,'_ident_COND'])
eval(['print -depsc2 ' IdentifDirectoryName '/' M_.fname '_ident_COND']);
eval(['print -dpdf ' IdentifDirectoryName '/' M_.fname '_ident_COND']);
if options_.nograph, close(gcf); end
eval(['print -depsc2 ' IdentifDirectoryName '/' M_.fname '_ident_COND.eps']);
if ~exist('OCTAVE_VERSION'),
saveas(gcf,[IdentifDirectoryName,'/',M_.fname,'_ident_COND'])
eval(['print -dpdf ' IdentifDirectoryName '/' M_.fname '_ident_COND']);
end
close(gcf);
ncut=floor(SampleSize/10*9);
[dum,is]=sort(idelre.cond);
[proba, dproba] = stab_map_1(params, is(1:ncut), is(ncut+1:end), 'MC_HighestCondNumberLRE', 1, [], IdentifDirectoryName, 0.1);
......@@ -334,14 +348,20 @@ else
end
if save_figure,
figure(f1);
saveas(f1,[IdentifDirectoryName,'/',M_.fname,'_MC_dent_pattern_1'])
eval(['print -depsc2 ' IdentifDirectoryName '/' M_.fname '_MC_ident_pattern_1']);
eval(['print -dpdf ' IdentifDirectoryName '/' M_.fname '_MC_ident_pattern_1']);
eval(['print -depsc2 ' IdentifDirectoryName '/' M_.fname '_MC_ident_pattern_1.eps']);
if ~exist('OCTAVE_VERSION'),
saveas(f1,[IdentifDirectoryName,'/',M_.fname,'_MC_dent_pattern_1'])
eval(['print -dpdf ' IdentifDirectoryName '/' M_.fname '_MC_ident_pattern_1']);
end
close(f1);
if nparam>4,
figure(f2),
saveas(f2,[IdentifDirectoryName,'/',M_.fname,'_MC_ident_pattern_2'])
eval(['print -depsc2 ' IdentifDirectoryName '/' M_.fname '_MC_ident_pattern_2']);
eval(['print -dpdf ' IdentifDirectoryName '/' M_.fname '_MC_ident_pattern_2']);
eval(['print -depsc2 ' IdentifDirectoryName '/' M_.fname '_MC_ident_pattern_2.eps']);
if ~exist('OCTAVE_VERSION'),
saveas(f2,[IdentifDirectoryName,'/',M_.fname,'_MC_ident_pattern_2'])
eval(['print -dpdf ' IdentifDirectoryName '/' M_.fname '_MC_ident_pattern_2']);
end
close(f2);
end
end
end
......
......@@ -67,7 +67,11 @@ if nargin>1
end
end
if isempty(dim)
idx = find(size(A)~=1);
dim = idx(1);
end
if isempty(ntype)
y = sqrt(sum( abs(A).^2 , dim) );
elseif ntype==1
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment