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

state_check(K,R)
function [info,N] = state_check(K,R)

%  PURPOSE: checks whether variables defined by the matrix K can be chosen
%           as state variables
%
%           as state variables are taken variables 
%               x_t = K y_t
%
%           if variables x_t cannot be chosen as state variables, then the
%           matrix N presents relations between variables x_t, that
%           always holds in the model:
%               Nx_t = 0
%
% ---------------------------------------------------
%  USAGE: state_check(K,R)
%  where: 
%         K                         a matrix representing state variables
%         R                         a matrix determining observations in
%                                   the system
%                                       u_t   = P u_t-1 + V epsilon_t
%                                       y_t   = R u_t   + W epsilon_t
%
%  Output:
%        info                       0 if selected variables may not
%                                   represent state variables, 1 otherwise
%        N                          matrix representing relations between variables x_t, that
%                                   always holds in the model
%
%   COMMENTS:
%
% Copyright  (c) Pawel Kowal (2006)
% All rights reserved
% LREM_SOLVE toolbox is available free for noncommercial academic use only.
% pkowal3@sgh.waw.pl

R           = K*R;
S           = sum(abs(R),2);
I           = find(S==0);
for i=1:1:length(I)
    warning(['selected variable ' int2str(I(i)) ' may not be a state variable']);
end

[Q,R,E]       = qr(R);
[Abar,U,k]    = putv(R,1);
if k < size(R,1)
    info      = 0;
else
    info      = 1;
end

if nargout==2
    N         = U(:,k+1:end)';
end

Contact us at files@mathworks.com