%% Convert an ARMA model to an MA Model
% Find the lag coefficients of the truncated, MA approximation of this univariate, stationary, and invertible ARMA model
% y_t = 0.2y_{t-1} - 0.1 y_{t-2} + \varepsilon_t + 0.5 \varepsilon_{t-1}.
% The ARMA model is in difference-equation notation because the left side contains only y_t and its coefficient 1. Create a vector containing the AR lag term coefficients in order starting from t - 1.

ar0 = [0.2 -0.1];

% Alternatively, you can create a cell vector of the scalar coefficients.
%
% Create a vector containing the MA lag term coefficient.

ma0 = 0.5;

%
% Convert the ARMA model to an MA model by obtaining the coefficients of the truncated approximation of the infinite-lag polynomial.

ma = arma2ma(ar0,ma0)

% ma is a numeric vector because ar0 and ma0 are numeric vectors.
% The approximate MA model truncated at 4 lags is
% \begin{array}{*{20}{l}} {{y_t}} = \varepsilon _t + 0.7{\varepsilon_{t -
% 1}} + 0.04{\varepsilon_{t - 2}} - 0.062{\varepsilon_{t - 3}} -
% 0.0164{\varepsilon_{t - 4}}.  \end{array}
% Copyright 2015 The MathWorks, Inc.