| [RR,PP,SS1,SS2,QQ1,QQ2]=state_set(R,P,S1,S2,Q1,Q2,K)
|
function [RR,PP,SS1,SS2,QQ1,QQ2]=state_set(R,P,S1,S2,Q1,Q2,K)
% PURPOSE: set chosen variables as state variables in a model in the
% state-space form
%
% y_t = R u_t + S_1 epsilon_t + S_2 omega_t
% u_t = P u_t + Q_1 epsilon_t + Q_2 omega_t
%
% where epsilon_t, omega_t are i.i.d. random variable with zero mean
% y_t is a vector of endogenous variables, and u_t is a vector of
% state variables
%
% This model is transformed to the model
%
% y_t = RR v_t + SS_1 epsilon_t + SS_2 omega_t
% v_t = PP v_t + QQ_1 epsilon_t + QQ_2 omega_t
%
% where v_t = [x_t, w_t]', dim(x_t) + dim(w_t) = dim(u_t)
% and
%
% x_t = K y_t
%
% ---------------------------------------------------
% USAGE: [RR,PP,SS1,SS2,QQ1,QQ2] = state_set(R,P,S1,S2,Q1,Q2,K)
% where:
% R,P,S1,S2,Q1,Q2 matrices representing the model,
% K a matrix determining selected state
% variables
% RR,PP,SS1,SS2,QQ1,QQ2 matrices representing the transformed
% 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
%checks whether selected variables may be chosen as state variables
info = state_check(K,R);
if info==0
error('selected variables may not be chosen as state variables');
end
[U,S,V] = svd(K*R);
n = size(S,1);
S = S(:,1:n);
SS = diag(diag(S).^-1);
P = V'*P*V;
P11 = P(1:n,1:n);
P12 = P(1:n,n+1:end);
P21 = P(n+1:end,1:n);
P22 = P(n+1:end,n+1:end);
PP =[U*S*P11*SS*U' U*S*P12;P21*SS*U' P22];
QQ1 =[U*S*Q1(1:n,:);Q1(n+1:end,:)];
QQ2 =[U*S*Q2(1:n,:);Q2(n+1:end,:)];
RR =R*[V(:,1:n)*SS*U' V(:,n+1:end)];
SS1 =S1;
SS2 =S2;
|
|