Debian Codegraph @

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

raw
1 function [Ui,Vi,n0,np] = ftd_2s_caseall_upperchol6v(lags,nvar,nStates,indxEqnTv_m,nexo)
2 % Case 2&3: Policy a0j and a+j have only time-varying structural variances -- Case 2.
3 % All policy and nonpolicy a0j's and the corresponding constant terms are completely time-varying and only the scale
4 % of each variable in d+j,1** (excluding the constant term) is time-varying -- Case 3.
5 %
6 % Variables: Pcom, M2, FFR, y, P, U. Equations: information, policy, money demand, y, P, U.
7 % Exporting orthonormal matrices for the deterministic linear restrictions
8 % (equation by equation) with time-varying A0 and D+** equations.
9 % See Model II.3 on pp.71k-71r in TVBVAR NOTES (and Waggoner and Zha's Gibbs sampling paper and TVBVAR NOTES p.58).
10 %
11 % lags: Maximum length of lag.
12 % nvar: Number of endogeous variables.
13 % nStates: Number of states.
14 % indxEqnTv_m: nvar-by-2. Stores equation characteristics.
15 % 1st column: labels of equations [1:nvar]'.
16 % 2nd column: labels of time-varying features with
17 % 1: indxConst -- all coefficients are constant,
18 % 2: indxStv -- only shocks are time-varying,
19 % 3: indxTva0pv -- a0 are freely time-varying and each variable i for d+ is time-varying only by the scale lambda_i(s_t).
20 % 4: indxTva0ps -- a0 are freely time-varying and only the scale for the whole of d+ is time-varying.
21 % 5: indxTv -- time-varying for all coeffficients (a0 and a+) where the lag length for a+ may be shorter.
22 % nexo: number of exogenous variables. If nexo is not supplied, nexo=1 as default for a constant.
23 % So far this function is written to handle one exogenous variable, which is a constant term.
24 %-----------------
25 % Ui: nvar-by-1 cell. In each cell, nvar*nStates-by-qi*si orthonormal basis for the null of the ith
26 % equation contemporaneous restriction matrix where qi is the number of free parameters
27 % within the state and si is the number of free states.
28 % With this transformation, we have ai = Ui*bi or Ui'*ai = bi where ai is a vector
29 % of total original parameters and bi is a vector of free parameters. When no
30 % restrictions are imposed, we have Ui = I. There must be at least one free
31 % parameter left for the ith equation in the order of [a_i for 1st state, ..., a_i for last state].
32 % Vi: nvar-by-1 cell. In each cell, k*nStates-by-ri*si orthonormal basis for the null of the ith
33 % equation lagged restriction matrix where k is a total of exogenous variables and
34 % ri is the number of free parameters within the state and si is the number of free states.
35 % With this transformation, we have fi = Vi*gi or Vi'*fi = gi where fi is a vector of total original
36 % parameters and gi is a vector of free parameters. The ith equation is in the order of [nvar variables
37 % for 1st lag and 1st state, ..., nvar variables for last lag and 1st state, const for 1st state, nvar
38 % variables for 1st lag and 2nd state, nvar variables for last lag and 2nd state, const for 2nd state, and so on].
39 % n0: nvar-by-1, whose ith element represents the number of free A0 parameters in ith equation in *all states*.
40 % np: nvar-by-1, whose ith element represents the number of free D+ parameters in ith equation in *all states*.
41 %
42 % Tao Zha, February 2003
43
44
45
46 Ui = cell(nvar,1); % initializing for contemporaneous endogenous variables
47 Vi = cell(nvar,1); % initializing for lagged and exogenous variables
48 n0 = zeros(nvar,1); % ith element represents the number of free A0 parameters in ith equation in all states.
49 np = zeros(nvar,1); % ith element represents the number of free D+ parameters in ith equation in all states.
50
51 if (nargin==3)
52 nexo = 1; % 1: constant as default where nexo must be a nonnegative integer
53 end
54
55
56 n = nvar*nStates;
57 kvar=lags*nvar+nexo; % Maximum number of lagged and exogenous variables in each equation under each state.
58 k = kvar*nStates; % Maximum number of lagged and exogenous variables in each equation in all states.
59
60 Qi = zeros(n,n,nvar); % 3rd dim: nvar contemporaneous equations.
61 Ri = zeros(k,k,nvar); % 1st and 2nd dims: lagged and exogenous equations.
62 % Row corresponds to equation with nvar variables for state 1, ..., nvar variables for state nState.
63 % 0 means no restriction.
64 % 1 and -1 or any other number means the linear combination of the corresponding parameters is restricted to 0.
65 % 1 (only 1) means that the corresponding parameter is restricted to 0.
66
67 %nfvar = 6; % number of foreign (Granger causing) variables
68 %nhvar = nvar-nfvar; % number of home (affected) variables.
69
70
71 %-------------------------------------------------------------
72 % Beginning the manual input of the restrictions one quation at a time for A0_s.
73 %-------------------------------------------------------------
74 %
75
76 %======== The first equation ===========
77 eqninx = 1;
78 nreseqn = 5; % Number of linear restrictions for A0(:,eqninx) for each state.
79 if (indxEqnTv_m(eqninx, 2)<=2)
80 %**** For constant A0_s. In the order of [a0j(1),...,a0j(nStates)] for the 2nd dim of Qi.
81 Qi(1:(nStates-1)*nvar+nreseqn,:,eqninx) = [
82 1 0 0 0 0 0 -1 0 0 0 0 0
83 0 1 0 0 0 0 0 -1 0 0 0 0
84 0 0 1 0 0 0 0 0 -1 0 0 0
85 0 0 0 1 0 0 0 0 0 -1 0 0
86 0 0 0 0 1 0 0 0 0 0 -1 0
87 0 0 0 0 0 1 0 0 0 0 0 -1
88
89 0 0 0 0 0 0 0 1 0 0 0 0
90 0 0 0 0 0 0 0 0 1 0 0 0
91 0 0 0 0 0 0 0 0 0 1 0 0
92 0 0 0 0 0 0 0 0 0 0 1 0
93 0 0 0 0 0 0 0 0 0 0 0 1
94 ];
95 %**** For constant D+_s. In the order of [aj+(1),...,aj+(nStates)] for the 2nd dim of Ri.
96 for si=1:nStates-1
97 for ki=1:kvar
98 Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
99 end
100 end
101 else % Time-varying equations at least for A0_s. For D+_s, constant-parameter equations in general.
102 %**** For time-varying A0_s. In the order of [a0j(1),...,a0j(nStates)] for the 2nd dim of Qi.
103 Qi(1:nreseqn*nStates,:,eqninx) = [
104 0 1 0 0 0 0 0 0 0 0 0 0
105 0 0 1 0 0 0 0 0 0 0 0 0
106 0 0 0 1 0 0 0 0 0 0 0 0
107 0 0 0 0 1 0 0 0 0 0 0 0
108 0 0 0 0 0 1 0 0 0 0 0 0
109
110 0 0 0 0 0 0 0 1 0 0 0 0
111 0 0 0 0 0 0 0 0 1 0 0 0
112 0 0 0 0 0 0 0 0 0 1 0 0
113 0 0 0 0 0 0 0 0 0 0 1 0
114 0 0 0 0 0 0 0 0 0 0 0 1
115 ];
116
117 %**** For D+_s. In the order of [aj+(1),...,aj+(nStates)] for the 2nd dim of Ri.
118 if (indxEqnTv_m(eqninx, 2)==3) % For constant D+** except the constant term. In the order of [dj**(1),...,dj**(nStates)] for the 2nd dim of Ri.
119 for si=1:nStates-1
120 for ki=1:kvar-1 % -1: no restrictions on the constant term, which is freely time-varying.
121 Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
122 end
123 end
124 elseif (indxEqnTv_m(eqninx, 2)==4) % For constant D+**. In the order of [dj**(1),...,dj**(nStates)] for the 2nd dim of Ri.
125 for si=1:nStates-1
126 for ki=1:kvar
127 Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
128 end
129 end
130 else
131 error('.../ftd_2s_caseall_simszha5v.m: Have not got time to deal with the simple case indxEqnTv_m(eqninx, 2)=5.')
132 end
133 end
134
135
136
137 %======== The second equation ===========
138 eqninx = 2;
139 nreseqn = 4; % Number of linear restrictions for A0(:,eqninx) for each state.
140 if (indxEqnTv_m(eqninx, 2)<=2)
141 %**** For constant A0_s. In the order of [a0j(1),...,a0j(nStates)] for the 2nd dim of Qi.
142 Qi(1:(nStates-1)*nvar+nreseqn,:,eqninx) = [
143 1 0 0 0 0 0 -1 0 0 0 0 0
144 0 1 0 0 0 0 0 -1 0 0 0 0
145 0 0 1 0 0 0 0 0 -1 0 0 0
146 0 0 0 1 0 0 0 0 0 -1 0 0
147 0 0 0 0 1 0 0 0 0 0 -1 0
148 0 0 0 0 0 1 0 0 0 0 0 -1
149
150 0 0 0 0 0 0 0 0 1 0 0 0
151 0 0 0 0 0 0 0 0 0 1 0 0
152 0 0 0 0 0 0 0 0 0 0 1 0
153 0 0 0 0 0 0 0 0 0 0 0 1
154 ];
155 %**** For constant D+_s. In the order of [aj+(1),...,aj+(nStates)] for the 2nd dim of Ri.
156 for si=1:nStates-1
157 for ki=1:kvar
158 Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
159 end
160 end
161 else % Time-varying equations at least for A0_s. For D+_s, constant-parameter equations in general.
162 %**** For time-varying A0_s. In the order of [a0j(1),...,a0j(nStates)] for the 2nd dim of Qi.
163 Qi(1:nreseqn*nStates,:,eqninx) = [
164 0 0 1 0 0 0 0 0 0 0 0 0
165 0 0 0 1 0 0 0 0 0 0 0 0
166 0 0 0 0 1 0 0 0 0 0 0 0
167 0 0 0 0 0 1 0 0 0 0 0 0
168
169 0 0 0 0 0 0 0 0 1 0 0 0
170 0 0 0 0 0 0 0 0 0 1 0 0
171 0 0 0 0 0 0 0 0 0 0 1 0
172 0 0 0 0 0 0 0 0 0 0 0 1
173 ];
174
175 %**** For D+_s. In the order of [aj+(1),...,aj+(nStates)] for the 2nd dim of Ri.
176 if (indxEqnTv_m(eqninx, 2)==3) % For constant D+** except the constant term. In the order of [dj**(1),...,dj**(nStates)] for the 2nd dim of Ri.
177 for si=1:nStates-1
178 for ki=1:kvar-1 % -1: no restrictions on the constant term, which is freely time-varying.
179 Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
180 end
181 end
182 elseif (indxEqnTv_m(eqninx, 2)==4) % For constant D+**. In the order of [dj**(1),...,dj**(nStates)] for the 2nd dim of Ri.
183 for si=1:nStates-1
184 for ki=1:kvar
185 Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
186 end
187 end
188 else
189 error('.../ftd_2s_caseall_simszha5v.m: Have not got time to deal with the simple case indxEqnTv_m(eqninx, 2)=5.')
190 end
191 end
192
193
194 %======== The third equation ===========
195 eqninx = 3;
196 nreseqn = 3; % Number of linear restrictions for A0(:,eqninx) for each state.
197 if (indxEqnTv_m(eqninx, 2)<=2)
198 %**** For constant A0_s. In the order of [a0j(1),...,a0j(nStates)] for the 2nd dim of Qi.
199 Qi(1:(nStates-1)*nvar+nreseqn,:,eqninx) = [
200 1 0 0 0 0 0 -1 0 0 0 0 0
201 0 1 0 0 0 0 0 -1 0 0 0 0
202 0 0 1 0 0 0 0 0 -1 0 0 0
203 0 0 0 1 0 0 0 0 0 -1 0 0
204 0 0 0 0 1 0 0 0 0 0 -1 0
205 0 0 0 0 0 1 0 0 0 0 0 -1
206
207 0 0 0 0 0 0 0 0 0 1 0 0
208 0 0 0 0 0 0 0 0 0 0 1 0
209 0 0 0 0 0 0 0 0 0 0 0 1
210 ];
211 %**** For constant D+_s. In the order of [aj+(1),...,aj+(nStates)] for the 2nd dim of Ri.
212 for si=1:nStates-1
213 for ki=1:kvar
214 Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
215 end
216 end
217 else % Time-varying equations at least for A0_s. For D+_s, constant-parameter equations in general.
218 %**** For time-varying A0_s. In the order of [a0j(1),...,a0j(nStates)] for the 2nd dim of Qi.
219 Qi(1:nreseqn*nStates,:,eqninx) = [
220 0 0 0 1 0 0 0 0 0 0 0 0
221 0 0 0 0 1 0 0 0 0 0 0 0
222 0 0 0 0 0 1 0 0 0 0 0 0
223
224 0 0 0 0 0 0 0 0 0 1 0 0
225 0 0 0 0 0 0 0 0 0 0 1 0
226 0 0 0 0 0 0 0 0 0 0 0 1
227 ];
228
229 %**** For D+_s. In the order of [aj+(1),...,aj+(nStates)] for the 2nd dim of Ri.
230 if (indxEqnTv_m(eqninx, 2)==3) % For constant D+** except the constant term. In the order of [dj**(1),...,dj**(nStates)] for the 2nd dim of Ri.
231 for si=1:nStates-1
232 for ki=1:kvar-1 % -1: no restrictions on the constant term, which is freely time-varying.
233 Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
234 end
235 end
236 elseif (indxEqnTv_m(eqninx, 2)==4) % For constant D+**. In the order of [dj**(1),...,dj**(nStates)] for the 2nd dim of Ri.
237 for si=1:nStates-1
238 for ki=1:kvar
239 Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
240 end
241 end
242 else
243 error('.../ftd_3s_case3a.m: Have not got time to deal with the simple case indxEqnTv_m(eqninx, 2)=5.')
244 end
245
246 %==== For freely time-varying A+ for only the first 6 lags.
247 %==== Lagged restrictions: zeros on all lags except the first 6 lags in the MS equation.
248 % nlagsno0 = 6; % Number of lags to be nonzero.
249 % for si=1:nStates
250 % for ki = 1:lags-nlagsno0
251 % for kj=1:nvar
252 % Ri(kvar*(si-1)+nlagsno0*nvar+nvar*(ki-1)+kj,kvar*(si-1)+nlagsno0*nvar+nvar*(ki-1)+kj,2) = 1;
253 % end
254 % end
255 % end
256 %**** For constant D+_s except the first two lags and the constant term. In the order of [aj+(1),...,aj+(nStates)] for the 2nd dim of Ri.
257 % for si=1:nStates-1
258 % for ki=[2*nvar+1:kvar-1]
259 % Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
260 % end
261 % end
262 end
263
264
265 %======== The fourth equation ===========
266 eqninx = 4;
267 nreseqn = 2; % Number of linear restrictions for the equation for each state.
268 if (indxEqnTv_m(eqninx, 2)<=2)
269 %**** For constant A0_s. In the order of [a0j(1),...,a0j(nStates)] for the 2nd dim of Qi.
270 Qi(1:(nStates-1)*nvar+nreseqn,:,eqninx) = [
271 1 0 0 0 0 0 -1 0 0 0 0 0
272 0 1 0 0 0 0 0 -1 0 0 0 0
273 0 0 1 0 0 0 0 0 -1 0 0 0
274 0 0 0 1 0 0 0 0 0 -1 0 0
275 0 0 0 0 1 0 0 0 0 0 -1 0
276 0 0 0 0 0 1 0 0 0 0 0 -1
277
278 0 0 0 0 0 0 0 0 0 0 1 0
279 0 0 0 0 0 0 0 0 0 0 0 1
280 ];
281 %**** For constant D+_s. In the order of [aj+(1),...,aj+(nStates)] for the 2nd dim of Ri.
282 for si=1:nStates-1
283 for ki=1:kvar
284 Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
285 end
286 end
287 else % Time-varying equations at least for A0_s. For D+_s, constant-parameter equations in general.
288 %**** For time-varying A0_s. In the order of [a0j(1),...,a0j(nStates)] for the 2nd dim of Qi.
289 Qi(1:nreseqn*nStates,:,eqninx) = [
290 0 0 0 0 1 0 0 0 0 0 0 0
291 0 0 0 0 0 1 0 0 0 0 0 0
292
293 0 0 0 0 0 0 0 0 0 0 1 0
294 0 0 0 0 0 0 0 0 0 0 0 1
295 ];
296 %**** For D+_s. In the order of [aj+(1),...,aj+(nStates)] for the 2nd dim of Ri.
297 if (indxEqnTv_m(eqninx, 2)==3) % For constant D+** except the constant term. In the order of [dj**(1),...,dj**(nStates)] for the 2nd dim of Ri.
298 for si=1:nStates-1
299 for ki=1:kvar-1 % -1: no restrictions on the constant term, which is freely time-varying.
300 Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
301 end
302 end
303 elseif (indxEqnTv_m(eqninx, 2)==4) % For constant D+**. In the order of [dj**(1),...,dj**(nStates)] for the 2nd dim of Ri.
304 for si=1:nStates-1
305 for ki=1:kvar
306 Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
307 end
308 end
309 else
310 error('.../ftd_2s_caseall_simszha5v.m: Have not got time to deal with the simple case indxEqnTv_m(eqninx, 2)=5.')
311 end
312 end
313
314
315 %======== The fifth equation ===========
316 eqninx = 5;
317 nreseqn = 1; % Number of linear restrictions for the equation for each state.
318 if (indxEqnTv_m(eqninx, 2)<=2)
319 %**** For constant A0_s. In the order of [a0j(1),...,a0j(nStates)] for the 2nd dim of Qi.
320 Qi(1:(nStates-1)*nvar+nreseqn,:,eqninx) = [
321 1 0 0 0 0 0 -1 0 0 0 0 0
322 0 1 0 0 0 0 0 -1 0 0 0 0
323 0 0 1 0 0 0 0 0 -1 0 0 0
324 0 0 0 1 0 0 0 0 0 -1 0 0
325 0 0 0 0 1 0 0 0 0 0 -1 0
326 0 0 0 0 0 1 0 0 0 0 0 -1
327
328 0 0 0 0 0 0 0 0 0 0 0 1
329 ];
330 %**** For constant D+_s. In the order of [aj+(1),...,aj+(nStates)] for the 2nd dim of Ri.
331 for si=1:nStates-1
332 for ki=1:kvar
333 Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
334 end
335 end
336 else % Time-varying equations at least for A0_s. For D+_s, constant-parameter equations in general.
337 %**** For time-varying A0_s. In the order of [a0j(1),...,a0j(nStates)] for the 2nd dim of Qi.
338 Qi(1:nreseqn*nStates,:,eqninx) = [
339 0 0 0 0 0 1 0 0 0 0 0 0
340
341 0 0 0 0 0 0 0 0 0 0 0 1
342 ];
343 %**** For D+_s. In the order of [aj+(1),...,aj+(nStates)] for the 2nd dim of Ri.
344 if (indxEqnTv_m(eqninx, 2)==3) % For constant D+** except the constant term. In the order of [dj**(1),...,dj**(nStates)] for the 2nd dim of Ri.
345 for si=1:nStates-1
346 for ki=1:kvar-1 % -1: no restrictions on the constant term, which is freely time-varying.
347 Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
348 end
349 end
350 elseif (indxEqnTv_m(eqninx, 2)==4) % For constant D+**. In the order of [dj**(1),...,dj**(nStates)] for the 2nd dim of Ri.
351 for si=1:nStates-1
352 for ki=1:kvar
353 Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
354 end
355 end
356 else
357 error('.../ftd_2s_caseall_simszha5v.m: Have not got time to deal with the simple case indxEqnTv_m(eqninx, 2)=5.')
358 end
359 end
360
361
362 %======== The sixth equation ===========
363 eqninx = 6;
364 nreseqn = 0; % Number of linear restrictions for the equation for each state.
365 if (indxEqnTv_m(eqninx, 2)<=2)
366 %**** For constant A0_s. In the order of [a0j(1),...,a0j(nStates)] for the 2nd dim of Qi.
367 Qi(1:(nStates-1)*nvar+nreseqn,:,eqninx) = [
368 1 0 0 0 0 0 -1 0 0 0 0 0
369 0 1 0 0 0 0 0 -1 0 0 0 0
370 0 0 1 0 0 0 0 0 -1 0 0 0
371 0 0 0 1 0 0 0 0 0 -1 0 0
372 0 0 0 0 1 0 0 0 0 0 -1 0
373 0 0 0 0 0 1 0 0 0 0 0 -1
374 ];
375 %**** For constant D+_s. In the order of [aj+(1),...,aj+(nStates)] for the 2nd dim of Ri.
376 for si=1:nStates-1
377 for ki=1:kvar
378 Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
379 end
380 end
381 else % Time-varying equations at least for A0_s. For D+_s, constant-parameter equations in general.
382 %**** For D+_s. In the order of [aj+(1),...,aj+(nStates)] for the 2nd dim of Ri.
383 if (indxEqnTv_m(eqninx, 2)==3) % For constant D+** except the constant term. In the order of [dj**(1),...,dj**(nStates)] for the 2nd dim of Ri.
384 for si=1:nStates-1
385 for ki=1:kvar-1 % -1: no restrictions on the constant term, which is freely time-varying.
386 Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
387 end
388 end
389 elseif (indxEqnTv_m(eqninx, 2)==4) % For constant D+**. In the order of [dj**(1),...,dj**(nStates)] for the 2nd dim of Ri.
390 for si=1:nStates-1
391 for ki=1:kvar
392 Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
393 end
394 end
395 else
396 error('.../ftd_2s_caseall_simszha5v.m: Have not got time to deal with the simple case indxEqnTv_m(eqninx, 2)=5.')
397 end
398 end
399
400
401
402
403
404 %===== Lagged restrictions in foreign (Granger causing) block
405 %nfbres = lags*(nvar-nfvar); % number of block restrictions in each foreign equation
406 %bfor = zeros(nfbres,k); % each foreign equation
407 %cnt=0;
408 %for ki = 1:lags
409 % for kj=1:nvar-nfvar
410 % cnt=cnt+1;
411 % bfor(cnt,nvar*(ki-1)+nfvar+kj) = 1;
412 % end
413 %end
414 %%
415 %if cnt~=nfbres
416 % error('Check lagged restrictions in foreign equations!')
417 %end
418 %%
419 %for kj=1:nfvar
420 % Ri(1:nfbres,:,kj) = bfor;
421 %end
422
423
424 %===== Lagged restrictions in home (affected) block
425 %
426 %~~~~~ selected domestic equations
427 %dlrindx = nfvar+1; %[nfvar+1 nfvar+2]; % index for relevant home equations
428 %rfvindx = []; %[6]; %[1 2 3 5]; % index for restricted foreign variables (e.g., Poil, M2, FFR, P).
429 %%nf2hvar = nfvar-length(rfvindx); % number of free parameters -- foreign variables entering the home sector
430 %nhbres = lags*length(rfvindx); % number of block restrictions in each home equation
431 %bhom = zeros(nhbres,k); % each home equation
432 %cnt=0;
433 %for ki = 1:lags
434 % for kj=1:length(rfvindx)
435 % cnt=cnt+1;
436 % bhom(cnt,nvar*(ki-1)+rfvindx(kj)) = 1;
437 % end
438 %end
439 %%
440 %if cnt~=nhbres
441 % error('Check lagged restrictions in domestic equations!')
442 %end
443 %%
444 %for kj=dlrindx
445 % Ri(1:nhbres,:,kj) = bhom;
446 %end
447
448
449
450 for ki=1:nvar % initializing loop for each equation
451 Ui{ki} = null(Qi(:,:,ki));
452 Vi{ki} = null(Ri(:,:,ki));
453 n0(ki) = size(Ui{ki},2);
454 np(ki) = size(Vi{ki},2);
455 end