UV garch model forecasts

Discussions of ARCH, GARCH, and related models
ac_1
Posts: 465
Joined: Thu Apr 15, 2010 6:30 am

UV garch model forecasts

Unread post by ac_1 »

Hi Tom,

Questions regarding GARCH models:

1) I can estimate an EWMA model using ESMOOTH, however an EWMA is a special version of an IGARCH with fixed parameters e.g. alpha=0.06, beta=(1-0.06). How do I specify and estimate an IGARCH model with fixed parameters, equivalently?


2) To generate rolling one-step forecast sd's, the following produces a TRUE OOS forecast i.e. %allocend()+1

Code: Select all

garch(p=1,q=1,resids=u,hseries=h,noprint,nomean) tstart+i tend+i y
*
* Compute the one-step forecast for the sqrt(variance)
*
compute hhat = sqrt( %beta(1) + %beta(2)*u(tend+i)^2 + %beta(3)*h(tend+i) )
But RATS 10.0 UG says use group

Code: Select all

garch(p=1,q=1,hseries=ht,resids=at) / y
*
* Compute the one-step forecast for the variance
*
set uu tstart+i tend+i = at^2
*
compute vc=%beta(2), vb=%beta(4), va=%beta(3)
frml hfrml ht = vc + vb*ht{tend+i} + va*uu{tend+i}
frml uufrml uu = ht
group garchmod hfrml>>ht uufrml>>uu
forecast(model=garchmod,from=tend+1+i,to=tend+1+i,steps=1)
The forecast variance being the ht series, but I cannot generate a TRUE OOS forecast? Why?


3) Also, the manual says for EGARCH models simulate/bootstrap to generate forecasts. How do I do those recursively/rolling for EGARCH models with normal and t-distributed errors?


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

Re: UV garch model forecasts

Unread post by TomDoan »

ac_1 wrote:Hi Tom,

Questions regarding GARCH models:

1) I can estimate an EWMA model using ESMOOTH, however an EWMA is a special version of an IGARCH with fixed parameters e.g. alpha=0.06, beta=(1-0.06). How do I specify and estimate an IGARCH model with fixed parameters, equivalently?
ESMOOTH can "estimate" an EWMA model by applying it to squared "residuals", but where are you getting the residuals? Also, it uses a different objective function (the squared difference between the predicted variance and the squared residuals) than does GARCH, where the log likelihood combines a term in ratio of squared residuals to the predicted variance with a term that penalizes a high variance.

Why wouldn't you just estimate that using GARCH? EWMA applies to univariate models as well.
ac_1 wrote: 2) To generate rolling one-step forecast sd's, the following produces a TRUE OOS forecast i.e. %allocend()+1

Code: Select all

garch(p=1,q=1,resids=u,hseries=h,noprint,nomean) tstart+i tend+i y
*
* Compute the one-step forecast for the sqrt(variance)
*
compute hhat = sqrt( %beta(1) + %beta(2)*u(tend+i)^2 + %beta(3)*h(tend+i) )
But RATS 10.0 UG says use group

Code: Select all

garch(p=1,q=1,hseries=ht,resids=at) / y
*
* Compute the one-step forecast for the variance
*
set uu tstart+i tend+i = at^2
*
compute vc=%beta(2), vb=%beta(4), va=%beta(3)
frml hfrml ht = vc + vb*ht{tend+i} + va*uu{tend+i}
frml uufrml uu = ht
group garchmod hfrml>>ht uufrml>>uu
forecast(model=garchmod,from=tend+1+i,to=tend+1+i,steps=1)
The forecast variance being the ht series, but I cannot generate a TRUE OOS forecast? Why?
The description in the manual is for any number of out-of-sample steps. It even says explicitly that when k=0 you can do the calculation using just sample data. So I don't understand why you are trying to hack out the formulas in the text to do one-step forecasts. The procedure in the UG will work fine if you leave it as is---the whole point of FRML's is that they automatically adjust their calculations as the entries change. You're trying to change a FRML to hard code entry calculations.
ac_1 wrote: 3) Also, the manual says for EGARCH models simulate/bootstrap to generate forecasts. How do I do those recursively/rolling for EGARCH models with normal and t-distributed errors?
One step out forecasts are still closed form. That will be true of pretty much any GARCH model since the whole point of the model is to predict variance for the next time period.
ac_1
Posts: 465
Joined: Thu Apr 15, 2010 6:30 am

