Fluorite | Level 6

## Predicting variance for GJR-GARCH model

Hello Everyone,

I am trying to come up with the predicted values of conditional variance by using the following code (GJR-GARCH model):

proc model data = wti;
parms arch0 .1 arch1 .2 garch1 .75 phi .1;
y = intercept;
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 y / method = marquardt fiml;
run ;
quit ;

My data contains daily observations of Stock X returns. I want to run this GJR-GARCH model on yearly basis. The problem is this code does not generate the predicted values of conditional variance. Can you please help in this regard?

Regards,

Aman

1 ACCEPTED SOLUTION

Accepted Solutions
SAS Employee

## Re: Predicting variance for GJR-GARCH model

Hello @amanjot_42

In PROC MODEL, you can first assign the h.y variable to a temporary variable, say, h_y = h.y, then use the OUTVARS statement with the OUT = dataset option in the FIT statement to output the values of the h.y into the output data set. For example:

```   /* 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) ;      h_y = h.y ;
/* fit the model */
fit y / method = marquardt fiml out = outdata;      outvars h_y ;
run ;
quit ;proc print data = outdata; run;```

Please note that the GJR-GARCH model can also be specified directly in PROC AUTOREG with option

TYPE = THRES | THRESHOLD | TGARCH | GJR | GJRGARCH

in the MODEL statement. And you can use CEV = option in the OUTPUT statement in PROC AUTOREG to output the conditional error variance in the output data set, for example:

proc autoreg data =gjrgarch ;
model y = /garch =(p=1,q=1, type = gjr);
output out = out_auto cev = cev ;
run;

proc print data = out_auto; run;

Please also note that the GJR-GARCH model implemented in PROC AUTOREG has slightly different parameterizations on the indicator function as that specified in the above PROC MODEL step, see the equation for h_t in PROC AUTOREG documentation:

https://go.documentation.sas.com/doc/en/pgmsascdc/v_030/etsug/etsug_autoreg_details12.htm#etsug_auto...

where the indicator is equal to 1 when epsilon_t < 0, and equal to 0 otherwise. In the PROC MODEL code above, the indicator is for epsilon_t > 0 instead.  They are equivalent model with this slightly different parameterizations on the indicator function, and you can convert from one to the other as you wish.

I hope this helps.

3 REPLIES 3
SAS Super FREQ

## Re: Predicting variance for GJR-GARCH model

Moved post to "SAS Forecasting and Econometrics" board

, and calling @SASCom1 .

Koen

SAS Employee

## Re: Predicting variance for GJR-GARCH model

Hello @amanjot_42

In PROC MODEL, you can first assign the h.y variable to a temporary variable, say, h_y = h.y, then use the OUTVARS statement with the OUT = dataset option in the FIT statement to output the values of the h.y into the output data set. For example:

```   /* 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) ;      h_y = h.y ;
/* fit the model */
fit y / method = marquardt fiml out = outdata;      outvars h_y ;
run ;
quit ;proc print data = outdata; run;```

Please note that the GJR-GARCH model can also be specified directly in PROC AUTOREG with option

TYPE = THRES | THRESHOLD | TGARCH | GJR | GJRGARCH

in the MODEL statement. And you can use CEV = option in the OUTPUT statement in PROC AUTOREG to output the conditional error variance in the output data set, for example:

proc autoreg data =gjrgarch ;
model y = /garch =(p=1,q=1, type = gjr);
output out = out_auto cev = cev ;
run;

proc print data = out_auto; run;

Please also note that the GJR-GARCH model implemented in PROC AUTOREG has slightly different parameterizations on the indicator function as that specified in the above PROC MODEL step, see the equation for h_t in PROC AUTOREG documentation:

https://go.documentation.sas.com/doc/en/pgmsascdc/v_030/etsug/etsug_autoreg_details12.htm#etsug_auto...

where the indicator is equal to 1 when epsilon_t < 0, and equal to 0 otherwise. In the PROC MODEL code above, the indicator is for epsilon_t > 0 instead.  They are equivalent model with this slightly different parameterizations on the indicator function, and you can convert from one to the other as you wish.

I hope this helps.

Fluorite | Level 6

## Re: Predicting variance for GJR-GARCH model

Thank you so much, This is working really well!

Regards,

Amanjot

Discussion stats
• 3 replies
• 1118 views
• 2 likes
• 3 in conversation