www.gusucode.com > econ 案例源码程序 matlab代码 > econ/SimulateResponsesInnovationsandUnconditionalDisturbancesExample.m
%% Simulate Responses, Innovations, and Unconditional Disturbances % Simulate paths of responses, innovations, and unconditional disturbances % from a regression model with $\rm{SARIMA}(2,1,1)_{12}$ errors. % Copyright 2015 The MathWorks, Inc. %% % Specify the model: % % $$\begin{array}{c} % {y_t} = X\left[ {\begin{array}{*{20}{c}} % {1.5}\\ % { - 2} % \end{array}} \right] + {u_t}\\ % \left( {1 - 0.2L - 0.1{L^2}} \right)\left( {1 - L} \right)\left( {1 - 0.01{L^{12}}} \right)\left( {1 - {L^{12}}} \right){u_t} = \left( {1 + 0.5L} \right)\left( {1 + 0.02{L^{12}}} \right){\varepsilon _t}, % \end{array}$$ % % where $\varepsilon_{t}$ follows a t-distribution with 15 degrees of freedom. Distribution = struct('Name','t','DoF',15); Mdl = regARIMA('AR',{0.2, 0.1},'MA',{0.5},'SAR',0.01,... 'SARLags',12,'SMA',0.02,'SMALags',12,'D',1,... 'Seasonality',12,'Beta',[1.5; -2],'Intercept',0,... 'Variance',0.1,'Distribution',Distribution) %% % Simulate and plot 500 paths with 25 observations each. T = 25; rng(1) X = randn(T,2); [Y,E,U] = simulate(Mdl,T,'NumPaths',500,'X',X); figure subplot(2,1,1); plot(Y) axis tight title('{\bf Simulated Response Paths}') subplot(2,2,3); plot(E) axis tight title('{\bf Simulated Innovations Paths}') subplot(2,2,4); plot(U) axis tight title('{\bf Simulated Unconditional Disturbances Paths}') %% % Plot the 2.5th, 50th (median), and 97.5th percentiles of the simulated % response paths. lower = prctile(Y,2.5,2); middle = median(Y,2); upper = prctile(Y,97.5,2); figure plot(1:25,lower,'r:',1:25,middle,'k',... 1:25,upper,'r:') title('\bf{95% Percentile Confidence Interval for the Response}') legend('95% Interval','Median','Location','Best') %% % Compute statistics across the second dimension (across paths) to summarize % the sample paths. %% % Plot a histogram of the simulated paths at time 20. figure histogram(Y(20,:),10) title('Response Distribution at Time 20')