GARCH - constraint

Discussions of ARCH, GARCH, and related models

GARCH - constraint

Postby saurabhatkekar » Thu Jan 20, 2011 7:48 am

Hi
I am using following GARCH code for estimating volatility:

Code: Select all
cal 1986 1 12
all 1996:12
open data returns.xls
data(format=xls,org=cols)
*
compute gstart=2,gend=1996:12
set y = sp500
*
nonlin(parmset=meanparms) b0
frml resid = y - b0
declare series u    ;* Residuals
declare series h    ;* Variances
*
*  GARCH(1,1) with initial variance from regression
*
NONLIN(parmset=garchparms) VC VA VB
FRML HF = VC + VA*H{1} + VB*U{1}**2
FRML LOGL = (H(T)=HF(T)),(U(T)=RESID(T)),-.5*(log(h)+u**2/h)
LINREG(NOPRINT) Y / U
# CONSTANT
COMPUTE B0=%BETA(1)
COMPUTE VC=%SEESQ,VA=.05,VB=.05
SET H = %SEESQ
MAXIMIZE(parmset=meanparms+garchparms,METHOD=SIMPLEX,ITERS=5,NOPRINT) LOGL GSTART GEND
MAXIMIZE(parmset=meanparms+garchparms,METHOD=Bfgs,robusterrors,ITERS=100) LOGL GSTART GEND


I have taken a base as John Hull book formula which is as follows:
sigma^2 = gamma*VL + alfa*u^2 (n-1)+ beta * sigma^2 (n-1).

How do i correlate the above code with this formula. Also, from initial inspection it appears that VB = alfa and VA = beta.
But one of the fundamental assumption in the John - Hull book is that gamma + alfa + beta = 1.
So how do i incorporate this constraint in the above code.

Thanx
saurabhatkekar
 
Posts: 8
Joined: Thu Jan 13, 2011 11:26 pm

Re: GARCH - constraint

Postby TomDoan » Thu Jan 20, 2011 12:28 pm

saurabhatkekar wrote:Hi
I am using following GARCH code for estimating volatility:

Code: Select all
cal 1986 1 12
all 1996:12
open data returns.xls
data(format=xls,org=cols)
*
compute gstart=2,gend=1996:12
set y = sp500
*
nonlin(parmset=meanparms) b0
frml resid = y - b0
declare series u    ;* Residuals
declare series h    ;* Variances
*
*  GARCH(1,1) with initial variance from regression
*
NONLIN(parmset=garchparms) VC VA VB
FRML HF = VC + VA*H{1} + VB*U{1}**2
FRML LOGL = (H(T)=HF(T)),(U(T)=RESID(T)),-.5*(log(h)+u**2/h)
LINREG(NOPRINT) Y / U
# CONSTANT
COMPUTE B0=%BETA(1)
COMPUTE VC=%SEESQ,VA=.05,VB=.05
SET H = %SEESQ
MAXIMIZE(parmset=meanparms+garchparms,METHOD=SIMPLEX,ITERS=5,NOPRINT) LOGL GSTART GEND
MAXIMIZE(parmset=meanparms+garchparms,METHOD=Bfgs,robusterrors,ITERS=100) LOGL GSTART GEND


I have taken a base as John Hull book formula which is as follows:
sigma^2 = gamma*VL + alfa*u^2 (n-1)+ beta * sigma^2 (n-1).

How do i correlate the above code with this formula. Also, from initial inspection it appears that VB = alfa and VA = beta.
But one of the fundamental assumption in the John - Hull book is that gamma + alfa + beta = 1.
So how do i incorporate this constraint in the above code.

Thanx


That's usually done by estimating a single parameter for gamma*vl (typically called "omega") and backing out the vl by using the identity for gamma. With the GARCH instruction, this is done with

Code: Select all
garch(p=1,q=1) / y
summarize(title="Equilibrium Variance") %beta(2)/(1-%beta(3)-%beta(4))


If you want to estimate all four parameters in your setup, you would do

