UV garch model forecasts

Discussions of ARCH, GARCH, and related models
TomDoan
Posts: 7774
Joined: Wed Nov 01, 2006 4:36 pm

Re: UV garch model forecasts

Unread post by TomDoan »

ac_1 wrote:1. EGARCH
Based on GARCHBOOT.RPF (which works well for GARCH & GJR-GARCH), I am having problems with EGARCH bootstrapped & simulated multi-step ahead VaR and ES values: e.g. for h-step greater than 3 (say) they occasionally blow-up despite converged estimations. Why would that be and how do I resolve?
It sounds like you're doing the EGARCH simulations incorrectly.
ac_1 wrote: 2. Density plots
From GARCHSEMIPARAM.RPF, the following defines the empirical density of standardized residuals from a garch model i.e. the fitted garch distribution relative to the standard Normal.

Code: Select all

set ustandard gstart gend = u/sqrt(h)
@gridseries(from=-6.0,to=6.0,size=.001,pts=gpts) xgrid
density(type=gauss,grid=input) ustandard gstart gend xgrid fgrid
set ngrid 1 gpts = %density(xgrid)
scatter(style=line,key=upleft,klabels=||"Empirical","N(0,1)"||) 2
# xgrid fgrid
# xgrid ngrid
What information do I require and how do I plot TOOS multi-step ahead density forecasts from garch processes: analytical, bootstrapped & simulated?
You use DENSITY to compute density estimates. To get the density of (say) the bootstrapped draws, you would need to transfer them to a series, since that's what DENSITY uses:

set mybootseries 1 mynumberdraws = mybootdraws(t)

then use mybootseries (or whatever you call it) as the input to DENSITY. You wouldn't use GRID=INPUT on DENSITY since (unlike the example above) you don't have an obvious range.
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:1. EGARCH
Based on GARCHBOOT.RPF (which works well for GARCH & GJR-GARCH), I am having problems with EGARCH bootstrapped & simulated multi-step ahead VaR and ES values: e.g. for h-step greater than 3 (say) they occasionally blow-up despite converged estimations. Why would that be and how do I resolve?
It sounds like you're doing the EGARCH simulations incorrectly.
In a loop I am wrapping the code as per GARCHBOOT.RPF, in a backtest. Structure with changed/additional code inc. comments as follows:

Code: Select all

dec rect[real] mVaR(%allocend()-WE+1,10); * collate multi-step ahead VaR forecasts
dec rect[real] mES(%allocend()-WE+1,10); * collate multi-step ahead ES forecasts

do jj loop over the backtest sample

   * Estimate the EGARCH-bootstrapped(1,1) model

   * Generate a forecasting formula from the results of the EGARCH
   * estimation. gstart and gend are the regression range, which we need
   * for drawing standardized residuals.
   compute gstart=%regstart(),gend=%regend()
   compute b0=%beta(1); * b0=0.0
   compute chat=%beta(%nregmean+1),ahat=%beta(%nregmean+2),bhat=%beta(%nregmean+3),dhat=%beta(%nregmean+4)
   frml hf = exp( chat + bhat*log(h{1}) + ahat*abs(u{1}) + dhat*%max(u{1},0.0) )

   * Standardize the historical residuals


   dofor kk = 1 2 3 4 5 6 7 8 9 10

   * kk-STEPS
   * ========
   * span is the number of periods over which returns are to be computed.
   * ndraws is the number of bootstrapping draws

   compute span=kk

   * Extend out the h series (values aren't important--this is just to get
   * the extra space).

   do draw loop

   end do draw

   * Compute desired fractiles of the returns

   do i loop

   end do i

   comp [rect] mVaR(jj+1,kk) = %scalar(%fractiles(returns,.01))
   comp [vect] mES(jj+1,kk)  = %scalar(-es)

   end dofor kk

end do jj
TomDoan
Posts: 7774
Joined: Wed Nov 01, 2006 4:36 pm

Re: UV garch model forecasts

Unread post by TomDoan »

The EGARCH recursion uses standardized U's not U's:

frml hf = exp( chat + bhat*log(h{1}) + ahat*abs(u{1}) + dhat*%max(u{1},0.0) )
ac_1
Posts: 465
Joined: Thu Apr 15, 2010 6:30 am

