Page 1 of 2

UV MAX garch model forecasts

Posted: Fri Nov 10, 2023 12:35 pm
by ac_1
Hi Tom,

Can you please provide the reference/paper for the models in GARCHUVMAX.RPF.

Further to viewtopic.php?f=11&t=3645, and based on GARCHUVMAX.RPF, I have attempted to generate forecasts: (i) fmu, (ii) sigma, (iii) VaR, (iv) ES; for APARCH (chosen because ZARCH can be done as APARCH with lambda pegged to 1.0). They look a little low to me, please can you check. Thanks.

Code: Select all

*
open data garch.asc
data(format=free,org=columns) 1 1867 bp cd dm jy sf
*
set dlogdm = 100.0*log(dm/dm{1})


*===============================
compute tstart = 1+1+1
compute tend = 1867

compute value = 100


*===============================
*
* Parameter sets
*
linreg dlogdm
# constant dlogdm{1}
frml(lastreg,vector=beta) meanf
nonlin(parmset=meanparms) beta
*

*===============================
*
* APARCH (asymmetric power GARCH)
*
set uu = %seesq
set h  = %seesq
set u  = 0.0

nonlin(parmset=garchparms) c a b
nonlin(parmset=powerparms) lambda
nonlin(parmset=asymmparms) d

compute a=0.0
compute b=0.0
compute c=%seesq
compute lambda=2.0
compute d=0.0

frml varf = uupower=uu{1}^(.5*lambda),$
            (c+a*uupower+d*%if(u{1}<0,uupower,0.0)+b*h{1}^(.5*lambda))^(2.0/lambda)
frml logl = (h(t)=varf(t)),$
            (u=dlogdm-meanf),$
            (uu(t)=u^2),$
            %logdensity(h,u)
maximize(parmset=meanparms+garchparms+asymmparms+powerparms,title="Asymmetric power GARCH",METHOD=BFGS) logl tstart tend


*
* 1-step ahead forecast
*
comp fmu = %beta(1)+(%beta(2)*dlogdm(tend))
disp 'fmu=' fmu


compute c=%beta(3),a=%beta(4),b=%beta(5),d=%beta(6),lambda=%beta(7)
comp hhat = uupower=uu(tend)^(.5*lambda),$
            (c + a*uupower+d*%if(u(tend)<0,uupower,0.0) + b*h(tend)^(.5*lambda))^(2.0/lambda)

comp hat = (hhat)^(1.0/lambda)
comp VaR = ( ( -%invnormal(.01) * (hhat)^(1.0/lambda) * value ) + fmu ) / value; * DIVIDE BY value BECAUSE VALUE <> 1
comp ES = ( ( (hhat)^(1.0/lambda) * %density(%invnormal(.01))/.01 * value ) + fmu ) / value; * DIVIDE BY value BECAUSE VALUE <> 1

comp hat_1 = (hhat)^(1.0/lambda)
comp VaR_1 = VaR
comp ES_1  = ES

disp 'sigma=' hat_1
disp 'VaR=  ' VaR_1
disp 'ES=   ' ES_1

Re: UV MAX garch model forecasts

Posted: Fri Nov 10, 2023 9:18 pm
by TomDoan
The various specialized models are in Cappiello, L., R. Engle & K. Sheppard(2006), "Asymmetric Dynamics in the Correlations of Global Equity and Bond Returns," Journal of Financial Econometrics, vol. 4, no 4, pages 537-572.

You're doing a lot of extra work. MEANF is a FRML for the mean, VARF is a FRML for the variance---see the description of the set up of GARCHUVMAX in the User's Guide. You're trying to hack out the estimates to rebuild the calculation of those when the program already did that. MEANF(TEND+1) is the computed mean at TEND+1 and VARF(TEND+1) is the variance.

Re: UV MAX garch model forecasts

Posted: Sun Nov 12, 2023 8:17 am
by ac_1
TomDoan wrote: You're doing a lot of extra work. MEANF is a FRML for the mean, VARF is a FRML for the variance---see the description of the set up of GARCHUVMAX in the User's Guide. You're trying to hack out the estimates to rebuild the calculation of those when the program already did that. MEANF(TEND+1) is the computed mean at TEND+1 and VARF(TEND+1) is the variance.
In the previous GARCH estimations:
- GARCH
- GJR-GARCH
based on GARCHBACKTEST.RPF, FRML has not been used.