Code: Select all
NONLIN(parmset=garchparms) GAMMA VL VA VB GAMMA=1-VA-VB
FRML HF = GAMMA*VL+ VA*H{1} + VB*U{1}**2
FRML LOGL = (H(T)=HF(T)),(U(T)=RESID(T)),-.5*(log(h)+u**2/h)
LINREG(NOPRINT) Y / U
# CONSTANT
COMPUTE B0=%BETA(1)
COMPUTE VL=%SEESQ,VA=.05,VB=.05
SET H = %SEESQ
MAXIMIZE(parmset=meanparms+garchparms,METHOD=SIMPLEX,ITERS=5,NOPRINT) LOGL GSTART GEND
MAXIMIZE(parmset=meanparms+garchparms,METHOD=Bfgs,robusterrors,ITERS=100) LOGL GSTART GEND
TomDoan
 
Posts: 2720
Joined: Wed Nov 01, 2006 5:36 pm

Re: GARCH - constraint

Postby saurabhatkekar » Mon Jan 24, 2011 8:25 am

Hi Tom

thanx for your help

Still i have 2 querries on the same

Query 1
I have incorporated the changes suggested by you (2nd suggestion).
Variable Coeff Std Error T-Stat Signif
**********************************************************************************************
1. B0 1.3474963697 0.0023687955 568.85297 0.00000000
2. GAMMA 0.0014703705 0.0008874468 1.65685 0.09754883
3. VL 0.0271146046 0.0066550110 4.07431 0.00004615
4. VA 0.0832996546 0.0345517296 2.41087 0.01591461
5. VB 0.9152299749 0.0339590488 26.95099 0.00000000

As i mentioned in my earlier post it appears that VB = alfa = weight assigned to u^2 and VA = beta = weight assigned to variance.

By using John Hull book's approach variance's weight (beta) is coming greater than U^2 weight (alfa) whereas here i am getting exactly the reverse output.

Query 2

I am also trying to calculate volatility for different tenors i.e 1W, 2W, 3W, 1M etc.
For calculating the same John -Hull book have following equation :

vol^2 = VL + (alfa +beta)^7 * (variance-VL) - for calculating 1W vol.

Can i use above equation to calculate 1W vol in the RAT? if yes then how should i incoporate the equation in the GARCH code.or is there any other approach available in RATS to calculate the vols for different tenors.'

I am assuming while calculating volatility for different tenors we have to re-callibrate the parameters every time.

thanx
saurabhatkekar
 
Posts: 8
Joined: Thu Jan 13, 2011 11:26 pm

Re: GARCH - constraint

Postby TomDoan » Mon Jan 24, 2011 10:23 am

saurabhatkekar wrote:Hi Tom

thanx for your help

Still i have 2 querries on the same

Query 1
I have incorporated the changes suggested by you (2nd suggestion).
Variable Coeff Std Error T-Stat Signif
**********************************************************************************************
1. B0 1.3474963697 0.0023687955 568.85297 0.00000000
2. GAMMA 0.0014703705 0.0008874468 1.65685 0.09754883
3. VL 0.0271146046 0.0066550110 4.07431 0.00004615
4. VA 0.0832996546 0.0345517296 2.41087 0.01591461
5. VB 0.9152299749 0.0339590488 26.95099 0.00000000

As i mentioned in my earlier post it appears that VB = alfa = weight assigned to u^2 and VA = beta = weight assigned to variance.

By using John Hull book's approach variance's weight (beta) is coming greater than U^2 weight (alfa) whereas here i am getting exactly the reverse output.


You may be getting a local maximum for the likelihood. You might want to try guess values for VA and VB more like VA=.75 and VB=.05 rather than .05 on each.

saurabhatkekar wrote:Query 2

I am also trying to calculate volatility for different tenors i.e 1W, 2W, 3W, 1M etc.
For calculating the same John -Hull book have following equation :

vol^2 = VL + (alfa +beta)^7 * (variance-VL) - for calculating 1W vol.

Can i use above equation to calculate 1W vol in the RAT? if yes then how should i incoporate the equation in the GARCH code.or is there any other approach available in RATS to calculate the vols for different tenors.'

I am assuming while calculating volatility for different tenors we have to re-callibrate the parameters every time.

thanx


