Debian Codegraph @

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

raw
1 function [Ui,Vi,n0,np,ixmC0Pres] = ftd_simszha5v(lags,nvar,nexo,indxC0Pres)
2 %vlist = [21 141 93 127 124]; % 1: Pcom 2 (exchange rate 21); 2: M3 141 (M2 140); 3: R; 4: GDP; 5: GDP deflator 124 (consumption deflator 79).
3 %varlist={'Ex', 'M3', 'R', 'y','P'};
4 %
5 % Exporting orthonormal matrices for the deterministic linear restrictions (equation by equation)
6 % See Waggoner and Zha's Gibbs sampling paper.
7 %
8 % q_m: quarter or month
9 % lags: the maximum length of lag
10 % nvar: number of endogeous variables
11 % nexo: number of exogenous variables. If nexo is not supplied, nexo=1 as default for a constant
12 % indxC0Pres: index for cross-A0-A+ restrictions. if 1: cross-A0-and-A+ restrictions; 0: idfile is all we have
13 % Example for indxOres==1: restrictions of the form P(t) = P(t-1).
14 % These restrictions have to be manually and carefully keyed in.
15 %-----------------
16 % Ui: nvar-by-1 cell. In each cell, nvar-by-qi orthonormal basis for the null of the ith
17 % equation contemporaneous restriction matrix where qi is the number of free parameters.
18 % With this transformation, we have ai = Ui*bi or Ui'*ai = bi where ai is a vector
19 % of total original parameters and bi is a vector of free parameters. When no
20 % restrictions are imposed, we have Ui = I. There must be at least one free
21 % parameter left for the ith equation.
22 % Vi: nvar-by-1 cell. In each cell, k-by-ri orthonormal basis for the null of the ith
23 % equation lagged restriction matrix where k is a total of exogenous variables and
24 % ri is the number of free parameters. With this transformation, we have fi = Vi*gi
25 % or Vi'*fi = gi where fi is a vector of total original parameters and gi is a
26 % vector of free parameters. There must be at least one free parameter left for
27 % the ith equation.
28 % n0: nvar-by-1, ith element represents the number of free A0 parameters in ith equation
29 % np: nvar-by-1, ith element represents the number of free A+ parameters in ith equation
30 % ixmC0Pres: neq_cres-by-1 cell. Effective only if indxC0Pres=1, otherwise equals NaN.
31 % neq_cres is the number of equations in which cross-A0-A+ restrictions occur.
32 % In the jth cell representing equation, we have 4 columns:
33 % 1st: the jth column (equation) of A+ or A0: f_j or a_j
34 % 2nd: the ith element f_j(i) -- the ith element in the jth column of A+
35 % 3rd: the hth element a_j(h) -- the hth element in the jth column of A0
36 % 4th: the number s such that f_j(i) = s * a_j(h) holds.
37 %
38 % Tao Zha, May 2000
39
40
41
42 Ui = cell(nvar,1); % initializing for contemporaneous endogenous variables
43 Vi = cell(nvar,1); % initializing for lagged and exogenous variables
44 n0 = zeros(nvar,1); % ith element represents the number of free A0 parameters in ith equation
45 np = zeros(nvar,1); % ith element represents the number of free A+ parameters in ith equation
46
47 if (nargin==2)
48 nexo = 1; % 1: constant as default where nexo must be a nonnegative integer
49 elseif (nargin==3)
50 indxC0Pres = 0; % default is no cross-A0-and-A+ restrictions.
51 end
52
53 k = lags*nvar+nexo; % maximum number of lagged and exogenous variables in each equation
54
55 Qi = zeros(nvar,nvar,nvar); % for nvar contemporaneous equations
56 Ri = zeros(k,k,nvar); % for nvar lagged and exogenous equations
57 % Row corresponds to equation. 0 means no restriction.
58 % 1 means exclusion restriction such that the corresponding parameter is restricted to 0.
59
60 %nfvar = 6; % number of foreign (Granger causing) variables
61 %nhvar = nvar-nfvar; % number of home (affected) variables.
62
63
64 %-------------------------------------------------------------
65 % Beginning the manual input of the restrictions one quation at a time
66 %-------------------------------------------------------------
67 %
68
69 %======== The first equation: information sector ===========
70
71
72 %======== The second equation: monetary policy ===========
73 %Qi(1:2,:,2) = [
74 % 0 0 0 1 0
75 % 0 0 0 0 1
76 % ]; % Respond to Pcom.
77 Qi(1:3,:,2) = [
78 1 0 0 0 0
79 0 0 0 1 0
80 0 0 0 0 1
81 ]; % Not respond to Pcom.
82
83 %======== The third equation: money demand ===========
84 Qi(1,:,3) = [
85 1 0 0 0 0
86 ];
87
88 %======== The fourth equation: y equation ===========
89 Qi(1:4,:,4) = [
90 1 0 0 0 0
91 0 1 0 0 0
92 0 0 1 0 0
93 0 0 0 0 1
94 ];
95
96 %======== The fifth equation: p equation ===========
97 Qi(1:3,:,5) = [
98 1 0 0 0 0
99 0 1 0 0 0
100 0 0 1 0 0
101 ];
102
103
104 %===== Lagged restrictions in foreign (Granger causing) block
105 %nfbres = lags*(nvar-nfvar); % number of block restrictions in each foreign equation
106 %bfor = zeros(nfbres,k); % each foreign equation
107 %cnt=0;
108 %for ki = 1:lags
109 % for kj=1:nvar-nfvar
110 % cnt=cnt+1;
111 % bfor(cnt,nvar*(ki-1)+nfvar+kj) = 1;
112 % end
113 %end
114 %%
115 %if cnt~=nfbres
116 % error('Check lagged restrictions in foreign equations!')
117 %end
118 %%
119 %for kj=1:nfvar
120 % Ri(1:nfbres,:,kj) = bfor;
121 %end
122
123
124 %===== Lagged restrictions in home (affected) block
125 %
126 %~~~~~ selected domestic equations
127 %dlrindx = nfvar+1; %[nfvar+1 nfvar+2]; % index for relevant home equations
128 %rfvindx = []; %[6]; %[1 2 3 5]; % index for restricted foreign variables (e.g., Poil, M2, FFR, P).
129 %%nf2hvar = nfvar-length(rfvindx); % number of free parameters -- foreign variables entering the home sector
130 %nhbres = lags*length(rfvindx); % number of block restrictions in each home equation
131 %bhom = zeros(nhbres,k); % each home equation
132 %cnt=0;
133 %for ki = 1:lags
134 % for kj=1:length(rfvindx)
135 % cnt=cnt+1;
136 % bhom(cnt,nvar*(ki-1)+rfvindx(kj)) = 1;
137 % end
138 %end
139 %%
140 %if cnt~=nhbres
141 % error('Check lagged restrictions in domestic equations!')
142 %end
143 %%
144 %for kj=dlrindx
145 % Ri(1:nhbres,:,kj) = bhom;
146 %end
147
148
149 for n=1:nvar % initializing loop for each equation
150 Ui{n} = null(Qi(:,:,n));
151 Vi{n} = null(Ri(:,:,n));
152 n0(n) = size(Ui{n},2);
153 np(n) = size(Vi{n},2);
154 end
155
156
157
158 %(2)-------------------------------------------------------------
159 % Cross-A0-and-A+ rerestrictions one quation at a time
160 % i.e., the first, second, ..., kjth, ..., equation
161 %(2)-------------------------------------------------------------
162 %
163 if indxC0Pres
164 neq_cres = 3; % the number of equations in which cross-A0-A+ restrictions occur.
165 ixmC0Pres = cell(neq_cres,1); % in each cell representing equation, we have 4 columns:
166 % 1st: the jth column (equation) of A+ or A0: f_j or a_j
167 % 2nd: the ith element f_j(i) -- the ith element in the jth column of A+
168 % 3rd: the hth element a_j(h) -- the hth element in the jth column of A0
169 % 4th: the number s such that f_j(i) = s * a_j(h) holds.
170 %** 1st equation
171 ixmC0Pres{1} = [1 2 2 1
172 1 7 1 1];
173 %** 2nd equation
174 ixmC0Pres{2} = [2 2 2 2];
175 %** 3rd equation
176 ixmC0Pres{3} = [3 7 1 1
177 3 2 2 1];
178
179
180 % % 4 columns.
181 % ncres = 5; % manually key in the number of cross-A0-A+ restrictions
182
183 % % 1st: the jth column (equation) of A+ or A0: f_j or a_j
184 % % 2nd: the ith element f_j(i) -- the ith element in the jth column of A+
185 % % 3rd: the hth element a_j(h) -- the hth element in the jth column of A0
186 % % 4th: the number s such that f_j(i) = s * a_j(h) holds.
187 else
188 ixmC0Pres = NaN;
189 end
190