Added realtime conditional forecast shock decomposition

time-shift
Marco Ratto 2017-01-20 13:58:56 +01:00 committed by Stéphane Adjemian (Charybdis)
parent 3bebeb1832
commit 92f79a14f4
1 changed files with 31 additions and 1 deletions

View File

@ -180,7 +180,7 @@ for j=presample+1:nobs,
z1(:,nshocks+1) = z1(:,nshocks+2) - sum(z1(:,1:nshocks),2);
end
%%
%% conditional shock decomp k step ahead
if forecast_ && forecast_<j,
zn = zeros(endo_nbr,nshocks+2,forecast_+1);
@ -206,6 +206,36 @@ for j=presample+1:nobs,
end
%%
%% realtime conditional shock decomp k step ahead
if forecast_ && presample<j,
for ind_forecast_=1:min(forecast_,j-presample)
zn = zeros(endo_nbr,nshocks+2,ind_forecast_+1);
zn(:,end,1:ind_forecast_+1) = Smoothed_Variables_deviation_from_mean(:,gend-ind_forecast_:gend);
for i=1:ind_forecast_+1,
if i > 1 && i <= maximum_lag+1
lags = min(i-1,maximum_lag):-1:1;
end
if i > 1
tempx = permute(zn(:,1:nshocks,lags),[1 3 2]);
m = min(i-1,maximum_lag);
tempx = [reshape(tempx,endo_nbr*m,nshocks); zeros(endo_nbr*(maximum_lag-i+1-1),nshocks)];
zn(:,1:nshocks,i) = A(inv_order_var,:)*tempx(i_state,:);
lags = lags+1;
zn(:,1:nshocks,i) = zn(:,1:nshocks,i) + B(inv_order_var,:).*repmat(epsilon(:,i+gend-ind_forecast_-1)',endo_nbr,1);
end
% zn(:,1:nshocks,i) = zn(:,1:nshocks,i) + B(inv_order_var,:).*repmat(epsilon(:,i+gend-forecast_-1)',endo_nbr,1);
zn(:,nshocks+1,i) = zn(:,nshocks+2,i) - sum(zn(:,1:nshocks,i),2);
if i==1 && ind_forecast_==1
oo_.realtime_conditional_shock_decomposition.(['time_' int2str(j-ind_forecast_)])(:,:,1)=zn(:,:,1);
end
end
oo_.realtime_conditional_shock_decomposition.(['time_' int2str(j-ind_forecast_)])(:,:,1+ind_forecast_)=zn(:,:,end);
end
end
%%
if init,
zreal(:,:,1:j) = z(:,:,1:j);
else