And in simulations:
- garchbootstrap and garchsimulate
- EGARCH
based on GARCHBOOT.RPF EGARCHBOOTSTRAP.RPF, EGARCHSIMULATE.RPF, FRML has been used but no GROUP.

To be clear, generally speaking, whenever FRML is used I have to GROUP to generate OOS forecasts as per UG-301, otherwise (in non-simulated) I evaluate expressions using COMPUTE only, and generate 1-step ahead OOS forecasts as in GARCHBACKTEST.RPF. Correct? Likewise, multi-steps ahead OOS forecasts using COMPUTE.

I think the following is correct? And I should expect results similar to GJR-GARCH depending on LAMBDA?

Code: Select all

*
* 1-step ahead forecast
*
comp fmu = %beta(1)+(%beta(2)*dlogdm(tend))
disp 'fmu=' fmu
disp 'acMEANF=' MEANF(TEND+1)


set uu = (dlogdm-meanf)^2
frml hfrml ht = uupower=uu{1}^(.5*lambda),$
            (c+a*uupower+d*%if(u{1}<0,uupower,0.0)+b*h{1}^(.5*lambda))^(2.0/lambda)
frml uufrml uu = ht
group garchmod hfrml>>ht uufrml>>uu
forecast(model=garchmod,from=tend+1,steps=1)

prin tend+1 tend+1 ht
disp 'acVARF=' VARF(TEND+1)


set hat tend+1 tend+1 =  sqrt(ht^lambda)
set VaR tend+1 tend+1 = ( ( -%invnormal(.01) * sqrt(ht^lambda) * value ) + fmu ) / value; * DIVIDE BY value BECAUSE VALUE <> 1
set ES tend+1 tend+1 = ( ( sqrt(ht^lambda) * %density(%invnormal(.01))/.01 * value ) + fmu ) / value; * DIVIDE BY value BECAUSE VALUE <> 1

prin tend+1 tend+1 hat VaR ES
Can I loop round and generate a 1-step ahead OOS backtest, GROUP included?

Re: UV MAX garch model forecasts

Posted: Sun Nov 12, 2023 10:54 am
by TomDoan
The GARCH instruction is not based on FRML's, and is roughly four times faster and a lot more convenient---for models which are included. For models which are NOT included in GARCH, you need to use FRML's and NONLIN and MAXIMIZE, as described in the User's Guide. It's slower, more cumbersome, but more general.

No. That is not correct. Parametric ES and VaR depend upon the mean and the variance and the assumed distribution. The VARF FRML computes the variance. You don't have to strip out any pieces from that. Just use the FRML to get the variance as I explained.

Re: UV MAX garch model forecasts

Posted: Tue Nov 14, 2023 3:06 am
by ac_1
TomDoan wrote: No. That is not correct. Parametric ES and VaR depend upon the mean and the variance and the assumed distribution. The VARF FRML computes the variance. You don't have to strip out any pieces from that. Just use the FRML to get the variance as I explained.
Within a loop, I have a rolling backtest, fixed window WE. I removed the AR(1) term in the LINREG for the MEAN to be consistent with the GARCHUV models.

Code: Select all

infobox(action=define,lower=0,upper=%allocend()-WE,progress) "APARCH (asymmetric power GARCH) Model Backtest"
*
do i=1,%allocend()-WE

   *
   * Parameter sets
   *
   *
   * APARCH (asymmetric power GARCH)
   *


   *
   * 1-step ahead forecast
   *
   disp 'MEANF=' MEANF(tend+1+i)
   disp 'VARF= ' VARF(tend+1+i)
   *
   *
   set hat tend+1+i tend+1+i = sqrt(VARF(tend+1+i))
   set VaR tend+1+i tend+1+i = ( ( -%invnormal(.01) * sqrt(VARF(tend+1+i)) * value ) + MEANF(tend+1+i) ) / value; * DIVIDE BY value BECAUSE VALUE <> 1
   set ES tend+1+i tend+1+i = ( ( sqrt(VARF(tend+1+i)) * %density(%invnormal(.01))/.01 * value ) + MEANF(tend+1+i) ) / value; * DIVIDE BY value BECAUSE VALUE <> 1

   prin tend+1+i tend+1+i hat VaR ES

   *
  INFOBOX(CURRENT=i)
