FORMAT 4,0;
DD=DATE; TT=TIME;

@ ------------------------------------------------------- @
@ THE SECOND PROGRAMME - PLOTTING IMPULSE RESPONSES       @
@ ------------------------------------------------------- @

HX=HSEC;
"   IMPULSE RESPONSE FUNCTIONS ARE GRAPHED ";
"1: INITIALIZING";
LOCATE 1,50;"DATE";;DD[3,1];;DD[2,1];;DD[1,1];
LOCATE 2,50;"TIME";;TT[1,1];;TT[2,1];;TT[3,1];

@ ------------------------------------------------------- @
@         ORDERING OF VARIABLES                           @
@ ------------------------------------------------------- @

@   1   2   3
X:  K   Z   G
    1   2
U:  N   I  @
 

@ ------------------------------------------------------- @
@ IN PROG1 WE DERIVED THE SOLUTION. NOW WE SIMULATE
  THE RESPONSE TO TWO TYPES OF SHOCKS                     @
@ ------------------------------------------------------- @

X=1|Z[1:3,1];
FORMAT 10,10;

HOR=30;                       @ CHOOSE YOUR TIME HORIZON @

H1=HSEC;

L=0.1*zss|.00*gss;           @  CHOOSE WHICH VARIABLE YOU WISH
                                TO SHOCK. NOTE THAT THESE ARE
                                DEFINED IN TERMS OF % OF STEADY-STATE
                                VALUES @
XT=zeros(3,HOR); UT=zeros(2,HOR);

@ ------------------------------------------------------- @
@    SIMULATION FOR A TIME-HORIZON OF HOR QUARTERS        @
@ ------------------------------------------------------- @
 I=1;
 DO UNTIL I>HOR;
   XX=O*X+G*L;
   U=-FF*X;
   XT[.,I]=X[2:4,1];
   UT[1:2,I]=U;
   X=XX;
   I=I+1;
   L=zeros(2,1);
 ENDO;

@ ------------------------------------------------------- @
@ WE CAN NOW DERIVE THE LEVEL OF C AND Y                  @
@ ------------------------------------------------------- @
IT=UT[2,.]';
NT=UT[1,.]';
ZT=XT[2,.]';
KT=XT[1,.]';
GOT=XT[3,.]';
YT=ZT.*(KT^SK).*(NT^SN);
CT=YT-GOT-IT;
APNT=YT./NT;
WT=SN*ZT.*(KT^SK).*(NT^(SN-1));
RT=SK*ZT.*(KT^(SK-1)).*(NT^SN);

DIT=100*(IT-IT[1,1])/IT[1,1];
DNT=100*(NT-NT[1,1])/NT[1,1];
DZT=100*(ZT-ZT[1,1])/ZT[1,1];
DKT=100*(KT-KT[1,1])/KT[1,1];
DGT=100*(GOT-GOT[1,1])/GOT[1,1];
DYT=100*(YT-YT[1,1])/YT[1,1];
DCT=100*(CT-CT[1,1])/CT[1,1];
DAPNT=100*(APNT-APNT[1,1])/APNT[1,1];
DWT=100*(WT-WT[1,1])/WT[1,1];
DRT=100*(RT-RT[1,1])/RT[1,1];

LIBRARY PGRAPH;
T=SEQA(1,1,HOR);
TITLE("PRODUCTION, INPUTS AND FACTOR PRICES");
XLABEL("KVARTAL");
YLABEL("% DEVIATION FROM STEADY STATE");
_PLEGCTL={2,3,1.7,4.5};
_PLEGSTR="Y \000"\
         "K \000"\
         "N \000"\
         "APN \000"\
         "W \000"\
         "R \000";

XY(t,DYT~DKT~DNT~DAPNT~DWT~DRT);

TITLE("OUTPUT AND ITS COMPONENTS");
_PLEGSTR="Y \000"\
         "C \000"\
         "G \000"\
         "I \000";
XY(t,DYT~DCT~DGT~DIT);