GARCH Forecasting with GARCHFORE and MVGARCHFORE

Use this forum for posting example programs or short bits of sample code.
TomM
Posts: 20
Joined: Tue Oct 24, 2006 3:34 pm

GARCH Forecasting with GARCHFORE and MVGARCHFORE

Unread post by TomM »

This is an example which uses MVGARCHFORE in a non-trivial fashion. Note that because "h" is a SERIES[SYMMETRIC], you reference its elements as h(time)(i,j).

This also demonstrates the univariate forecasting procedure, GARCHFORE.

The example is from Ruey Tsay's Analysis of Financial Time Series.

Code: Select all

*
* Tsay, Analysis of Financial Time Series, 3rd edition
* Example from section 10.7 from pp 546-548
*
open data d-spcscointc.txt
data(format=free,org=columns) 1 2275 sp500 cisco intel
*
* Create the two mean equations, and group them into a model
*
equation eq1 cisco
# constant cisco{1 2 3}
equation eq2 intel
# constant
group bimodel eq1 eq2
*
* Do the univariate GARCH models and forecast the variances. (You need
* to do the variance forecasts immediately after the GARCH instruction)
*
garch(equation=eq1,p=1,q=1,resids=a1,hseries=h1)
@garchfore(steps=1) h1 a1
garch(equation=eq2,p=1,q=1,resids=a2,hseries=h2)
@garchfore(steps=1) h2 a2
*
* Forecast the means
*
forecast(model=bimodel,steps=1,results=rhat)
compute q1=rhat(1)(2276)+%invnormal(.05)*sqrt(h1(2276))
compute q2=rhat(2)(2276)+%invnormal(.05)*sqrt(h2(2276))
vcv(noprint)
# a1 a2
compute rho=%sigma(1,2)/sqrt(%sigma(1,1)*%sigma(2,2))
compute q12=sqrt(q1^2+q2^2+2*rho*q1*q2)
*
disp "Univariate Models"
disp "VaR on Cisco" @20 -10000*q1
disp "VaR on Intel" @20 -10000*q2
disp "VaR Overall" @20 10000*q12
*
garch(model=bimodel,p=1,q=1,mv=cc,hmatrices=h,rvectors=a)
*
@mvgarchfore(steps=1,mv=cc) h a
forecast(model=bimodel,steps=1,results=rhat)
*
compute q1=rhat(1)(2276)+%invnormal(.05)*sqrt(h(2276)(1,1))
compute q2=rhat(2)(2276)+%invnormal(.05)*sqrt(h(2276)(2,2))
compute rho=h(2276)(1,2)/sqrt(h(2276)(1,1)*h(2276)(2,2))
compute q12=sqrt(q1^2+q2^2+2*rho*q1*q2)
disp "Bivariate Model"
disp "VaR on Cisco" @20 -10000*q1
disp "VaR on Intel" @20 -10000*q2
disp "VaR Overall" @20 10000*q12
Data file:
d-spcscointc.txt
(55.57 KiB) Downloaded 1188 times
Tom Maycock
Estima

support@estima.com
HinderAlex
Posts: 5
Joined: Thu Mar 08, 2007 9:23 am

Unread post by HinderAlex »

Hi, where can I find the data file d-spcscointc.txt? I am still using RATS version 6.20. :?:
TomM
Posts: 20
Joined: Tue Oct 24, 2006 3:34 pm

Unread post by TomM »

You can find the data files on Ruey Tsay's web site. The link in our "textbook examples" section should take you there.

Or order RATS 6.35, which will be shipping in a few days.
Tom Maycock
Estima

support@estima.com
Gregory
Posts: 20
Joined: Mon Nov 13, 2006 8:05 am

Re: GARCH Forecasting with GARCHFORE and MVGARCHFORE

Unread post by Gregory »

TomM wrote: *
disp "Univariate Models"
disp "VaR on Cisco" @20 -10000*q1
disp "VaR on Intel" @20 -10000*q2
disp "VaR Overall" @20 10000*q12
*

I tried running this with my own series. Everything works fine until this point. I get NA for the VaRs. What does the @20 refer to? If it is a line result, then that may be my problem because I added a couple of lines to the code.
"You sound pretty good, kid, but can your mom recognize you on the radio?"
- Les Paul
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Unread post by TomDoan »

The @20's will have no effect on the values - they just position all the VaR values to the same position in the output.

If you're getting NA's, you should check the pieces that go into the final calculation. The rhat's are the forecast means and the h's are the forecast variances. One or the other has to be NA's. It's more likely to be a problem with the forecasts - you can stick a PRINT option on the FORECAST instruction to see.
Post Reply