end do i
*
infobox(action=remove)
I think that's correct?

I want to generate multi-step ahead forecasts for APARCH, but do not know the formulae?

How do I peg lambda=1.0 to estimate a ZARCH?

Re: UV MAX garch model forecasts

Posted: Tue Nov 14, 2023 8:08 am
by TomDoan
No. It doesn't look like you are dealing with a non-zero mean properly---all the calculations (mean and standard deviation) are for whatever is the underlying value represented by the data. Whatever you mean "value" to be, you shouldn't be treating the two parts of the Var and ES calculations differently. The natural calculations for both VaR and ES come up with negative numbers. You have to flip the full result, not just part of it, if you want the conventional positive value.

None of these have a closed form expression for forecasting.

Put LAMBDA=1.0 and leave POWERPARMS out of the PARMSET. However, you can also just use the VARF FRML that defines the ZARCH---all that does is directly substitute 1 for LAMBDA.

I have no idea what your loop is supposed to be looping over. Where are you estimating the model? The calculations that you are doing are valid only for one step outside the estimation period.

Re: UV MAX garch model forecasts

Posted: Tue Nov 14, 2023 12:03 pm
by ac_1
TomDoan wrote:No. It doesn't look like you are dealing with a non-zero mean properly---all the calculations (mean and standard deviation) are for whatever is the underlying value represented by the data. Whatever you mean "value" to be, you shouldn't be treating the two parts of the Var and ES calculations differently. The natural calculations for both VaR and ES come up with negative numbers. You have to flip the full result, not just part of it, if you want the conventional positive value.

I have no idea what your loop is supposed to be looping over. Where are you estimating the model? The calculations that you are doing are valid only for one step outside the estimation period.
Based on the data in GARCHUVMAX.RPF.

value = value of the portfolio

Code: Select all

*===============================
open data garch.asc
data(format=free,org=columns) 1 1867 bp cd dm jy sf
*
set dlogdm = 100.0*log(dm/dm{1})


*===============================
comp WE = 1500
comp value = 100; * value of the portfolio

compute tstart= 1
compute tend  = WE


infobox(action=define,lower=0,upper=%allocend()-WE,progress) "APARCH (asymmetric power GARCH) Model Backtest"
*
do i=1,%allocend()-WE


   *===============================
   *
   * Parameter sets
   *
   linreg dlogdm tstart+i tend+i
   # constant; * removed ar(1) term for consistency
   frml(lastreg,vector=beta) meanf
   nonlin(parmset=meanparms) beta
   *

   *===============================
   *
   * APARCH (asymmetric power GARCH)
   *
   set uu = %seesq
   set h  = %seesq
   set u  = 0.0

   nonlin(parmset=garchparms) c a b
   nonlin(parmset=powerparms) lambda
   nonlin(parmset=asymmparms) d

   compute a=0.0
   compute b=0.0
   compute c=%seesq
   compute lambda=2.0; * baseline
   compute d=0.0

   frml varf = uupower=uu{1}^(.5*lambda),$
               (c+a*uupower+d*%if(u{1}<0,uupower,0.0)+b*h{1}^(.5*lambda))^(2.0/lambda)
   frml logl = (h(t)=varf(t)),$
               (u=dlogdm-meanf),$
               (uu(t)=u^2),$
               %logdensity(h,u)
   maximize(parmset=meanparms+garchparms+asymmparms+powerparms,title="Asymmetric power GARCH",METHOD=BFGS,ITERS=5000) logl tstart+i tend+i
   *
   if (%converged == 0); maximize(parmset=meanparms+garchparms+asymmparms+powerparms,title="Asymmetric power GARCH",METHOD=BHHH,ITERS=5000) logl tstart+i tend+i
   if (%converged == 0); maximize(parmset=meanparms+garchparms+asymmparms+powerparms,title="Asymmetric power GARCH",METHOD=SIMPLEX,ITERS=5000) logl tstart+i tend+i
   if (%converged == 0); maximize(parmset=meanparms+garchparms+asymmparms+powerparms,title="Asymmetric power GARCH",METHOD=GENETIC,ITERS=5000) logl tstart+i tend+i
   if (%converged == 0); maximize(parmset=meanparms+garchparms+asymmparms+powerparms,title="Asymmetric power GARCH",METHOD=ANNEALING,ITERS=5000) logl tstart+i tend+i
   if (%converged == 0); maximize(parmset=meanparms+garchparms+asymmparms+powerparms,title="Asymmetric power GARCH",METHOD=GA,ITERS=5000) logl tstart+i tend+i

   *
   * 1-step ahead forecast
   *
   disp 'MEANF=' MEANF(tend+1+i)
   disp 'VARF= ' VARF(tend+1+i)
   *
   *
   set hat tend+1+i tend+1+i = sqrt(VARF(tend+1+i))
   set VaR tend+1+i tend+1+i = ( ( -%invnormal(.01) * sqrt(VARF(tend+1+i)) * value ) + MEANF(tend+1+i) ) / value; * DIVIDE BY value BECAUSE VALUE <> 1
   set ES tend+1+i tend+1+i = ( ( sqrt(VARF(tend+1+i)) * %density(%invnormal(.01))/.01 * value ) + MEANF(tend+1+i) ) / value; * DIVIDE BY value BECAUSE VALUE <> 1

   prin tend+1+i tend+1+i hat VaR ES

   *
  INFOBOX(CURRENT=i)
