Rolling Garch code in Eviews 9

For questions regarding programming in the EViews programming language.

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

Student15
Posts: 19
Joined: Fri Apr 17, 2015 2:23 pm

Rolling Garch code in Eviews 9

Postby Student15 » Tue Jun 23, 2015 3:53 pm

Hi Eviews Gareth

I am estimating a Garch rolling regression with a moving window of 126 observations and a step size of 20.6. I have used the following code in Eviews 8 and I got some decent results, however when I use the same code in Eviews 9, I get the same value for each coefficient for the whole sample problem. Do you have any idea of what could be the problem with my code?

Code: Select all

'run rolling regression ' set window size !window = 126 ' set step size !step = 20.6 ' 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(9,!nrolls) coefmat ' where 9 is the number of coefficients matrix(9,!nrolls) tmat '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 ' estimate equation sample s0 @first @first+1 sample s1 @first+2+!i-1 @first+!i-1+!window-2 smpl @all ' declare coef vectors to use in ARCH likelihood coef(4) beta = 0 coef(3) alpha = 0 coef(1) dof = 0 coef(1) mu = 0 ' get starting values equation eq1.arch(1,1,ged,archm=sd,backcast=1) y c y(-1) eq1.makegarch garchm equation eq1.arch(1,1,ged,archm=sd,backcast=1) y c garchm*y(-1) y(-1) beta(1) = eq1.c(1) beta(2) = eq1.c(2) beta(3) = eq1.c(3) beta(4) = eq1.c(4) alpha(1) = eq1.c(5) alpha(2) = eq1.c(6) alpha(3) = eq1.c(7) dof(1) = eq1.c(8) mu(1) = eq1.@se^2 ' set presample values of expressions in logl series sig2 = mu(1) series resid = resid ' set up GARCH likelihood logl ll1 ll1.append @logl logl ll1.append @byeqn ll1.append resid = y - beta(2) - beta(1)*sig2 - beta(3)*sig2*y(-1)- beta(4)*y(-1) ll1.append sig2 = alpha(1)+ alpha(2)*resid(-1)^2 + alpha(3)*sig2(-1) ll1.append z = resid/@sqrt(sig2) ll1.append logl = log(@dged(z,dof(1))) - log(sig2)/2 ' declare coef vectors to use in ARCH likelihood coef(4) beta = 0 coef(1) thresh = 0 coef(3) alpha = 0 coef(1) dof = 0 coef(1) mu = 0 ' get starting values eq1.arch(1,1,thrsh=1,archm=sd,ged,backcast=1) y c y(-1) eq1.makegarch garchm eq1.arch(1,1,thrsh=1,archm=sd,ged,backcast=1) y c garchm*y(-1) y(-1) beta(1) = eq1.c(1) beta(2) = eq1.c(2) beta(3) = eq1.c(3) beta(4) = eq1.c(4) alpha(1) = eq1.c(5) alpha(2) = eq1.c(6) thresh(1) = eq1.c(7) alpha(3) = eq1.c(8) dof(1) = eq1.c(9) mu(1) = eq1.@se^2 ' set presample values of expressions in logl series sig2 = mu(1) series resid = resid ' set up GARCH likelihood logl ll1 ll1.append @logl logl ll1.append @byeqn ll1.append resid = y - beta(2) - beta(1)*sig2 - beta(3)*sig2*y(-1)- beta(4)*y(-1) ll1.append sig2 = alpha(1)+ alpha(2)*resid(-1)^2 + alpha(3)*sig2(-1) + thresh(1)*resid(-1)^2*(resid(-1)<0) ll1.append z = resid/@sqrt(sig2) ll1.append logl = log(@dged(z,dof(1))) - log(sig2)/2 ' estimate and display results smpl s1 ll1.ml(showopts, m=1000, c=1e-5) show ll1.output delete s0 s1 'store coefficients colplace(coefmat,ll1.@coefs,!j) colplace(tmat,ll1.@tstats,!j) next show coefmat show tmat
Thank you.
Attachments
daily returns-dated.wf1
(70.29 KiB) Downloaded 303 times

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

Re: Rolling Garch code in Eviews 9

Postby EViews Gareth » Wed Jun 24, 2015 7:08 am

How can you have a step size of 20.6?

Student15
Posts: 19
Joined: Fri Apr 17, 2015 2:23 pm

Re: Rolling Garch code in Eviews 9

Postby Student15 » Wed Jun 24, 2015 1:47 pm

Thank you Gareth for your response, the issue is I intend to have 115 rolls which translate into 115 monthly(rolling) coefficients over the sample period. So I used 20.6, which I now understand that it is mispecified, so that the number of rolls

Code: Select all

!nrolls = @round((!length-!window)/!step)
will equal to 115. I did not know if it is possible to simply state the actual number of rolls without specifying it as it is in the code. I have tried to change the step size to 21 and now I get 113 rolls, I have also tried to change the number of rolls to 115 but I get 113 filled columns and the remaining 2 are filled with zeros. The code still gives me the same value for each coefficient over the sample period. Please help me on how I can best solve this.

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

Re: Rolling Garch code in Eviews 9

Postby EViews Gareth » Wed Jun 24, 2015 2:27 pm

Two possible causes for the identical coefficients:
  • Your estimates are different in each iteration, but you're not recording them properly
  • Your estimates are the same in each iteration.
I would just stop the program randomly half way through and look at the estimation output and check what the estimates are. That should tell you which of the two cases it is. If the estimates are different in each iteration, you can take a look at the code that's recording them. If the estimates are the same in each iteration, either you're not changing the sample, or something funky is going on.

Student15
Posts: 19
Joined: Fri Apr 17, 2015 2:23 pm

Re: Rolling Garch code in Eviews 9

Postby Student15 » Thu Jun 25, 2015 5:08 am

Thank you for those suggestions. I have tried to stop the program halfway, several times and noted that the sample is changing but the coefficients alternate between these two values -0.052891 and -0.056721 over the sample period or it could be a case of a string of the same value (e.g -0.052891) and then alternates (e.g to -0.056721). I have also looked at this part of the code where the coefficients are recorded

Code: Select all

colplace(coefmat,ll1.@coefs,!j) colplace(tmat,ll1.@tstats,!j)
and tried to change where the estimates are stored from i.e either eq1 or ll1. The coefficients from eq1 are negative and statistically significant whereas those from ll1 are still negative but insignificant and the coefficient values are similar in both cases. May you please check if my whole code is right. Thank you.


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests