%% Convert an ARMA model to an AR Model
% Find the lag coefficients of the truncated, AR 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 AR model by obtaining the coefficients of the truncated approximation of the infinite-lag polynomial.

ar = arma2ar(ar0,ma0)

% ar is a numeric vector because ar0 and ma0 are numeric vectors.
% The approximate AR model truncated at 7 lags is
% \begin{array}{*{20}{l}}
% {{y_t}}& = &{0.7{y_{t - 1}} - 0.45{y_{t - 2}} + 0.225{y_{t - 3}} - 0.1125{y_{t - 4}} + 0.0562{y_{t - 5}} + ...}\\
% {}&{}&{ - 0.0281{y_{t - 6}} + 0.0141{y_{t - 7}} + {\varepsilon _t}}
% \end{array}
% Copyright 2015 The MathWorks, Inc.