File size: 2,952 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 |
close all
t = 242;
EVh = griddedInterpolant({p.agrid, (1: 1:p.no*p.nt*p.nh*p.nz)'}, reshape(vbarh(:, t + 1), p.na, p.no*p.nt*p.nh*p.nz), intmeth, 'linear');
Whinterp = griddedInterpolant({p.lgrid, (1: 1: p.no*p.nt*p.nh*p.nz)'}, reshape(wh(:, t), p.nl, p.no*p.nt*p.nh*p.nz), intmeth, 'linear');
Wrinterp = griddedInterpolant({p.lgrid, (1: 1: p.nz)'}, reshape(wr(:, t), p.nl, p.nz), intmeth, 'linear');
N = 100;
oind = p.no; onow = oind*ones(N, 1);
tind = 5; tnow = tind*ones(N, 1);
hind = 5; hnow = hind*ones(N, 1);
zind = 7; znow = zind*ones(N, 1);
ind2 = sub2ind([p.no, p.nt, p.nh, p.nz], onow, tnow, hnow, znow);
state = gridmake(nodeunif(N, 0, 2), p.ogrid(oind), p.tgrid(tind), p.hgrid(hind), p.zgrid(zind));
cmin = bisect('savings', 1e-13, 1e5, state(:,1), p, 'h', amax);
cmax = bisect('savings', 1e-13, 1e5, state(:,1), p, 'h', amin);
C = solve_golden('wfunc', cmin, cmax, state, ind2, EVh, p, 'h');
[~, Aprime] = savings(C, state, p, 'h');
figure(1)
subplot(1, 2, 1)
plot(state(:, 1), C);
title('consumption', 'Interpreter', 'Latex');
xlabel('$l$', 'Interpreter', 'Latex');
set(gca, 'ygrid', 'on')
subplot(1, 2, 2)
plot(state(:, 1), Aprime);
title('$a^{\prime}$', 'Interpreter', 'Latex');
xlabel('$l$', 'Interpreter', 'Latex');
set(gca, 'ygrid', 'on')
% Housing Choice
eind = 2;
state = gridmake(nodeunif(N, 8, 15), p.ogrid(oind), p.tgrid(tind), p.hgrid(hind), p.zgrid(zind), p.egrid(eind));
Y = p.lambdat(t)*p.zgrid(zind)*p.egrid(eind);
A = state(:,1);
[Lall, omegaall, thetaall, hall, v, pall, vall] = solveh(state, Whinterp, Wrinterp, p, p.thetay(t), 'h', A, Y, znow, hnow, tnow);
figure(2)
subplot(2, 3, 1)
plot(A, pall);
title('prob. each choice', 'Interpreter', 'Latex')
xlabel('$a$', 'Interpreter', 'Latex');
set(gca, 'ygrid', 'on')
h = legend('1', '2', '3', '4', '5');
subplot(2, 3, 2)
plot(A, Lall);
title('liquidity','Interpreter', 'Latex')
xlabel('$a$', 'Interpreter', 'Latex');
set(gca, 'ygrid', 'on')
h = legend('1', '2', '3', '4', '5');
subplot(2, 3, 3)
plot(A, omegaall);
title('$\omega^{\prime}$','Interpreter', 'Latex')
xlabel('$a$', 'Interpreter', 'Latex');
set(gca, 'ygrid', 'on')
h = legend('1', '2', '3', '4', '5');
subplot(2, 3, 4)
plot(A, thetaall);
title('$\bar{\theta}^{\prime}$','Interpreter', 'Latex')
xlabel('$a$', 'Interpreter', 'Latex');
set(gca, 'ygrid', 'on')
h = legend('1', '2', '3', '4', '5');
subplot(2, 3, 5)
plot(A, hall);
title('$h^{\prime}$','Interpreter', 'Latex')
xlabel('$a$', 'Interpreter', 'Latex');
set(gca, 'ygrid', 'on')
h = legend('1', '2', '3', '4', '5');
subplot(2, 3, 6)
plot(A, vall);
title('value','Interpreter', 'Latex')
xlabel('$a$', 'Interpreter', 'Latex');
set(gca, 'ygrid', 'on')
h = legend('1', '2', '3', '4', '5');
|