Page 1 of 2

Rolling GARCH with forecasting

Posted: Thu Apr 16, 2009 3:10 am
by thomasft
Hi guys :)

I need to do a rolling estimation of a GARCH(1,1), outputting 1-day ahead forecast for the conditional variance.
I have 2869 observations a need a rolling window of 783. Therefor the first estimated GARCH should be based on observation 1 through 783, outputting a forecasted conditional variance for observation 784. Hereafter a new estimation based on 2 through 784, forecasting a conditional variance for observation 785 etc etc.
From other studies I have pieced together this code:

Code: Select all

load var 'workfile with a return series called "return" containing 2869 observations scalar noobs=2869 scalar nw=783 matrix(2869,1) results for !i=nw to noobs smpl !i-nw !i equation garch_n garch_n.ARCH(1,1) return smpl !i !i garch_n.forecast se var scalar condvari_n = var smpl @all results(!i,1)=condvari_n next
But apparently it doesnt work - can anyone give me a hint?

Secondly, I am looking into simulating a GARCH model 1000 times, calculating a return and finding the 5% quantile of the 1000 simulations. My code looks like this:

Code: Select all

matrix(!sim,1) var_n matrix(1,1) result 'SIMULATE !m=1000 for !sim=1 to !m equation garch_n garch_n.ARCH(1,1) return scalar omega_n = garch_n.@coefs(1) scalar alpha_n = garch_n.@coefs(2) scalar beta_n = garch_n.@coefs(3) series z = nrnd series sigmat2_n = omega_n + (alpha_n * z(-1)^2) + (beta_n * sigmat2_n(-1)) series r_n = z*@sqrt(sigmat2_n) var_n(!sim)=r_n next result=@quantile(var_n, 0.05)
Is this code correct?

Re: Rolling GARCH with forecasting

Posted: Thu Apr 16, 2009 10:53 pm
by Gene
You need to set sample to the next period for the forecast.

Code: Select all

smpl !i+1 !i+1
As for the next set of code there is an issue with the line

Code: Select all

series sigmat2_n = omega_n + (alpha_n * z(-1)^2) + (beta_n * sigmat2_n(-1))
the first observation is calculated as

sigmat2_n(t=1) = omega_n + (alpha_n * z(t=0)^2) + (beta_n * sigmat2_n(t=0))

See the problem? z(t=0) = NA, sigmat2_n(t=0)=na. So, sigmat2_n(t=1) = NA, and therefore sigmat2_n(t=2) = NA, etc.

I would do:

Code: Select all

smpl @all series z = nrnd series sigmat2_n = z^2 smpl @first+1 @last series sigmat2_n = omega_n + (alpha_n * z(-1)^2) + (beta_n * sigmat2_n(-1))
A second problem. You have

Code: Select all

var_n(!sim) = r_n
But var_n(!sim) is an 1x1 matrix (or scalar) and r_n is a n-length series, where n is the length of you workfile. They won't match.

There might be more problems.

Re: Rolling GARCH with forecasting

Posted: Wed Jul 29, 2009 6:34 am
by Vaal1
Hi

I am quite new to using Eviews programs and I would like to implement the first code, rolling GARCH (1,1), for my present study. However, when I try to do so, it doesn't quite work. I keep geting an error message: series assigned to scalar in: ''SCALAR CONDVARI_N=VAR'' , and there are of course no results. I would be very grateful if you can tell me how to fix this problem please.

Re: Rolling GARCH with forecasting

