-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathrun01_createModel.m
More file actions
140 lines (107 loc) · 3.21 KB
/
Copy pathrun01_createModel.m
File metadata and controls
140 lines (107 loc) · 3.21 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
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
%% Create and solve model object
%
% Create a model object from the model file <Simple_SPBC.model>, assign
% parameters to the model object, calculate its steady state, and compute
% first-order solution matrices.
%
%% Clear the workspace
%
% Clear all variables, close all figure windows.
%
close all
clear
if ~exist("mat", "dir")
mkdir mat
end
%% Read the model file and create a model object
%
% The function `Model()` reads the model file <Simple_SPBC.model>, and
% translates it into a model object, called here `m`. Model objects are
% complex structures that carry all the necessary information about the
% model, and can be manipulated by calling various IRIS functions.
%
m = Model.fromFile( ...
"model-source/spbc.model" ...
, "growth", true ...
, "savePreparsed", "model-source/spbc.preparsed.model" ...
);
disp(m)
%% Calibrate model parameters
%
% Assign parameters using the dot syntax, e.g. `m.gamma = 0.60` where
% `gamma` is the name of a parameter, and `0.60` is the value to be
% assigned. Use the function `access()` to retrieve a databank with the
% currently assigned values of parameters and std deviations; the
% parameters that have been assigned no value are `NaN`.
%
m.alpha = 1.025^(1/4);
m.beta = 0.985^(1/4);
m.beta0 = 0;
m.beta1 = 0.8;
m.gamma = 0.60;
m.delta = 0.03;
m.pi = 1.02^(1/4);
m.eta = 6;
m.k = 10;
m.psi = 0.25;
m.chi = 0.85;
m.xiw = 60;
m.xip = 300;
m.rhoa = 0.90;
m.rhoterm20 = 0.80;
m.rhor = 0.85;
m.kappap = 4;3.5;
m.kappan = 0;
m.Short_ = 0;
m.Long_ = 0;
m.Infl_ = 0;
m.Growth_ = 0;
m.Wage_ = 0;
m.std_Mp = 0;
m.std_Mw = 0;
m.std_Ea = 0.001;
access(m, "parameter-values")
access(m, "std-values")
%% Find steady state
%
% Run `steady()` to calculate the steady-state values for all model
% variables. The option `growth=true` used in the model constructor means
% this is a non-stationary BGP model where variables can grow at a constant
% rate over time; the steady-state solution algorithm is modified to handle
% models with growth. Use `checkSteady()` to numerically verify the steady
% state values on dynamic equations; if there is a significant numerical
% discrepancy, the function will throw an error.
%
m.RR = 1.01^(1/4);
m = steady(m, "exogenize", "RR", "endogenize", "beta0", "saveAs", "model-source/spbc.blazer.md");
checkSteady(m);
m1 = m;
m1.A = 2;
m1.P = 1;
m1 = steady(m1, "fixLevel", ["A", "P"]);
checkSteady(m1);
access(m, 'steady')
table( ...
[m, m1], ["steadyLevel", "steadyChange", "form", "description"] ...
, "writeTable", "steady.xlsx" ...
)
%% Calculate first-order solution matrices
%
% Run `solve()` to calculate a first-order expansion of the model
% equations around the steady state, and finds a first-order
% rational-expectations solution. The solution matrices (state-space
% matrices) are stored within the model object; they are examined in
% <know_all_about_solution>. The availability of a first-order solution is
% indicated the model object is displayed.
%
m = solve(m);
disp(m)
%% Extract first-order solution matrices
st = solutionMatrices(m);
sr = solutionMatrices(m, "triangular", false);
%% Save the model object
%
% Save the solved model object to a mat file (internal Matlab binary file)
% for future use.
%
save mat/createModel.mat m