BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Gigiwen
Calcite | Level 5

Dear Helpers, I want to run GRJ-Garch model. Two versions of code I have tried:

 

Version 1: from the following webpage

https://communities.sas.com/t5/SAS-Code-Examples/Estimating-GARCH-Models/ta-p/905609#ets_webex.garch...

  /* Estimate GJR-GARCH Model */
   proc model data = gjrgarch ;
      parms arch0 .1 arch1 .2 garch1 .75 phi .1;
      /* mean model */
      y = intercept ;
      /* variance model */
      if zlag(resid.y) > 0 then 
         h.y = arch0 + arch1*xlag(resid.y**2,mse.y) + garch1*xlag(h.y,mse.y)  ;
      else
         h.y = arch0 + arch1*xlag(resid.y**2,mse.y) + garch1*xlag(h.y,mse.y) +
               phi*xlag(resid.y**2,mse.y) ;
      /* fit the model */
      fit y / method = marquardt fiml ;
   run ;
   quit ;

Version 2: I modified from what I read from the manual. "type = grjgarch"

proc autoreg data=oneCoin ;
   model ret =    / nlag=1 garch=(p=1, q=1, type=gjrgarch) ; 
run ;

In the version 1, I understand the variable of interest is phi. But I do not know how to read the output of the Version 2. Although I read page 402 in the below manual, I do not know what shows in my below snapshot. Could you please help me understand?

https://support.sas.com/documentation/onlinedoc/ets/132/autoreg.pdf

Gigiwen_0-1711907174894.png

 

Besides, I also wish to understand whether Version 1 and 2 are exactly the same? Thank you!

 

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
SASCom1
SAS Employee

Hello @Gigiwen 

 

In your version 1 PROC MODEL code, you specified a pure GJR-GARCH model without autoregressive errors; in your version 2 PROC AUTOREG code, you specified a GJR-GARCH model with autoregressive errors(with the NLAG = option in your code). If you intended to specify a pure GJR-GARCH model without autoregressive errors, then you may want to remove the NLAG = option in your version 2 PROC AUTOREG code.

 

Once you have removed the NLAG = option in your version 2 PROC AUTOREG code, then both versions specify a GJR-GARCH model without AR errors, but they are equivalent with some re-parameterization as discussed below:

 

In your version 1 PROC MODEL code, it specifies that:

 

      if zlag(resid.y) > 0 then 
         h.y = arch0 + arch1*xlag(resid.y**2,mse.y) + garch1*xlag(h.y,mse.y)  ;
      else
         h.y = arch0 + arch1*xlag(resid.y**2,mse.y) + garch1*xlag(h.y,mse.y) +
               phi*xlag(resid.y**2,mse.y) ;

 

*Note: the resid.y is an internal variable in PROC MODEL defined as:

resid.y = pred.y - actual.y

 

SAS Help Center: Equation Translations

 

this means that resid.y in PROC MODEL is the negative of the residual usually defined in the literature(which is actual - predicted).  So the variance equation in the version 1 PROC MODEL code is defined as 

 

if epsilon_t-1  < 0 , then 

h_t = arch0 + arch1*(epsilon_t-1)**2 + garch1*h_t-1 ;

 

else if epsilon_t-1 >=0 then

h_t = arch0 + arch1*(epsilon_t-1)**2 + garch1*h_t-1 + phi*(epsilon_t-1)**2 

 

 

While in version 2 PROC AUTOREG code(after removing NLAG = 1 option from your code), the GJR-GARCH model specifies the variance equation as discussed in the following section:

 

SAS Help Center: GARCH Models

 

h_t = omega + (alpha1 + I_{epsilon_t-1 < 0}*psi1)*(epsilon_t-1)**2 + gamma1*h_t-1

 

 where I_{epsilon_t-1<0} is the indicator that takes the value 1 when epsilon_t-1 <0, and takes the value of 0 when epsilon_t-1 > = 0. The above variance equation is thus translated as:

 

if epsilon_t-1 < 0, then

h_t = omega + (alpha1 + psi1)*(epsilon_t-1)**2 + gamm1*h_t-1 ;

 

else if epsilon_t-1 >=0 then 

h_t = omega + alpha1*(epsilon_t-1)**2 + gamma1*h_t-1 ;

 

Corresponding to the parameter names in PROC AUTOREG parameter estimates table,

 

omega = TARCHA0

alpha1 = TARCHA1

psi1     = TARCHB1 

gamma1 = TGARCH1

 

Comparing the variance equations in the two versions, they are equivalent with the following reparameterization:

 

Version 1  PROC MODEL                                        Version 2 PROC AUTOREG(after removing NLAG = option)

arch0                                                                             TARCHA0

arch1                                                                              TARCHA1 + TARCHB1

arch1 + phi                                                                    TARCHA1

garch1                                                                            TGARCH1

 

From row 2 and row 3 above, you can see that phi and TARCHB1 is negative of each other:

 

phi = -TARCHB1

 

******************************************************

Or alternatively, you may simply modify your version 1 PROC MODEL code by reversing the variance equations between the cases zlag(resid.y) >0 and  zlag(resid.y)<=0, i.e., specify the following variance equations instead:

 

      /* variance model */
      if zlag(resid.y) <= 0 then 
         h.y = arch0 + arch1*xlag(resid.y**2,mse.y) + garch1*xlag(h.y,mse.y)  ;
      else
         h.y = arch0 + arch1*xlag(resid.y**2,mse.y) + garch1*xlag(h.y,mse.y) +
               phi*xlag(resid.y**2,mse.y) ;

 

