forked from binhpham79/DYIndex
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExample_MATLAB.m
More file actions
54 lines (36 loc) · 1.49 KB
/
Copy pathExample_MATLAB.m
File metadata and controls
54 lines (36 loc) · 1.49 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
% Example 1
load data_JDanish;
% create new varm object
K = 4;
p = 2;
estMdl = varm(K, p);
estMdl.SeriesNames = DataTable.Properties.VariableNames;
estMdl = estimate(estMdl, DataTable.Series);
%% IRF
% compute othogonalized IRF using MATLAB function
estIRF = irf(estMdl, 'Method', 'orthogonalized', 'NumObs', 100);
% Or use computeIRF function
IRF = computeIRF(estMdl, 100, [], true);
% compute generalized IRF using MATLAB function
estGIRF = irf(estMdl, 'Method', 'generalized', 'NumObs', 100);
% Or use computeGIRF function
gIRF = computeGIRF(estMdl, 100, [], true);
% In MATLAB IRF and FEVD return a matrix of (horz, impulse, response)
% so that IRF(:,2,3) refers to responses of var 3 w.r.t impulse on var 2.
% plot Orthogonalized IRF
armairf(estMdl.AR,[], 'InnovCov', estMdl.Covariance, 'NumObs', 100);
% plot Generalized IRF
armairf(estMdl.AR,[], 'InnovCov', estMdl.Covariance, 'Method', 'generalized', 'NumObs', 100);
%% FEVD
%
% compute orthogonalized FEVD
oFEVD = fevd(estMdl, 'Method', 'orthogonalized', 'NumObs', 30);
% plot FEVD from MATLAB
armafevd(estMdl.AR,[], "InnovCov", estMdl.Covariance, 'Method', 'orthogonalized', 'NumObs', 30);
% compute generalized FEVD
gFEVD = fevd(estMdl, 'Method', 'generalized', 'NumObs', 30);
% Plot g-FEVD from MATLAB
armafevd(estMdl.AR,[], "InnovCov", estMdl.Covariance, 'Method', 'generalized', 'NumObs', 30);
% compute FEVD use function
oMSPE = computeMSPE(estMdl, 30);
gMSPE = computeGMSPE(estMdl, 30);