Re: UV garch model forecasts

Unread post by ac_1 »

TomDoan wrote:
ac_1 wrote:Hi Tom,

Questions regarding GARCH models:

1) I can estimate an EWMA model using ESMOOTH, however an EWMA is a special version of an IGARCH with fixed parameters e.g. alpha=0.06, beta=(1-0.06). How do I specify and estimate an IGARCH model with fixed parameters, equivalently?
ESMOOTH can "estimate" an EWMA model by applying it to squared "residuals", but where are you getting the residuals? Also, it uses a different objective function (the squared difference between the predicted variance and the squared residuals) than does GARCH, where the log likelihood combines a term in ratio of squared residuals to the predicted variance with a term that penalizes a high variance.

Why wouldn't you just estimate that using GARCH. EWMA applies to univariate models as well.
squared "residuals" = squared returns.

Sorry, but that does not answer my question. How do I set fixed parameters to estimate IGARCH, alpha=0.06, beta=(1-0.06)?

TomDoan wrote:
ac_1 wrote: 2) To generate rolling one-step forecast sd's, the following produces a TRUE OOS forecast i.e. %allocend()+1

Code: Select all

garch(p=1,q=1,resids=u,hseries=h,noprint,nomean) tstart+i tend+i y
*
* Compute the one-step forecast for the sqrt(variance)
*
compute hhat = sqrt( %beta(1) + %beta(2)*u(tend+i)^2 + %beta(3)*h(tend+i) )
But RATS 10.0 UG says use group

Code: Select all

garch(p=1,q=1,hseries=ht,resids=at) / y
*
* Compute the one-step forecast for the variance
*
set uu tstart+i tend+i = at^2
*
compute vc=%beta(2), vb=%beta(4), va=%beta(3)
frml hfrml ht = vc + vb*ht{tend+i} + va*uu{tend+i}
frml uufrml uu = ht
group garchmod hfrml>>ht uufrml>>uu
forecast(model=garchmod,from=tend+1+i,to=tend+1+i,steps=1)
The forecast variance being the ht series, but I cannot generate a TRUE OOS forecast? Why?
The description in the manual is for any number of out-of-sample steps. It even says explicitly that when k=0 you can do the calculation using just sample data. So I don't understand why you are trying to hack out the formulas in the text to do one-step forecasts. The procedure in the UG will work fine if you leave it as is---the whole point of FRML's is that they automatically adjust their calculations as the entries change. You're trying to change a FRML to hard code entry calculations.
The procedure in the UG is not generating rolling 1-step OOS forecasts, which I can do, but not with group for a TOOS forecast.
TomDoan
Posts: 7774
Joined: Wed Nov 01, 2006 4:36 pm

Re: UV garch model forecasts

Unread post by TomDoan »

If you are fixing the parameters, what are you "estimating"? That's just a calculation, which you can do just fine with ESMOOTH, or with a SET instruction. You *could* do it with GARCH, by using the INITIAL option and METHOD=EVALUATE, but that's massive overkill. See DIEB3P397.RPF in the Diebold textbook examples (which also does GARCH model forecasts).

I'm not sure what you mean by the "true" out-of-sample forecasts. I can assure you that the code given in the RATS manual, when applied one-step out of sample will give the correct forecast. (But again, if all you need is one-step, just do the straightforward calculation). I have no idea what the code that you posted will do, and I have no intention of trying to figure it out---the whole idea behind it is completely wrong.
ac_1
Posts: 465
Joined: Thu Apr 15, 2010 6:30 am

