TomDoan wrote:You're doing one-step, which are deterministic, so yes, all the stats are the same.
As written, if you extend it beyond one step, you'll be overwriting the 2 to H step forecasts with the next pass through the loop---you can't wait until after the outer loop to do the calculations of the means.
To change to a fixed starting point window instead (recursive scheme) remove t1 from istart+t1? Right? Although, the UG says to be very careful about making an estimation window too narrow for a moving window.
How else could I improve the loop to (maybe) include multistep ahead bootstrapped forecasts?
I also want to backtest EGARCH with t-errors:
garch(p=1,q=1,exp,asymmetric,hseries=h,noprint,DIST=T)
TomDoan wrote:
Convergence issues are covered in the User's Guide---the GARCHBACKTEST.RPF example shows how to handle that (see the last part of the section before that). Moving window estimation of GARCH models is, in general, a really bad idea. (Extending the sample is fine; the problem is removing the front of the sample). It creates all kinds of estimation issues and has no tangible effect on the estimated variances at the end of the sample other than through the changes in the estimated coefficients. (Given a particular set of GARCH estimates, the H at T=1000 will be the same to any reasonable standard whether you start the recursion at T=1 or T=500---initial conditions wash long before that).
Interestingly, the UG also says:
The calculated value of the GARCH variance rarely depends on more than about the last 100 data points anyway, so the only effect of the rolling sample is to change the parameters, not (necessarily) for the better --- which I didn't know.
I have removed the 100.0 from the return calculation, to adjust the scaling, and have set a portfolio value = 100
set dlogdm = log(dm/dm{1})
comp value = 100
And calculated VaR without the expected return (as from descriptive statistics SE >> Sample Mean, which is almost always very near zero in daily financial returns). So, VaR = -quantile * sigma * portfolio value.
Further, I have plotted -VaR i.e. upside-down VaR and calculated a violation ratio vr.
How do I graph Exceedence plots: 2 scale with returns as a cloud of small dots rather than traditionally as a 'sound-wave', -VaR forecasts as a line, and the trigger/exceedence values as dots?
Code: Select all
*===============================
clear(len=iend+1) lower
clear(len=iend+1) upper
clear(len=iend+1) median
clear(len=iend+1) mean
set lower ibegin+1 iend+1 = %fractiles(hdraws(t),||.05||)(1)
set upper ibegin+1 iend+1 = %fractiles(hdraws(t),||.95||)(1)
set median ibegin+1 iend+1 = %fractiles(hdraws(t),||.50||)(1)
set mean ibegin+1 iend+1 = %avg(hdraws(t))
prin / dlogdm h lower upper median mean
*===============================
set fmean ibegin+1 %allocend()+1 = mean
set VaR ibegin+1 %allocend()+1 = -%invnormal(.01)*fmean*value
prin / fmean VaR
graph(header="Bootstrapped Forecasts for EGARCH model")
# VaR ibegin+1 %allocend()+1 2
set minusVaR ibegin+1 %allocend()+1 = -VaR
graph(header="Bootstrapped Forecasts for EGARCH model")
# minusVaR ibegin+1 %allocend()+1 2
*===============================
set ftrigger ibegin+1 iend = VaR/value
set trigger ibegin+1 iend = dlogdm < -ftrigger; * return is less than VaR
prin / dlogdm ftrigger trigger
sstats ibegin+1 iend trigger>>ntrigger
disp ntrigger
table ibegin+1 iend trigger
comp vr = ntrigger/((%allocend()-window)*.01); * violation ratio (vr)
disp vr