GARCH with new estimation window

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt

Davidkuyt
Posts: 3
Joined: Fri Dec 05, 2014 1:02 pm

GARCH with new estimation window

Postby Davidkuyt » Fri Dec 05, 2014 1:10 pm

Hello everyone,

I am in the middle of the process of writing a thesis about GARCH and its performance on risk management. However, I'm completely stuck! I search the whole internet for this problem, but I simply do not have the knowledge to understand the codes and transform them to my own needs...

I have 3000 daily return observations, called "returns". I want to use GARCH to get the right parameters for volatility forecasting. My estimation window is 500 observations. So I use the first 500 observations to get my parameters. I go to Quick -> Estimate Equation -> Mean Equation: Returns -> Arch 1, Garch 1 -> Sample: the timespan which runs from the first to the 500th observation -> OK.

This gives me the values for C, RESID(-1)^2, GARCH(-1) and the value for the Log Likelihood. I have to have the coefficient values, and I prefer to also have the Log likelihood value (but this is not that hardly needed..).

After that I need to roll the window 1 day, so that my sample runs from the second observation till the 501th.

At the end I want to have a file with all the coefficient values..

As you can probably see, this will take years and years to do. Could someone please make some code for me? It would completely save my Master thesis..

EDIT: I forgot to mention; I'm using Eviews 7 :)

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13604
Joined: Tue Sep 16, 2008 5:38 pm

Re: GARCH with new estimation window

Postby EViews Gareth » Fri Dec 05, 2014 3:21 pm


Davidkuyt
Posts: 3
Joined: Fri Dec 05, 2014 1:02 pm

Re: GARCH with new estimation window

Postby Davidkuyt » Fri Dec 05, 2014 3:57 pm

First of all, thanks for the very quick response! I looked at the code, and I think that it is the one I'm searching for. However, I have no idea what I'm doing. I just have to do this code for 500 stocks each, and I don't really have to know the idea behind the system.

Code: Select all

series y=return '------------------------------------------------------------------------------------- 'run rolling regression ' set window size !window =500 ' set step size !step = 1 ' get size of workfile !length = @obsrange ' declare equation for estimation equation eq1 'calculate number of rolls !nrolls = @round((!length-!window)/!step) 'matrix to store coefficient estimates matrix(3,!nrolls) coefmat ' where 3 is the number of coefficients 'variable keeping track of how many rolls we've done !j=0 ' move sample !step obs at a time for !i = 1 to !length-!window+1-!step step !step !j=!j+1 ' set sample to estimation period smpl @first+!i-1 @first+!i+!window-2 ' estimate equation - where the equation is y=c(1) + c(2)*x1 + c(3)*x2 eq1.ls y c resid(-1)^2 garc 'store coefficients colplace(coefmat,eq1.@coefs,!j) next show coefmat
I understand the idea behind window size and step size. I also think that the return should be 'y'. However, I have no idea what I should do with the rest of the code.. I have to admit that I'm a complete noob with programming..

Could you please help me out a bit more?
Attachments
GARCH rolling window.wf1
The file that is being used
(51.03 KiB) Downloaded 154 times

Davidkuyt
Posts: 3
Joined: Fri Dec 05, 2014 1:02 pm

Re: GARCH with new estimation window

Postby Davidkuyt » Sat Dec 06, 2014 3:31 am

Code: Select all

!window = 500 !step = 1 !length = @obsrange equation eq1 !nrolls = @round((!length-!window)/!step) matrix(3,!nrolls) coefmat ' where 3 is the number of coefficients !j=0 for !i = 1 to !length-!window+1-!step step !step !j=!j+1 smpl @first+!i-1 @first+!i+!window-2 ' estimate equation - where the equation is y=c(1) + c(2)*x1 + c(3)*x2 eq1.ls series02 c resid(-1)^2 garch(-1) colplace(coefmat,eq1.@coefs,!j) next show coefmat
Okay, I just need a little bit more help. I hope I have done everything right till this point.

Step 1. Quick Estimate Equation - Method: ARCH - Mean Equation: Series02 (these are my returns of the full sample) - Model GARCH/TARCH - ARCH 1 - GARCH 1 - OK.

Step 2. Name - Eq1 (because this was also the name in the original code)

Step 3. Run the programm. Everything seems to go wright, till the 'estimate equation - where the equation is y=c(1) + c(2)*x1 + c(3)*x2'. In the output of Equation EQ1 I can see three coefficients: C, Resid(-1)^2 and GARCH(-1). However, how should I refer to them in my code?

Currently I get the error message: GARCH is not defined in "Do_Eq1.LS Series02 C Resid(-1)^2 GARCH(-1)"


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests