-
Notifications
You must be signed in to change notification settings - Fork 9
/
dynamics.m
82 lines (58 loc) · 2.85 KB
/
dynamics.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
% Shell which declares parameters and calls Dynare to solve model using
% first order approximation of aggregate dynamics
%
% Thomas Winberry, July 26th, 2016
clear all
close all
clc
cd('./Auxiliary Functions');
%----------------------------------------------------------------
% Set parameters
%----------------------------------------------------------------
setParameters;
%----------------------------------------------------------------
% Compute approximation tools
%----------------------------------------------------------------
% Grids
computeGrids;
% Polynomials over grids (only if using polynomials to approximate conditional expectation)
if splineOpt == 0
computePolynomials;
end
%----------------------------------------------------------------
% Save parameters in .mat files to import into Dynare
%----------------------------------------------------------------
if splineOpt == 0 % if using polynomials to approximate individual decisions
% Economic parameters
save economicParameters.mat bbeta ssigma aaBar aalpha ddelta vEpsilonGrid aggEmployment ...
mmu ttau rrhoTFP ssigmaTFP mEpsilonTransition
% Approximation parameters
save approximationParameters.mat nEpsilon nAssets nState assetsMin assetsMax nAssetsFine nStateFine nAssetsQuadrature nStateQuadrature ...
nMeasure nMeasureCoefficients kRepSS maxIterations tolerance dampening
% Grids
save grids.mat vAssetsGridZeros vAssetsGrid mEpsilonGrid mAssetsGrid mEpsilonPrimeGrid vAssetsGridFine ...
vAssetsGridFineZeros mEpsilonGridFine mAssetsGridFine mEpsilonPrimeGridFine vQuadratureWeights ...
vAssetsGridQuadratureZeros vAssetsGridQuadrature mEpsilonGridQuadrature mAssetsGridQuadrature
% Polynomials
save polynomials.mat vAssetsPoly vAssetsPolySquared vAssetsPolyFine vAssetsPolyQuadrature vAssetsPolyBC
else % if using splines to approximate individual decisions
% Economic parameters
save economicParameters.mat bbeta ssigma aaBar aalpha ddelta vEpsilonGrid aggEmployment ...
mmu ttau rrhoTFP ssigmaTFP mEpsilonTransition
% Approximation parameters
save approximationParameters.mat nEpsilon nAssets nState assetsMin assetsMax nAssetsFine nStateFine nAssetsQuadrature nStateQuadrature ...
nMeasure nMeasureCoefficients kRepSS maxIterations tolerance dampening
% Grids
save grids.mat vAssetsGrid mEpsilonGrid mAssetsGrid mEpsilonPrimeGrid vAssetsGridFine ...
mEpsilonGridFine mAssetsGridFine mEpsilonPrimeGridFine vQuadratureWeights ...
vAssetsGridQuadrature mEpsilonGridQuadrature mAssetsGridQuadrature
end
%----------------------------------------------------------------
% Run Dynare
%----------------------------------------------------------------
if splineOpt == 0 % if using polynomials to approximate individual decisions
dynare firstOrderDynamics_polynomials
else % if using splines to approximate individual decisions
dynare firstOrderDynamics_splines
end
cd('../')