Debian Codegraph @

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

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