Debian Codegraph @

contrib/ms-sbvar/TZcode/MatlabFiles/fshock.m

raw
1 function yhat = fshock(Bh,phi,shock,nn)
2 % fshock: unconditionally forecasts supplied with reduced-form shocks
3 % yhat = fshock(Bh,phi,shock,nn)
4 %
5 % y_hat(t+h) = c + x_hat(t+h-1)*Bh, X: 1*k; Bh: k*nvar; y_hat: 1*nvar
6 % where Bh: the (posterior) estimate of B;
7 % phi: the 1-by-(nvar*lags+1) initial data matrix where k=nvar*lags+1
8 % (last period plus lags before the beginning of forecast);
9 % shock: forep-by-nvar reduced-form residuals, where forep: forecast periods;
10 % nn: [nvar,lags,forep];
11 % yhat: forep-by-nvar.
12 %
13 % For structural shocks, see forefixe.m
14 %
15 % Copyright (C) 1997-2012 Tao Zha
16 %
17 % This free software: you can redistribute it and/or modify
18 % it under the terms of the GNU General Public License as published by
19 % the Free Software Foundation, either version 3 of the License, or
20 % (at your option) any later version.
21 %
22 % It is distributed in the hope that it will be useful,
23 % but WITHOUT ANY WARRANTY; without even the implied warranty of
24 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 % GNU General Public License for more details.
26 %
27 % If you did not received a copy of the GNU General Public License
28 % with this software, see <http://www.gnu.org/licenses/>.
29 %
30
31 % ** setup
32 nvar = nn(1);
33 lags = nn(2);
34 forep = nn(3);
35 tcwc = nvar*lags; % total coefficients without constant
36
37 % ** reconstruct x(t) for y(t+h) = x(t+h-1)*B
38 % ** where phi = x(t+h-1) with last column being constant
39 yhat = zeros(forep,nvar);
40 for k=1:forep
41 yhat(k,:) = phi*Bh + shock(k,:);
42 phi(1,nvar+1:tcwc) = phi(1,1:tcwc-nvar);
43 phi(1,1:nvar) = yhat(k,:);
44 end