I'm assuming the "variance" in your formula is the estimated GARCH variance for a given data point. If you're estimating this out-of-sample, you can compute it with

Code: Select all
compute volsq=vl+(va+vb)^7*(h(gend)-vl)
disp "1W Vol = " volsq
TomDoan
 
Posts: 2720
Joined: Wed Nov 01, 2006 5:36 pm

Re: GARCH - constraint

Postby saurabhatkekar » Tue Jan 25, 2011 8:26 am

Hi Tom

i have used the values for parameters VA and VB suggested in your earlier post. But still i am not getting desire output.
Please find the code as below where VA =.75 and VB = .05.

Code: Select all
cal(DAILY) 2006 1 2
all 2010:12:31
open data Rates2.xls
data(format=xls,org=cols)
*
compute gstart=2,gend=2010:12:31
set y = sp500
*
nonlin(parmset=meanparms) b0
frml resid = y - b0
declare series u    ;* Residuals
declare series h    ;* Variances
*
*  GARCH(1,1) with initial variance from regression
*
NONLIN(parmset=garchparms) GAMMA VL VA VB GAMMA=1-VA-VB
FRML HF = GAMMA*VL + VA*H{1} + VB*U{1}**2
FRML LOGL = (H(T)=HF(T)),(U(T)=RESID(T)),-.5*(log(h)+u**2/h)
LINREG(NOPRINT) Y / U
# CONSTANT
COMPUTE B0=%BETA(1)
COMPUTE VL=%SEESQ,VA=.75,VB=.05
SET H = %SEESQ
MAXIMIZE(parmset=meanparms+garchparms,METHOD=SIMPLEX,ITERS=5,NOPRINT) LOGL GSTART GEND
MAXIMIZE(parmset=meanparms+garchparms,METHOD=Bfgs,robusterrors,ITERS=1000) LOGL GSTART GEND


Output is as below:

MAXIMIZE - Estimation by BFGS
Convergence in 91 Iterations. Final criterion was 0.0000000 < 0.0000100
Daily(5) Data From 2006:01:03 To 2010:12:31
Usable Observations 1304
Function Value 3035.20064862

Variable Coeff Std Error T-Stat Signif
*******************************************************************************************
1. B0 1.3475000650 0.0147050210 91.63537 0.00000000
2. GAMMA 0.0012886532 0.0562876439 0.02289 0.98173477
3. VL 0.0308271711 1.2085419480 0.02551 0.97964998
4. VA 0.0839438064 0.5187974471 0.16180 0.87145974
5. VB 0.9147675404 0.4625418061 1.97770 0.04796290
saurabhatkekar
 
Posts: 8
Joined: Thu Jan 13, 2011 11:26 pm

Re: GARCH - constraint

Postby TomDoan » Tue Jan 25, 2011 9:11 am

You'll have to attach your data set (there's an "Upload Attachment" tab below the message editor). Your series seems to have a very high mean relative to the variance which doesn't look like the behavior of returns.
TomDoan
 
Posts: 2720
Joined: Wed Nov 01, 2006 5:36 pm

Re: GARCH - constraint

Postby saurabhatkekar » Thu Jan 27, 2011 8:03 am

Tom

Please find the attachment. Attachment contain EUR/USD FX rates. Same data on which i am trying GARCH model.

thanx
Attachments
Rates.xls
EUR/USD FX rates
(82.5 KiB) Downloaded 65 times
saurabhatkekar
 
Posts: 8
Joined: Thu Jan 13, 2011 11:26 pm

Re: GARCH - constraint

Postby TomDoan » Thu Jan 27, 2011 9:37 am

As I suspected, you haven't converted to returns, so a "mean-only" model for the mean of the process is simply wrong. Probably 90% of GARCH models are fit to return data, not raw prices.
TomDoan
 
Posts: 2720
Joined: Wed Nov 01, 2006 5:36 pm

Re: GARCH - constraint

Postby saurabhatkekar » Fri Jan 28, 2011 8:38 am

Tom

Thanx for your help. Now i am using my data as daily returns.