end do i
*
infobox(action=remove)
Please can you tell me where are the errors?

Re: UV MAX garch model forecasts

Posted: Tue Nov 14, 2023 1:37 pm
by TomDoan
The calculation of the VaR and ES. Pretty much everything about those. You need to go back to check your formulas for how the mean and standard deviations are used. And I still don't understand what you *intend* to do with value. Why are you multiplying by value and then dividing by it? If it's to adjust for the fact that the returns were scaled by 100 (which they were), then that scale is already in the calculations---the standard deviation and means are already multiplied by 100 relative to the same model done with returns not multiplied by 100.

Re: UV MAX garch model forecasts

Posted: Wed Nov 15, 2023 1:17 pm
by ac_1
TomDoan wrote:The calculation of the VaR and ES. Pretty much everything about those. You need to go back to check your formulas for how the mean and standard deviations are used. And I still don't understand what you *intend* to do with value. Why are you multiplying by value and then dividing by it? If it's to adjust for the fact that the returns were scaled by 100 (which they were), then that scale is already in the calculations---the standard deviation and means are already multiplied by 100 relative to the same model done with returns not multiplied by 100.
Sorry. I have removed value from VaR and ES.

set VaR tend+1+i tend+1+i = ( ( -%invnormal(.01) * sqrt(VARF(tend+1+i)) ) + MEANF(tend+1+i) )
set ES tend+1+i tend+1+i = ( ( sqrt(VARF(tend+1+i)) * %density(%invnormal(.01))/.01 ) + MEANF(tend+1+i) )

I now have VaR and ES in percentage terms.

My confusion was with the portfolio value e.g. VaR*value (=in monetary terms), and using value=100 when scaling to calculate the violation ratios; thereafter Kupiec and markov tests for VaR. So I have comp SCALE=100.0, and no value variable.
Are there similar tests for ES?


I have backtested APARCH on another dataset and unfortunately as of convergence takes a long time (in comparison to GARCH) due to using METHOD=SIMPLEX, despite the 'ALL methods' code e.g.
if (%converged == 0); MAXIMISE()
etc

Also, APARCH has no multi-step ahead forecasts formulae, so I have to use square-root-of-time rule.

Re: UV MAX garch model forecasts

Posted: Wed Nov 15, 2023 9:11 pm
by TomDoan
1. Your formulas are still wrong. Think about what it means for the mean to be positive. Does that increase or decrease the VaR and ES? You have it increasing both.
2. They aren't in "percentage" terms. Given the data preparation, they are for an investment of 100.
3. No. VaR gives a threshold value which you can compare with observed values which is what the two tests are based upon. ES is an expected value, not a specific comparison number.
4. I already told you (several times) that your menu of optimizations isn't a good idea. Have you been able to successfully fit it to the whole sample? It makes little sense to do rolling estimates of a model which you can't really fit in the first place.
5. You do simulations or bootstraps, as you do with any other form of GARCH model which doesn't have a closed form forecast.