Posted: Wed Jul 29, 2009 9:43 am
by tchaithonov
Isn't var a series when you load it? What you've possibly done (I didn't really see that scalar condvari_n =var line anywhere in your code) is you are creating a scalar holder called condvari_n to hold var, which is, as the complaint says, a series. Maybe you want to change it to series condvari_n = var? I am just guessing since I don't know what you are trying to do.

Re: Rolling GARCH with forecasting

Posted: Wed Jul 29, 2009 10:40 am
by Vaal1
Hi

I have modified the code according to your suggestion. At first it seems to work, but there are no results being generated. In this framework, I have a rolling window of 200 points and an overall sample size of 2703. Thus, at the end of the rolling estimation stage, I should end up with 2503 GARCH(1,1) estimates. However, after eviews finishes the computations, my results vector is only filled with zeroes. I have re-posted the code, and would be very grateful for any suggestions.

Code: Select all

scalar noobs=2702 scalar nw=2000 matrix(2703,1) results for !i=nw to noobs smpl !i-nw !i equation garch_n garch_n.ARCH(1,1) return smpl !i+1 !i+1 garch_n.forecast se var scalar condvari_n smpl @all results(!i,1)=condvari_n next

Re: Rolling GARCH with forecasting

Posted: Wed Jul 29, 2009 10:48 am
by startz
I think you've forgotten to put the result you want into condvari_n.

Re: Rolling GARCH with forecasting

Posted: Wed Jul 29, 2009 10:55 am
by Vaal1
Hi

Thanks for the response. However, doesn't this line put the result into condvari_n? If not how do I go about doing so?

Code: Select all

results(!i,1)=condvari_n
Thanks

Re: Rolling GARCH with forecasting

Posted: Wed Jul 29, 2009 11:08 am
by startz
Hi

Thanks for the response. However, doesn't this line put the result into condvari_n? If not how do I go about doing so?

Code: Select all

results(!i,1)=condvari_n
Thanks
No, that puts condvari_n into results(!i,1), not the other way around. So first you have to get whatever you're looking for into condvari_n.

Re: Rolling GARCH with forecasting

Posted: Wed Jul 29, 2009 11:16 am
by Vaal1
Hi

Therein lies my problem: how do I get the computed GARCH(1,1) estimates into condvari_n? Any suggestions?

Thanks

Re: Rolling GARCH with forecasting

Posted: Wed Jul 29, 2009 10:07 pm
by tchaithonov
First of all, I am not sure why you have "return" after your <model_name>.arch, it shouldn't even work. Correct me if I am wrong, but isn't <model_name>.arch only pops up an ARCH result window for "Method: ML - ARCH (Marquardt) - Normal distribution"? Check the manual and see if there is a way to save the result separately.

So, the variable that contains the y_hat SERIES coming out from the forecast is "var". And in the latest code that you posted, you just created an empty scalar called condvari_n and putting it into an undeclared table RESULTS? Don't you need to do, at least, the following step?

Code: Select all

table(noobs-nw,1) results ' this would be before the for loop ... ' (inside the loop) results(!i,1) = .... ' whatever scalar values you are planning to drop into the table


Since you haven't assigned anything to condvari_n, obviously eviews would give you zeros as a result. Make sure you understand what values you want to get out of the ARCH, and find out from the manual what is the appropriate command to get the values you need.

Rolling GARCH with forecasting

Posted: Wed Jul 06, 2011 5:50 pm
by Abelima
hy!
please,
I want to know how to program the FIGARCH model in Eviews
thank you...
Abelima

Re: Rolling GARCH with forecasting

Posted: Mon Aug 08, 2011 4:24 pm
by fariz888
Dear users,

I m recently doing my dissertation and faced with problem in estimation basic rolling GARCh (1,1) process. I have 2500 observation and need to forecast 1 day ahead volatility in rolling form. I will highly appreciate if advanced users provide me assistance in that issue.. I looked guideline but there was no information. In addition I have 6 day remaining to finish my dissertation. So I need your help immediately. Please share any knowledge that you have in that issue

Sincerely

Fariz

Thanks all

Re: Rolling GARCH with forecasting

Posted: Wed Oct 05, 2011 6:53 am
by stasibab
Hi,
Probably its a stupid question but I am forecasting the conditional volatility with GARCH(1,1) model using static forecast in eviews. When I click forecast my last observation in the out-sample-forecast is N.A for both the conditional volatilty and the s.e (see vol1, vol2 in the attached). Isn't the last observation in vol1&vol2 series ,the forecast of conditional volatility and the s.e for period (t=2295)

Any ideas why?

Thank you in advance!

Re: Rolling GARCH with forecasting

Posted: Wed Oct 05, 2011 7:52 am
by EViews Gareth
Without knowing what you did, it is hard to know what you did wrong.

Re: Rolling GARCH with forecasting

Posted: Wed Oct 05, 2011 10:52 am
by stasibab
I am sorry I did not send you the eviews file with the equation.

Now you will be able to see it.