As reference to my previous query regarding How to forecast or calculate vols for different tenors like 1W, 2W and so on. I have asked how would i incorporate vol^2 = VL + (alfa +beta)^7 * (variance-VL) - for calculating 1W vol. this equation in the GARCH code. And as u suggested i have used the same in my GARCH setup and got the following output.

1W Vol = 4.62400e-05

I just wanted to understand

1. whether this number is the 1W vol from 31dec 2010 as last data point in my data set is asof 31dec 2010.
2. Also, above equation we are solving for vol^2 so to calculate vol we have to take sqrt(4.62400e-05).
3. variance = 1D vol which we have calculated using daily returns by standard GARCH formula.
4. What is h(gend) ?

Following is my code:

Code: Select all
cal(DAILY) 2006 1 3
all 2010:12:31
open data Rates2_returns.xls
data(format=xls,org=cols)
*
compute gstart=2,gend=2010:12:31
set y = sp500
*
nonlin(parmset=meanparms) b0
frml resid = y - b0
declare series u    ;* Residuals
declare series h    ;* Variances
*
*  GARCH(1,1) with initial variance from regression
*
NONLIN(parmset=garchparms) GAMMA VL VA VB GAMMA=1-VA-VB
FRML HF = GAMMA*VL + VA*H{1} + VB*U{1}**2
FRML LOGL = (H(T)=HF(T)),(U(T)=RESID(T)),-.5*(log(h)+u**2/h)
LINREG(NOPRINT) Y / U
# CONSTANT
COMPUTE B0=%BETA(1)
COMPUTE VL=%SEESQ,VA=.85,VB=.05
COMPUTE volsq=VL+(VA+VB)**7*(h(gend)-VL)
disp "1W Vol = " volsq

SET H = %SEESQ
MAXIMIZE(parmset=meanparms+garchparms,METHOD=SIMPLEX,ITERS=5,NOPRINT) LOGL GSTART GEND
MAXIMIZE(parmset=meanparms+garchparms,METHOD=Bfgs,robusterrors,ITERS=1000) LOGL GSTART GEND


Output is

# SR12. We recommend File-Clear Program or END xxx before ALLOCATE
1W Vol = 4.68308e-05

MAXIMIZE - Estimation by BFGS
Convergence in 17 Iterations. Final criterion was 0.0000000 < 0.0000100
Daily(5) Data From 2006:01:04 To 2010:12:31
Usable Observations 1303
Function Value 6027.52275112

Variable Coeff Std Error T-Stat Signif
******************************************************************************************
1. B0 0.0002317189 0.0001318932 1.75687 0.07894043
2. GAMMA 0.0015639114 0.0036209495 0.43191 0.66580941
3. VL 0.0000633971 0.0001087785 0.58281 0.56002194
4. VA 0.9566225868 0.0068654456 139.33875 0.00000000
5. VB 0.0418135018 0.0064666280 6.46604 0.00000000
saurabhatkekar
 
Posts: 8
Joined: Thu Jan 13, 2011 11:26 pm

Re: GARCH - constraint

Postby TomDoan » Fri Jan 28, 2011 3:21 pm

saurabhatkekar wrote:Tom

1W Vol = 4.62400e-05

I just wanted to understand

1. whether this number is the 1W vol from 31dec 2010 as last data point in my data set is asof 31dec 2010.
2. Also, above equation we are solving for vol^2 so to calculate vol we have to take sqrt(4.62400e-05).
3. variance = 1D vol which we have calculated using daily returns by standard GARCH formula.
4. What is h(gend) ?


1. Yes.
2. Correct.
3&4. H is the series of estimated GARCH variances. GEND is the last data point (31 Dec 2010), so h(gend) is the GARCH variance computed for that last data point. VARIANCE is a variable in your formula. I'm assuming that that should be the last computed variance before the forecast period. Perhaps it's supposed to be something else, but you'll have to check your book to see what that would be.
TomDoan
 
Posts: 2720
Joined: Wed Nov 01, 2006 5:36 pm

Re: GARCH - constraint

Postby saurabhatkekar » Tue Mar 22, 2011 7:26 am

Hi TOM

Long time since we communicated with each other.

Finally i am able to get output from GARCH code which i shared with you last time.
I am again pasting here my final code in which i wanted to confirm that for calculating future vols e.g. 1W, 2W etc RATS is using the same parameters or will it recalibrate the parameters seperately for each tenors.

