Rolling AR(1)-GARCH(1,1)

Discussions of ARCH, GARCH, and related models
Farid
Posts: 19
Joined: Sun Jun 05, 2011 9:02 pm

Rolling AR(1)-GARCH(1,1)

Unread post by Farid »

Hi. I did model estimation first and then rolling procedure, although I'm not sure if it's correct. Seems like AR(1) is missing in the rolling stage, but I'm not sure. Here is the code.

Code: Select all

OPEN DATA "C:\Documents and Settings\admin\Desktop\teze.RAT"
CALENDAR(D) 2006:1:3
DATA(FORMAT=RATS) 2006:01:03 2010:12:08 RT
smpl 2 511
garch(p=1,q=1,reg,resids=u,hseries=h) / rt
# constant rt{1}

***Testing standardized residuals

set ustd = u/sqrt(h)
set ustdsq = ustd^2
correlate(qstat,number=40,dfc=1,title="LB Test") ustd
correlate(qstat,number=40,dfc=2,title="McLeod-Li Test") ustdsq
stats ustd


***Rolling GARCH
compute width=511
dec vect[series] coeffs(4)

do gend=width,1287

	if gend==width
		garch(p=1,q=1,resids=u,hseries=h,noprint) gend-width+1 gend rt

	else
		garch(p=1,q=1,resids=u,hseries=h,initial=%beta,hessian=%xx,noprint) $
			gend-width+1 gend rt

	compute %pt(coeffs,gend,%beta)

end do gend

TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Rolling AR(1)-GARCH(1,1)

Unread post by TomDoan »

You are indeed missing the AR(1) parts in the code inside the loop. You'll have to add the REG option and the supplementary card to each of the two GARCH instructions in the loop.
Farid
Posts: 19
Joined: Sun Jun 05, 2011 9:02 pm

Re: Rolling AR(1)-GARCH(1,1)

Unread post by Farid »

Thanks for quick response Tom. :

Code: Select all

OPEN DATA "C:\Documents and Settings\admin\Desktop\teze.RAT"
CALENDAR(D) 2006:1:3
DATA(FORMAT=RATS) 2006:01:03 2010:12:08 RT
smpl 2 511
garch(p=1,q=1,reg,resids=u,hseries=h) / rt
# constant rt{1}

***Testing standardized residuals

set ustd = u/sqrt(h)
set ustdsq = ustd^2
correlate(qstat,number=40,dfc=1,title="LB Test") ustd
correlate(qstat,number=40,dfc=2,title="McLeod-Li Test") ustdsq
stats ustd


***Rolling GARCH
compute width=511
dec vect[series] coeffs(4)

do gend=width,1287

	if gend==width
		garch(p=1,q=1,reg,resids=u,hseries=h,noprint) gend-width+1 gend rt
                            # constant rt{1}
	else
		garch(p=1,q=1,reg,resids=u,hseries=h,initial=%beta,hessian=%xx,noprint) $ gend-width+1 gend rt
		# constant rt{1}

	compute %pt(coeffs,gend,%beta)

end do gend
it gives an error "# SX19. This Character is Illegal Here >>>> #<<<<" after the second "# constant rt{1}". Do you know what could be a problem?


And I have got 1 more question regarding outputs:
1) Rolling Garch generates 4 coefficient series. From approximate values I logically figured out that Coef 3 stands for lagged error term coefficient, while Coeff 4 stands for lagged variance coefficient. Could you please tell what Coef 1 & 2 stand for?

Thanks in advance
moderator
Site Admin
Posts: 269
Joined: Thu Oct 19, 2006 4:33 pm

Re: Rolling AR(1)-GARCH(1,1)

Unread post by moderator »

You have a line continuation symbol ($) here,

garch(p=1,q=1,reg,resids=u,hseries=h,initial=%beta,hessian=%xx,noprint) $ gend-width+1 gend rt

but aren't continuing the command on the next line. RATS stops processing the line when it hits the $, so it is expecting to find the start, end, and dependent variable parameters on the next line, but sees the "#" instead.

You should either get rid of the $, or insert the expected line break--that is, either:

garch(p=1,q=1,reg,resids=u,hseries=h,initial=%beta,hessian=%xx,noprint) gend-width+1 gend rt
# constant rt{1}

or

garch(p=1,q=1,reg,resids=u,hseries=h,initial=%beta,hessian=%xx,noprint) $
gend-width+1 gend rt
# constant rt{1}

Also, I don't think your starting period is correct: "gend-width+1" returns "1" for the first trip through the loop, but you can't start the estimation at entry 1 due to the lags in the model.

Finally, you should have 5 coefficients, not 4, so you want to adjust the dimensions on that vector of series accordingly. The order in which GARCH presents the coefficients is described in the Reference Manual, and can be easily seen by removing the NOPRINT option on GARCH, but in this case, they are pretty straightforward: the constant and the AR{1} coefficients are first and second, then the constant term in the variance equation (C), followed by the lagged squared residual and lagged variance terms (A and B).

Regards,
Tom Maycock
Estima
Farid
Posts: 19
Joined: Sun Jun 05, 2011 9:02 pm

Re: Rolling AR(1)-GARCH(1,1)

Unread post by Farid »

Thanks a lot Tom. You are right gend-width+1 didn't work out with AR(1), while gend-width+2 generated forecasts(I changed it to +2 in both lines). Although I'm not sure how it will affect the overall forecasting process. Could you please comment on that?

