Multipliers for a Third-Order System

/*--------------------------------------------------------------

                    SAS Sample Library

        Name: simex02.sas
 Description: Example program from SAS/ETS User's Guide,
              The SIMLIN Procedure
       Title: Multipliers for a Third-Order System
     Product: SAS/ETS Software
        Keys: structural equations
        PROC: SIMLIN
       Notes:

--------------------------------------------------------------*/

data test;
   input y ylag1 ylag2 ylag3 x;
   n+1;
datalines;
 8.2369     8.5191     6.9491     7.8800    -1.2593
 8.6285     8.2369     8.5191     6.9491    -1.6805
10.2223     8.6285     8.2369     8.5191    -1.9844
10.1372    10.2223     8.6285     8.2369    -1.7855
10.0360    10.1372    10.2223     8.6285    -1.8092
10.3560    10.0360    10.1372    10.2223    -1.3921
11.4835    10.3560    10.0360    10.1372    -2.0987
10.8508    11.4835    10.3560    10.0360    -1.8788
11.2684    10.8508    11.4835    10.3560    -1.7154
12.6310    11.2684    10.8508    11.4835    -1.8418
11.9096    12.6310    11.2684    10.8508    -2.0470
12.2193    11.9096    12.6310    11.2684    -1.8109
13.0518    12.2193    11.9096    12.6310    -1.8780
12.8666    13.0518    12.2193    11.9096    -2.0845
13.3405    12.8666    13.0518    12.2193    -2.0509
13.3683    13.3405    12.8666    13.0518    -1.7805
13.1531    13.3683    13.3405    12.8666    -2.0595
14.5805    13.1531    13.3683    13.3405    -2.3643
13.1989    14.5805    13.1531    13.3683    -1.4725
12.4139    13.1989    14.5805    13.1531    -1.1796
14.8030    12.4139    13.1989    14.5805    -1.9951
13.9480    14.8030    12.4139    13.1989    -1.8967
14.3449    13.9480    14.8030    12.4139    -2.4828
16.7221    14.3449    13.9480    14.8030    -2.9054
15.9229    16.7221    14.3449    13.9480    -2.6875
16.3114    15.9229    16.7221    14.3449    -2.9113
16.7162    16.3114    15.9229    16.7221    -1.9644
15.4270    16.7162    16.3114    15.9229    -1.7433
17.1469    15.4270    16.7162    16.3114    -2.5479
16.2746    17.1469    15.4270    16.7162    -1.7809
;

title1 'Simulate Equation with Third-Order Lags';
title2 'Listing of Simulated Input Data';
proc print data=test(obs=10);
run;

title2 'Estimated Parameters';
proc reg data=test outest=a;
   model y=ylag3 x;
run;

title2 'Listing of OUTEST= Data Set';
proc print data=a;
run;

title2 'Simulation of Equation';
proc simlin est=a data=test nored;
   endogenous y;
   exogenous  x;
   lagged ylag3 y 3;
   id n;
   output out=out1 predicted=yhat residual=yresid;
run;

title2 'Plots of Simulation Results';
proc sgplot data=out1;
   scatter x=n y=y;
   series x=n y=yhat / markers markerattrs=(symbol=plus);
run;

data test2;
   set test;
   ylag1x=ylag1;
   ylag2x=ylag2;
run;

title2 'Estimation of parameters and definition of identities';
proc syslin data=test2 outest=b;
   endogenous y ylag1x ylag2x;
   model y=ylag3 x;
   identity ylag1x=ylag1;
   identity ylag2x=ylag2;
run;

title2 'Listing of OUTEST= data set from PROC SYSLIN';
proc print data=b;
run;

title2 'Simulation of transformed first-order equation system';

proc simlin est=b data=test2 total interim=2;
   endogenous y ylag1x ylag2x;
   exogenous  x;
   lagged  ylag1 y 1  ylag2 ylag1x 1  ylag3 ylag2x 1;
   id n;
   output out=out2 predicted=yhat residual=yresid;
run;