2011-05-02 11:12:39 +02:00
|
|
|
function [condJ, ind0, indnoJ, ixnoJ, McoJ, PcoJ, jweak, jweak_pair] = identification_checks(JJ, hess_flag)
|
|
|
|
% function [condJ, ind0, indnoJ, ixnoJ, McoJ, PcoJ, jweak, jweak_pair] = identification_checks(JJ, hess_flag)
|
2011-02-28 16:55:21 +01:00
|
|
|
% checks for identification
|
|
|
|
%
|
|
|
|
% INPUTS
|
2011-05-02 11:12:39 +02:00
|
|
|
% o JJ [matrix] [output x nparams] IF hess_flag==0
|
|
|
|
% derivatives of output w.r.t. parameters and shocks
|
|
|
|
% o JJ [matrix] [nparams x nparams] IF hess_flag==1
|
|
|
|
% information matrix
|
2011-02-28 16:55:21 +01:00
|
|
|
%
|
|
|
|
% OUTPUTS
|
2011-05-02 11:12:39 +02:00
|
|
|
% o cond condition number of JJ
|
|
|
|
% o ind0 [array] binary indicator for non-zero columns of H
|
|
|
|
% o indnoJ [matrix] index of non-identified params
|
|
|
|
% o ixnoJ number of rows in indnoJ
|
|
|
|
% o Mco [array] multicollinearity coefficients
|
|
|
|
% o Pco [matrix] pairwise correlations
|
|
|
|
% o jweak [binary array] gives 1 if the parameter has Mco=1(with tolerance 1.e-10)
|
|
|
|
% o jweak_pair [binary matrix] gives 1 if a couple parameters has Pco=1(with tolerance 1.e-10)
|
2011-02-28 16:55:21 +01:00
|
|
|
%
|
|
|
|
% SPECIAL REQUIREMENTS
|
|
|
|
% None
|
2009-12-16 18:17:34 +01:00
|
|
|
|
2011-02-04 17:27:33 +01:00
|
|
|
% Copyright (C) 2008-2011 Dynare Team
|
2009-12-16 18:17:34 +01:00
|
|
|
%
|
|
|
|
% 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/>.
|
|
|
|
|
|
|
|
% My suggestion is to have the following steps for identification check in
|
|
|
|
% dynare:
|
|
|
|
|
2011-05-02 11:12:39 +02:00
|
|
|
% 1. check rank of JJ at theta
|
|
|
|
npar = size(JJ,2);
|
2010-09-29 16:18:57 +02:00
|
|
|
indnoJ = zeros(1,npar);
|
2011-02-28 16:55:21 +01:00
|
|
|
|
2013-12-06 08:01:01 +01:00
|
|
|
if size(JJ,1)>1,
|
|
|
|
ind1 = find(vnorm(JJ)>=eps); % take non-zero columns
|
|
|
|
else
|
|
|
|
ind1 = find(abs(JJ)>=eps); % take non-zero columns
|
|
|
|
end
|
2011-05-02 11:12:39 +02:00
|
|
|
JJ1 = JJ(:,ind1);
|
2010-09-29 16:18:57 +02:00
|
|
|
[eu,ee2,ee1] = svd( JJ1, 0 );
|
2011-05-02 11:12:39 +02:00
|
|
|
condJ= cond(JJ1);
|
2015-10-13 10:45:35 +02:00
|
|
|
rankJ = rank(JJ);
|
2011-05-02 11:12:39 +02:00
|
|
|
rankJJ = rankJ;
|
2011-09-01 11:16:42 +02:00
|
|
|
% if hess_flag==0,
|
|
|
|
% rankJJ = rank(JJ'*JJ);
|
|
|
|
% end
|
2011-05-02 11:12:39 +02:00
|
|
|
|
|
|
|
ind0 = zeros(1,npar);
|
|
|
|
ind0(ind1) = 1;
|
|
|
|
|
|
|
|
if hess_flag==0,
|
|
|
|
% find near linear dependence problems:
|
|
|
|
McoJ = NaN(npar,1);
|
|
|
|
for ii = 1:size(JJ1,2);
|
|
|
|
McoJ(ind1(ii),:) = cosn([JJ1(:,ii),JJ1(:,find([1:1:size(JJ1,2)]~=ii))]);
|
2009-12-16 18:17:34 +01:00
|
|
|
end
|
2011-05-02 11:12:39 +02:00
|
|
|
else
|
2011-05-30 14:34:19 +02:00
|
|
|
deltaJ = sqrt(diag(JJ(ind1,ind1)));
|
|
|
|
tildaJ = JJ(ind1,ind1)./((deltaJ)*(deltaJ'));
|
|
|
|
McoJ(ind1,1)=(1-1./diag(inv(tildaJ)));
|
2011-05-02 11:12:39 +02:00
|
|
|
rhoM=sqrt(1-McoJ);
|
|
|
|
% PcoJ=inv(tildaJ);
|
2011-05-30 14:34:19 +02:00
|
|
|
PcoJ=NaN(npar,npar);
|
|
|
|
PcoJ(ind1,ind1)=inv(JJ(ind1,ind1));
|
2011-05-02 11:12:39 +02:00
|
|
|
sd=sqrt(diag(PcoJ));
|
2011-05-30 14:34:19 +02:00
|
|
|
PcoJ = abs(PcoJ./((sd)*(sd')));
|
2009-12-16 18:17:34 +01:00
|
|
|
end
|
|
|
|
|
2011-05-02 11:12:39 +02:00
|
|
|
|
|
|
|
ixnoJ = 0;
|
2015-06-05 18:22:45 +02:00
|
|
|
if npar>0 && (rankJ<npar || rankJJ<npar || min(1-McoJ)<1.e-10)
|
2009-12-16 18:17:34 +01:00
|
|
|
% - find out which parameters are involved
|
|
|
|
% disp('Some parameters are NOT identified by the moments included in J')
|
|
|
|
% disp(' ')
|
2011-05-02 11:12:39 +02:00
|
|
|
if length(ind1)<npar,
|
2011-02-28 16:55:21 +01:00
|
|
|
% parameters with zero column in JJ
|
2011-05-02 11:12:39 +02:00
|
|
|
ixnoJ = ixnoJ + 1;
|
|
|
|
indnoJ(ixnoJ,:) = (~ismember([1:npar],ind1));
|
2010-09-29 16:18:57 +02:00
|
|
|
end
|
2011-05-02 11:12:39 +02:00
|
|
|
ee0 = [rankJJ+1:length(ind1)];
|
2009-12-16 18:17:34 +01:00
|
|
|
for j=1:length(ee0),
|
2011-02-28 16:55:21 +01:00
|
|
|
% linearely dependent parameters in JJ
|
2011-05-02 11:12:39 +02:00
|
|
|
ixnoJ = ixnoJ + 1;
|
|
|
|
indnoJ(ixnoJ,ind1) = (abs(ee1(:,ee0(j))) > 1.e-3)';
|
2009-12-16 18:17:34 +01:00
|
|
|
end
|
|
|
|
else %rank(J)==length(theta) =>
|
2011-02-04 17:17:48 +01:00
|
|
|
% disp('All parameters are identified at theta by the moments included in J')
|
2009-12-16 18:17:34 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
% here there is no exact linear dependence, but there are several
|
|
|
|
% near-dependencies, mostly due to strong pairwise colliniearities, which can
|
|
|
|
% be checked using
|
|
|
|
|
2011-05-02 11:12:39 +02:00
|
|
|
jweak=zeros(1,npar);
|
|
|
|
jweak_pair=zeros(npar,npar);
|
|
|
|
|
|
|
|
if hess_flag==0,
|
2009-12-16 18:17:34 +01:00
|
|
|
PcoJ = NaN(npar,npar);
|
|
|
|
|
|
|
|
for ii = 1:size(JJ1,2);
|
2011-05-02 11:12:39 +02:00
|
|
|
PcoJ(ind1(ii),ind1(ii)) = 1;
|
2010-03-08 16:17:00 +01:00
|
|
|
for jj = ii+1:size(JJ1,2);
|
2011-05-02 11:12:39 +02:00
|
|
|
PcoJ(ind1(ii),ind1(jj)) = cosn([JJ1(:,ii),JJ1(:,jj)]);
|
|
|
|
PcoJ(ind1(jj),ind1(ii)) = PcoJ(ind1(ii),ind1(jj));
|
2009-12-16 18:17:34 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-05-02 11:12:39 +02:00
|
|
|
for j=1:npar,
|
|
|
|
if McoJ(j)>(1-1.e-10),
|
|
|
|
jweak(j)=1;
|
|
|
|
[ipair, jpair] = find(PcoJ(j,j+1:end)>(1-1.e-10));
|
|
|
|
for jx=1:length(jpair),
|
|
|
|
jweak_pair(j, jpair(jx)+j)=1;
|
|
|
|
jweak_pair(jpair(jx)+j, j)=1;
|
|
|
|
end
|
2010-03-08 16:17:00 +01:00
|
|
|
end
|
2010-01-15 10:58:09 +01:00
|
|
|
end
|
2011-05-02 11:12:39 +02:00
|
|
|
end
|
2010-01-15 10:58:09 +01:00
|
|
|
|
2011-05-02 11:12:39 +02:00
|
|
|
jweak_pair=dyn_vech(jweak_pair)';
|
2009-12-16 18:17:34 +01:00
|
|
|
|