全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
5253 2
2011-03-20
See at the bottom.

The first and second are provided by SAS.


/*-----------------------------------------------------------------
     Example: Estimating GARCH Models
     Requires: SAS/ETS
     Version: 9.0                                                                       
     ------------------------------------------------------------------*/

   %let df = 7.5;
   %let sig1 = 1;
   %let sig2 = 0.1 ;
   %let var2 = 2.5;
   %let nobs = 1000 ;
   %let nobs2 = 2000 ;
   %let arch0 = 0.1 ;
   %let arch1 = 0.2 ;
   %let garch1 = 0.75 ;
   %let intercept = 0.5 ;
   
   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 ;
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2012-3-8 20:30:27
多谢楼主分享经验!
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2012-4-30 14:58:19
多谢,学习了
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群