Re: UV garch model forecasts

Unread post by ac_1 »

Thanks. Yes,

declare vector[real] params(3)
comp params = ||0.0,0.06,0.94||

and GARCH with INITIAL=params, METHOD=EVALUATE, I get the same results as ESMOOTH.


Regarding 3), I would like to generate
(a) DYNAMIC multistep and
(b) rolling STATIC 1-step
SIMULATION and BOOTSTRAP volatility (sqrt of variance) OOS and TOOS forecasts, maybe including SE's for PI's, for the more complicated GARCH models, as in garchuvmax.rpf

But first here's an attempt at BOOTSTRAP (a) Dynamic volatility TOOS (i.e. beyond the last sample point) forecasts for an EGARCH(1,1) with normal errors, based on garchuv.rpf, I am not certain if it's correct?

Code: Select all

*===============================
comp regstart = 2
comp regend = 1867


garch(p=1,q=1,exp,asymm,hseries=ht,resids=at,nomean) regstart regend dlogdm

* Create the historical UU series
set uu = at^2
*
* Copy the coefficients out of the %BETA vector
*
compute vc=%beta(1), va=%beta(2), vb=%beta(3), vd=%beta(4)
*
* Define the forecasting model
*
frml hfrml ht = sqrt( exp( vc + vb*log(ht{1}) + va*( uu{1}/sqrt(ht{1}) ) + $
                           vd*( (abs(uu{1})/sqrt(ht{1})) - sqrt(2/%pi) ) ) )
frml uufrml uu = ht
group garchmod hfrml>>ht uufrml>>uu

*
* Compute average across bootstraps INCLUDING SE's
*
set fxfore_S regend+1 regend+10 = 0.0
set fxfore_SS regend+1 regend+10 = 0.0
set fxfore_M regend+1 regend+10 = 0.0
set fxfore_MSS regend+1 regend+10 = 0.0
set fxfore_SE regend+1 regend+10 = 0.0

*
* This gets into <<bstart>> to <<bend>> the range of residuals available
* for bootstrapping.
*
inquire(series=uu) bstart bend

compute ndraws=5000
do draw=1,ndraws

   boot entries regend+1 regend+10 bstart bend
   set shocks regend+1 regend+10 = uu(entries)
   forecast(paths,model=garchmod,from=regend+1,to=regend+10,results=sims)
   # shocks

   set fxfore_S regend+1 regend+10 = fxfore_S+sims(2)
   set fxfore_SS regend+1 regend+10 = fxfore_SS+(sims(2))^2

   * save SIMS(2) in a cloud of simulations
   dec vect[series] columns(ndraws)
   set columns(draw) regend+1 regend+10 = SIMS(2)

end do draw

*
* Calculate MEAN & SE of BOOTSTRAP forecasts
*
set fxfore_M regend+1 regend+10 = fxfore_S/ndraws
set fxfore_MSS regend+1 regend+10 = fxfore_SS/ndraws
set fxfore_SE regend+1 regend+10 = sqrt(fxfore_MSS-(fxfore_M)^2)

prin / fxfore_M fxfore_SE
TomDoan
Posts: 7774
Joined: Wed Nov 01, 2006 4:36 pm

Re: UV garch model forecasts

Unread post by TomDoan »

