This is a supplement to the GAUSS part of lab 1. This gives a more detailed GAUSS program to analyze various AR processes. You might find this more helpful than the program I handed out in the Friday lab. Topics Covered in this part of the lab 1. Simulating time series 2. Difference equations 3. Impulse response function Required Reading 1. J. Hamilton, Time Series Analysis, chapters 1 - 3 2. T. Mills, The Econometric Modelling of Financial Time Series, chapters 1-2. Computer Problems 1. Consider the following stochastic difference equations (AR(p) models): (I) y(t) = 2 + 0.9y(t-1) + w(t) (ii)y(t) = 2 + y(t-1) + w(t) (iii) y(t) = 2 + 1.01y(t-1) + w(t) (iv) y(t) = 2 + 1.34y(t-1) + .45y(t-2) + w(t) (v) y(t) = 2 + 1.75y(t-1) - y(t-2) + w(t) (vi) y(t) = 2 + 0.5y(t-1) - 0.85y(t-2) + w(t) where w(t) ~ i.i.d. N(0,4) and all initial values are equal to zero. For each process above, do the following: (a) Simulate and plot 100 observations. Note the effects of initial values. What value, if any, does each equation tend to fluctuate about? That is, what is the unconditional mean of the series? (b) Determine if the equation is stable: compute modulus of eigenvalues of respective F matrix and/or roots to characteristic polynomial. Note: For the AR(2) models, you can use the "stability triangle" (see Enders pg. 32) to determine dynamic behavior. (c) Compute impulse responses (moving average weights or the Wold coefficients) for a horizon of 100 periods. Plot the impulse responses for 30 periods. (d) Compute long-run response of a one unit shock today: that is, compute the sum of impulse responses over the 100 period horizon. For the stable models, you can give an analytical expression for the long-run response based on the AR coefficients. Hints on using GAUSS to solve the above problems I have created some procedures that you can use to answer all of the questions above. The procedures are posted to the class web page. However, I encourage you to write your own procedures to do the lab so you can get better aquainted with GAUSS. The procedures on the web page are: _F Computes the state space F matrix for an AR(p) model. _IRAR Computes impulse responses from an AR(p) model. _ROOTSAR Computes the eigenvalues of the state space F matrix for an AR(p) model. Sample batch program /* LAB1.PRG Program for problem set 1 computations ** Last update: 1/15/94 by Eric Zivot */ library tsutil1,pgraph; format 8,5; /* global variables */ T=100; @ sample size @ n=100; @ # of impulse responses @ c=2; @ constant term @ sigma=2; @ std. dev of innovations @ tindex1=seqa(1,1,T); @ time index for plots @ tindex2=seqa(1,1,30); @ time index for plots @ seed=137953; w=rndns(T,1,seed)*sigma; @ iid N(0,sigma^2) errors @ /* ----------------------------AR(1) models------------------------------- */ /* model 1: y(t) = 2 + 0.9y(t-1) + w(t) */ phi1 = 0.9; y0 = 0; @ initial value @ /* part (a): simulate y(t) */ y1 = recserar(c+w,y0,phi1); /* part (b): compute e-values (not necessary for AR(1)) */ /* part (c): compute impulse responses */ ir1 = zeros(n,1); @ vector of impulse responses @ i = 1; do until i > n; ir1[i] = phi1^i; i = i + 1; endo; /* part (d): compute long-run response to 1 time shock */ lr1 = sumc(ir1) + 1; @ add 1 for initial impact of shock @ /* part (e): compute autocorrelations */ acf1 = zeros(n,1); @ vector of autocorrelations @ i = 1; @ look familiar? @ do until i > n; acf1[i] = phi1^i; i = i + 1; endo; /* model 2: y(t) = 2 + y(t-1) + w(t) */ phi2 = 1; y0 = 0; @ initial value @ /* part (a): simulate y(t) */ y2 = recserar(c+w,y0,phi2); /* part (b): compute e-values (not necessary for AR(1)) */ /* part (c): compute impulse responses */ ir2 = zeros(n,1); @ vector if impulse responses @ i = 1; do until i > n; ir2[i] = phi2^i; i = i + 1; endo; /* part (d): compute long-run response to 1 time shock */ lr2 = sumc(ir2) + 1; @ add 1 for initial impact of shock @ /* part (e): compute autocorrelations */ acf2 = zeros(n,1); @ vector of autocorrelations @ i = 1; @ look familiar? @ do until i > n; acf2[i] = phi2^i; i = i + 1; endo; /* model 3: y(t) = 2 + 1.01y(t-1) + w(t) */ phi3 = 1.01; y0 = 0; @ initial value @ /* part (a): simulate y(t) */ y3 = recserar(c+w,y0,phi3); /* part (b): compute e-values (not necessary for AR(1)) */ /* part (c): compute impulse responses */ ir3 = zeros(n,1); @ vector if impulse responses @ i = 1; do until i > n; ir3[i] = phi3^i; i = i + 1; endo; /* part (d): compute long-run response to 1 time shock */ lr3 = sumc(ir3) + 1; @ add 1 for initial impact of shock @ /* part (e): compute autocorrelations */ acf3 = zeros(n,1); @ vector of autocorrelations @ i = 1; @ look familiar? @ do until i > n; acf3[i] = phi3^i; i = i + 1; endo; /* ---------------------------AR(2) models-------------------------------- */ /* model 4: y(t) = 2 + 1.34y(t-1) - 0.45y(t-2) + w(t) */ phi4 = {1.34,-0.45}; y0 = zeros(2,1); y4 = recserar(c+w,y0,phi4); /* part (b): compute e-vals of F matrix */ evals4 = _ROOTSAR(phi4); modeval4 = abs(evals4); /* part (c): compute impulse responses */ ir4 = _IRAR(phi4,n); /* part (d): compute long-run response to 1 time shock */ lr4 = sumc(ir4) + 1; @ add 1 for initial impact of shock @ /* part (e): compute autocorrelations ** see Mills, page 74 */ acf4 = zeros(n,1); @ vector of autocorrelations @ acf4[1] = phi4[1]/(1-phi4[2]); acf4[2] = (phi4[1]^2)/(1-phi4[2]) + phi4[2]; i = 3; do until i > n; acf4[i] = phi4[1]*acf4[i-1] + phi4[2]*acf4[i-2]; i = i + 1; endo; /* model 5: y(t) = 2 + 1.75y(t-1) - y(t-2) + w(t) */ phi5 = {1.75,-1}; y0 = zeros(2,1); y5 = recserar(c+w,y0,phi5); /* part (b): compute e-vals of F matrix */ evals5 = _ROOTSAR(phi5); modeval5 = abs(evals5); /* part (c): compute impulse responses */ ir5 = _IRAR(phi5,n); /* part (d): compute long-run response to 1 time shock */ lr5 = sumc(ir5) + 1; @ add 1 for initial impact of shock @ /* part (e): compute autocorrelations */ acf5 = zeros(n,1); @ vector of autocorrelations @ acf5[1] = phi5[1]/(1-phi5[2]); acf5[2] = (phi5[1]^2)/(1-phi5[2]) + phi5[2]; i = 3; do until i > n; acf5[i] = phi5[1]*acf5[i-1] + phi5[2]*acf5[i-2]; i = i + 1; endo; /* model 6 */ phi6 = {0.5,-0.85}; y0 = zeros(2,1); y6 = recserar(c+w,y0,phi6); /* part (b): compute e-vals of F matrix */ evals6 = _ROOTSAR(phi6); modeval6 = abs(evals6); /* part (c): compute impulse responses */ ir6 = _IRAR(phi6,n); /* part (d): compute long-run response to 1 time shock */ lr6 = sumc(ir6) + 1; @ add 1 for initial impact of shock @ /* part (e): compute autocorrelations */ acf6 = zeros(n,1); @ vector of autocorrelations @ acf6[1] = phi6[1]/(1-phi6[2]); acf6[2] = (phi6[1]^2)/(1-phi6[2]) + phi6[2]; i = 3; do until i > n; acf6[i] = phi6[1]*acf6[i-1] + phi6[2]*acf6[i-2]; i = i + 1; endo; /* send output to disk file */ output file=lab1.out reset; " Eigenvalues and Modulus of e-values "; "--------------------------------------------"; " Model4"; "--------------------------------------------"; evals4~modeval4; "--------------------------------------------"; " Model5"; "--------------------------------------------"; evals5~modeval5; "--------------------------------------------"; " Model6"; "--------------------------------------------"; evals6~modeval6; ""; "--------------------------------------------"; " Long-Run Responses "; "--------------------------------------------"; "Model1 Model2 Model3 Model4 Model5 Model6"; "----------------------------------------------------"; lr1~lr2~lr3~lr4~lr5~lr6; ""; output off; @ close disk file @ /* plot series */ begwind; window(2,3,0); @ create tiled 6 window graph @ xlabel("time"); ylabel("y(t)"); setwind(1); @ first window @ title("Model 1"); xy(tindex1,y1); nextwind; @ second window @ title("Model 2"); xy(tindex1,y2); nextwind; title("Model 3"); xy(tindex1,y3); nextwind; title("Model 4"); xy(tindex1,y4); nextwind; title("Model 5"); xy(tindex1,y5); nextwind; title("Model 6"); xy(tindex1,y6); endwind; @ press for graphics menu @ /* plot impulse responses */ begwind; window(2,3,0); @ create tiled 6 window graph @ xlabel("t+s"); ylabel("Impulse responses"); setwind(1); @ first window @ title("Model 1"); xy(tindex2,ir1[1:30]); nextwind; @ second window @ title("Model 2"); xy(tindex2,ir2[1:30]); nextwind; title("Model 3"); xy(tindex2,ir3[1:30]); nextwind; title("Model 4"); xy(tindex2,ir4[1:30]); nextwind; title("Model 5"); xy(tindex2,ir5[1:30]); nextwind; title("Model 6"); xy(tindex2,ir6[1:30]); endwind;@ press for graphics menu @ /* plot autocorrelations */ begwind; window(2,3,0); @ create tiled 6 window graph @ xlabel("j"); ylabel("Autocorrelations"); setwind(1); @ first window @ title("Model 1"); xy(tindex2,acf1[1:30]); nextwind; @ second window @ title("Model 2"); xy(tindex2,acf2[1:30]); nextwind; title("Model 3"); xy(tindex2,acf3[1:30]); nextwind; title("Model 4"); xy(tindex2,acf4[1:30]); nextwind; title("Model 5"); xy(tindex2,acf5[1:30]); nextwind; title("Model 6"); xy(tindex2,acf6[1:30]); endwind;@ press for graphics menu @