Identification is made compatible with octave.

time-shift
Marco Ratto 2011-10-27 13:09:26 +02:00
parent d806fdd617
commit 3367014970
4 changed files with 77 additions and 44 deletions

View File

@ -267,7 +267,7 @@ if iload <=0,
if SampleSize > 1, if SampleSize > 1,
disp(' ') disp(' ')
disp('Monte Carlo Testing') disp('Monte Carlo Testing')
h = waitbar(0,'Monte Carlo identification checks ...'); h = dyn_waitbar(0,'Monte Carlo identification checks ...');
iteration = 0; iteration = 0;
loop_indx = 0; loop_indx = 0;
file_index = 0; file_index = 0;
@ -364,7 +364,11 @@ if iload <=0,
end end
if SampleSize > 1, 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
end end
@ -372,7 +376,12 @@ if iload <=0,
if SampleSize > 1, if SampleSize > 1,
close(h), if exist('OCTAVE_VERSION') || options_.console_mode,
fprintf('\n');
diary on;
else
close(h),
end
normTAU=std(TAU')'; normTAU=std(TAU')';
normLRE=std(LRE')'; normLRE=std(LRE')';
normGAM=std(GAM')'; normGAM=std(GAM')';

View File

@ -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 % You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licen % along with Dynare. If not, see <http://www.gnu.org/licen
global M_ global M_ options_
OutputDirectoryName = CheckPath('Identification'); OutputDirectoryName = CheckPath('Identification');
@ -41,7 +41,7 @@ end
cosnJ=zeros(k,n); cosnJ=zeros(k,n);
pars{k,n}=[]; pars{k,n}=[];
for ll = 1: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 for ii = 1:k
tmp = find([1:k]~=ii); tmp = find([1:k]~=ii);
tmp2 = nchoosek(tmp,ll); tmp2 = nchoosek(tmp,ll);
@ -61,9 +61,9 @@ for ll = 1:n,
else else
pars{ii,ll} = NaN(1,ll); pars{ii,ll} = NaN(1,ll);
end end
waitbar(ii/k,h) dyn_waitbar(ii/k,h)
end end
close(h), dyn_waitbar_close(h);
if TeX if TeX
filename = [OutputDirectoryName '/' M_.fname '_collinearity_patterns' int2str(ll) '.TeX']; filename = [OutputDirectoryName '/' M_.fname '_collinearity_patterns' int2str(ll) '.TeX'];
fidTeX = fopen(filename,'w'); fidTeX = fopen(filename,'w');

View File

@ -39,7 +39,7 @@ function plot_identification(params,idemoments,idehess,idemodel, idelre, advance
global M_ options_ global M_ options_
if nargin<10 || isempty(save_figure), if nargin<10 || isempty(save_figure),
save_figure=0; save_figure=1;
end end
[SampleSize, nparam]=size(params); [SampleSize, nparam]=size(params);
@ -88,9 +88,11 @@ if SampleSize == 1,
else else
title('Sensitivity component with moments Information matrix (log-scale)') title('Sensitivity component with moments Information matrix (log-scale)')
end end
saveas(gcf,[IdentifDirectoryName,'/',M_.fname,'_ident_strength_',tittxt1]) eval(['print -depsc2 ' IdentifDirectoryName '/' M_.fname '_ident_strength_' tittxt1 '.eps']);
eval(['print -depsc2 ' IdentifDirectoryName '/' M_.fname '_ident_strength_' tittxt1]); if ~exist('OCTAVE_VERSION'),
eval(['print -dpdf ' IdentifDirectoryName '/' M_.fname '_ident_strength_' tittxt1]); saveas(gcf,[IdentifDirectoryName,'/',M_.fname,'_ident_strength_',tittxt1])
eval(['print -dpdf ' IdentifDirectoryName '/' M_.fname '_ident_strength_' tittxt1]);
end
if advanced, if advanced,
disp(' ') disp(' ')
@ -112,14 +114,14 @@ if SampleSize == 1,
for ip=1:nparam, for ip=1:nparam,
text(ip,dy(1),name{is(ip)},'rotation',90,'HorizontalAlignment','right','interpreter','none') text(ip,dy(1),name{is(ip)},'rotation',90,'HorizontalAlignment','right','interpreter','none')
end end
if advanced,
legend('Moments','Model','LRE model','Location','Best')
end
title('Sensitivity bars using derivatives (log-scale)') title('Sensitivity bars using derivatives (log-scale)')
if save_figure if save_figure
saveas(gcf,[IdentifDirectoryName,'/',M_.fname,'_sensitivity_',tittxt1]) eval(['print -depsc2 ' IdentifDirectoryName '/' M_.fname '_sensitivity_' tittxt1 '.eps']);
eval(['print -depsc2 ' IdentifDirectoryName '/' M_.fname '_sensitivity_' tittxt1]); if ~exist('OCTAVE_VERSION'),
eval(['print -dpdf ' IdentifDirectoryName '/' M_.fname '_sensitivity_' tittxt1]); saveas(gcf,[IdentifDirectoryName,'/',M_.fname,'_sensitivity_',tittxt1])
eval(['print -dpdf ' IdentifDirectoryName '/' M_.fname '_sensitivity_' tittxt1]);
end
close(gcf);
end end
% identificaton patterns % identificaton patterns
@ -159,12 +161,14 @@ if SampleSize == 1,
end end
set(gca,'xgrid','on') set(gca,'xgrid','on')
set(gca,'ygrid','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 if save_figure
saveas(gcf,[IdentifDirectoryName,'/',M_.fname,'_ident_collinearity_', tittxt1, '_', int2str(j)]) eval(['print -depsc ' IdentifDirectoryName '/' M_.fname '_ident_collinearity_' tittxt1 '_' int2str(j) '.eps']);
eval(['print -depsc ' IdentifDirectoryName '/' M_.fname '_ident_collinearity_' tittxt1 '_' int2str(j)]); if ~exist('OCTAVE_VERSION'),
eval(['print -dpdf ' IdentifDirectoryName '/' M_.fname '_ident_collinearity_' tittxt1 '_' int2str(j)]); saveas(gcf,[IdentifDirectoryName,'/',M_.fname,'_ident_collinearity_', tittxt1, '_', int2str(j)])
if options_.nograph, close(gcf); end eval(['print -dpdf ' IdentifDirectoryName '/' M_.fname '_ident_collinearity_' tittxt1 '_' int2str(j)]);
end
close(gcf);
end end
end end
disp('') disp('')
@ -213,14 +217,20 @@ if SampleSize == 1,
end end
if save_figure, if save_figure,
figure(f1); figure(f1);
saveas(f1,[IdentifDirectoryName,'/',M_.fname,'_ident_pattern_',tittxt1,'_1']) eval(['print -depsc2 ' IdentifDirectoryName '/' M_.fname '_ident_pattern_' tittxt1 '_1.eps']);
eval(['print -depsc2 ' IdentifDirectoryName '/' M_.fname '_ident_pattern_' tittxt1 '_1']); if ~exist('OCTAVE_VERSION'),
eval(['print -dpdf ' IdentifDirectoryName '/' M_.fname '_ident_pattern_' tittxt1 '_1']); 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, if nparam>4,
figure(f2), figure(f2),
saveas(f2,[IdentifDirectoryName,'/',M_.fname,'_ident_pattern_',tittxt1,'_2']) eval(['print -depsc2 ' IdentifDirectoryName '/' M_.fname '_ident_pattern_' tittxt1 '_2.eps']);
eval(['print -depsc2 ' IdentifDirectoryName '/' M_.fname '_ident_pattern_' tittxt1 '_2']); if ~exist('OCTAVE_VERSION'),
eval(['print -dpdf ' IdentifDirectoryName '/' M_.fname '_ident_pattern_' tittxt1 '_2']); 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 end
end end
@ -252,14 +262,16 @@ else
legend('Moments','Model','LRE model','Location','Best') legend('Moments','Model','LRE model','Location','Best')
end end
title('MC mean of sensitivity measures') title('MC mean of sensitivity measures')
saveas(gcf,[IdentifDirectoryName,'/',M_.fname,'_MC_sensitivity']) eval(['print -depsc2 ' IdentifDirectoryName '/' M_.fname '_MC_sensitivity.eps']);
eval(['print -depsc2 ' IdentifDirectoryName '/' M_.fname '_MC_sensitivity']); if ~exist('OCTAVE_VERSION'),
eval(['print -dpdf ' IdentifDirectoryName '/' M_.fname '_MC_sensitivity']); saveas(gcf,[IdentifDirectoryName,'/',M_.fname,'_MC_sensitivity'])
if options_.nograph, close(gcf); end eval(['print -dpdf ' IdentifDirectoryName '/' M_.fname '_MC_sensitivity']);
end
close(gcf);
if advanced, if advanced,
disp(' ') disp(' ')
disp('Press ENTER to display advanced diagnostics'), pause(5), disp('Press ENTER to display advanced diagnostics'), pause(5),
options_.nograph=1; % options_.nograph=1;
figure('Name','MC Condition Number'), figure('Name','MC Condition Number'),
subplot(221) subplot(221)
hist(log10(idemodel.cond)) hist(log10(idemodel.cond))
@ -270,10 +282,12 @@ else
subplot(223) subplot(223)
hist(log10(idelre.cond)) hist(log10(idelre.cond))
title('log10 of Condition number in the LRE model') title('log10 of Condition number in the LRE model')
saveas(gcf,[IdentifDirectoryName,'/',M_.fname,'_ident_COND']) eval(['print -depsc2 ' IdentifDirectoryName '/' M_.fname '_ident_COND.eps']);
eval(['print -depsc2 ' IdentifDirectoryName '/' M_.fname '_ident_COND']); if ~exist('OCTAVE_VERSION'),
eval(['print -dpdf ' IdentifDirectoryName '/' M_.fname '_ident_COND']); saveas(gcf,[IdentifDirectoryName,'/',M_.fname,'_ident_COND'])
if options_.nograph, close(gcf); end eval(['print -dpdf ' IdentifDirectoryName '/' M_.fname '_ident_COND']);
end
close(gcf);
ncut=floor(SampleSize/10*9); ncut=floor(SampleSize/10*9);
[dum,is]=sort(idelre.cond); [dum,is]=sort(idelre.cond);
[proba, dproba] = stab_map_1(params, is(1:ncut), is(ncut+1:end), 'MC_HighestCondNumberLRE', 1, [], IdentifDirectoryName, 0.1); [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 end
if save_figure, if save_figure,
figure(f1); figure(f1);
saveas(f1,[IdentifDirectoryName,'/',M_.fname,'_MC_dent_pattern_1']) eval(['print -depsc2 ' IdentifDirectoryName '/' M_.fname '_MC_ident_pattern_1.eps']);
eval(['print -depsc2 ' IdentifDirectoryName '/' M_.fname '_MC_ident_pattern_1']); if ~exist('OCTAVE_VERSION'),
eval(['print -dpdf ' IdentifDirectoryName '/' M_.fname '_MC_ident_pattern_1']); 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, if nparam>4,
figure(f2), figure(f2),
saveas(f2,[IdentifDirectoryName,'/',M_.fname,'_MC_ident_pattern_2']) eval(['print -depsc2 ' IdentifDirectoryName '/' M_.fname '_MC_ident_pattern_2.eps']);
eval(['print -depsc2 ' IdentifDirectoryName '/' M_.fname '_MC_ident_pattern_2']); if ~exist('OCTAVE_VERSION'),
eval(['print -dpdf ' IdentifDirectoryName '/' M_.fname '_MC_ident_pattern_2']); 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 end
end end

View File

@ -67,7 +67,11 @@ if nargin>1
end end
end end
if isempty(dim)
idx = find(size(A)~=1);
dim = idx(1);
end
if isempty(ntype) if isempty(ntype)
y = sqrt(sum( abs(A).^2 , dim) ); y = sqrt(sum( abs(A).^2 , dim) );
elseif ntype==1 elseif ntype==1