FOCUS AREAS

SAS/ETS Examples

Efficiency Test for Estimators by Simulation


Contents | Back to Example

SAS Program

/* Efficiency Test for Estimators by Simulation */

/*----------------------------*
   Create Monte Carlo data
 *----------------------------*/

data sample;

   rho = 0.9;

do samp = 1 to 1000;

   /* first error term */
   eps = rho * rannor( 47392 ) + rannor( 82745 );

   do x = 1 to 20;
       y = 2 + 5 * x + eps;
       eps=eps;
       eps = rho * eps  + rannor( 32815 );
       output;
   end;
end;

/*----------------------------*
      OLS estimation
 *----------------------------*/

proc autoreg data=sample outest=est0 noprint;
by samp;
model y = x ;
run;

data estbar0;
 set est0;
 rename x=xbar0;
 rename intercep=inter0;
 run;

proc univariate data=estbar0;
   var xbar0 ;
   histogram xbar0 / normal(color=blue) cframe=ligr
                     cfill=green;
   title 'Distribution of OLS Estimate';
run;

/*----------------------------*
   Yule-Walker estimation
 *----------------------------*/

proc autoreg data=sample outest=est1 noprint;
by samp;
model y = x / nlag=1;
run;

data estbar1;
 set est1;
 rename x=xbar1;
 rename intercep=inter1;
 run;

proc univariate data=estbar1;
   var xbar1 ;
   histogram xbar1 / normal(color=blue) cframe=ligr
                     cfill=green;
   title 'Distribution of Yule-Walker Estimate';
run;