File size: 3,964 Bytes
2a8276b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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

close all

% Inaction Region

figure(1)

[~, pall]           = solveh(sv, Winterp, p);

data = [sv, pall(:,1)]; 
data = data(data(:,1) <= 3, :); 
n1   = numel(unique(data(:,1)));
n2   = numel(unique(data(:,2)));

surf(reshape(data(:,1), n1, n2), reshape(data(:,2), n1, n2), reshape(data(:,3), n1, n2)); colorbar 

xlabel('$w$', 'Interpreter', 'Latex');
ylabel('$\theta$', 'Interpreter', 'Latex');
title('probability refinance', 'Interpreter', 'Latex');
xlim([0, 3])


state = gridmake(nodeunif(100, 0.5, 4.5), 0.50); 

[v, pall, vall, Lall, thetaall] = solveh(state, Winterp, p);

call         = zeros(size(pall)); 
aprimeall    = zeros(size(pall)); 

for i = 1 : 2

cmax         = bisect('savings', 1e-13, 1e5, Lall(:, i), p, amin);     % c that implies a' = amin
cmin         = bisect('savings', 1e-13, 1e5, Lall(:, i), p, amax);     % c that implies a' = amax

call(:,i)    = solve_golden('wfunc', cmin, cmax, [Lall(:,i), thetaall(:,i)], EV, p);

[~, aprimeall(:,i)]  = savings(call(:,i), [Lall(:,i), thetaall(:,i)], p);

end

%{
figure(2)

subplot(2, 3, 1)
plot(state(:,1), pall(:,1));
set(gca, 'ygrid', 'on')
xlabel('$w$', 'Interpreter', 'Latex');
title('probability refinance', 'Interpreter', 'Latex');

subplot(2, 3, 2)
plot(state(:,1), Lall);
set(gca, 'ygrid', 'on')
xlabel('$w$', 'Interpreter', 'Latex');
title('$l$', 'Interpreter', 'Latex');
legend('refinance', 'dont refinance')

subplot(2, 3, 3)
plot(state(:,1), thetaall);
set(gca, 'ygrid', 'on')
xlabel('$w$', 'Interpreter', 'Latex');
title('$\theta^{\prime}$', 'Interpreter', 'Latex');

subplot(2, 3, 4)
plot(state(:,1), call);
set(gca, 'ygrid', 'on')
xlabel('$w$', 'Interpreter', 'Latex');
title('$c$', 'Interpreter', 'Latex');

subplot(2, 3, 5)
plot(state(:,1), aprimeall);
set(gca, 'ygrid', 'on')
xlabel('$w$', 'Interpreter', 'Latex');
title('$a^{\prime}$', 'Interpreter', 'Latex');


subplot(2, 3, 6)
plot(state(:,1), [vall, v]);
set(gca, 'ygrid', 'on')
xlabel('$w$', 'Interpreter', 'Latex');
title('values', 'Interpreter', 'Latex');
legend('refinance', 'dont refinance', 'envelope')
%}

figure(1)

subplot(2, 2, 1)
plot(state(:,1), [vall(:,1) - vall(:,2)]);
set(gca, 'ygrid', 'on')
xlabel('cash on hand', 'Interpreter', 'Latex');
title('$V^{R} - V^{N}$', 'Interpreter', 'Latex');

subplot(2, 2, 2)
plot(state(:,1), [call]);
set(gca, 'ygrid', 'on')
xlabel('cash on hand', 'Interpreter', 'Latex');
title('$c$', 'Interpreter', 'Latex');
legend('refinance', 'do not refinance')

subplot(2, 2, 3)
plot(state(:,1), [aprimeall]);
set(gca, 'ygrid', 'on')
xlabel('cash on hand', 'Interpreter', 'Latex');
title('$a^{\prime}$', 'Interpreter', 'Latex');

subplot(2, 2, 4)
plot(state(:,1), pall(:,1));
set(gca, 'ygrid', 'on')
xlabel('cash on hand', 'Interpreter', 'Latex');
title('probability of refinancing', 'Interpreter', 'Latex');

%{
figure(3)

state = gridmake(nodeunif(100, lmin, 3), 0.5); 

cmax  = bisect('savings', 1e-13, 1e5, state(:,1), p, amin);     % c that implies a' = amin
cmin  = bisect('savings', 1e-13, 1e5, state(:,1), p, amax);     % c that implies a' = amax

c     = solve_golden('wfunc', cmin, cmax, state, EV, p);

[~, aprime]  = savings(c, state, p);


subplot(1, 2, 1)
plot(state(:,1), c);
set(gca, 'ygrid', 'on')
xlabel('$l$', 'Interpreter', 'Latex');
title('$c$', 'Interpreter', 'Latex');

subplot(1, 2, 2)
plot(state(:,1), aprime);
set(gca, 'ygrid', 'on')
xlabel('$w$', 'Interpreter', 'Latex');
title('$a^{\prime}$', 'Interpreter', 'Latex');
%}

figure(2)

gain       = nodeunif(1000, -5000, 20000); 

factor     = 36500; % scaling factor to convert units in the model into u'(c) times 12896 in the data

plot(gain, [(1 - exp(-3*max(gain/factor, 0))).*(gain >=0), ...
            (1 - exp(-10*max(gain/factor, 0))).*(gain >=0), ...
            (1 - exp(-10000*max(gain/factor, 0))).*(gain >=0)]) 

title('probability of refinancing', 'Interpreter', 'Latex');
xlabel('welfare gains from refinancing', 'Interpreter', 'Latex');
legend('$\nu = 1/3$', '$\nu = 1/10$', '$\nu = 0$');