function [R ZNP] = nopolicy(k,A0,A1,A2,A4,H0,H1,shk)
% Calculates equilibrium in the period before policy reacts
% shk
% k = policy delay
% N = number of endogenous plus exogenous variables
% Equil. from t+k forward is y(t+k) = H0*y(t+k-1) + H1*v(t)
%
% If z(t) is N x 1, ZNP is N x k, where policy starts in t+k
% ZNP = [y(t) y(t+1) ... y(t+k-1)]

N    = size(A1,1);
ZNP  = zeros(k*N,1); % [Z(t); Z(t+1);...; Z(t+k-1)]'
Shk  = zeros(k*N,1);
R    = zeros(k*N,k*N);
%%
if k > 0
    for s = 1:k-1
    R(1+(s-1)*N:s*N,1+(s-1)*N:s*N)  =  A1;
    R(1+s*N:(s+1)*N,1+(s-1)*N:s*N)  = -A0;
    R(1+(s-1)*N:s*N,1+s*N:(s+1)*N)  = -A2;
    end
    R(1+(k-1)*N:k*N,1+(k-1)*N:k*N)  = A1-A2*H0;
    Shk(1:N,:)                      = A4*shk;
    ZNP                             = R\Shk;
end

% example: for k = 3
% R = [A1 -A2  0   0 
%     -A0  A1 -A2  0
%      0  -A0 vA1 -A2];
%if k == 3
%    R                   = zeros(k*N);
%    Shk(1:N,:)          = A4;
%    R(1:N,:)            = [A1 -A2 zeros(N,N)]; %[A1-A2*H0 -A0 zeros(N,N)]
%    R(N+1:2*N,:)        = [-A0 A1 -A2 ];
%    R(2*N+1:3*N,:)      = [zeros(N,N) -A0 A1-A2*H0];
%    ZNP                 = R\Shk
%end