Repository navigation
Expand file tree
/
Copy pathXPanelCrossSections.m
More file actions
114 lines (75 loc) · 2.27 KB
/
Copy pathXPanelCrossSections.m
File metadata and controls
114 lines (75 loc) · 2.27 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
%% Panel models
clear
close all
clear classes
rehash path
import cross.*
%% Prepare data and a reduced-form model
inputTbx = tablex.fromCsv("panel_data.csv");
estimStart = datex("1972-Q1");
estimEnd = datex("2014-Q4");
estimSpan = datex.span(estimStart, estimEnd);
meta = Meta( ...
endogenous=["YER", "HICSA", "STN"], ...
units=["US", "EA", "UK"], ...
exogenous=["Oil"], ...
order=4, ...
intercept=true, ...
estimationSpan=estimSpan, ...
...
identificationHorizon=20, ...
shockConcepts=["DEM", "SUP", "POL"] ...
);
dataH = DataHolder(meta, inputTbx);
numSamples = 100;
rng(0);
%% Cross-sectional static model
estimatorR5 = estimator.StaticCrossPanel(meta);
estimatorR5.Settings
modelR5 = ReducedForm(meta=meta, dataHolder=dataH, estimator=estimatorR5);
rng(0);
modelR5.initialize();
info5 = modelR5.presample(numSamples);
% disp('Beta Median Static Cross Panel Model:')
% betaMedian5 = calcMedian(modelR5,"beta")
%% Cross-sectional Dynamic model
% This one is the most complicated and takes a lot of time to sample. Not going
% to run it here now. It is already
estimatorR6 = estimator.DynamicCrossPanel(meta);
estimatorR6.Settings
modelR6 = ReducedForm( ...
meta=meta ...
, dataHolder=dataH ...
, estimator=estimatorR6 ...
);
rng(0);
modelR6.initialize();
info6 = modelR6.presample(10);
%% Indentify a SVAR using Cholesky (without reordering)
identChol = identifier.Cholesky(ordering=[]);
modelS5 = Structural(reducedForm=modelR5, identifier=identChol);
modelS5.initialize();
info5 = modelS5.presample(numSamples);
modelS5.Presampled{1}
modelS5.Presampled{1}.IdentificationDraw
modelS5.Presampled{1}.IdentificationDraw.A{1,1}
modelS5.Presampled{1}.IdentificationDraw.A{2,1}
modelS6 = Structural(reducedForm=modelR6, identifier=identChol);
modelS6.initialize();
info6 = modelS6.presample(10);
%% Impulse responses
% Static model
prctileFunc = @(x) prctile(x, [10, 50, 90], 2);
resp5 = modelS5.simulateResponses();
respPct5 = tablex.apply(resp5, prctileFunc);
respPct5 = tablex.flatten(respPct5);
resp5
respPct5
%% Plot results
close all
figure();
tablex.plot(respPct5, "US_YER___US_DEM");
title("US_YER___US_DEM", interpreter="none");
figure();
tablex.plot(respPct5, "EA_YER___US_DEM");
title("EA_YER___US_DEM", interpreter="none");