That's not the way RATS parameterizes EGARCH models and that's not how EGARCH models would be handled anyway. (You're trying to adapt the standard GARCH calculations to a model that has completely different form). See

https://www.estima.com/forum/viewtopic.php?f=8&t=1614
ac_1
Posts: 465
Joined: Thu Apr 15, 2010 6:30 am

Re: UV garch model forecasts

Unread post by ac_1 »

Based on egarchbootstrap.rpf, here's an attempt at rolling 1 step ahead fixed window bootstrap forecasts. Please can you have a look to see if its correct?

Code: Select all

*===============================
compute ndraws=10000

comp window = 1800; * 1867 to match Dynamic
comp value = 100

compute ibegin = 1800; * end of 1st regression, 1st forecast is for 1801
                       * OR ibegin = 1867; * end of 1st regression, 1st forecast is for 1868 to match Dynamic
compute istart = (2+ibegin-window-1)
compute iend   = %allocend()

dec series[vect] hdraws


*===============================
infobox(action=define,lower=0,upper=%allocend()-window,progress) "egarchbootstrap Model Backtest"

do t1 = 0, (iend-ibegin)
   *
   garch(p=1,q=1,exp,asymmetric,hseries=h) istart+t1 ibegin+t1 dlogdm
   *
   compute c=%beta(2),a=%beta(3),b=%beta(4),d=%beta(5)
   compute gstart=istart+t1,gend=ibegin+t1
   *
   set stdu = %resids/sqrt(h)
   *
   compute bstart=gend+1,bend=gend+1
   set h bstart bend = %na
   *
   gset hdraws bstart bend = %zeros(ndraws,1)
   *
   * Compute the one-step bootstrap forecast for the variance
   *
   do draw=1,ndraws
      boot entries bstart bend gstart gend
      *
      set stdu bstart bend = h=exp(c+b*log(h{1})+a*abs(stdu{1})+d*%max(stdu{1},0.0)),stdu(entries(t))
      do t=bstart,bend
         compute hdraws(t)(draw)=h(t)
      end do t
   end do draw
   *
   infobox(current=t1) "Model converged "+%converged
end do t1
infobox(action=remove)


*===============================
clear(len=iend+1) flower
clear(len=iend+1) fupper
clear(len=iend+1) fmedian
clear(len=iend+1) fmean
set flower ibegin+1 iend+1 = %fractiles(hdraws(t),||.05||)(1)
set fupper ibegin+1 iend+1 = %fractiles(hdraws(t),||.95||)(1)
set fmedian ibegin+1 iend+1 = %fractiles(hdraws(t),||.50||)(1)
set fmean ibegin+1 iend+1 = %avg(hdraws(t))

prin / dlogdm h flower fupper fmedian fmean
flower and fupper are almost the same as fmedian (as in ENTRY 1868 forecast in egarchbootstrap.rpf); and also fmean.

The obvious problems with backtesting GARCH models (e.g. for VaR) is convergence & gaps 0's /NA's; how to find a way around/circumvent these?
TomDoan
Posts: 7774
Joined: Wed Nov 01, 2006 4:36 pm

Re: UV garch model forecasts

Unread post by TomDoan »

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.

If you have gaps in your data, get rid of them. The standard treatment in GARCH modeling is to run the data into consecutive entries.

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).
ac_1
Posts: 465
Joined: Thu Apr 15, 2010 6:30 am

Re: UV garch model forecasts

Unread post by ac_1 »

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
TomDoan
Posts: 7774
Joined: Wed Nov 01, 2006 4:36 pm

Re: UV garch model forecasts

Unread post by TomDoan »

ac_1 wrote:
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.
Correct. I hope you understand that fixing the start period makes the rolling samples BIGGER, not smaller.
ac_1 wrote: How else could I improve the loop to (maybe) include multistep ahead bootstrapped forecasts?
It's fine if you just move your calculations of the means (and anything else that depends upon T1) INSIDE the T1 loop.
ac_1 wrote: I also want to backtest EGARCH with t-errors:

garch(p=1,q=1,exp,asymmetric,hseries=h,noprint,DIST=T)
If you're bootstrapping, it doesn't really matter. The GARCH estimates will be slightly different, but you don't do anything different with the residuals when bootstrapping.
ac_1 wrote:
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 no idea what you're saying. The sentence out of the UG is basically saying the same thing as the parenthetical statement in the quote.
ac_1 wrote: 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?
OVERLAY=DOTS?
ac_1
Posts: 465
Joined: Thu Apr 15, 2010 6:30 am