Re: UV MAX garch model forecasts

Posted: Thu Nov 16, 2023 1:22 am
by ac_1
TomDoan wrote:1. Your formulas are still wrong. Think about what it means for the mean to be positive. Does that increase or decrease the VaR and ES? You have it increasing both.
I am basing VaR calculations following TSay: e.g. https://estima.com/textbooks/tsay_3/tsay3p334.rpf

VaR = -value * ( quantile function(left tail p) * sqrt(variance) + mean )

What is the correct RATS code for VaR and ES, for APARCH?

TomDoan wrote: 2. They aren't in "percentage" terms. Given the data preparation, they are for an investment of 100.
So the results cannot be scaled-up? VaR=2.5 for an investment of 100 cannot be interpreted as VaR=25.0 for an investment of 1000?

TomDoan wrote: 3. No. VaR gives a threshold value which you can compare with observed values which is what the two tests are based upon. ES is an expected value, not a specific comparison number.
Noted.

TomDoan wrote: 4. I already told you (several times) that your menu of optimizations isn't a good idea. Have you been able to successfully fit it to the whole sample? It makes little sense to do rolling estimates of a model which you can't really fit in the first place.
Data changes throughtout the sample. Just because a model fits over the whole sample does not been it will fit over a smaller sample, especially if there are large moves. Using a single METHOD sometimes does not converge in rolling estimations and results in gaps.

TomDoan wrote: 5. You do simulations or bootstraps, as you do with any other form of GARCH model which doesn't have a closed form forecast.
How for APARCH? The EGARCHBOOTSTRAP.RPF method or the GARCHBOOT.RPF method?

Re: UV MAX garch model forecasts

Posted: Thu Nov 16, 2023 8:02 am
by TomDoan
ac_1 wrote:
TomDoan wrote:1. Your formulas are still wrong. Think about what it means for the mean to be positive. Does that increase or decrease the VaR and ES? You have it increasing both.
I am basing VaR calculations following TSay: e.g. https://estima.com/textbooks/tsay_3/tsay3p334.rpf

VaR = -value * ( quantile function(left tail p) * sqrt(variance) + mean )

What is the correct RATS code for VaR and ES, for APARCH?
-(A+B)=-A-B, not -A+B. Assume that when I say you did something wrong, that you did something wrong.
ac_1 wrote:
TomDoan wrote: 2. They aren't in "percentage" terms. Given the data preparation, they are for an investment of 100.
So the results cannot be scaled-up? VaR=2.5 for an investment of 100 cannot be interpreted as VaR=25.0 for an investment of 1000?
Yes. You just need to understand what you are computing. As written, this is VaR and ES per 100 investment.
ac_1 wrote:
TomDoan wrote: 4. I already told you (several times) that your menu of optimizations isn't a good idea. Have you been able to successfully fit it to the whole sample? It makes little sense to do rolling estimates of a model which you can't really fit in the first place.
Data changes throughtout the sample. Just because a model fits over the whole sample does not been it will fit over a smaller sample, especially if there are large moves. Using a single METHOD sometimes does not converge in rolling estimations and results in gaps.
GARCHBACKTEST.RPF suggests that you fit the model over the full sample, then use that as the basis for the guess values for the subsamples. If the estimates are that erratic over subsamples, it's probably not a good model.
ac_1 wrote:
TomDoan wrote: 5. You do simulations or bootstraps, as you do with any other form of GARCH model which doesn't have a closed form forecast.
How for APARCH? The EGARCHBOOTSTRAP.RPF method or the GARCHBOOT.RPF method?
They are the same basic idea. You use the GARCH recursion (whatever it is) to compute the variance, do a bootstrap value from the standardized residuals, scale it up by the square root of the variance to get the bootstrapped u, add the mean to get the bootstrapped data, and save whatever you need to get the next variance calculation.

Re: UV MAX garch model forecasts

