Simulated Method of Moments -- AR(1) Process

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

                    SAS Sample Library

        Name: modex16.sas
 Description: Example program from SAS/ETS User's Guide,
              The MODEL Procedure
       Title: Simulated Method of Moments -- AR(1) Process
     Product: SAS/ETS Software
        Keys: nonlinear simultaneous equation models
        PROC: MODEL
       Notes:

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

%let nobs=500;
data ardata;
   lu =0;
   do i=-10 to &nobs;
      x = rannor( 1011 );
      e = rannor( 1011 );
      u = .6 * lu + 1.5 * e;
      Y = 2 + 1.5 * x + u;
      lu = u;
      if i > 0 then output;
   end;
run;

title1 'Simulated Method of Moments for AR(1) Process';

proc model data=ardata ;
   parms a b s 1 alpha .5;
   instrument x;

   u = alpha * zlag(u) + s * rannor( 8003 );
   ysim = a + b * x + u;
   y = ysim;
   moment y = (2) lag1(1);

   fit y / gmm npreobs=10 ndraw=10;
   bound s > 0, 1 > alpha > 0;
run;