Rolling window realized GARCH

For questions regarding programming in the EViews programming language.

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

cgsantamaria
Posts: 5
Joined: Mon Mar 04, 2019 8:02 pm

Rolling window realized GARCH

Postby cgsantamaria » Fri Mar 08, 2019 2:30 pm

Hi to everybody I´m proving to make a rolling window with a realized GARCH of Hansen. I need to evaluate the model and estimate in sample and out of sample a parametric Value at Risk. Well, I attach the code and the file and the problem is about the matrix "coefmat" that shows the same values of each coefficient of rolling window. Maybe I have a problem with the sampel? Could somebody help me?

Thank you!!!!
Attachments
rolling window rgarch.prg
(1.68 KiB) Downloaded 252 times
data SP500.WF1
(38.8 MiB) Downloaded 266 times

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

Re: Rolling window realized GARCH

Postby EViews Gareth » Fri Mar 08, 2019 3:36 pm

You're using the same sample to estimate under in each iteration of your loop.
Follow us on Twitter @IHSEViews

cgsantamaria
Posts: 5
Joined: Mon Mar 04, 2019 8:02 pm

Re: Rolling window realized GARCH

Postby cgsantamaria » Wed Mar 13, 2019 3:16 pm

Thank you for your soon answer!!! I understand the fail, but how can I do to solve this? Cause I make in:

´ estimate equation
sample s0 @first @first+1
sample s1 @first+2 @last
smpl @all

And the program displays "s0 already exists...."

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

Re: Rolling window realized GARCH

Postby EViews Gareth » Wed Mar 13, 2019 3:23 pm

Use smpl to set the sample.
Follow us on Twitter @IHSEViews

cgsantamaria
Posts: 5
Joined: Mon Mar 04, 2019 8:02 pm

Re: Rolling window realized GARCH

Postby cgsantamaria » Thu Mar 14, 2019 3:23 pm

It is like this?

´ estimate equation
smpl s0 @first @first+1
smpl s1 @first+2 @last
smpl @all

Because doesn´t works

cgsantamaria
Posts: 5
Joined: Mon Mar 04, 2019 8:02 pm

Re: Rolling window realized GARCH

Postby cgsantamaria » Sun Mar 17, 2019 1:29 pm

That´s my code

'run rolling regression

' set window size
!window = 3750
' set step size
!step = 1

' get size of workfile
!length = @obsrange

' declare equation for estimation
equation eq01

'calculate number of rolls
!nrolls = @ceiling((!length-!window)/!step)

'matrix to store coefficient estimates
matrix(9,!nrolls) coefmat ' where 9 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-1+!window-2

' estimate equation

smpl @first @first+1
smpl @first+2 @last
smpl @all

' declare coef vectors to use in ARCH likelihood

smpl @first+2 @last
coef(1) mu = 0.022616
coef(1) omega1 = 0.085462
coef(1) beta1 = 0.568876
coef(1) gamma1 = 2.475915
coef(1) xi = -0.008748
coef(1) phi = 0.153614
coef(2) tau
coef(1) tau11 = -0.018957
coef(1) tau12 = 0.022325
coef(1) sigma = 0.072021

'get starting values

smpl @first @first+1
series ht = omega1(1)
series res = 0.1
series nt = 0.1
!pi = @acos(-1)

' set up ARCH likelihood

logl logl11
logl11.append @logl logl
logl11.append @byeqn
logl11.append res = rt-mu(1)
logl11.append ht = omega1(1)+beta1(1)*ht(-1)+gamma1(1)*rkvar(-1)
logl11.append nt = res/@sqrt(ht)
logl11.append ut = rkvar-xi(1)-phi(1)*ht-tau11(1)*nt-tau12(1)*((nt^2)-1)
logl11.append logl = -0.5*log(2*!pi)-0.5*log(ht)-0.5*((res^2)/ht)-0.5*log(2*!pi)-0.5*log(sigma(1))-0.5*((ut^2)/sigma(1))

' estimate and display results
smpl @first+2 @last
logl11.ml(showopts, m=1000, c=1e-5, optmethod=legacy, cov=white)
show logl11.output

'store coefficients
colplace(coefmat,logl11.@coefs,!j)

next

show coefmat


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 25 guests