Posted: Wed Nov 22, 2023 6:32 am
by ac_1
TomDoan wrote:
ac_1 wrote:
TomDoan wrote:1. Your formulas are still wrong. Think about what it means for the mean to be positive. Does that increase or decrease the VaR and ES? You have it increasing both.
I am basing VaR calculations following TSay: e.g. https://estima.com/textbooks/tsay_3/tsay3p334.rpf

VaR = -value * ( quantile function(left tail p) * sqrt(variance) + mean )

What is the correct RATS code for VaR and ES, for APARCH?
-(A+B)=-A-B, not -A+B. Assume that when I say you did something wrong, that you did something wrong.

Normal distribution
To handle the mean, as you say:

Code: Select all

comp VaR = -%beta(1) + (-%invnormal(.01)*sqrt(hhat))
comp ES =  -%beta(1) + (%density(%invnormal(.01))/(.01) * sqrt(hhat))

Standardized Student-t distribution
From https://estima.com/textbooks/tsay_3/tsay3p334.rpf

Code: Select all

comp VaR = ( ( -%invtcdf(.01,%shape)*sqrt(hhat)/sqrt(%shape/(%shape-2.0)) ) - %beta(1) )
From TSay(2013) https://faculty.chicagobooth.edu/ruey-s ... ata-with-r
There may be 2 typos in ES, I think it should be
(i) minus the mean
(ii) divide sqrt(%shape/(%shape-2.0))

Code: Select all

comp invtcdfstd = %invtcdf(.01,%shape)*(sqrt(hhat)/(sqrt(%shape/(%shape-2.0)))) + %beta(1)
comp tdensitystd = %tdensity((invtcdfstd-%beta(1))/sqrt(hhat)*sqrt(%shape/(%shape-2.0)),%shape) * sqrt(%shape/(%shape-2.0))/(sqrt(hhat))
comp ES = ( (sqrt(hhat)/sqrt(%shape/(%shape-2.0)) * tdensitystd/.01 * (((%shape-2)+invtcdfstd^2)/(%shape-1))) - %beta(1) )
Correct?

Although https://en.wikipedia.org/wiki/Expected_shortfall, has different formulae to TSay for Generalized Student's t-distribution.


GED
Minus the mean in both VaR and ES?


TomDoan wrote:
ac_1 wrote:
TomDoan wrote: 2. They aren't in "percentage" terms. Given the data preparation, they are for an investment of 100.
So the results cannot be scaled-up? VaR=2.5 for an investment of 100 cannot be interpreted as VaR=25.0 for an investment of 1000?
Yes. You just need to understand what you are computing. As written, this is VaR and ES per 100 investment.
Tsay multiplies VaR and ES by any value. How do I convert the per 100 investment to any Amount of position?

Re: UV MAX garch model forecasts

Posted: Wed Nov 22, 2023 11:34 am
by TomDoan
ac_1 wrote: Normal distribution
To handle the mean, as you say:

Code: Select all

comp VaR = -%beta(1) + (-%invnormal(.01)*sqrt(hhat))
comp ES =  -%beta(1) + (%density(%invnormal(.01))/(.01) * sqrt(hhat))

Standardized Student-t distribution
From https://estima.com/textbooks/tsay_3/tsay3p334.rpf

Code: Select all

comp VaR = ( ( -%invtcdf(.01,%shape)*sqrt(hhat)/sqrt(%shape/(%shape-2.0)) ) - %beta(1) )
Those look correct.
ac_1 wrote: From TSay(2013) https://faculty.chicagobooth.edu/ruey-s ... ata-with-r
There may be 2 typos in ES, I think it should be
(i) minus the mean
(ii) divide sqrt(%shape/(%shape-2.0))

Code: Select all

comp invtcdfstd = %invtcdf(.01,%shape)*(sqrt(hhat)/(sqrt(%shape/(%shape-2.0)))) + %beta(1)
comp tdensitystd = %tdensity((invtcdfstd-%beta(1))/sqrt(hhat)*sqrt(%shape/(%shape-2.0)),%shape) * sqrt(%shape/(%shape-2.0))/(sqrt(hhat))
comp ES = ( (sqrt(hhat)/sqrt(%shape/(%shape-2.0)) * tdensitystd/.01 * (((%shape-2)+invtcdfstd^2)/(%shape-1))) - %beta(1) )
Correct?

