| 1 |
function y = fn_uncondfcst_var1(G1, y0, nsteps); |
| 2 |
%y = fn_irf_var1(G1,y0,nsteps); |
| 3 |
% Inputs: |
| 4 |
% G1: n-by-n; |
| 5 |
% y0: n-by-1, initial condition; |
| 6 |
% nsteps: number of forecasts steps. |
| 7 |
%--- |
| 8 |
% Outputs: |
| 9 |
% y: nsteps-by-n unconditional forecasts. |
| 10 |
% |
| 11 |
% See fn_vds.m, fn_irf_var1.m. |
| 12 |
% |
| 13 |
% Copyright (C) 1997-2012 Tao Zha |
| 14 |
% |
| 15 |
% This free software: you can redistribute it and/or modify |
| 16 |
% it under the terms of the GNU General Public License as published by |
| 17 |
% the Free Software Foundation, either version 3 of the License, or |
| 18 |
% (at your option) any later version. |
| 19 |
% |
| 20 |
% It is distributed in the hope that it will be useful, |
| 21 |
% but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 22 |
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 23 |
% GNU General Public License for more details. |
| 24 |
% |
| 25 |
% If you did not received a copy of the GNU General Public License |
| 26 |
% with this software, see <http://www.gnu.org/licenses/>. |
| 27 |
% |
| 28 |
|
| 29 |
n = length(y0); |
| 30 |
|
| 31 |
[n1,n2] = size(G1); |
| 32 |
if (n1 ~= n2) || (n1 ~= n) |
| 33 |
error('fn_uncondfcst_var1.m: make sure that (1) G1 is square and (2) size(G1,1) = length(y0)'); |
| 34 |
end |
| 35 |
|
| 36 |
y = zeros(nsteps,n); |
| 37 |
|
| 38 |
|
| 39 |
%---- Forecast at the first step. |
| 40 |
y(1,:) = (G1*y0)'; |
| 41 |
|
| 42 |
for ti = 2:nsteps |
| 43 |
y(ti,:) = (G1*y(ti-1,:)')'; |
| 44 |
end |