My name’s Arun, I’m from Thailand. I’m in my senior year studying Economics at Chulalongkorn University
Now I’m doing my dissertation about comparing the effectiveness of calculating Value-at-Risk between varied methods (models). One of them is a semi-parametric method (called “Filtered Historical Simulation (FHS)”) which is the combination of parametric method from GARCH-type models (I use GJR-GRACH this time) and non-parametric method from simulations.
I have to write code in E-views programming which I have gathered from many sources. Then, I used the FHS method with rolling estimate and also calculated a 1-day Value-at-Risk (using @quantile command) with 99% confidence interval in every window (250 days in each window). Then, I received error messages.
“ -47 is not a valid index for vector-series-coefficient TGARCH1ERR in “RT_BOOT_FOR(1,1)= TGARCH1ERR(U(1,1))*@SQRT(HT_BOOT_FOR(1,1))”. “
Another Error message is ...
“(3,1) is not valid index for matrix HT_NORM_FOR in “HT_NORM_FOR(2+1,1=3.510…E-06+0.02177…*RT_BOOT_FOR(2,1)^2+0.97706…*HT_BOOT_FOR(2,1) -0.0374…*RT_BOOT_FOR(2,1)*(RT_BOOT_FOR(2,1) - @ABS(RT_BOOT_FOR(2,1)))/2”. ”
Every time I run the program, these error messages appear and the number (-47) changes to other negative integral numbers as then same problem as the number in parenthesis.
Here is my code. It would be very grateful for any help.
Code: Select all
!window = 250 'set window workfile
!length = @obsrange ' get size of workfile
series value2 ' declare series to store results
scalar nperiods=1
scalar nsim=5000
scalar T =250
' compute stats for each window
for !k = 1 to !length-!window+1
smpl @first+!k-1 @first+!k+!window-2
equation tgarch!k.arch(1,1,thrsh=1) ds50
'save the conditional GARCH variance
tgarch!k.makegarch tgarch!kvar
'compute th corresponding vol
series tgarch!kvol=@sqrt(tgarch!kvar)
'compute the standardize residuals
series tgarch!kerr=ds50/tgarch!kvol
!x1=c(1)
!x2=c(2)
!x3=c(3)
!x4=c(4)
matrix u=@round((T-1)*@mnrnd(nperiods, nsim))+1
matrix(nperiods+1, nsim) ht_boot_for=tgarch!kvar(T)
matrix(nperiods, nsim) rt_boot_for
vector(nsim) ret_cum_boot=0
for !j=1 to nsim
for !i=1 to nperiods
rt_boot_for(!i, !j)=tgarch!kerr(u(!i, !j))*@sqrt(ht_boot_for(!i, !j))
ht_norm_for(!i+1, !j)=!x1+!x2*rt_boot_for(!i, !j)^2+!x4*ht_boot_for(!i, !j)+!x3*rt_boot_for(!i, !j)*(rt_boot_for(!i, !j)-@abs(rt_boot_for(!i, !j)))/2
ret_cum_boot(!j)=ret_cum_boot(!j)+rt_boot_for(!i, !j)
next
next
!var2 = @quantile(ret_cum_boot,0.01)
' reset to one observation sample
smpl @first+!k-1 @first+!k-1
' and assign to series
value2 = !var2
next
smpl @all
