Debian Codegraph @

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

raw
1 function rootsinv = fn_varoots(Bhat,nvar,lags)
2 %
3 % Using eigenvalues to find the inverse of all roots associated with the VAR proceess:
4 % y_t' = C + y_{t-1}'*B_1 + ... + Y_{t-p}'*B_p + u_t'.
5 % where columns correspond to equations. See also Judge (1), pp.753-755 where rows correspond to equations.
6 % Bhat: ncoef-by-nvar where ncoef=nvar*lags+nexo and nvar is the number of endogenous variables.
7 % Columns corresponds to equations with
8 % ncoef=[nvar for 1st lag, ..., nvar for last lag, other exogenous terms, const term]
9 % ..., nvar coef in the last lag, and nexo coefficients.
10 % Note that entries in the rows of Bhat that > nvar*lags are irrelevant.
11 % nvar: number of endogenous variables.
12 % lags: number of lags.
13 %-------
14 % rootsinv: a vector of nvar*lags inverse roots. When > 1, explosive. When all < 1, stationary.
15 %
16 % Tao Zha, September 2000
17 %
18 % Copyright (C) 1997-2012 Tao Zha
19 %
20 % This free software: you can redistribute it and/or modify
21 % it under the terms of the GNU General Public License as published by
22 % the Free Software Foundation, either version 3 of the License, or
23 % (at your option) any later version.
24 %
25 % It is distributed in the hope that it will be useful,
26 % but WITHOUT ANY WARRANTY; without even the implied warranty of
27 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 % GNU General Public License for more details.
29 %
30 % If you did not received a copy of the GNU General Public License
31 % with this software, see <http://www.gnu.org/licenses/>.
32 %
33
34
35 if size(Bhat,1)<nvar*lags
36 disp(' ')
37 warning('Make sure that Bhat has at least nvar*lags rows')
38 return
39 end
40
41 %--------- Strack the VAR(p) to the VAR(1) with z_t = Az_{t-1}.
42 %
43 A1 = diag(ones(nvar*(lags-1),1));
44 A2 = [A1 zeros(nvar*(lags-1),nvar)];
45 A = [Bhat(1:nvar*lags,:)'; A2];
46 rootsinv=eig(A);