Home > matlab > partial_information > PI_gensys_singularC.m

PI_gensys_singularC

PURPOSE ^

[C1,C2,C3,C4, C5, F1, F2, F3, F4, F5, M1, M2, UAVinv,FL_RANK, V01, V02]...

SYNOPSIS ^

function [C1,C2,C3,C4, C5, F1, F2, F3, F4, F5, M1, M2, UAVinv, FL_RANK, V01, V02]=PI_gensys_singularC(C1in, C2in, C3in, C4in, C5in, F1, F2, F3, F4, F5, V01, V02, level)

DESCRIPTION ^

 [C1,C2,C3,C4, C5, F1, F2, F3, F4, F5, M1, M2, UAVinv,FL_RANK, V01, V02]...
         =PI_gensys_singularC(C1in, C2in, C3in, C4in, C5in, F1, F2, F3, F4, F5, V01, V02, level)
 
 Recursive extension for PI_gensys function PCL general DSGE solver
 devised by Prof. Joseph Pearlman 
 developed by George Perendia
 December 2010

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [C1,C2,C3,C4, C5, F1, F2, F3, F4, F5, M1, M2, UAVinv, FL_RANK, V01, V02]=PI_gensys_singularC(C1in, C2in, C3in, C4in, C5in, F1, F2, F3, F4, F5, V01, V02, level)
0002 % [C1,C2,C3,C4, C5, F1, F2, F3, F4, F5, M1, M2, UAVinv,FL_RANK, V01, V02]...
0003 %         =PI_gensys_singularC(C1in, C2in, C3in, C4in, C5in, F1, F2, F3, F4, F5, V01, V02, level)
0004 %
0005 % Recursive extension for PI_gensys function PCL general DSGE solver
0006 % devised by Prof. Joseph Pearlman
0007 % developed by George Perendia
0008 % December 2010
0009 
0010 % Copyright (C) 1996-2011 Dynare Team
0011 %
0012 % This file is part of Dynare.
0013 %
0014 % Dynare is free software: you can redistribute it and/or modify
0015 % it under the terms of the GNU General Public License as published by
0016 % the Free Software Foundation, either version 3 of the License, or
0017 % (at your option) any later version.
0018 %
0019 % Dynare is distributed in the hope that it will be useful,
0020 % but WITHOUT ANY WARRANTY; without even the implied warranty of
0021 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0022 % GNU General Public License for more details.
0023 %
0024 % You should have received a copy of the GNU General Public License
0025 % along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
0026 
0027 level=level+1
0028 if level>100
0029     error( ' PI_gensys_singularC recurssion exceeeded its maximum of 100 iterations! ');
0030 end
0031 warning('', '');
0032 M1=[];M2=[]; UAVinv=[];
0033 %
0034 % Find SVD of a0, and create partitions of U, S and V
0035 %
0036 
0037 [J0,K0,L0] = svd(C2in);
0038 n=size(C2in,1);
0039 K_RANK=rank(K0);
0040 J2=J0(1:n,K_RANK+1:n);
0041 
0042 J2C1=J2'*C1in;
0043 M = null(J2C1)';
0044 MJCinv= inv([M;J2C1]);
0045 [sm1, sm2]=size (M');
0046 M1=MJCinv(1:sm1,1:sm2);
0047 M2=MJCinv(1:sm1,1+sm2:end);
0048 FL_RANK=rank(M);
0049 
0050 %Define new Cs
0051 C5=[ C5in; J2C1*F5];
0052 C4=[C4in C3in*M2; J2C1*F4 J2C1*F3*M2];
0053 C3=[ C3in*M1; J2C1*F3*M1];
0054 C2=[C2in C1in*M2; J2'*(C4in+C1in*F2) J2'*(C3in+C1in*F1)*M2];
0055 C1=[ C1in*M1; J2'*(C3in+C1in*F1)*M1];
0056 %define new after Cs Fs
0057 % keep this reverse order!!
0058 F5 =M*F5 ;
0059 F4 =[M*F4  M*F3*M2];
0060 F3 = M*F3*M1;
0061 F2 =[M*F2  M*F1*M2];
0062 F1 = M*F1*M1;
0063 
0064 V02=[V02 V01*M2];
0065 V01=V01*M1;
0066 
0067 warning('', '');
0068 singular=0;
0069 try
0070     if rcond(C2) < 1e-8
0071         singular=1;
0072     else
0073         UAVinv=inv(C2);
0074         [LastWarningTxt LastWarningID]=lastwarn;
0075         if any(any(isinf(UAVinv)))==1
0076             singular=1;
0077         end
0078     end
0079     % line test is for Octave strncmp('warning: inverse: matrix singular',LastWarningTxt, 33)==1 || ...
0080     if  singular==1 || strcmp('MATLAB:nearlySingularMatrix',LastWarningID)==1 || ...
0081                  strcmp('MATLAB:illConditionedMatrix',LastWarningID)==1 || ...
0082                  strcmp('MATLAB:singularMatrix',LastWarningID)==1
0083         [C1,C2,C3,C4, C5, F1, F2, F3, F4, F5, M1, M2, UAVinv, FL_RANK, V01, V02] = PI_gensys_singularC(C1,C2,C3,C4, C5, F1, F2, F3, F4, F5, V01, V02, level);
0084     end
0085 catch
0086     [errmsg, errcode]=lasterr;
0087     warning(['error callig PI_gensys_singularC: ' errmsg ],'errcode');
0088     error('errcode',['error callig PI_gensys_singularC: ' errmsg ]);
0089 end
0090 
0091 return;
0092

Generated on Tue 22-May-2012 02:40:23 by m2html © 2005