generated from MCHatcher/RE_solutions_structural_change_OLD
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Cho_and_Moreno.m
67 lines (48 loc) · 2.09 KB
/
Cho_and_Moreno.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
% Based on Cho and Moreno (2011, Journal of Econ Dynamics and Control)
% Recursive algorithm for computing the unique fixed-structure fundamental
% rational expectations solution that satisfies the no-bubbles condition
% Written by Michael Hatcher ([email protected]). Any errors are my own.
%Cho and Moreno (2011) method for computing fixed structure solutions
J = 10000; %no. iterations
%% Warning: DO NOT AMEND. Structures are specified in the main files.
if abs(det(B1)) > 0 && abs(det(B1_tild)) > 0
A = B1 \ B2; B = B1 \ B3; C = B1 \ B4; D = B1 \ B5;
A_tild = B1_tild \ B2_tild; B_tild = B1_tild \ B3_tild;
C_tild = B1_tild \ B4_tild; D_tild = B1_tild \ B5_tild;
%Note R = 0_{m \times m} as shocks in e(t) are white noise. Persistent shocks can be included in x(t).
%See Kulish and Pagan (2017, Journal of Applied Econometrics)
%Taken from main file
I = eye(length(B1));
%Initial values (run main file with structure)
AT = A; BT = B; CT = C; DT = D;
AT_tild = A_tild; BT_tild = B_tild; CT_tild = C_tild; DT_tild = D_tild;
for i=1:J
decomp = decomposition(I - A*BT);
if isIllConditioned(decomp)==1
break
end
AT = (I - A*BT) \ A*AT;
CT = (I - A*BT) \ C; %Since R = 0_{ m \times m}
DT = (I - A*BT) \ (D + A*DT);
BT = (I - A*BT) \ B;
end
for i = 1:J
decomp = decomposition(I - A_tild*BT_tild);
if isIllConditioned(decomp)==1
break
end
AT_tild = (I - A_tild*BT_tild) \ A_tild*AT_tild;
CT_tild = (I - A_tild*BT_tild) \ C_tild; %Since R = 0_{ m \times m}
DT_tild = (I - A_tild*BT_tild) \ (D_tild + A_tild*DT_tild);
BT_tild = (I - A_tild*BT_tild) \ B_tild;
end
%Check no-bubbles condition
Check1 = AT, Check2 = AT_tild
%Solution matrices
Omega_bar = BT; Gama_bar = CT; Psi_bar = DT;
Omega_tild = BT_tild; Gama_tild = CT_tild; Psi_tild = DT_tild;
end
if abs(det(B1)) == 0 || abs(det(B1_tild)) == 0
disp('Matrix B1 and/or B1_tild non-invertible')
run Cho_Moreno_alternative
end