data normal;
lu = &var2;
lh = &var2;
do i= -500 to &nobs ;
/* GARCH(1,1) with normally distributed residuals */
h = &arch0 + &arch1*lu**2 + &garch1*lh;
u = sqrt(h) * rannor(12345) ;
y = &intercept + u;
lu = u;
lh = h;
if i > 0 then output;
end;
run;
proc autoreg data = normal ;
/* Estimate GARCH(1,1) with normally distributed residuals with AUTOREG*/
model y = / garch = ( q=1,p=1 ) ;
run ;
quit ;
/* Estimate GARCH(1,1) with normally distributed residuals with MODEL*/
proc model data = normal ;
parms arch0 .1 arch1 .2 garch1 .75 ;
/* mean model */
y = intercept ;
/* variance model */
h.y = arch0 + arch1*xlag(resid.y**2,0) +
garch1*xlag(h.y,0) ;
/* fit the model */
fit y / method = marquardt fiml ;
run ;
quit ;
/* Estimate GARCH(1,1) with normally distributed residuals with NLMIXED*/
proc nlmixed data = normal ;
/* error mean model */
err=y-intercept ;
/* variance model */
h = arch0 + arch1*xlag(err**2,0) +
garch1*xlag(h,0) ;
loglik=-0.5*(log(2*constant('pi'))+log(h)+err**2/h);
model err ~ general (loglik) ;
run ;
quit ;