%% Plot Orthogonalized IRF of Univariate ARMA Model
% Plot the entire IRF of the univariate ARMA(2,1) model
% y_t = 0.3y_{t-1} - 0.1y_{t-2} + \varepsilon_t + 0.05\varepsilon_{t-1}.
% Create vectors for the autoregressive and moving average coefficients as you encounter them in the model as expressed in difference-equation notation.

AR0 = [0.3 -0.1];
MA0 = 0.05;

%
% Plot the orthogonalized IRF of y_t.

armairf(AR0,MA0);

% The impulse response fades after four periods.
%
% Alternatively, create an ARMA model that represents y_t. Specify 1 for the variance of the innovations, and no model constant.

Mdl = arima('AR',AR0,'MA',MA0,'Variance',1,'Constant',0);

% Mdl is an arima model object.
%
% Plot the IRF using Mdl.

impulse(Mdl);

% impulse uses a stem plot, whereas armairf uses a line plot. However, the IRFs in the two implementations are equal because the variance of the ARMA model is 1.
% Copyright 2018 The MathWorks, Inc.