Re: UV garch model forecasts

Unread post by ac_1 »

TomDoan wrote:The EGARCH recursion uses standardized U's not U's:

frml hf = exp( chat + bhat*log(h{1}) + ahat*abs(u{1}) + dhat*%max(u{1},0.0) )
Sorry, I have changed hf:

frml hf = exp( chat + bhat*log(h{1}) + ahat*abs(ustandard{1}) + dhat*%max(ustandard{1},0.0) )

but VaR and ES do not accumulate multi-steps ahead, unlike in GARCH and GJR-GARCH where they do.
TomDoan
Posts: 7774
Joined: Wed Nov 01, 2006 4:36 pm

Re: UV garch model forecasts

Unread post by TomDoan »

You don't "accumulate" VaR and ES over multiple steps. You accumulate the simulated returns, save those and analyze them. As I said before, the only difference between doing this with a standard GARCH and an EGARCH is how you generate the simulated/bootstrapped data---what you do with that is the same.
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 don't "accumulate" VaR and ES over multiple steps. You accumulate the simulated returns, save those and analyze them. As I said before, the only difference between doing this with a standard GARCH and an EGARCH is how you generate the simulated/bootstrapped data---what you do with that is the same.
Using GARCHBOOT.RPF for GARCH and GJR-GARCH, VaR and ES increase almost in-line with square-root-of-time rule multiple-steps ahead, as output from GARCHBOOT.RPF, having made the changes as I have described for GARCH and GJR-GARCH, as a backtest. Given further changes for EGARCH I would expect similar! But VaR and ES do not. My question is how do I make VaR and ES increase for EGARCH as they do for GARCH and GJR-GARCH?
TomDoan
Posts: 7774
Joined: Wed Nov 01, 2006 4:36 pm

Re: UV garch model forecasts

Unread post by TomDoan »

By doing your EGARCH simulations/bootstraps correctly. You are almost certainly still doing something wrong. Standard GARCH and EGARCH may produce very similar results (when done correctly), but they have very different recursions with coefficients which have completely different meanings. An EGARCH bootstrap/simulation uses the final sample lagged standardized u, then draws for the standardized u's out-of-sample. The simulated data, however, are the non-standardized u's. You have to make sure you are doing that correctly. Look more carefully at the EGARCHBOOTRAP and EGARCHSIMULATE programs.
ac_1
Posts: 465
Joined: Thu Apr 15, 2010 6:30 am

Re: UV garch model forecasts

Unread post by ac_1 »