Following is my code:

Code: Select all
cal(DAILY) 2006 1 3
all 2010:12:31
open data Rates2_returns.xls
data(format=xls,org=cols)
*
compute gstart=2,gend=2010:12:31
set y = sp500
*
nonlin(parmset=meanparms) b0
frml resid = y - b0
declare series u    ;* Residuals
declare series h    ;* Variances
*
*  GARCH(1,1) with initial variance from regression
*
NONLIN(parmset=garchparms) GAMMA VL VA VB GAMMA=1-VA-VB
FRML HF = GAMMA*VL + VA*H{1} + VB*U{1}**2
FRML LOGL = (H(T)=HF(T)),(U(T)=RESID(T)),-.5*(log(h)+u**2/h)
LINREG(NOPRINT) Y / U
# CONSTANT
COMPUTE B0=%BETA(1)
COMPUTE VL=%SEESQ,VA=.94,VB=.04
COMPUTE volsq=VL+(VA+VB)**7*(h(gend)-VL)
disp "1W Vol = " volsq
COMPUTE volsq=VL+(VA+VB)**14*(h(gend)-VL)
disp "2W Vol = " volsq
COMPUTE volsq=VL+(VA+VB)**21*(h(gend)-VL)
disp "3W Vol = " volsq
COMPUTE volsq=VL+(VA+VB)**28*(h(gend)-VL)
disp "1M Vol = " volsq
COMPUTE volsq=VL+(VA+VB)**56*(h(gend)-VL)
disp "2M Vol = " volsq
COMPUTE volsq=VL+(VA+VB)**84*(h(gend)-VL)
disp "3M Vol = " volsq
COMPUTE volsq=VL+(VA+VB)**112*(h(gend)-VL)
disp "4M Vol = " volsq
COMPUTE volsq=VL+(VA+VB)**168*(h(gend)-VL)
disp "6M Vol = " volsq
COMPUTE volsq=VL+(VA+VB)**252*(h(gend)-VL)
disp "9M Vol = " volsq
COMPUTE volsq=VL+(VA+VB)**336*(h(gend)-VL)
disp "1Y Vol = " volsq
COMPUTE volsq=VL+(VA+VB)**504*(h(gend)-VL)
disp "18 M Vol = " volsq
COMPUTE volsq=VL+(VA+VB)**672*(h(gend)-VL)
disp "2Y Vol = " volsq
COMPUTE volsq=VL+(VA+VB)**1680*(h(gend)-VL)
disp "5Y Vol = " volsq


SET H = %SEESQ
MAXIMIZE(parmset=meanparms+garchparms,METHOD=SIMPLEX,ITERS=5,NOPRINT) LOGL GSTART GEND
MAXIMIZE(parmset=meanparms+garchparms,METHOD=Bfgs,robusterrors,ITERS=1000) LOGL GSTART GEND


thanx
saurabhatkekar
 
Posts: 8
Joined: Thu Jan 13, 2011 11:26 pm

Re: GARCH - constraint

Postby TomDoan » Tue Mar 22, 2011 10:15 am

saurabhatkekar wrote:Hi TOM

Long time since we communicated with each other.

Finally i am able to get output from GARCH code which i shared with you last time.
I am again pasting here my final code in which i wanted to confirm that for calculating future vols e.g. 1W, 2W etc RATS is using the same parameters or will it recalibrate the parameters seperately for each tenors.



The parameters are estimated for daily data and you aren't doing anything after that to change them; you're just using them to extrapolate for different horizons.
TomDoan
 
Posts: 2720
Joined: Wed Nov 01, 2006 5:36 pm

Re: GARCH - constraint

Postby saurabhatkekar » Tue Mar 22, 2011 11:56 pm

thanx Tom

Is that a correct way of doin it ? or do i need to code it such a way that for every horizon model will recallibrate the GARCH parameters ?

thanx
saurabhatkekar
 
Posts: 8
Joined: Thu Jan 13, 2011 11:26 pm

Re: GARCH - constraint