Re: UV garch model forecasts

Unread post by ac_1 »

[1] Exceedence Graph

I am having problems plotting the Exceedence Graph. I have plotted the graph as follows:

Code: Select all

set xdots ibegin+1 %allocend() = %if(trigger>=1,dlogdm,%na)
prin / xdots

graph(key=upleft,style=line,overlay=dots,ovsamescale,ovcount=1) 2
# dlogdm ibegin+1 %allocend()
# xdots ibegin+1 %allocend() 4
I want to include the minusVaR line, but cannot get the scaling right. The returns are plotted as a line, ideally I'd like them as a cloud of small dots.


[2] Convergence Filter

If there are convergence errors, rather than having an "odd" or NA volatility forecast, hence an erroneous VaR=0; an idea (Bollerslev et al) is to impute/filter the volatility forecast: the non-convergent forecast being replaced by the unconditional mean over EACH in-sample rolling window. So something like:

if %converged == 1

*** bootstrap as I have ***

if %converged == 0
comp gstart=istart+t1,gend=ibegin+t1
sstats(noprint) gstart gend dlogdm>>fimpmu
disp "replaced at ENTRY:" t1
set fmean gstart gend = fimpmu

How to implement within the moving window loop?
TomDoan
Posts: 7774
Joined: Wed Nov 01, 2006 4:36 pm

Re: UV garch model forecasts

Unread post by TomDoan »

ac_1 wrote:[1] Exceedence Graph

I am having problems plotting the Exceedence Graph. I have plotted the graph as follows:

Code: Select all

set xdots ibegin+1 %allocend() = %if(trigger>=1,dlogdm,%na)
prin / xdots

graph(key=upleft,style=line,overlay=dots,ovsamescale,ovcount=1) 2
# dlogdm ibegin+1 %allocend()
# xdots ibegin+1 %allocend() 4
I want to include the minusVaR line, but cannot get the scaling right. The returns are plotted as a line, ideally I'd like them as a cloud of small dots.
I have no idea what you are asking for. You are graphing the series using a line graph and then "dotting" the elements that have trigger>=1. So, yes, the returns are plotted as a line, as that's what you asked for. I'm not sure what "cloud" means when you're graphing time series---whatever you graph has to move with time. If you want two different colored dots, just use STYLE=DOTS,OVERLAY=DOTS.
ac_1 wrote: [2] Convergence Filter

If there are convergence errors, rather than having an "odd" or NA volatility forecast, hence an erroneous VaR=0; an idea (Bollerslev et al) is to impute/filter the volatility forecast: the non-convergent forecast being replaced by the unconditional mean over EACH in-sample rolling window. So something like:

if %converged == 1

*** bootstrap as I have ***

if %converged == 0
comp gstart=istart+t1,gend=ibegin+t1
sstats(noprint) gstart gend dlogdm>>fimpmu
disp "replaced at ENTRY:" t1
set fmean gstart gend = fimpmu

How to implement within the moving window loop?
That seems like a bad idea. Why wouldn't you just use the most recent converged estimates? If there are major problems with non-convergence, I would seriously question whether the model is reasonable for the data set. (There's a good reason for RiskMetrics using a fixed parameter IGARCH model---it probably isn't too far off, and eliminates the possibility of "adjusting" the model to produce the results that you want).
ac_1
Posts: 465
Joined: Thu Apr 15, 2010 6:30 am

Re: UV garch model forecasts

Unread post by ac_1 »

TomDoan wrote: I have no idea what you are asking for. You are graphing the series using a line graph and then "dotting" the elements that have trigger>=1. So, yes, the returns are plotted as a line, as that's what you asked for. I'm not sure what "cloud" means when you're graphing time series---whatever you graph has to move with time. If you want two different colored dots, just use STYLE=DOTS,OVERLAY=DOTS.
That's a typo, it should be trigger==1

