www.gusucode.com > econ 案例源码程序 matlab代码 > econ/ImpulseResponseFunctionOfVARModelExample.m
%% Impulse Response Function of VAR Model % Compute the generalized impulse response function of the two-dimensional % VAR(3) model % % $${y_t} = \left[ {\begin{array}{*{20}{c}} % {1}&{ - 0.2}\\ % { - 0.1}&{0.3} % \end{array}} \right]{y_{t - 1}} - \left[ {\begin{array}{*{20}{c}} % {0.75}&{ - 0.1}\\ % { - 0.05}&{0.15} % \end{array}} \right]{y_{t - 2}} + \left[ {\begin{array}{*{20}{c}} % {0.55}&{ - 0.02}\\ % { - 0.01}&{0.03} % \end{array}} \right]{y_{t - 3}} + {\varepsilon _t}.$$ % % In the equation, $y_t = [y_{1,t}\;\;\;y_{2,t}]'$, $\varepsilon_t = % [\varepsilon_{1,t}\;\;\; % \varepsilon_{2,t}]'$, and, for all _t_, $\varepsilon_t$ is Gaussian with % mean zero and covariance matrix % % $$\Sigma = \left[ {\begin{array}{*{20}{c}} % {0.5}&{ - 0.1}\\ % { - 0.1}&{0.25} % \end{array}} \right].$$ % %% % Create a cell vector of matrices for the autoregressive coefficients as % you encounter them in the model expressed in difference-equation % notation. Specify the innovation covariance matrix. AR1 = [1 -0.2; -0.1 0.3]; AR2 = -[0.75 -0.1; -0.05 0.15]; AR3 = [0.55 -0.02; -0.01 0.03]; ar0 = {AR1 AR2 AR3}; InnovCov = [0.5 -0.1; -0.1 0.25]; %% % Compute the entire, generalized impulse response function of $y_t$. % Because no MA terms exist, specify an empty array (|[]|) for the second input % argument. Y = armairf(ar0,[],'Method','generalized','InnovCov',InnovCov); size(Y) %% % |Y| is a 31-by-2-2 array of impulse responses. Rows correspond to % periods, columns correspond to variables, and pages correspond to the % variable that |armairf| shocks. |armairf| satisfies the stopping % criterion after 31 periods. You can specify to stop sooner using the % |'NumObs'| name-value pair argument. This practice is beneficial when % the system has many variables. %% % Compute and display the generalized impulse responses for the first 10 % periods. Y20 = armairf(ar0,[],'Method','generalized','InnovCov',InnovCov,... 'NumObs',10) %% % The impulse responses appear to die out with increasing time, % suggesting a stable system.