I have got the following for now:

Code: Select all

OPEN DATA "C:\Documents and Settings\admin\Desktop\teze.RAT"
CALENDAR(D) 2006:1:3
DATA(FORMAT=RATS) 2006:01:03 2010:12:08 RT
smpl 2 511
garch(p=1,q=1,reg,resids=u,hseries=h) / rt
# constant rt{1}

***Testing standardized residuals

set ustd = u/sqrt(h)
set ustdsq = ustd^2
correlate(qstat,number=40,dfc=1,title="LB Test") ustd
correlate(qstat,number=40,dfc=2,title="McLeod-Li Test") ustdsq
stats ustd


***Rolling GARCH
compute width=511
dec vect[series] coeffs(5)

do gend=width,1287

	if gend==width
	   garch(p=1,q=1,reg,resids=u,hseries=h,noprint) gend-width+2 gend rt
	   # constant rt{1}

	else
	   garch(p=1,q=1,reg,resids=u,hseries=h,initial=%beta,hessian=%xx,noprint) gend-width+2 gend rt
	   # constant rt{1}

	compute %pt(coeffs,gend,%beta)

end do gend


moderator
Site Admin
Posts: 269
Joined: Thu Oct 19, 2006 4:33 pm

Re: Rolling AR(1)-GARCH(1,1)

Unread post by moderator »

Farid wrote:Although I'm not sure how it will affect the overall forecasting process. Could you please comment on that?
I'm not sure what you mean? What's the "it" you are referring to?

Tom
Farid
Posts: 19
Joined: Sun Jun 05, 2011 9:02 pm

Re: Rolling AR(1)-GARCH(1,1)

Unread post by Farid »

I guess now I got it. Thanks again.
Farid
Posts: 19
Joined: Sun Jun 05, 2011 9:02 pm

Re: Rolling AR(1)-GARCH(1,1)

Unread post by Farid »

Hi Tom,

I've attached 2 codes which should estimate AR(1)-GARCH(1,1,) coefficients by using initial sample of 505 days and then rolling the sample by 1 day each time. In one file I used GARCH command, in another - I made it more flexible(because my 2nd model must needs some flexibility) constructing mean and variance equations separately.


Could you please explain why they estimate different coefficients? Actually in the code where I constructed the equations separately some of the variance coefficients appear to be large(some even more than 1) and negative.
Attachments
FINAL - Daily.RAT
(32.5 KiB) Downloaded 1058 times
Normal AR(1)-GARCH(1,1) with separate equations.RPF
(701 Bytes) Downloaded 1053 times
Normal AR(1)-GARCH(1).RPF
(658 Bytes) Downloaded 1083 times
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Rolling AR(1)-GARCH(1,1)

Unread post by TomDoan »

The sequence of MAXIMIZE instructions will use for the pre-sample values of the variance the estimates obtained from the previous window. On the other hand, each GARCH uses the information only within its sample. When your window comes out of that zone in 2008 with very volatile data, you will have very high pre-sample variances on the MAXIMIZE, much higher than GARCH will generate. You then have a relatively quiet sample with a high pre-sample variance, which leads to rather unstable estimates.
Farid
Posts: 19
Joined: Sun Jun 05, 2011 9:02 pm

Re: Rolling AR(1)-GARCH(1,1)

Unread post by Farid »

What I aim to do is to estimate coefficients and variance/mean estimates over the moving window. For example, for estimating coefficients and h/u series for 706th day I want to use exclusively information from days 200-705(moving window of 505 days). And so on.

1) Does built-in GARCH instruction code or MAXIMIZE code fit for that purpose? (from what I understood from your previous reply GARCH is the relevant one, but I'm not sure).

2) Could you please tell me what this means and whether it contradicts the estimating procedure I described above (using the information exclusively from the moving window for estimating the next day's coefficients and h/u series).

Code: Select all

initial=%beta,hessian=%xx
Without it I get much poorer estimates with GARCH instruction.
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Rolling AR(1)-GARCH(1,1)

Unread post by TomDoan »

Farid wrote:What I aim to do is to estimate coefficients and variance/mean estimates over the moving window. For example, for estimating coefficients and h/u series for 706th day I want to use exclusively information from days 200-705(moving window of 505 days). And so on.

1) Does built-in GARCH instruction code or MAXIMIZE code fit for that purpose? (from what I understood from your previous reply GARCH is the relevant one, but I'm not sure).
That's what GARCH is doing. The MAXIMIZE loop as you've written it uses information from previous windows for the pre-sample variances.
Farid wrote: 2) Could you please tell me what this means and whether it contradicts the estimating procedure I described above (using the information exclusively from the moving window for estimating the next day's coefficients and h/u series).

Code: Select all

initial=%beta,hessian=%xx
Without it I get much poorer estimates with GARCH instruction.
The INITIAL and HESSIAN options do not change the likelihood that's being maximized; they just start the iteration process using the already converged estimates from the previous window.

There is no "unconditional" likelihood function for a GARCH model the way there is for an ARMA model. As a result, all GARCH likelihoods are conditional on the treatment of the pre-sample variances (and lagged squared residuals). You were getting different results because those pre-sample values were different in the different procedures and thus the likelihoods were different.
Post Reply