* * VAR_ex2.PRG * * This program computes and graphs impulse response functions for * a VAR model. * The only lines below the ******* line in the middle * which need to be modified are those marked with ;*<<<<<<< * * Reading the data file calendar 1960 1 4 allocate 1991:4 open data us.prn data(format=prn,org=cols) / M1 TBILL r3 r10 GDPDEF GDP85 GOVT * Transforming the variables set gm1 = log(m1) - log(m1{1}) set inf = log(gdpdef) - log(gdpdef{1}) diff tbill / dtbill table / inf gm1 tbill ************************************************************************* * *** Correct only the statements with ;*<<<<<< * COMPUTE NEQN = 2 ;*<<<<<< COMPUTE NLAGS = 8 ;*<<<<<< COMPUTE NSTEPS = 24 ;*<<<<<< * SYSTEM(MODEL=VARMODEL) VARIABLES inf gm1 ;*<<<<<<< LAGS 1 TO NLAGS DET CONSTANT END(SYSTEM) * DECLARE RECT[SERIES] IMPBLK(NEQN,NEQN) DECLARE VECT[SERIES] SCALED(NEQN) DECLARE VECT[STRINGS] IMPLABEL(NEQN) * * To help create publication-quality graphs, this sets longer labels for * the series. These are used both in graph headers and key labels. * COMPUTE IMPLABEL=|| $ 'INF',$ ;* <<<<<< 'GM1' || ;* <<<<<< ESTIMATE(NOPRINT) * * These apply to the GRAPH instructions which are coming up later * LIST IEQN = 1 TO NEQN SMPL 1 NSTEPS * * This computes the full set of impulse responses, which are in the series in * IMPBLK. IMPBLK(i,j) is the response of variable i to a shock in j. * IMPULSE(MODEL=VARMODEL,RESULT=IMPBLK,NOPRINT) * NSTEPS * %SIGMA * * This loop plots the responses of all series to a single series. The response * of a series is normalized by dividing by its innovation variance. This * allows all the responses to a shock to be plotted on a single scale. Note that * these graphs get a bit hard to read with more than five or six variables. * * As this program will generate a dozen graphs in a bunch, the WINDOW option * is used on the GRAPH instructions to give them descriptive labels in * the WINDOW menu. * DO I=1,NEQN COMPUTE HEADER='Plot of Responses to '+IMPLABEL(I) DO J=1,NEQN SET SCALED(J) = (IMPBLK(J,I))/SQRT(%SIGMA(J,J)) END DO J GRAPH(HEADER=HEADER,KEY=BELOW,KLABELS=IMPLABEL,NUMBER=0,WINDOW='TO_'+IMPLABEL(I)) NEQN CARDS SCALED(IEQN) END DO I * * And this loop graphs the responses of a variable to all shocks. * These don't have to be normalized. * DO I=1,NEQN COMPUTE HEADER='Plot of Responses of '+IMPLABEL(I) GRAPH(HEADER=HEADER,KEY=BELOW,KLABELS=IMPLABEL,NUMBER=0,WINDOW='OF_'+IMPLABEL(I)) NEQN CARDS IMPBLK(I,IEQN) END DO I