Code: Select all

set xdots ibegin+1 %allocend() = %if(trigger==1,dlogdm,%na); * exceedence's or violations
prin / xdots
For the moving window loop, I have the settings

Code: Select all

set dlogdm = log(dm/dm{1})

compute ndraws=10000

comp window = 1000; * 1867 to match Dynamic
comp value = 100

compute ibegin = 1500; * end of 1st regression, 1st forecast is for 1501
                       * OR ibegin = 1867; * end of 1st regression, 1st forecast is for 1868 to match Dynamic
compute istart = (2+ibegin-window-1)
compute iend   = %allocend()
I would like a graph plotting the returns, minusVaR, and the xdots. The xdots are plotted at the end of the violated return, and the minusVaR line should be above it, i.e. the return has been violated.

Code: Select all

graph(key=upleft,style=line,overlay=dots,ovsamescale,ovcount=1) 2
# dlogdm ibegin+1 %allocend()
# xdots ibegin+1 %allocend() 4
How do I add the minusVaR line on the correct scale? Attached is the graph.

TomDoan wrote: That seems like a bad idea. Why wouldn't you just use the most recent converged estimates? If there are major problems with non-convergence, I would seriously question whether the model is reasonable for the data set. (There's a good reason for RiskMetrics using a fixed parameter IGARCH model---it probably isn't too far off, and eliminates the possibility of "adjusting" the model to produce the results that you want).
There's at least the following ways to deal with non-convergence:
1) Replace with the unconditional mean of the moving in-sample window --- if it's good enough for them it's good enough for me.
2) Use the most recent converged estimates.
3) If %converged = 0 use a different optimizer within the loop --- but that may lead to too many if statements.
4) Those covered in the Users Guide.

For either 1) and 2) how within the t1 loop?
Attachments
ac_egarchbootstrap___1-step-ahead.rgf
(2.51 KiB) Downloaded 36201 times
TomDoan
Posts: 7774
Joined: Wed Nov 01, 2006 4:36 pm

Re: UV garch model forecasts

Unread post by TomDoan »

ac_1 wrote: I would like a graph plotting the returns, minusVaR, and the xdots. The xdots are plotted at the end of the violated return, and the minusVaR line should be above it, i.e. the return has been violated.

Code: Select all

graph(key=upleft,style=line,overlay=dots,ovsamescale,ovcount=1) 2
# dlogdm ibegin+1 %allocend()
# xdots ibegin+1 %allocend() 4
How do I add the minusVaR line on the correct scale? Attached is the graph.
The minusVAR is a line, and it's a line in the same scale as the return series. So why isn't it just a second series covered by STYLE=LINE? You only need overlay if either the style changes or the scale changes.
ac_1 wrote:
TomDoan wrote: That seems like a bad idea. Why wouldn't you just use the most recent converged estimates? If there are major problems with non-convergence, I would seriously question whether the model is reasonable for the data set. (There's a good reason for RiskMetrics using a fixed parameter IGARCH model---it probably isn't too far off, and eliminates the possibility of "adjusting" the model to produce the results that you want).
There's at least the following ways to deal with non-convergence:
1) Replace with the unconditional mean of the moving in-sample window --- if it's good enough for them it's good enough for me.
2) Use the most recent converged estimates.
3) If %converged = 0 use a different optimizer within the loop --- but that may lead to too many if statements.
4) Those covered in the Users Guide.

For either 1) and 2) how within the t1 loop?
(1) The unconditional mean of WHAT? Whatever it is, just do a SSTATS instruction on it over the sample that you are using for the failed GARCH model.

(2) If you are feeding in the previous values, just do a new GARCH with METHOD=EVAL rather than METHOD=estimation method.
ac_1
Posts: 465
Joined: Thu Apr 15, 2010 6:30 am

Re: UV garch model forecasts

Unread post by ac_1 »

