-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathget_varma_sw.m
103 lines (68 loc) · 2.86 KB
/
get_varma_sw.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
%% GET POPULATION VARMA(p,infty) AS DGP
% this version: 05/21/2024
%% SETTINGS
%----------------------------------------------------------------
% Lag Lengths
%----------------------------------------------------------------
settings.ps = [1 2 4 8];
settings.n_p = length(settings.ps);
dgps = cell(settings.n_p,1);
%----------------------------------------------------------------
% Computational Settings
%----------------------------------------------------------------
settings.VMA_hor = 500; % maximal horizon for VMA representation
settings.VAR_poplaglength = 250; % lag length in population VAR
settings.alpha_lags = 100;
%----------------------------------------------------------------
% DGP Settings
%----------------------------------------------------------------
settings.resp_ind = resp_ind; % response variable of interest
settings.innov_ind = innov_ind; % innovation variable of interest
% Other
settings.max_hor_h = 10; % maximal IRF horizon of interest
settings.max_hor_alpha_l = settings.VMA_hor; % maximal lag length for worst-case \alpha(L)
settings.T = 240; % sample size for DGP
settings.zeta = 1/2; % mis-specification scaling
%% GET DGPs
for i_p = 1:settings.n_p
settings.VAR_estimlaglength = settings.ps(i_p); % number of lags in mis-specified VAR
%----------------------------------------------------------------
% SW Model
%----------------------------------------------------------------
% run model
dynare SW_Model noclearall
clean_folder_SW
SW_model.decision = decision(2:end,:);
% ABCD representation
SW_model.obs = SW_model_obs;
SW_model.n_y = size(SW_model.obs,2);
SW_model.n_eps = M_.exo_nbr;
SW_model.n_s = M_.nspred;
SW_model.ABCD = ABCD_fun_SW(SW_model);
% clean-up
clean_workspace_SW
model = SW_model;
clear SW_model
%----------------------------------------------------------------
% VARMA(p,\infty)
%----------------------------------------------------------------
% VAR(infty)
VAR_infty = popVAR(model,settings);
y_aux = get2ndmoments_VAR(VAR_infty,model,settings);
% VAR(p)
VAR_p = popVARp(model,settings,y_aux);
% Residual VMA(infty)
[VMA,VARMA] = getresidVMA(VAR_infty,VAR_p,model,settings);
%----------------------------------------------------------------
% Simulation DGP
%----------------------------------------------------------------
dgps{i_p} = dgp_fn(VAR_p,VMA,model,settings);
clear model VAR_infty VAR_p VARMA VMA y_aux
end
clear i_p
dgp_inputs = dgps;
dgp_settings = settings;
clear settings dgps
results_filename = ['varma_sw_dgps_' scheme];
save(strcat(results_filename, '.mat'), 'dgp_inputs', 'dgp_settings');
delete polfunction.mat