Home > matlab > AIM > SPObstruct.m

SPObstruct

PURPOSE ^

scof = SPObstruct(cof,cofb,neq,nlag,nlead)

SYNOPSIS ^

function scof = SPObstruct(cof,cofb,neq,nlag,nlead)

DESCRIPTION ^

 scof = SPObstruct(cof,cofb,neq,nlag,nlead)

 Construct the coefficients in the observable structure.
    
   Input arguments:

            cof    structural coefficients
            cofb   reduced form
            neq    number of equations
            nlag   number of lags
            nlead  number of leads

   Output arguments:

            scof  observable structure coefficients

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % scof = SPObstruct(cof,cofb,neq,nlag,nlead)
0002 %
0003 % Construct the coefficients in the observable structure.
0004 %
0005 %   Input arguments:
0006 %
0007 %            cof    structural coefficients
0008 %            cofb   reduced form
0009 %            neq    number of equations
0010 %            nlag   number of lags
0011 %            nlead  number of leads
0012 %
0013 %   Output arguments:
0014 %
0015 %            scof  observable structure coefficients
0016 
0017 % Original author: Gary Anderson
0018 % Original file downloaded from:
0019 % http://www.federalreserve.gov/Pubs/oss/oss4/code.html
0020 % Adapted for Dynare by Dynare Team.
0021 %
0022 % This code is in the public domain and may be used freely.
0023 % However the authors would appreciate acknowledgement of the source by
0024 % citation of any of the following papers:
0025 %
0026 % Anderson, G. and Moore, G.
0027 % "A Linear Algebraic Procedure for Solving Linear Perfect Foresight
0028 % Models."
0029 % Economics Letters, 17, 1985.
0030 %
0031 % Anderson, G.
0032 % "Solving Linear Rational Expectations Models: A Horse Race"
0033 % Computational Economics, 2008, vol. 31, issue 2, pages 95-113
0034 %
0035 % Anderson, G.
0036 % "A Reliable and Computationally Efficient Algorithm for Imposing the
0037 % Saddle Point Property in Dynamic Models"
0038 % Journal of Economic Dynamics and Control, 2010, vol. 34, issue 3,
0039 % pages 472-489
0040 
0041 function scof = SPObstruct(cof,cofb,neq,nlag,nlead)
0042 
0043 
0044 % Append the negative identity to cofb
0045 
0046 cofb = [cofb, -eye(neq)];
0047 scof = zeros(neq,neq*(nlag+1));
0048 q    = zeros(neq*nlead, neq*(nlag+nlead));
0049 [rc,cc] = size(cofb);
0050 qs=sparse(q);
0051 qs(1:rc,1:cc) = sparse(cofb);
0052 qcols = neq*(nlag+nlead);
0053 
0054 if( nlead > 1 ) 
0055    for i = 1:nlead-1
0056       rows = i*neq + (1:neq);
0057       qs(rows,:) = SPShiftright( qs((rows-neq),:), neq );
0058    end
0059 end
0060 
0061 l = (1: neq*nlag);
0062 r = (neq*nlag+1: neq*(nlag+nlead));
0063 
0064  qs(:,l) = - qs(:,r) \ qs(:,l);
0065 
0066 minus =              1:       neq*(nlag+1);
0067 plus  = neq*(nlag+1)+1: neq*(nlag+1+nlead);
0068 
0069 cofs=sparse(cof);
0070 scof(:,neq+1:neq*(nlag+1)) = cofs(:,plus)*qs(:,l);
0071 scof = scof + cofs(:,minus);

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