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
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:
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.
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:
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.
Thank you so much, This is working really well!
Regards,
Amanjot
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.