then the two versions will have one on one matching on all the parameters.

 

I hope this helps.

 

Wen

 

View solution in original post

2 REPLIES 2
SASCom1
SAS Employee

Hello @Gigiwen 

 

In your version 1 PROC MODEL code, you specified a pure GJR-GARCH model without autoregressive errors; in your version 2 PROC AUTOREG code, you specified a GJR-GARCH model with autoregressive errors(with the NLAG = option in your code). If you intended to specify a pure GJR-GARCH model without autoregressive errors, then you may want to remove the NLAG = option in your version 2 PROC AUTOREG code.

 

Once you have removed the NLAG = option in your version 2 PROC AUTOREG code, then both versions specify a GJR-GARCH model without AR errors, but they are equivalent with some re-parameterization as discussed below:

 

In your version 1 PROC MODEL code, it specifies that:

 

      if zlag(resid.y) > 0 then 
         h.y = arch0 + arch1*xlag(resid.y**2,mse.y) + garch1*xlag(h.y,mse.y)  ;
      else
         h.y = arch0 + arch1*xlag(resid.y**2,mse.y) + garch1*xlag(h.y,mse.y) +
               phi*xlag(resid.y**2,mse.y) ;

 

*Note: the resid.y is an internal variable in PROC MODEL defined as:

resid.y = pred.y - actual.y

 

SAS Help Center: Equation Translations

 

this means that resid.y in PROC MODEL is the negative of the residual usually defined in the literature(which is actual - predicted).  So the variance equation in the version 1 PROC MODEL code is defined as 

 

if epsilon_t-1  < 0 , then 

h_t = arch0 + arch1*(epsilon_t-1)**2 + garch1*h_t-1 ;

 

else if epsilon_t-1 >=0 then

h_t = arch0 + arch1*(epsilon_t-1)**2 + garch1*h_t-1 + phi*(epsilon_t-1)**2 

 

 

While in version 2 PROC AUTOREG code(after removing NLAG = 1 option from your code), the GJR-GARCH model specifies the variance equation as discussed in the following section:

 

SAS Help Center: GARCH Models

 

h_t = omega + (alpha1 + I_{epsilon_t-1 < 0}*psi1)*(epsilon_t-1)**2 + gamma1*h_t-1

 

 where I_{epsilon_t-1<0} is the indicator that takes the value 1 when epsilon_t-1 <0, and takes the value of 0 when epsilon_t-1 > = 0. The above variance equation is thus translated as:

 

if epsilon_t-1 < 0, then

h_t = omega + (alpha1 + psi1)*(epsilon_t-1)**2 + gamm1*h_t-1 ;

 

else if epsilon_t-1 >=0 then 

h_t = omega + alpha1*(epsilon_t-1)**2 + gamma1*h_t-1 ;

 

Corresponding to the parameter names in PROC AUTOREG parameter estimates table,

 

omega = TARCHA0

alpha1 = TARCHA1

psi1     = TARCHB1 

gamma1 = TGARCH1

 

Comparing the variance equations in the two versions, they are equivalent with the following reparameterization:

 

Version 1  PROC MODEL                                        Version 2 PROC AUTOREG(after removing NLAG = option)

arch0                                                                             TARCHA0

arch1                                                                              TARCHA1 + TARCHB1

arch1 + phi                                                                    TARCHA1

garch1                                                                            TGARCH1

 

From row 2 and row 3 above, you can see that phi and TARCHB1 is negative of each other:

 

phi = -TARCHB1

 

******************************************************

Or alternatively, you may simply modify your version 1 PROC MODEL code by reversing the variance equations between the cases zlag(resid.y) >0 and  zlag(resid.y)<=0, i.e., specify the following variance equations instead:

 

      /* variance model */
      if zlag(resid.y) <= 0 then 
         h.y = arch0 + arch1*xlag(resid.y**2,mse.y) + garch1*xlag(h.y,mse.y)  ;
      else
         h.y = arch0 + arch1*xlag(resid.y**2,mse.y) + garch1*xlag(h.y,mse.y) +
               phi*xlag(resid.y**2,mse.y) ;

 

then the two versions will have one on one matching on all the parameters.

 

I hope this helps.

 

Wen

 

Gigiwen
Calcite | Level 5

hi, Wen, thanks for your detailed replies.  Following your advise, I have change into the following:

/* Verion 1 */
proc model data = oneCoin ;
   parms arch0 .1 arch1 .2 garch1 .75 phi .1;
   /* mean model */
   ret = intercept ;
   /* variance model */
   if zlag(resid.ret) <= 0 then
      h.ret = arch0 + arch1*xlag(resid.ret**2,mse.ret) + garch1*xlag(h.ret,mse.ret)  ;
   else
      h.ret = arch0 + arch1*xlag(resid.ret**2,mse.ret) + garch1*xlag(h.ret,mse.ret) +
            phi*xlag(resid.ret**2,mse.ret) ;
   /* fit the model */
   fit ret / method = marquardt fiml ;
run ;
quit ;

/* Verion 2 */
proc autoreg data=oneCoin ;
   model ret =    / garch=(p=1, q=1, type=gjrgarch) ; 
run ;

 

The output are not identical, but I guess they are close enough. Thank you!

Gigiwen_0-1712804616792.png

 

 

 

 

 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

Multiple Linear Regression in SAS

Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 2636 views
  • 0 likes
  • 2 in conversation