Resources

Lack-of-Fit Study

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

                    SAS Sample Library

        Name: autex03.sas
 Description: Example program from SAS/ETS User's Guide,
              The AUTOREG Procedure
       Title: Lack-of-Fit Study
     Product: SAS/ETS Software
        Keys: autoregression
        PROC: AUTOREG
       Notes:

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

ods graphics on;

title1 'Lack of Fit Study';
title2 'Fitting White Noise Plus Autoregressive Errors to a Sine Wave';

data a;
   pi=3.14159;
   do time = 1 to 75;
      if time > 75 then y = .;
      else y = sin( pi * ( time / 50 ) );
      x = ranuni( 1234567 );
      output;
   end;
run;

proc autoreg data=a plots;
   model y = x / nlag=1;
   output out=b p=pred pm=xbeta;
run;

proc sgplot data=b;
   scatter y=y x=time / markerattrs=(color=black);
   series y=pred x=time / lineattrs=(color=blue);
   series y=xbeta x=time / lineattrs=(color=red);
run;