-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathrun09_nonlinearSimulation.m
More file actions
88 lines (64 loc) · 2.05 KB
/
Copy pathrun09_nonlinearSimulation.m
File metadata and controls
88 lines (64 loc) · 2.05 KB
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
%% Nonlinear simulations
%
% Illustrate the use of nonlinear simulation methods. By default, IrisT
% uses a first-order approximate solution to run the `simulate()` function.
% There are two nonlinear simulation methods available:
%
% * a stacked-time method (solving the model as a large system of nonlinear
% equations stacked in time) with a first-order terminal condition;
%
% * a period-by-period method meant for special use cases where a total
% control about forward-looking expectations is needed.
%
%% Clear workspace
close all
clear
%#ok<*VUNUS>
load mat/createModel.mat m
%% Prepare input databank with unanticipated demand and supply shocks
startDate = 1;
endDate = startDate + 19;
d = steadydb(m, startDate:endDate);
d.Ey(1:2) = -0.05;
d.Ep(1:3) = -0.05;
%% Run first-order simulation
s1 = simulate( ...
m, d, startDate:endDate ...
, "plan", false ...
);
%% Run nonlinear stacked-time simulation with first-order terminal condition
s2 = simulate( ...
m, d, startDate:endDate ...
, "method", "stacked" ...
, "plan", false ...
, "prependInput", true ...
);
%% Run nonlinear period-by-period simulations with fixed-data terminal condition
s3 = simulate( ...
m, d, startDate:endDate ...
, "method", "period" ...
, "terminal", "data" ...
, "plan", false ...
, "blocks", false ...
, "prependInput", true ...
);
%% Compare results
ch = databank.Chartpack();
ch.Range = startDate-1 : startDate+19;
ch.Transform = @(x) 100*(x-1);
ch.Round = 8;
add(ch, "Inflation, Q/Q PA // Pp Deviations: dP^4 ");
add(ch, "Policy rate, PA // Pp Deviations: R^4 ");
add(ch, "Output // Pct Level Deviations: Y ");
add(ch, "Hours Worked // Pct Level Deviations: N ");
add(ch, "Real Wage // Pct Level Deviations: W/P ");
add(ch, "Capital Price // Pct Level Deviations: Pk");
tempDb = databank.merge("horzcat", s1, s2, s3);
tempDb = databank.minusControl(m, tempDb);
draw(ch, tempDb);
visual.hlegend( ...
"bottom" ...
, "First order" ...
, "Nonlinear stacked time" ...
, "Period by period with fixed expectations" ...
);