No BSD License  

Highlights from
Solution to Linear Rational Expectations Models

from Solution to Linear Rational Expectations Models by Pawel Kowal
Solves linear rational expectation models, delivers derivatives of solutions

linear2ss(A,B,C,V,W,xi,do_reduction,method)
function [P,R,S,Q,N1,N2,eigenvalues,info] = linear2ss(A,B,C,V,W,xi,do_reduction,method)
%  PURPOSE: solves model of the form 
%
%               0 = A y_t + B y_t+1 + C E_t{y_t+1} + V epsilon_t + W epsilon_t+1
%
%           where epsilon_t+1 is i.i.d. random variable with zero mean
%           and holds the transversality condition 
%
%               lim (t->infty) xi^t E_0 y_t = 0
%
%           the model is represented in the state-space form
%
%               y_t     = R u_t   + (S + N1 X1) epsilon_t + N1 X2 omega_t
%               u_t     = P u_t-1 + (Q + N2 X1) epsilon_t + N2 X2 omega_t
%
%           where u_t is a state variable, omega_t is i.i.d. random
%           variable with mean zero, X1, X2 are any
%           matrices with appropriate size.
%           
% ---------------------------------------------------
%  USAGE: [P,R,S,Q,N1,N2,eigenvalues,info] = linear2ss(A,B,C,V,W,xi,do_reduction,method)
%  where: 
%         A,B,C,V,W                 matrices representing the model,
%                                   matrices A,B,C must be square and the
%                                   matrix pair (A,B+C) must be regural
%         xi                        growth restriction
%         do_reduction              optional parameter, if do_redution~=0,
%                                   then the orginal problem is reduced
%                                   first
%         method                    method to calculate null spaces
%                                   (optional)
%                                       1 - qr with pivoting (default)
%                                       2 - svd
%
%         P,R,S,Q,N1,N2             matrices representing the model in the
%                                   state-space form
%         eigenvalues               eigenvalues of the matrix pair (A,B+C)
%         info                      return 1 is solution exists and zero
%                                   otherwise. If number of output
%                                   variables is lower than eight, then
%                                   an error is thrown if there are no
%                                   solutions.
%
%   COMMENTS:
%
% Copyright  (c) Pawel Kowal (2006)
% All rights reserved
% LREM_SOLVE toolbox is available free for noncommercial academic use only.
% pkowal3@sgh.waw.pl

if nargin<7
    do_reduction        = 1;
end
if nargin<8
    method              = 1;
end
if nargout<8
    throw_error = false;
else
    throw_error = true;
end
info            = 1;

[P,R,eigenvalues]       = solve_deterministic(-A,B+C,xi,do_reduction,method);
[S,Q,N1,N2,info]        = solve_stochastic(A,B,V,W,R,method);

if info==0
    if throw_error
        error('there are no solutions');
    else
        S       =[];
        Q       =[];
        N1      =[];
        N2      =[];
        info    = 0;
        return;
    end      
end

Contact us at files@mathworks.com