Although https://en.wikipedia.org/wiki/Expected_shortfall, has different formulae to TSay for Generalized Student's t-distribution.
Could you be more specific about what you think is wrong? You posted a link to a page full of nothing but links. Note that the wikipedia page had a sign error on the mean for the "Payoff" branch. (I fixed it).
ac_1 wrote: GED
Minus the mean in both VaR and ES?
I have no idea what you are asking.
ac_1 wrote: Tsay multiplies VaR and ES by any value. How do I convert the per 100 investment to any Amount of position?
If you do a GARCH model on 100xlog(p/p{1}) returns, it calculates means and standard deviations (and the VaR and ES using them) for investments of 100 (whatevers). If you do a GARCH model, on just log(p/p{1}), those are in units of 1. To get the VaR on V, you multiply numbers by V/100 in the first case and by V in the second.

Re: UV MAX garch model forecasts

Posted: Wed Nov 22, 2023 1:45 pm
by ac_1
TomDoan wrote:
ac_1 wrote: From TSay(2013) https://faculty.chicagobooth.edu/ruey-s ... ata-with-r
There may be 2 typos in ES, I think it should be
(i) minus the mean
(ii) divide sqrt(%shape/(%shape-2.0))

Code: Select all

comp invtcdfstd = %invtcdf(.01,%shape)*(sqrt(hhat)/(sqrt(%shape/(%shape-2.0)))) + %beta(1)
comp tdensitystd = %tdensity((invtcdfstd-%beta(1))/sqrt(hhat)*sqrt(%shape/(%shape-2.0)),%shape) * sqrt(%shape/(%shape-2.0))/(sqrt(hhat))
comp ES = ( (sqrt(hhat)/sqrt(%shape/(%shape-2.0)) * tdensitystd/.01 * (((%shape-2)+invtcdfstd^2)/(%shape-1))) - %beta(1) )
Correct?

Although https://en.wikipedia.org/wiki/Expected_shortfall, has different formulae to TSay for Generalized Student's t-distribution.
Could you be more specific about what you think is wrong? You posted a link to a page full of nothing but links. Note that the wikipedia page had a sign error on the mean for the "Payoff" branch. (I fixed it).
TSay (2013) An Introduction to Analysis of Financial Data with R, p.336, equation (7.8 ), may have 2 typos in ES, I think it might be
(i) minus the mean, not add
(ii) divide sqrt(%shape/(%shape-2.0)), not multiply

Therefore ES using a Standardized Student-t distribution, I think, is:

comp invtcdfstd = %invtcdf(.01,%shape)*(sqrt(hhat)/(sqrt(%shape/(%shape-2.0)))) + %beta(1)
comp tdensitystd = %tdensity((invtcdfstd-%beta(1))/sqrt(hhat)*sqrt(%shape/(%shape-2.0)),%shape) * sqrt(%shape/(%shape-2.0))/(sqrt(hhat))
comp ES = ( (sqrt(hhat)/sqrt(%shape/(%shape-2.0)) * tdensitystd/.01 * (((%shape-2)+invtcdfstd^2)/(%shape-1))) - %beta(1) )

Correct?

Or is the Wiki page Generalized Student's t-distribution using gamma functions a better formulae, compatible with the VaR formulae (ES should be greater than VaR), i.e. on the Wiki page Generalized Student's t-distribution, ES(alpha)(X) formulae? I see:
ES(alpha)(X) = -mu + ( sigma * [((dof)+(invT(alpha))^2)/(dof-1)] * [tau(invT(alpha))/(1-alpha)] )
where
invT(X) is the standard t-distribution quantile
tau(X) is the standard t-distribution PDF expressed in gamma functions

TomDoan wrote:
ac_1 wrote: Tsay multiplies VaR and ES by any value. How do I convert the per 100 investment to any Amount of position?
If you do a GARCH model on 100xlog(p/p{1}) returns, it calculates means and standard deviations (and the VaR and ES using them) for investments of 100 (whatevers). If you do a GARCH model, on just log(p/p{1}), those are in units of 1. To get the VaR on V, you multiply numbers by V/100 in the first case and by V in the second.
Thanks!