From 336701497001da77ca64959adf1fc2e601470d77 Mon Sep 17 00:00:00 2001 From: Marco Ratto Date: Thu, 27 Oct 2011 13:09:26 +0200 Subject: [PATCH] Identification is made compatible with octave. --- matlab/dynare_identification.m | 15 ++++-- matlab/ident_bruteforce.m | 8 +-- matlab/plot_identification.m | 92 +++++++++++++++++++++------------- matlab/vnorm.m | 6 ++- 4 files changed, 77 insertions(+), 44 deletions(-) diff --git a/matlab/dynare_identification.m b/matlab/dynare_identification.m index d6a9b171a..d7c5ed686 100644 --- a/matlab/dynare_identification.m +++ b/matlab/dynare_identification.m @@ -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')'; diff --git a/matlab/ident_bruteforce.m b/matlab/ident_bruteforce.m index 638ff4391..4be84c1c6 100644 --- a/matlab/ident_bruteforce.m +++ b/matlab/ident_bruteforce.m @@ -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 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 diff --git a/matlab/vnorm.m b/matlab/vnorm.m index 4e6b65114..99983f9ac 100644 --- a/matlab/vnorm.m +++ b/matlab/vnorm.m @@ -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