Home > matlab > AIM > SPNumeric_shift.m

SPNumeric_shift

PURPOSE ^

[h,q,iq,nnumeric] = ...

SYNOPSIS ^

function [h,q,iq,nnumeric] = SPNumeric_shift(h,q,iq,qrows,qcols,neq,condn)

DESCRIPTION ^

  [h,q,iq,nnumeric] = ...
             SPNumeric_shift(h,q,iq,qrows,qcols,neq,condn)

 Compute the numeric shiftrights and store them in q.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 %  [h,q,iq,nnumeric] = ...
0002 %             SPNumeric_shift(h,q,iq,qrows,qcols,neq,condn)
0003 %
0004 % Compute the numeric shiftrights and store them in q.
0005 
0006 % Original author: Gary Anderson
0007 % Original file downloaded from:
0008 % http://www.federalreserve.gov/Pubs/oss/oss4/code.html
0009 % Adapted for Dynare by Dynare Team.
0010 %
0011 % This code is in the public domain and may be used freely.
0012 % However the authors would appreciate acknowledgement of the source by
0013 % citation of any of the following papers:
0014 %
0015 % Anderson, G. and Moore, G.
0016 % "A Linear Algebraic Procedure for Solving Linear Perfect Foresight
0017 % Models."
0018 % Economics Letters, 17, 1985.
0019 %
0020 % Anderson, G.
0021 % "Solving Linear Rational Expectations Models: A Horse Race"
0022 % Computational Economics, 2008, vol. 31, issue 2, pages 95-113
0023 %
0024 % Anderson, G.
0025 % "A Reliable and Computationally Efficient Algorithm for Imposing the
0026 % Saddle Point Property in Dynamic Models"
0027 % Journal of Economic Dynamics and Control, 2010, vol. 34, issue 3,
0028 % pages 472-489
0029 
0030 function [h,q,iq,nnumeric] = SPNumeric_shift(h,q,iq,qrows,qcols,neq,condn)
0031 
0032 nnumeric = 0;
0033 left     = 1:qcols;
0034 right    = qcols+1:qcols+neq;
0035 
0036 [Q,R,E]  = qr( h(:,right) );
0037 zerorows = find( abs(diag(R)) <= condn );
0038 
0039 while( any(zerorows) && iq <= qrows )
0040    h=sparse(h);
0041    Q=sparse(Q);
0042    h = Q'*h;
0043    nz = length(zerorows);
0044    q(iq+1:iq+nz,:) = h(zerorows,left);
0045    h(zerorows,:)   = SPShiftright( h(zerorows,:), neq );
0046    iq       = iq + nz;
0047    nnumeric = nnumeric + nz;
0048    [Q,R,E] = qr( full(h(:,right)) );
0049    zerorows = find( abs(diag(R)) <= condn );
0050 end

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