www.gusucode.com > econ 案例源码程序 matlab代码 > econ/AutoregressiveModelExample.m
%% Autoregressive Model % This example shows how to compute and plot the impulse response function % for an autoregressive (AR) model. The AR(_p_) model is given by % % $${y_t} = \mu + \phi {(L)^{ - 1}}{\varepsilon _t},$$ % % where $\phi(L)$ is a $p$-degree % AR operator polynomial, $(1 - {\phi _1}L - \ldots - {\phi _p}{L^p})$. % % An AR process is stationary provided that the AR operator polynomial is % stable, meaning all its roots lie outside the unit circle. In this case, % the infinite-degree inverse polynomial, $\psi (L) = \phi {(L)^{ - 1}}$, % has absolutely summable coefficients, and the impulse response function % decays to zero. % Copyright 2015 The MathWorks, Inc. %% Step 1. Specify the AR model. % Specify an AR(2) model with coefficients $\phi_1 = 0.5$ % and $\phi_2 = -0.75$. modelAR = arima('AR',{0.5,-0.75}); %% Step 2. Plot the impulse response function. % Plot the impulse response function for 30 periods. impulse(modelAR,30) %% % The impulse function decays in a sinusoidal pattern.