@ THIRD PROGRAM  - COMPUTATION OF
  IMPULSE RESPONSE FUNCTIONS @

@ ORDERING OF VARIABLES
  S: (MKE-TRANSITION) K  A
  H: L  C  N  Y  AP I  @
 

@ CHOOSE SHOCK (ORDERING IS [K A]) @
S=0|1;

@ FORECAST HORIZON @
NIR=40;

@ GENERATING IMPULSES @
T=SEQA(1,1,NIR);
IR=ZEROS(ROWS(MKE)+ROWS(H),NIR);

I=1;
DO UNTIL I>NIR;
IR[1:ROWS(MKE),I]=S;
IR[ROWS(MKE)+1:ROWS(IR),I]=(H*S);
S=MKE*S;
I=I+1;
ENDO;

@ PLOT IMPULSE RESPONSES @
LIBRARY PGRAPH;
GRAPHSET;
/* 1. TRANSITION PATH IF K IS NOT KSS */
TITLE("TRANSITIONS TO STEADY STATE");
_PLEGCTL={2,3,1.7,4.5};
_PLEGSTR="K \000"\
         "C \000"\
         "N \000"\
         "Y \000"\
         "AP \000"\
         "I \000";
XY(T,IR[1,.]'~IR[4:8,.]');
/* 2. IF YOU HAVE A SHOCK THEN USE THIS NOW */
TITLE("REACTION TO SHOCK TO A");
_PLEGCTL={2,3,1.7,4.5};
_PLEGSTR="K \000"\
         "A \000"\
         "C \000"\
         "N \000"\
         "Y \000"\
         "AP \000"\
         "I \000";
XY(T,IR[1:2,.]'~IR[4:8,.]');