TomDoan wrote:By doing your EGARCH simulations/bootstraps correctly. You are almost certainly still doing something wrong. Standard GARCH and EGARCH may produce very similar results (when done correctly), but they have very different recursions with coefficients which have completely different meanings. An EGARCH bootstrap/simulation uses the final sample lagged standardized u, then draws for the standardized u's out-of-sample. The simulated data, however, are the non-standardized u's. You have to make sure you are doing that correctly. Look more carefully at the EGARCHBOOTRAP and EGARCHSIMULATE programs.
Attached is a backtest using EGARCHBOOTSTRAP: wrapped around a loop, multi-steps ahead forecasts (at least on my PC it's faster than GARCHBOOT).

Calculated is VaR. I am not certain it's correct but it is very similar to Standard GARCH.

I cannot calculate ES, as I do not understand the GSET command. What is the syntax:

sstats(mean) 1 ndraws %if(xdraws(t)< ? ,xdraws(t),%na)>>es

How do I calculate ES?

Code: Select all

*===============================
infobox(action=define,lower=0,upper=%allocend()-WE-1,progress) "EGARCH-bootstrapped Model Backtest"
*
do jj = 1, %allocend()-WE

   *
   * Estimate the EGARCH-bootstrapped(1,1) model.
   *
   garch(p=1,q=1,EXP,ASYMMETRIC,resids=u,hseries=h,print,METHOD=SIMPLEX) tstart+jj tend+jj y
   *
   if (%converged == 0); garch(p=1,q=1,EXP,ASYMMETRIC,resids=u,hseries=h,print,METHOD=BFGS) tstart+jj tend+jj y
   if (%converged == 0); garch(p=1,q=1,EXP,ASYMMETRIC,resids=u,hseries=h,print,METHOD=BHHH) tstart+jj tend+jj y
   if (%converged == 0); garch(p=1,q=1,EXP,ASYMMETRIC,resids=u,hseries=h,print,METHOD=GENETIC) tstart+jj tend+jj y
   if (%converged == 0); garch(p=1,q=1,EXP,ASYMMETRIC,resids=u,hseries=h,print,METHOD=ANNEALING) tstart+jj tend+jj y
   if (%converged == 0); garch(p=1,q=1,EXP,ASYMMETRIC,resids=u,hseries=h,print,METHOD=GA) tstart+jj tend+jj y
   if (%converged == 0); garch(p=1,q=1,EXP,ASYMMETRIC,resids=u,hseries=h,print,METHOD=EVALUATE) tstart+jj tend+jj y
   *
   if (%converged == 0); disp 'NO CONVERGENCE'


   * Pull out the coefficients for the EGARCH process
   *
   compute gmu=%beta(1),c=%beta(2),a=%beta(3),b=%beta(4),d=%beta(5)
   *
   * Estimation range, which is also the source range for bootstrapped residuals
   *
   compute gstart=%regstart(),gend=%regend()
   *
   set stdu = %resids/sqrt(h)
   *
   compute ndraws=ndraws
   compute nsteps=5
   *
   compute bstart=gend+1,bend=gend+nsteps
   set h bstart bend = %na
   set x bstart bend = %na
   dec series[vect] hdraws xdraws
   gset hdraws bstart bend = %zeros(ndraws,1)
   gset xdraws bstart bend = %zeros(ndraws,1)
   do draw=1,ndraws
      boot entries bstart bend gstart gend
      *
      * This is way the asymmetric EGARCH instruction is parameterized in
      * RATS. Nelson's original formulation is equivalent, but the c
      * coefficient has a different meaning. The recursion for the variance
      * uses the standardized residuals only.
      *
      set stdu bstart bend = su=stdu(entries(t)),$
                h=exp(c+b*log(h{1})+a*abs(stdu{1})+d*stdu{1}),$
                 x=gmu+sqrt(h)*su,su
      *
      * Replace x by its accumulation
      *
      acc x bstart bend
      do t=bstart,bend
         compute hdraws(t)(draw)=h(t)
         compute xdraws(t)(draw)=x(t)
      end do t
   end do draw


   *===============================
   set VaR bstart bend = %fractiles(xdraws(t),.01)(1)

   make vVaR bstart bend
   # VaR

   do j = 1, 5
      comp [rect] mVaR(jj+j-1,j) = vVaR(j,1)
   end do j


  INFOBOX(CURRENT=jj)
end do jj
*
infobox(action=remove)
TomDoan
Posts: 7774
Joined: Wed Nov 01, 2006 4:36 pm

Re: UV garch model forecasts

Unread post by TomDoan »

sstats(mean) 1 ndraws %if(xdraws(t)< ? ,xdraws(t),%na)>>es

takes the mean of all xdraws values that are less than whatever is ? (which would be your VaR threshold). That's quite literally how you compute ES. %IF(x,y,z) takes the value y (here XDRAWS(t)) if x is "true" (i.e. xdraws(t)<?)) and z (here %NA) if x is "false". %NA knocks the value out of the calculation of the mean.
ac_1
Posts: 465
Joined: Thu Apr 15, 2010 6:30 am

Re: UV garch model forecasts

Unread post by ac_1 »

TomDoan wrote:sstats(mean) 1 ndraws %if(xdraws(t)< ? ,xdraws(t),%na)>>es

takes the mean of all xdraws values that are less than whatever is ? (which would be your VaR threshold). That's quite literally how you compute ES. %IF(x,y,z) takes the value y (here XDRAWS(t)) if x is "true" (i.e. xdraws(t)<?)) and z (here %NA) if x is "false". %NA knocks the value out of the calculation of the mean.
I understand what SSTATS and what %IF do.

What is the syntax for ? (i.e. value-at-risk), from the above code in

sstats(mean) 1 ndraws %if(xdraws(t)< ? ,xdraws(t),%na)>>es

as I do not understand the GSET where xdraws is defined (it's not defined as e.g. DECLARE VECT XDRAWS(ndraws) but as SERIES[VECTOR[REAL]])?

The point I am making is if I try to calculate

sstats(mean) 1 ndraws %if(xdraws(t)<vVaR(1,1),xdraws(t),%na)>>es

just after the end do j loop and before INFOBOX(CURRENT=jj), there's an error

Can't Interpret VECTOR[REAL] < or .LT. REAL
## SX27. Illegal Combination of Data Types for Operation
>>>>draws(t)<vVaR(1,1),<<<<

So what VaR do I use to calculate ES (from the backtest code previously)? Or is there a simpler way to compute ES for each of the 1 to 5 steps ahead?
TomDoan
Posts: 7774
Joined: Wed Nov 01, 2006 4:36 pm

Re: UV garch model forecasts

Unread post by TomDoan »

XDRAWS(T) for T from BSTART to BEND is a VECTOR of size NDRAWS. The comparison is with whatever is the VaR that you calculating. Because you can't overload the use of T, you would need to do something like:

Code: Select all

do tt=bstart,bend
   compute var=%fractiles(xdraws(tt),||.01||)(1)
   sstats(mean) 1 ndraws %if(xdraws(tt)(t)<var,xdraws(tt)(t),%na)>>es
end do tt
where you have to figure out what you want to do the VAR and ES values that are computed there. (I don't know how you plan to organize the output from this).
ac_1
Posts: 465
Joined: Thu Apr 15, 2010 6:30 am

Re: UV garch model forecasts

Unread post by ac_1 »

A few questions:

(a) I have assigned VaR and ES to matrices, and then to vectors, and SET to SERIES.

Within a backtest, as h-step ahead time line graphs, VaR and ES EGARCH simulated and bootstrapped are 'more-spikey or less-smooth' and 'fatter' (viewing them vertically, i.e. width-wise) in comparison to any of the other GARCH's and GJR-GARCH's (inc. various underlying distributions, simulated and bootstrapped). They are only similar to normal GARCH analytical w.r.t. the maximum value(s) over the backtest sample.

(b) Again after assigning the forecast RETURNS or XDRAWS, I have generated TOOS density plots multi-steps ahead in all simulated and bootstrapped analysis. The 1-step ahead forecast distribution is very similar to the in-sample returns distribution :). And for h-steps > 1, the forecast distribution plots are lower in height, much smoother, and wider at the tails.

Are (a) and (b) reasonable?

Is it possible to plot TOOS forecast distribution plots from the analytical (non-simulated, non-bootstrapped) methods?


(c) Interpretation:
As an example, let's say an investor is long $1 million worth of 2000 shares purchased at the same price $500 per share, assuming no transaction costs and fees.
If the 1-day ahead 1% VaR forecast is e.g. 4.1 (from a GARCH model, e.g. GARCHBOOT.RPF) that means the 1% VaR for the investor is $1,000,000*0.041 = $41,000 i.e. such a portfolio will lose less than $41,000 an average of 99 days out of 100. So, $41,000 is the potential loss of holding that position next day.
Can VaR (to be more conservative) or ES be used as a stop-loss mechanism? If so, would the stop-loss be at $479.50 for the next day? i.e. the investor cannot lose more than $41,000/2000 = $20.50 per share, and $500-$20.50 = $479.50.

Also, is it sensible to combine VaR (or ES) forecasts i.e. to calculate the mean (or some optimal combination) across all the h-Day VaR (or ES) forecasts:
e.g. From all the 1 Day VaR (or ES) forecasts from all the various models? From all the 2 Day VaR (or ES) forecasts from all the various models? etc
TomDoan
Posts: 7774
Joined: Wed Nov 01, 2006 4:36 pm

Re: UV garch model forecasts

Unread post by TomDoan »

ac_1 wrote:A few questions:

(a) I have assigned VaR and ES to matrices, and then to vectors, and SET to SERIES.

Within a backtest, as h-step ahead time line graphs, VaR and ES EGARCH simulated and bootstrapped are 'more-spikey or less-smooth' and 'fatter' (viewing them vertically, i.e. width-wise) in comparison to any of the other GARCH's and GJR-GARCH's (inc. various underlying distributions, simulated and bootstrapped). They are only similar to normal GARCH analytical w.r.t. the maximum value(s) over the backtest sample.
Tail events (such as analysis of the left 1%) require a large number of draws---maybe 100,000---for real accuracy. However, if you are seeing very different behavior for EGARCH simulations and GARCH simulations, you are probably doing something wrong with the EGARCH. (EGARCH simulations and GARCH simulations literally should have about three lines that differ).
ac_1 wrote: (b) Again after assigning the forecast RETURNS or XDRAWS, I have generated TOOS density plots multi-steps ahead in all simulated and bootstrapped analysis. The 1-step ahead forecast distribution is very similar to the in-sample returns distribution :). And for h-steps > 1, the forecast distribution plots are lower in height, much smoother, and wider at the tails.

Are (a) and (b) reasonable?
They should be more spread out, shouldn't they? I'm not even sure what you are asking. h-step simulations should produce roughly the stationary distribution predicted by the model as h-->infinity regardless of the initial conditions. But 1-step simulations will be obviously tied more closely to the observed data.
ac_1 wrote: Is it possible to plot TOOS forecast distribution plots from the analytical (non-simulated, non-bootstrapped) methods?
No. They have a computable variance, but not a known distribution.
ac_1 wrote: (c) Interpretation:
As an example, let's say an investor is long $1 million worth of 2000 shares purchased at the same price $500 per share, assuming no transaction costs and fees.
If the 1-day ahead 1% VaR forecast is e.g. 4.1 (from a GARCH model, e.g. GARCHBOOT.RPF) that means the 1% VaR for the investor is $1,000,000*0.041 = $41,000 i.e. such a portfolio will lose less than $41,000 an average of 99 days out of 100. So, $41,000 is the potential loss of holding that position next day.
Can VaR (to be more conservative) or ES be used as a stop-loss mechanism? If so, would the stop-loss be at $479.50 for the next day? i.e. the investor cannot lose more than $41,000/2000 = $20.50 per share, and $500-$20.50 = $479.50.

Also, is it sensible to combine VaR (or ES) forecasts i.e. to calculate the mean (or some optimal combination) across all the h-Day VaR (or ES) forecasts:
e.g. From all the 1 Day VaR (or ES) forecasts from all the various models? From all the 2 Day VaR (or ES) forecasts from all the various models? etc
That's outside the scope. Consult someone who does finance.
ac_1
Posts: 465
Joined: Thu Apr 15, 2010 6:30 am

Re: UV garch model forecasts

Unread post by ac_1 »

This topic is related viewtopic.php?f=11&t=3673.

These may be outside the scope (although VaR and ES is computed in the example file GARCHBOOT.RPF), but question(s) regarding long position VaR and ES versus short position VaR and ES.

A priori I'd expect for a long position in an equity index to have a higher VaR and ES level than for a short position simply because equity indices historically are trending-upwards, but that depends on sample. However, in FX it's more difficult to have a view.

How to compute VaR and ES both for long and short positions in the preceding GARCH models: analytical and simulations?

Defining log-returns as: 100.0*log(P/P{1}), the VaR for a long position of $10 million with probability 0.01 is:

comp V = 10000000; * $10 million portfolio value
comp VaR = V/100.0 * ( -%beta(1) + (-%invnormal(.01)*sqrt(hhat)) )
comp ES = V/100.0 * ( -%beta(1) + (%density(%invnormal(.01))/(.01) * sqrt(hhat)) )

Noting, assuming zero mean returns, VaR for Simple Returns (actual amount) is approximately the same as the VaR for Log Returns for small invF(p)*sigma. But what is small?
TomDoan
Posts: 7774
Joined: Wed Nov 01, 2006 4:36 pm

Re: UV garch model forecasts

Unread post by TomDoan »

Over a short period (like 10 days), the difference should be quite modest, as the drift is small compared to the day-to-day movements.

Returns to a short position are sign flips of the returns to a long position. You *can* simply flip the sign of the returns data and redo the calculations. Alternatively, you can analyze the opposite tail of a model done in longs. For simulated data, the alpha VaR to a short position is the 1-alpha percentile of the simulated returns to a long position; the ES is the mean of the simulations that exceed that (note >= not <= that you would do for ES on a long position, since it's the upper tail behavior you are analyzing). If you use a symmetrical parametric distribution (t or Normal), the VaR and ES formulas are the same except for a sign flip on the mean.
Post Reply