%% Regression Model with ARIMA Errors
% This example shows how to plot the impulse response function of a regression model with ARIMA errors.
% Specify the regression model with ARIMA(4,1,10) errors:
% \begin{array}{c}{y_t} = 2 + {X_t}\left[ \begin{array}{l}5\\ - 1\end{array} \right] + {u_t}\\\left( {1 - 0.9L + 0.8{L^2} - 0.75{L^3} + 0.6{L^4}} \right)(1 - L){u_t} = \left( {1 + 0.5{L^2} - 0.4{L^4} - 0.3{L^6} + 0.2{L^8} - 0.1{L^{10}}} \right){\varepsilon _t}.\end{array}

Mdl = regARIMA('Intercept',2,'Beta',[5; -1],...
    'AR',{0.9, -0.8, 0.75, -0.6},...
    'MA',{0.5, -0.4, -0.3, 0.2, -0.1},...
    'MALags',[2 4 6 8 10],'D',1)

% One of the roots of the compound autoregressive polynomial is 1, therefore Mdl defines a nonstationary error process.
% You do not need to specify the innovation variance.
%
% Plot the first impulse responses.

quot = sum([1,cell2mat(Mdl.MA)])/sum([1,-cell2mat(Mdl.AR)])

impulse(Mdl,50)
hold on
plot([1 50],[quot quot],'r--','Linewidth',2.5)
hold off

% The impulse responses do not decay to 0. They settle at the quotient of the sums of the moving average and autoregressive polynomial coefficients (quot).
% \texttt{quot} = \frac{{1 + 0.5 - 0.4 - 0.3 + 0.2 - 0.1}}{{1 - 0.9 + 0.8 - 0.75 + 0.6}} = 1.2.
% Copyright 2015 The MathWorks, Inc.