Page 1 of 1
Rolling window realized GARCH
Posted: Fri Mar 08, 2019 2:30 pm
by cgsantamaria
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!!!!
Re: Rolling window realized GARCH
Posted: Fri Mar 08, 2019 3:36 pm
by EViews Gareth
You're using the same sample to estimate under in each iteration of your loop.
Re: Rolling window realized GARCH
Posted: Wed Mar 13, 2019 3:16 pm
by cgsantamaria
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...."
Re: Rolling window realized GARCH
Posted: Wed Mar 13, 2019 3:23 pm
by EViews Gareth
Use smpl to set the sample.
Re: Rolling window realized GARCH
Posted: Thu Mar 14, 2019 3:23 pm
by cgsantamaria
It is like this?
´ estimate equation
smpl s0 @first @first+1
smpl s1 @first+2 @last
smpl @all
Because doesn´t works
Re: Rolling window realized GARCH
Posted: Sun Mar 17, 2019 1:29 pm
by cgsantamaria
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