%% Return IRF of ARMA Model
% Compute the entire orthogonalized 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, which is expressed in difference-equation notation.

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

%
% Plot the orthogonalized IRF of y_t.

y = armairf(AR0,MA0)

% y is a 5-by-1 vector of impulse responses.  y(1) is the impulse response for time t = 0, y(2) is the impulse response for time t = 1, and so on. The IRF fades after period t = 4.
%
% 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 of the ARIMA model Mdl.

y = impulse(Mdl)

% The IRFs in the two implementations are equivalent.
% Copyright 2012 The MathWorks, Inc.