%% Plot Orthogonalized FEVDs of VARMA Model
% Plot the FEVD of the VARMA(3,1) model
% \[\begin{array}{c}
% {y_t} = \left[ {\begin{array}{*{20}{c}}
% { - 0.5}&{0.2}&{0.1}\\
% {0.3}&{0.1}&{ - 0.1}\\
% { - 0.4}&{0.2}&{0.05}
% \end{array}} \right]{y_{t - 1}} + \left[ {\begin{array}{*{20}{c}}
% { - 0.05}&{0.02}&{0.01}\\
% {0.1}&{0.01}&{0.001}\\
% { - 0.04}&{0.02}&{0.005}
% \end{array}} \right]{y_{t - 3}}
%  + {\varepsilon _t} + \left[ {\begin{array}{*{20}{c}}
% { - 0.02}&{0.03}&{0.3}\\
% {0.003}&{0.001}&{0.01}\\
% {0.3}&{0.01}&{0.01}
% \end{array}} \right]{\varepsilon _{t - 1}}
% \end{array}\]
% where y_t = \left[y_{1t}\;\;\;y_{2t}\;\;\;y_{3t}\right]' and \varepsilon_t = \left[\varepsilon_{1t}\;\;\;\varepsilon_{2t}\;\;\;\varepsilon_{3t}\right]'.
% The VARMA model is in difference-equation notation because the current response is isolated from all other terms in the equation.
% Create a cell vector containing the VAR matrix coefficients. The position of the coefficient matrix in the cell vector determines its lag.  Therefore, specify a 3-by-3 matrix of zeros as the  second element of the vector.

var0 = {[-0.5 0.2 0.1; 0.3 0.1 -0.1; -0.4 0.2 0.05],...
    zeros(3),...
    [-0.05 0.02 0.01; 0.1 0.01 0.001; -0.04 0.02 0.005]};

%
% Create a cell vector containing the VMA matrix coefficients.

vma0 = {[-0.02 0.03 0.3; 0.003 0.001 0.01; 0.3 0.01 0.01]};

%
% Plot the orthogonalized FEVDs of the VARMA model.

armafevd(var0,vma0);

% armafevd returns three figures. Figure k contains the generalized FEVD of variable k to a shock applied to all other variables at time 0.
% You can attribute most of the forecast error variance of variable 1 to a shock to variable 1.  A shock to variable 2 does not contribute much to the forecast error variance of variable 1.
% You can attribute most of the forecast error variance of variable 2 to a shock to variable 2.  A shock to variable 3 does not contribute much to the forecast error variance of variable 2.
% You can attribute most of the forecast error variance of variable 3 to a shock to variable 3.  A shock to variable 2 does not contribute much to the forecast error variance of variable 3.
% Copyright 2018 The MathWorks, Inc.