TomDoan wrote:
ac_1 wrote: I would like a graph plotting the returns, minusVaR, and the xdots. The xdots are plotted at the end of the violated return, and the minusVaR line should be above it, i.e. the return has been violated.

Code: Select all

graph(key=upleft,style=line,overlay=dots,ovsamescale,ovcount=1) 2
# dlogdm ibegin+1 %allocend()
# xdots ibegin+1 %allocend() 4
How do I add the minusVaR line on the correct scale? Attached is the graph.
The minusVAR is a line, and it's a line in the same scale as the return series. So why isn't it just a second series covered by STYLE=LINE? You only need overlay if either the style changes or the scale changes.
Many Thanks! :)

Works - I had to divide minusVaR/value and then

Code: Select all

graph(header="VaR Exceedence Graph",key=upleft,style=line,overlay=dots,ovsamescale,ovcount=1) 3
# dlogdm ibegin+1 iend
# minusVaR ibegin+1 iend 2
# xdots ibegin+1 iend 4
A general and important question regarding plotting DAILY UNDATED or IRREGULAR series: on the x-axis how to show the DATES not the ENTRY numbers?

TomDoan wrote:
ac_1 wrote:
TomDoan wrote: That seems like a bad idea. Why wouldn't you just use the most recent converged estimates? If there are major problems with non-convergence, I would seriously question whether the model is reasonable for the data set. (There's a good reason for RiskMetrics using a fixed parameter IGARCH model---it probably isn't too far off, and eliminates the possibility of "adjusting" the model to produce the results that you want).
There's at least the following ways to deal with non-convergence:
1) Replace with the unconditional mean of the moving in-sample window --- if it's good enough for them it's good enough for me.
2) Use the most recent converged estimates.
3) If %converged = 0 use a different optimizer within the loop --- but that may lead to too many if statements.
4) Those covered in the Users Guide.

For either 1) and 2) how within the t1 loop?
(1) The unconditional mean of WHAT? Whatever it is, just do a SSTATS instruction on it over the sample that you are using for the failed GARCH model.

(2) If you are feeding in the previous values, just do a new GARCH with METHOD=EVAL rather than METHOD=estimation method.
Yes,

Code: Select all

 if (%converged == 0); garch(p=1,q=1,exp,asymmetric,hseries=h,print,METHOD=BHHH) istart+t1 ibegin+t1 dlogdm
 if (%converged == 0); garch(p=1,q=1,exp,asymmetric,hseries=h,print,METHOD=SIMPLEX) istart+t1 ibegin+t1 dlogdm
 *etc etc
I achieve convergence at tricky points which may not converge ordinarily.


A few more questions:-

[A] Interpretation:

As coded in the rpf file, dlogdm=log(dm/dm{1}), log returns are time additive; the portfolio value is value=100, and ftrigger=VaR/value.
Now let's say e.g. VaR=2.6, this can be interpreted as 2.6% is at risk on the portfolio value: be it 1,000 USD, 10,000 USD or x USD in value. In otherwords, a probability p=0.01 (say) of losses >= to 2.6% on any USD sized portfolio. Correct?

E.g. For FX, from the point-of-view of a dollar investor, I would model USD/XXX, as that would be XXX per 1 USD, and based on the 100 USD portfolio the 2.6% loss would be in terms of USD. Correct?


Also, in GARCHBACKTEST.rpf there's:

(i) Kupiec POF measure:
observed alpha matching the chosen one,
- 0 indicating no evidence of any inadequacy
- >0 VaR model either systematically understates or overstates the portfolio’s underlying level of risk.
Is there a p-value?

(ii) Christofferson Markov independence measure: H0: independence, H0: no independence.
Is there a p-value?


[C] Within a bootstrapping framework I'd like to try the less standard GARCH model's as in GARCHUVMAX.RPF. Which one's would be appropriate in addition to EGARCH for financial returns?
Post Reply