-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmake_indo_model_restrictions.m
150 lines (119 loc) · 3.52 KB
/
make_indo_model_restrictions.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
% Linear restrictions
i_r_L = find( strcmpi( 'LENDRATE', options.names ) );
i_r_D = find( strcmpi( 'DEP3M', options.names ) );
i_Q_L = find( strcmpi( 'LPRIVCRED', options.names ) );
M = numel(options.names);
P = options.nlags;
N = numel( options.exo_names );
if 0 < N
K = M*P + N + N*(options.exo_lags(2) - options.exo_lags(1)) + options.constant;
else
K = M*P + options.constant;
end
% Think of the rows of Q, R representing individual restrictions. The
% columns represent the variables. We initialize everything to be
% unrestricted in the first instance.
%% A matrix
% ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
% Equation: cost of debt
i_rst = 0;
Q( :, :, i_r_D ) = zeros( M, M );
% i_r_L = 0
i_rst = i_rst+1;
Q( i_rst, i_r_L, i_r_D ) = 1;
% i_Q_L = 0
i_rst = i_rst+1;
Q( i_rst, i_Q_L, i_r_D ) = 1;
% ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
% Equation: markup
i_rst = 0;
Q( :, :, i_r_L ) = zeros( M, M );
% i_Q_L = 0
i_rst = i_rst+1;
Q( i_rst, i_Q_L, i_r_L ) = 1;
% i_r_D + i_r_L = 0
% i_rst = i_rst+1;
% Q( i_rst, i_r_L, i_r_L ) = 1;
% Q( i_rst, i_r_D, i_r_L ) = 1;
% ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
% Equation: quantity of loans
i_rst = 0;
Q( :, :, i_Q_L ) = zeros( M, M );
% r_D = 0
i_rst = i_rst+1;
Q( i_rst, i_r_D, i_Q_L ) = 1;
% Store the Q matrix in the options structure
options.restrictions.linear_restrictions.Q = Q;
%% F matrix
i_CAR = M*P + find( strcmpi( 'CAR_WTSUM', options.exo_names ) );
i_CARMIN = M*P + find( strcmpi( 'CAR_MIN_WTSUM', options.exo_names ) );
i_NPL = M*P + find( strcmpi( 'NPLR', options.exo_names ) );
i_RFR = M*P + find( strcmpi( 'POLRT', options.exo_names ) );
i_GDP = M*P + find( strcmpi( 'LRGDP', options.exo_names ) );
i_PRICE = M*P + find( strcmpi( 'LPRICES', options.exo_names ) );
% ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
% Equation: cost of debt
i_rst = 0;
R( :, :, i_r_D ) = zeros( K, K );
% Q_L = 0 and i_L = 0 at all lags
for lag = 1:P
i_rst = i_rst+1;
R( i_rst, i_Q_L+(lag-1)*M, i_r_D ) = 1;
i_rst = i_rst+1;
R( i_rst, i_r_L+(lag-1)*M, i_r_D ) = 1;
end
% CAR + CARMIN = 0
i_rst = i_rst+1;
R( i_rst, i_CAR, i_r_D ) = 1;
R( i_rst, i_CARMIN, i_r_D ) = 1;
% GDP = 0
i_rst = i_rst+1;
R( i_rst, i_GDP, i_r_D ) = 1;
% PRICE = 0
i_rst = i_rst+1;
R( i_rst, i_PRICE, i_r_D ) = 1;
% ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
% Equation: markup
i_rst = 0;
R( :, :, i_r_L ) = zeros( K, K );
% Q_L = 0 amd r_L + r_D = 0 at all lags
for lag = 1:P
i_rst = i_rst+1;
R( i_rst, i_Q_L+(lag-1)*M, i_r_L ) = 1;
% i_rst = i_rst+1;
% R( i_rst, i_r_L+(lag-1)*M, i_r_L ) = 1;
% R( i_rst, i_r_D+(lag-1)*M, i_r_L ) = 1;
end
% CAR + CARMIN = 0
i_rst = i_rst+1;
R( i_rst, i_CAR, i_r_L ) = 1;
R( i_rst, i_CARMIN, i_r_L ) = 1;
% GDP = 0
i_rst = i_rst+1;
R( i_rst, i_GDP, i_r_L ) = 1;
% PRICE = 0
i_rst = i_rst+1;
R( i_rst, i_PRICE, i_r_L ) = 1;
% ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
% Equation: quantity of loans
i_rst = 0;
R( :, :, i_Q_L ) = zeros( K, K );
% r_D = 0 at all lags
for lag = 1:P
i_rst = i_rst+1;
R( i_rst, i_r_D+(lag-1)*M, i_Q_L ) = 1;
end
% CAR = 0
i_rst = i_rst+1;
R( i_rst, i_CAR, i_Q_L ) = 1;
% CARMIN = 0
i_rst = i_rst+1;
R( i_rst, i_CARMIN, i_Q_L ) = 1;
% RFR = 0
i_rst = i_rst+1;
R( i_rst, i_RFR, i_Q_L ) = 1;
% NPLR = 0
i_rst = i_rst+1;
R( i_rst, i_NPL, i_Q_L ) = 1;
% Store the R matrix in the options structure
options.restrictions.linear_restrictions.R = R;