From 884ecb6d6c586e5e26257ba6b7c97e4f50272989 Mon Sep 17 00:00:00 2001 From: Marco Ratto Date: Thu, 1 Sep 2011 11:16:42 +0200 Subject: [PATCH 1/2] Fine tuning of checks of the rank condition --- matlab/identification_checks.m | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/matlab/identification_checks.m b/matlab/identification_checks.m index 0d760a6cc..3546b0146 100644 --- a/matlab/identification_checks.m +++ b/matlab/identification_checks.m @@ -49,11 +49,11 @@ ind1 = find(vnorm(JJ)>=eps); % take non-zero columns JJ1 = JJ(:,ind1); [eu,ee2,ee1] = svd( JJ1, 0 ); condJ= cond(JJ1); -rankJ = rank(JJ); +rankJ = rank(JJ./norm(JJ),1.e-10); rankJJ = rankJ; -if hess_flag==0, - rankJJ = rank(JJ'*JJ); -end +% if hess_flag==0, +% rankJJ = rank(JJ'*JJ); +% end ind0 = zeros(1,npar); ind0(ind1) = 1; From e3485e8929e2d85463ff0d2feda8a3e2a5a8af70 Mon Sep 17 00:00:00 2001 From: Marco Ratto Date: Thu, 1 Sep 2011 11:18:24 +0200 Subject: [PATCH 2/2] Changes around normalizing Jacobians: -) never use normalization for SVD and brute force covariance checks; -) Jacobians are normalized for checking the rank condition: this should allow for more uniformity in results across models. --- matlab/dynare_identification.m | 1 + matlab/identification_analysis.m | 27 +++++++++++++++++++-------- matlab/plot_identification.m | 9 +++++---- 3 files changed, 25 insertions(+), 12 deletions(-) diff --git a/matlab/dynare_identification.m b/matlab/dynare_identification.m index b10691a91..024260f56 100644 --- a/matlab/dynare_identification.m +++ b/matlab/dynare_identification.m @@ -58,6 +58,7 @@ options_ident = set_default_option(options_ident,'prior_range',0); options_ident = set_default_option(options_ident,'periods',300); options_ident = set_default_option(options_ident,'replic',100); options_ident = set_default_option(options_ident,'advanced',0); +options_ident = set_default_option(options_ident,'normalize_jacobians',1); options_ident = set_default_option(options_ident,'lik_init',1); if options_ident.gsa_sample_file, GSAFolder = checkpath('GSA'); diff --git a/matlab/identification_analysis.m b/matlab/identification_analysis.m index 6c20b5abb..066c4f51c 100644 --- a/matlab/identification_analysis.m +++ b/matlab/identification_analysis.m @@ -56,6 +56,7 @@ advanced = options_ident.advanced; replic = options_ident.replic; periods = options_ident.periods; max_dim_cova_group = options_ident.max_dim_cova_group; +normalize_jacobians = options_ident.normalize_jacobians; [I,J]=find(M_.lead_lag_incidence'); ide_hess = struct(); @@ -230,9 +231,18 @@ if info(1)==0, ide_lre.siLREnorm=siLREnorm; ide_hess.flag_score=flag_score; end, - normH = max(abs(siH)')'; - normJ = max(abs(siJ)')'; - normLRE = max(abs(siLRE)')'; + if normalize_jacobians, + normH = max(abs(siH)')'; + normH = normH(:,ones(nparam,1)); + normJ = max(abs(siJ)')'; + normJ = normJ(:,ones(nparam,1)); + normLRE = max(abs(siLRE)')'; + normLRE = normLRE(:,ones(size(gp,2),1)); + else + normH = 1; + normJ = 1; + normLRE = 1; + end ide_moments.indJJ=indJJ; ide_model.indH=indH; ide_lre.indLRE=indLRE; @@ -251,12 +261,13 @@ if info(1)==0, % ide_checks.idemodel_ino, ide_checks.idemoments_ino] = ... % identification_checks(H(indH,:)./normH(:,ones(nparam,1)),JJ(indJJ,:)./normJ(:,ones(nparam,1)), gp(indLRE,:)./normLRE(:,ones(size(gp,2),1))); [ide_moments.cond, ide_moments.ind0, ide_moments.indno, ide_moments.ino, ide_moments.Mco, ide_moments.Pco, ide_moments.jweak, ide_moments.jweak_pair] = ... - identification_checks(JJ(indJJ,:)./normJ(:,ones(nparam,1)), 0); + identification_checks(JJ(indJJ,:)./normJ, 0); [ide_model.cond, ide_model.ind0, ide_model.indno, ide_model.ino, ide_model.Mco, ide_model.Pco, ide_model.jweak, ide_model.jweak_pair] = ... - identification_checks(H(indH,:)./normH(:,ones(nparam,1)), 0); + identification_checks(H(indH,:)./normH, 0); [ide_lre.cond, ide_lre.ind0, ide_lre.indno, ide_lre.ino, ide_lre.Mco, ide_lre.Pco, ide_lre.jweak, ide_lre.jweak_pair] = ... - identification_checks(gp(indLRE,:)./normLRE(:,ones(size(gp,2),1)), 0); - [U, S, V]=svd(JJ(indJJ,:)./normJ(:,ones(nparam,1)),0); + identification_checks(gp(indLRE,:)./normLRE, 0); + normJ=1; + [U, S, V]=svd(JJ(indJJ,:)./normJ,0); S=diag(S); if nparam>8 ide_moments.S = S([1:4, end-3:end]); @@ -268,6 +279,6 @@ if info(1)==0, indok = find(max(ide_moments.indno,[],1)==0); if advanced, - [ide_moments.pars, ide_moments.cosnJ] = ident_bruteforce(JJ(indJJ,:)./normJ(:,ones(nparam,1)),max_dim_cova_group,options_.TeX,name_tex); + [ide_moments.pars, ide_moments.cosnJ] = ident_bruteforce(JJ(indJJ,:)./normJ,max_dim_cova_group,options_.TeX,name_tex); end end diff --git a/matlab/plot_identification.m b/matlab/plot_identification.m index 45d1e1c9f..e499f337d 100644 --- a/matlab/plot_identification.m +++ b/matlab/plot_identification.m @@ -56,7 +56,6 @@ tittxt1=regexprep(tittxt, ' ', '_'); tittxt1=strrep(tittxt1, '.', ''); if SampleSize == 1, siJ = idemoments.siJ; - normJ = max(abs(siJ)')'; figure('Name',[tittxt, ' - Identification using info from observables']), subplot(211) mmm = (idehess.ide_strength_J); @@ -171,6 +170,7 @@ if SampleSize == 1, disp('') if idehess.flag_score, [U,S,V]=svd(idehess.AHess,0); + S=diag(S); if nparam<5, f1 = figure('name',[tittxt,' - Identification patterns (Information matrix)']); else @@ -178,7 +178,8 @@ if SampleSize == 1, f2 = figure('name',[tittxt,' - Identification patterns (Information matrix): HIGHEST SV']); end else - [U,S,V]=svd(siJ./normJ(:,ones(nparam,1)),0); + S = idemoments.S; + V = idemoments.V; if nparam<5, f1 = figure('name',[tittxt,' - Identification patterns (moments)']); else @@ -197,10 +198,10 @@ if SampleSize == 1, subplot(4,1,jj), if j<5 bar(abs(V(:,end-j+1))), - Stit = S(end-j+1,end-j+1); + Stit = S(end-j+1); else bar(abs(V(:,jj))), - Stit = S(jj,jj); + Stit = S(jj); end set(gca,'xticklabel','') if j==4 || j==nparam || j==8,