Postby TomDoan » Wed Mar 23, 2011 10:12 am

No. You have formulas for extrapolating information from the parameters of a daily GARCH model. That's what you estimated. You do not need to or want to "recalibrate" those.
TomDoan
 
Posts: 2720
Joined: Wed Nov 01, 2006 5:36 pm

Re: GARCH - constraint

Postby saurabhatkekar » Fri Mar 25, 2011 12:37 am

Hi TOM

i have 2 queries

1. Can you pls little more elaborate on why we need not recalibrate the GARCH paramaters for different horizon?
2.
MAXIMIZE(parmset=meanparms+garchparms,METHOD=SIMPLEX,ITERS=5,NOPRINT) LOGL GSTART GEND
MAXIMIZE(parmset=meanparms+garchparms,METHOD=Bfgs,robusterrors,ITERS=1000) LOGL GSTART GEND

My understanding of this part of the code is, this is used for calibrating the GARCh parameters. as it maximizes the parameters.

So how does entire code work? first forecast the vol for different horizon and then calibrate the parameters or first calibrate the parameters and then forecast the vols.
For your ref pls find entire code below:

Code: Select all
cal(DAILY) 2006 1 3
all 2010:12:31
open data Rates2_returns.xls
data(format=xls,org=cols)
*
compute gstart=2,gend=2010:12:31
set y = sp500
*
nonlin(parmset=meanparms) b0
frml resid = y - b0
declare series u    ;* Residuals
declare series h    ;* Variances
*
*  GARCH(1,1) with initial variance from regression
*
NONLIN(parmset=garchparms) GAMMA VL VA VB GAMMA=1-VA-VB
FRML HF = GAMMA*VL + VA*H{1} + VB*U{1}**2
FRML LOGL = (H(T)=HF(T)),(U(T)=RESID(T)),-.5*(log(h)+u**2/h)
LINREG(NOPRINT) Y / U
# CONSTANT
COMPUTE B0=%BETA(1)
COMPUTE VL=%SEESQ,VA=.94,VB=.04
COMPUTE volsq=VL+(VA+VB)**7*(h(gend)-VL)
disp "1W Vol = " volsq
COMPUTE volsq=VL+(VA+VB)**14*(h(gend)-VL)
disp "2W Vol = " volsq
COMPUTE volsq=VL+(VA+VB)**21*(h(gend)-VL)
disp "3W Vol = " volsq
COMPUTE volsq=VL+(VA+VB)**28*(h(gend)-VL)
disp "1M Vol = " volsq
COMPUTE volsq=VL+(VA+VB)**56*(h(gend)-VL)
disp "2M Vol = " volsq
COMPUTE volsq=VL+(VA+VB)**84*(h(gend)-VL)
disp "3M Vol = " volsq
COMPUTE volsq=VL+(VA+VB)**112*(h(gend)-VL)
disp "4M Vol = " volsq
COMPUTE volsq=VL+(VA+VB)**168*(h(gend)-VL)
disp "6M Vol = " volsq
COMPUTE volsq=VL+(VA+VB)**252*(h(gend)-VL)
disp "9M Vol = " volsq
COMPUTE volsq=VL+(VA+VB)**336*(h(gend)-VL)
disp "1Y Vol = " volsq
COMPUTE volsq=VL+(VA+VB)**504*(h(gend)-VL)
disp "18 M Vol = " volsq
COMPUTE volsq=VL+(VA+VB)**672*(h(gend)-VL)
disp "2Y Vol = " volsq
COMPUTE volsq=VL+(VA+VB)**1680*(h(gend)-VL)
disp "5Y Vol = " volsq


SET H = %SEESQ
MAXIMIZE(parmset=meanparms+garchparms,METHOD=SIMPLEX,ITERS=5,NOPRINT) LOGL GSTART GEND
MAXIMIZE(parmset=meanparms+garchparms,METHOD=Bfgs,robusterrors,ITERS=1000) LOGL GSTART GEND

thanx
saurabhatkekar
 
Posts: 8
Joined: Thu Jan 13, 2011 11:26 pm

Next

Return to ARCH and GARCH Models

Who is online

Users browsing this forum: No registered users and 2 guests