Home > matlab > AIM > SPReduced_form.m

SPReduced_form

PURPOSE ^

[nonsing,b] = SPReduced_form(q,qrows,qcols,bcols,neq,b,condn);

SYNOPSIS ^

function [nonsing,b] = SPReduced_form(q,qrows,qcols,bcols,neq,condn);

DESCRIPTION ^

 [nonsing,b] = SPReduced_form(q,qrows,qcols,bcols,neq,b,condn);

 Compute reduced-form coefficient matrix, b.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % [nonsing,b] = SPReduced_form(q,qrows,qcols,bcols,neq,b,condn);
0002 %
0003 % Compute reduced-form coefficient matrix, b.
0004 
0005 % Original author: Gary Anderson
0006 % Original file downloaded from:
0007 % http://www.federalreserve.gov/Pubs/oss/oss4/code.html
0008 % Adapted for Dynare by Dynare Team.
0009 %
0010 % This code is in the public domain and may be used freely.
0011 % However the authors would appreciate acknowledgement of the source by
0012 % citation of any of the following papers:
0013 %
0014 % Anderson, G. and Moore, G.
0015 % "A Linear Algebraic Procedure for Solving Linear Perfect Foresight
0016 % Models."
0017 % Economics Letters, 17, 1985.
0018 %
0019 % Anderson, G.
0020 % "Solving Linear Rational Expectations Models: A Horse Race"
0021 % Computational Economics, 2008, vol. 31, issue 2, pages 95-113
0022 %
0023 % Anderson, G.
0024 % "A Reliable and Computationally Efficient Algorithm for Imposing the
0025 % Saddle Point Property in Dynamic Models"
0026 % Journal of Economic Dynamics and Control, 2010, vol. 34, issue 3,
0027 % pages 472-489
0028 
0029 function [nonsing,b] = SPReduced_form(q,qrows,qcols,bcols,neq,condn);
0030 b=[];
0031 %qs=SPSparse(q);
0032 qs=sparse(q);
0033 left = 1:qcols-qrows;
0034 right = qcols-qrows+1:qcols;
0035 nonsing = rcond(full(qs(:,right))) > condn;
0036 if(nonsing)
0037     qs(:,left) = -qs(:,right)\qs(:,left);
0038     b = qs(1:neq,1:bcols);
0039     b = full(b);
0040 else  %rescale by dividing row by maximal qr element
0041     %'inverse condition number small, rescaling '
0042     themax=max(abs(qs(:,right)),[],2);
0043     oneover = diag(1 ./ themax);
0044     nonsing = rcond(full(oneover *qs(:,right))) > condn;
0045     if(nonsing)
0046         qs(:,left) = -(oneover*qs(:,right))\(oneover*(qs(:,left)));
0047         b = qs(1:neq,1:bcols);
0048         b = full(b);
0049     end
0050 end
0051

Generated on Mon 21-May-2012 02:42:43 by m2html © 2005