Debian Codegraph @

tests/ms-sbvar/archive-files/ftd_RSvensson_4v.m

raw
1 function [Ui,Vi,n0,np,ixmC0Pres] = ftd_reac_function_4v(lags,nvar,nexo,indxC0Pres)
2 % vlist = [ff+ch fh dpgdp ffr)
3 %
4 % Exporting orthonormal matrices for the deterministic linear restrictions (equation by equation)
5 % See Waggoner and Zha's Gibbs sampling paper.
6 %
7 % HERE FIRTS 3 EQUATIONS ARE AR2 AND THE LAST EQUATION IS AN UNRESTRICTED
8 % REACTION FUNCTION 2 lags
9 %
10 % q_m: quarter or month
11 % lags: the maximum length of lag
12 % nvar: number of endogeous variables
13 % nexo: number of exogenous variables. If nexo is not supplied, nexo=1 as default for a constant
14 % indxC0Pres: index for cross-A0-A+ restrictions. if 1: cross-A0-and-A+ restrictions; 0: idfile is all we have
15 % Example for indxOres==1: restrictions of the form P(t) = P(t-1).
16 % These restrictions have to be manually and carefully keyed in.
17 %-----------------
18 % Ui: nvar-by-1 cell. In each cell, nvar-by-qi orthonormal basis for the null of the ith
19 % equation contemporaneous restriction matrix where qi is the number of free parameters.
20 % With this transformation, we have ai = Ui*bi or Ui'*ai = bi where ai is a vector
21 % of total original parameters and bi is a vector of free parameters. When no
22 % restrictions are imposed, we have Ui = I. There must be at least one free
23 % parameter left for the ith equation.
24 % Vi: nvar-by-1 cell. In each cell, k-by-ri orthonormal basis for the null of the ith
25 % equation lagged restriction matrix where k is a total of exogenous variables and
26 % ri is the number of free parameters. With this transformation, we have fi = Vi*gi
27 % or Vi'*fi = gi where fi is a vector of total original parameters and gi is a
28 % vector of free parameters. There must be at least one free parameter left for
29 % the ith equation.
30 % n0: nvar-by-1, ith element represents the number of free A0 parameters in ith equation
31 % np: nvar-by-1, ith element represents the number of free A+ parameters in ith equation
32 % ixmC0Pres: neq_cres-by-1 cell. Effective only if indxC0Pres=1, otherwise equals NaN.
33 % neq_cres is the number of equations in which cross-A0-A+ restrictions occur.
34 % In the jth cell representing equation, we have 4 columns:
35 % 1st: the jth column (equation) of A+ or A0: f_j or a_j
36 % 2nd: the ith element f_j(i) -- the ith element in the jth column of A+
37 % 3rd: the hth element a_j(h) -- the hth element in the jth column of A0
38 % 4th: the number s such that f_j(i) = s * a_j(h) holds.
39 %
40 % Tao Zha, May 2000
41 % BN
42
43 nvar=4;
44 lags=4;
45 nexo=1;
46
47 Ui = cell(nvar,1); % initializing for contemporaneous endogenous variables
48 Vi = cell(nvar,1); % initializing for lagged and exogenous variables
49 n0 = zeros(nvar,1); % ith element represents the number of free A0 parameters in ith equation
50 np = zeros(nvar,1); % ith element represents the number of free A+ parameters in ith equation
51
52 if (nargin==2)
53 nexo = 1; % 1: constant as default where nexo must be a nonnegative integer
54 elseif (nargin==3)
55 indxC0Pres = 0; % default is no cross-A0-and-A+ restrictions.
56 end
57
58 k = lags*nvar+nexo; % maximum number of lagged and exogenous variables in each equation
59
60 Qi = zeros(nvar,nvar,nvar); % for nvar contemporaneous equations
61 Ri = zeros(k,k,nvar); % for nvar lagged and exogenous equations
62 % Row corresponds to equation. 0 means no restriction.
63 % 1 means exclusion restriction such that the corresponding parameter is restricted to 0.
64
65 %nfvar = 6; % number of foreign (Granger causing) variables
66 %nhvar = nvar-nfvar; % number of home (affected) variables.
67
68
69 %-------------------------------------------------------------
70 % Beginning the manual input of the restrictions one quation at a time
71 %-------------------------------------------------------------
72 %
73 %======== The first equation ===========
74 Qi(1:3,:,1) = [
75 0 1 0 0
76 0 0 1 0
77 0 0 0 1
78 ];
79
80 %======== The second equation ===========
81 Qi(1:2,:,2) = [
82 0 0 1 0
83 0 0 0 1
84 ];
85
86 %======== The third equation =========== NOTE THAT WE FORBID A
87 %CONTEMPORANEOUS IMPACT OF OUTPUTON PRICES TO AVOID A CONSTRAINT THAT
88 %INVOLVE A0 and Aplus
89 Qi(1:3,:,3) = [
90 1 0 0 0
91 0 1 0 0
92 0 0 0 1
93 ];
94
95 %======== The fourth equation ===========
96
97
98 % Restrictions on the A+ in order to focus strictly on the reaction fucntion
99
100 % indicates free parameterers X i
101 % Ap = [
102 % X X X X
103 % X X X X
104 % -a1 -b1 X X
105 % a1 b1 0 X (1st lag)
106 % X X X X
107 % X X X X
108 % -a2 -b2 X X
109 % b2 b2 0 X (2nd lag)
110 % X 0 X X
111 % X X X X
112 % -a3 -b3 X X
113 % a3 a3 0 X (3rd lag)
114 % X X X X
115 % X X X X
116 % -a4 -b4 X X
117 % a4 b4 0 X (4th lag)
118 % X X X X (constant terms)
119 % ];
120
121 k=nvar*lags+nexo;
122 Ri = zeros(k,k,nvar);
123 % constraints on IS curve /conso+corporate investment
124 for nv=1:2
125 for ll=1:lags
126 Ri(ll,3+lags*(ll-1),nv)=1;
127 Ri(ll,4+lags*(ll-1),nv)=1;
128 end
129 end
130
131 % constraints on IS curve /conso+corporate investment only on the long run
132 % impact
133 % for nv=1:2
134 % for ll=1:lags
135 % Ri(1,3+lags*(ll-1),nv)=1;
136 % Ri(1,4+lags*(ll-1),nv)=1;
137 % end
138 % end
139
140
141 % constraints on Ph curve / inflation does not react to interest rates
142 for ll=1:lags
143 Ri(ll,4+lags*(ll-1),3)=1;
144 end
145
146
147 for n=1:nvar % initializing loop for each equation
148 Ui{n} = null(Qi(:,:,n));
149 Vi{n} = null(Ri(:,:,n));
150 n0(n) = size(Ui{n},2);
151 np(n) = size(Vi{n},2);
152 end
153
154
155
156 %(2)-------------------------------------------------------------
157 % Cross-A0-and-A+ rerestrictions one quation at a time
158 % i.e., the first, second, ..., kjth, ..., equation
159 %(2)-------------------------------------------------------------
160 %
161 if indxC0Pres
162 neq_cres = 3; % the number of equations in which cross-A0-A+ restrictions occur.
163 ixmC0Pres = cell(neq_cres,1); % in each cell representing equation, we have 4 columns:
164 % 1st: the jth column (equation) of A+ or A0: f_j or a_j
165 % 2nd: the ith element f_j(i) -- the ith element in the jth column of A+
166 % 3rd: the hth element a_j(h) -- the hth element in the jth column of A0
167 % 4th: the number s such that f_j(i) = s * a_j(h) holds.
168 %** 1st equation
169 ixmC0Pres{1} = [1 2 2 1
170 1 7 1 1];
171 %** 2nd equation
172 ixmC0Pres{2} = [2 2 2 2];
173 %** 3rd equation
174 ixmC0Pres{3} = [3 7 1 1
175 3 2 2 1];
176
177
178 % % 4 columns.
179 % ncres = 5; % manually key in the number of cross-A0-A+ restrictions
180
181 % % 1st: the jth column (equation) of A+ or A0: f_j or a_j
182 % % 2nd: the ith element f_j(i) -- the ith element in the jth column of A+
183 % % 3rd: the hth element a_j(h) -- the hth element in the jth column of A0
184 % % 4th: the number s such that f_j(i) = s * a_j(h) holds.
185 else
186 ixmC0Pres = NaN;
187 end
188